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.boot.test.context.SpringBootTest;
10 import org.springframework.context.annotation.Bean;
11 import org.springframework.context.annotation.Configuration;
12 import org.springframework.http.MediaType;
13 import org.springframework.test.web.reactive.server.WebTestClient;
14 import org.springframework.web.context.WebApplicationContext;
15 import org.springframework.web.reactive.function.client.WebClient;
18 class DemoApplicationIT extends IntegrationTestBase
20 WebTestClient webClient;
24 void setUp(WebApplicationContext context)
26 webClient = WebTestClient.bindToApplicationContext(context).build();
31 void test() throws Exception
34 .when(request().withPath("/test.txt"), exactly(1))
36 .withHost(NGINX.getContainerIpAddress())
37 .withPort(NGINX.getMappedPort(80)));
40 .uri(URI.create("http://S.U.T/?path=test.txt"))
42 .expectStatus().is2xxSuccessful()
43 .expectHeader().contentType(MediaType.TEXT_HTML)
44 .expectBody(String.class).isEqualTo("Hello World!\n");
48 static class Application
51 RemoteContentService service()
53 return new RemoteContentService(
56 .baseUrl("http://localhost:" +
57 DemoApplicationIT.MOCK_SERVER.getLocalPort())
62 HtmlController controller(RemoteContentService service)
64 return new HtmlController(service);