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.context.SpringBootTest;
11 import org.springframework.context.annotation.Bean;
12 import org.springframework.context.annotation.Configuration;
13 import org.springframework.http.MediaType;
14 import org.springframework.test.web.servlet.MockMvc;
15 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
16 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
17 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
18 import org.springframework.test.web.servlet.setup.MockMvcBuilders;
19 import org.springframework.web.context.WebApplicationContext;
20 import org.springframework.web.reactive.function.client.WebClient;
23 class DemoApplicationIT extends IntegrationTestBase
27 WebApplicationContext context;
31 void setUp(WebApplicationContext context)
33 mockMvc = MockMvcBuilders.webAppContextSetup(context).build();
38 void test() throws Exception
41 .when(request().withPath("/test.txt"), exactly(1))
43 .withHost(NGINX.getContainerIpAddress())
44 .withPort(NGINX.getMappedPort(80)));
46 .perform(get(URI.create("http://S.U.T/?path=test.txt")))
47 .andExpect(status().isOk())
48 .andExpect(content().contentType(MediaType.TEXT_PLAIN))
49 .andExpect(content().string("Hello World!\n"));
53 static class Application
56 RemoteContentService service()
58 return new RemoteContentService(
61 .baseUrl("http://localhost:" +
62 DemoApplicationIT.MOCK_SERVER.getLocalPort())
67 HtmlController controller(RemoteContentService service)
69 return new HtmlController(service);