3 import org.junit.jupiter.api.Test;
4 import static org.mockserver.matchers.Times.exactly;
5 import static org.mockserver.model.HttpForward.forward;
6 import static org.mockserver.model.HttpRequest.request;
7 import org.springframework.beans.factory.annotation.Autowired;
8 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
9 import org.springframework.boot.test.context.SpringBootTest;
10 import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
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.reactive.server.WebTestClient;
15 import org.springframework.web.reactive.function.client.WebClient;
17 @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
18 @EnableAutoConfiguration
19 class DemoApplicationIT extends IntegrationTestBase
22 WebTestClient webClient;
26 void test() throws Exception
29 .when(request().withPath("/test.txt"), exactly(1))
31 .withHost(NGINX.getContainerIpAddress())
32 .withPort(NGINX.getMappedPort(80)));
35 .uri("/?path=test.txt")
37 .expectStatus().isOk()
38 .expectHeader().contentType(MediaType.TEXT_HTML)
39 .expectBody().xpath("/html/body/main/div/div", "pre", "Hello World!");
43 static class Application
46 RemoteContentService service()
48 return new RemoteContentService(
51 .baseUrl("http://localhost:" + MOCK_SERVER.getLocalPort())
56 HtmlController controller(RemoteContentService service)
58 return new HtmlController(service);