4 import org.junit.jupiter.api.BeforeEach;
5 import org.junit.jupiter.api.Test;
6 import static org.mockserver.matchers.Times.exactly;
7 import static org.mockserver.model.HttpForward.forward;
8 import static org.mockserver.model.HttpRequest.request;
9 import org.springframework.beans.factory.annotation.Autowired;
10 import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest;
11 import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureWebMvc;
12 import org.springframework.context.annotation.Bean;
13 import org.springframework.context.annotation.Configuration;
14 import org.springframework.http.MediaType;
15 import org.springframework.test.web.servlet.MockMvc;
16 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
17 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
18 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
19 import org.springframework.test.web.servlet.setup.MockMvcBuilders;
20 import org.springframework.web.context.WebApplicationContext;
21 import org.springframework.web.reactive.function.client.WebClient;
25 class DemoApplicationIT extends IntegrationTestBase
29 WebApplicationContext context;
33 void setUp(WebApplicationContext context)
35 mockMvc = MockMvcBuilders.webAppContextSetup(context).build();
40 void test() throws Exception
43 .when(request().withPath("/test.txt"), exactly(1))
45 .withHost(NGINX.getContainerIpAddress())
46 .withPort(NGINX.getMappedPort(80)));
48 .perform(get(URI.create("http://S.U.T/?path=test.txt")))
49 .andExpect(status().isOk())
50 .andExpect(content().contentType(MediaType.TEXT_PLAIN))
51 .andExpect(content().string("Hello World!\n"));
55 static class Application
58 RemoteContentService service()
60 return new RemoteContentService(
63 .baseUrl("http://localhost:" +
64 DemoApplicationIT.MOCK_SERVER.getLocalPort())
69 HtmlController controller(RemoteContentService service)
71 return new HtmlController(service);