package de.juplo.demo;
+import de.juplo.demo.DemoApplicationIT.Application;
import java.net.URI;
+import org.junit.jupiter.api.BeforeEach;
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.autoconfigure.web.servlet.AutoConfigureWebMvc;
-import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.ApplicationContext;
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.context.junit.jupiter.SpringJUnitConfig;
+import org.springframework.test.web.reactive.server.WebTestClient;
import org.springframework.web.reactive.function.client.WebClient;
-@SpringBootTest
-@AutoConfigureWebMvc
+@SpringJUnitConfig(Application.class)
class DemoApplicationIT extends IntegrationTestBase
{
+ WebTestClient webClient;
@Autowired
- MockMvc mockMvc;
+ ApplicationContext context;
+
+
+ @BeforeEach
+ void setUp()
+ {
+ webClient = WebTestClient.bindToApplicationContext(context).build();
+ }
@Test
.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