|
|
|
@ -24,6 +24,8 @@ import org.springframework.boot.test.context.SpringBootTest |
|
|
|
import org.springframework.test.web.reactive.server.WebTestClient |
|
|
|
import org.springframework.test.web.reactive.server.WebTestClient |
|
|
|
import org.springframework.test.web.reactive.server.expectBody |
|
|
|
import org.springframework.test.web.reactive.server.expectBody |
|
|
|
import org.springframework.test.web.servlet.assertj.MockMvcTester |
|
|
|
import org.springframework.test.web.servlet.assertj.MockMvcTester |
|
|
|
|
|
|
|
import org.springframework.test.web.servlet.client.RestTestClient |
|
|
|
|
|
|
|
import org.springframework.test.web.servlet.client.expectBody |
|
|
|
|
|
|
|
|
|
|
|
@SpringBootTest |
|
|
|
@SpringBootTest |
|
|
|
@AutoConfigureMockMvc |
|
|
|
@AutoConfigureMockMvc |
|
|
|
@ -35,6 +37,15 @@ class MyMockMvcTests { |
|
|
|
.hasBodyTextEqualTo("Hello World") |
|
|
|
.hasBodyTextEqualTo("Hello World") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
fun testWithRestTestClient(@Autowired webClient: RestTestClient) { |
|
|
|
|
|
|
|
webClient |
|
|
|
|
|
|
|
.get().uri("/") |
|
|
|
|
|
|
|
.exchange() |
|
|
|
|
|
|
|
.expectStatus().isOk |
|
|
|
|
|
|
|
.expectBody<String>().isEqualTo("Hello World") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// If Spring WebFlux is on the classpath, you can drive MVC tests with a WebTestClient |
|
|
|
// If Spring WebFlux is on the classpath, you can drive MVC tests with a WebTestClient |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
|