4 import org.junit.jupiter.api.Test;
5 import static org.mockserver.matchers.Times.exactly;
6 import static org.mockserver.model.HttpForward.forward;
7 import static org.mockserver.model.HttpRequest.request;
8 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
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.web.reactive.function.client.WebClient;
22 class DemoApplicationIT extends IntegrationTestBase
29 void test() throws Exception
32 .when(request().withPath("/test.txt"), exactly(1))
34 .withHost(NGINX.getContainerIpAddress())
35 .withPort(NGINX.getMappedPort(80)));
37 .perform(get(URI.create("http://S.U.T/?path=test.txt")))
38 .andExpect(status().isOk())
39 .andExpect(content().contentType(MediaType.TEXT_PLAIN))
40 .andExpect(content().string("Hello World!\n"));
44 static class Application
47 RemoteContentService service()
49 return new RemoteContentService(
52 .baseUrl("http://localhost:" +
53 DemoApplicationIT.MOCK_SERVER.getLocalPort())
58 HtmlController controller(RemoteContentService service)
60 return new HtmlController(service);