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.ApplicationContext;
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.reactive.server.WebTestClient;
16 import org.springframework.web.reactive.function.client.WebClient;
19 class DemoApplicationIT extends IntegrationTestBase
21 WebTestClient webClient;
23 ApplicationContext context;
29 webClient = WebTestClient.bindToApplicationContext(context).build();
34 void test() throws Exception
37 .when(request().withPath("/test.txt"), exactly(1))
39 .withHost(NGINX.getContainerIpAddress())
40 .withPort(NGINX.getMappedPort(80)));
43 .uri(URI.create("http://S.U.T/?path=test.txt"))
45 .expectStatus().is2xxSuccessful()
46 .expectHeader().contentType(MediaType.TEXT_HTML)
47 .expectBody(String.class).isEqualTo("Hello World!\n");
51 static class Application
54 RemoteContentService service()
56 return new RemoteContentService(
59 .baseUrl("http://localhost:" +
60 DemoApplicationIT.MOCK_SERVER.getLocalPort())
65 HtmlController controller(RemoteContentService service)
67 return new HtmlController(service);