2016-09-21 22:15:35 +08:00
|
|
|
package com.example
|
|
|
|
|
|
|
|
@SpringBootApplication
|
|
|
|
@SpringBootTest(classes=RestTests, webEnvironment=WebEnvironment.RANDOM_PORT)
|
2014-05-28 19:11:48 +08:00
|
|
|
class RestTests {
|
|
|
|
|
2016-09-21 22:15:35 +08:00
|
|
|
@Autowired
|
2021-01-05 15:24:03 +08:00
|
|
|
TestRestTemplate testRestTemplate
|
2014-05-28 19:11:48 +08:00
|
|
|
|
|
|
|
@Test
|
|
|
|
void testHome() {
|
2016-09-21 22:15:35 +08:00
|
|
|
assertEquals('Hello', testRestTemplate.getForObject('/', String))
|
2014-05-28 19:11:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
static class Application {
|
|
|
|
@RequestMapping('/')
|
|
|
|
String hello() { 'Hello' }
|
|
|
|
}
|
2016-09-21 22:15:35 +08:00
|
|
|
|
2014-05-28 19:11:48 +08:00
|
|
|
}
|