4 import org.junit.jupiter.api.AfterAll;
5 import org.junit.jupiter.api.BeforeAll;
6 import org.mockserver.integration.ClientAndServer;
7 import org.testcontainers.containers.NginxContainer;
8 import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;
14 * {@link https://www.testcontainers.org/modules/nginx/ NginX-Webserver}
15 * via a {@link https://www.testcontainers.org/ Testcontainer} and a
16 * standalone {@link http://www.mock-server.com/#what-is-mockserver MockServer},
17 * that can be used to intercept requests for assertions / verifications.
20 * https://www.testcontainers.org/test_framework_integration/manual_lifecycle_control/#singleton-containers
21 * Singleton Pattern} to start the NginX-Testcontainer and start the MockServer
22 * programmatically via the {@link
23 * http://www.mock-server.com/mock_server/running_mock_server.html#client_api
27 public abstract class IntegrationTestBase
29 static final NginxContainer NGINX;
30 static final ClientAndServer MOCK_SERVER;
35 NGINX = new NginxContainer().withCustomContent("src/test/resources/");
36 MOCK_SERVER = ClientAndServer.startClientAndServer();
41 static void startMockServer()
43 NGINX.waitingFor(new HttpWaitStrategy()).start();
47 static void stopMockServer()
55 return NGINX.getContainerIpAddress();
60 return NGINX.getMappedPort(80);
65 return "http://" + getNginxIP() + ":" + getNginxPort();
68 int getMockServerPort()
70 return MOCK_SERVER.getLocalPort();
73 String getMockServerUri()
75 return "http://localhost:" + getMockServerPort();