WIP:itflux
authorKai Moritz <kai@juplo.de>
Tue, 14 Jan 2020 07:46:57 +0000 (08:46 +0100)
committerKai Moritz <kai@juplo.de>
Tue, 14 Jan 2020 07:54:44 +0000 (08:54 +0100)
src/test/java/de/juplo/demo/DemoApplicationIT.java

index be40c75..db6448a 100644 (file)
@@ -6,31 +6,24 @@ import org.junit.jupiter.api.Test;
 import static org.mockserver.matchers.Times.exactly;
 import static org.mockserver.model.HttpForward.forward;
 import static org.mockserver.model.HttpRequest.request;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.http.MediaType;
-import org.springframework.test.web.servlet.MockMvc;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import org.springframework.test.web.reactive.server.WebTestClient;
 import org.springframework.web.context.WebApplicationContext;
 import org.springframework.web.reactive.function.client.WebClient;
 
 @SpringBootTest
 class DemoApplicationIT extends IntegrationTestBase
 {
-  MockMvc mockMvc;
-  @Autowired
-  WebApplicationContext context;
+  WebTestClient webClient;
 
 
   @BeforeEach
   void setUp(WebApplicationContext context)
   {
-    mockMvc = MockMvcBuilders.webAppContextSetup(context).build();
+    webClient = WebTestClient.bindToApplicationContext(context).build();
   }
 
 
@@ -42,11 +35,13 @@ class DemoApplicationIT extends IntegrationTestBase
         .forward(forward()
             .withHost(NGINX.getContainerIpAddress())
             .withPort(NGINX.getMappedPort(80)));
-    mockMvc
-        .perform(get(URI.create("http://S.U.T/?path=test.txt")))
-        .andExpect(status().isOk())
-        .andExpect(content().contentType(MediaType.TEXT_PLAIN))
-        .andExpect(content().string("Hello World!\n"));
+    webClient
+        .get()
+        .uri(URI.create("http://S.U.T/?path=test.txt"))
+        .exchange()
+        .expectStatus().is2xxSuccessful()
+        .expectHeader().contentType(MediaType.TEXT_HTML)
+        .expectBody(String.class).isEqualTo("Hello World!\n");
   }
 
   @Configuration