+package de.juplo.demo;
+
+import java.net.URI;
+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.AutoConfigureMockMvc;
+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.web.reactive.function.client.WebClient;
+
+@SpringBootTest
+@AutoConfigureMockMvc
+class DemoApplicationIT extends IntegrationTestBase
+{
+ @Autowired
+ MockMvc mockMvc;
+
+
+ @Test
+ void test() throws Exception
+ {
+ MOCK_SERVER
+ .when(request().withPath("/test.txt"), exactly(1))
+ .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"));
+ }
+
+ @Configuration
+ static class Application
+ {
+ @Bean
+ RemoteContentService service()
+ {
+ return new RemoteContentService(
+ WebClient
+ .builder()
+ .baseUrl("http://localhost:" +
+ DemoApplicationIT.MOCK_SERVER.getLocalPort())
+ .build());
+ }
+
+ @Bean
+ HtmlController controller(RemoteContentService service)
+ {
+ return new HtmlController(service);
+ }
+ }
+}