Search in sources :

Example 16 with WireMockTestClient

use of com.github.tomakehurst.wiremock.testsupport.WireMockTestClient in project wiremock by wiremock.

the class RecordApiAcceptanceTest method proxyServerStart.

private void proxyServerStart(WireMockConfiguration config) {
    proxyingService = new WireMockServer(config.dynamicPort());
    proxyingService.start();
    proxyTargetUrl = "http://localhost:" + wireMockServer.port();
    proxyingService.stubFor(proxyAllTo(proxyTargetUrl).withMetadata(metadata().attr("proxy", true)));
    proxyingTestClient = new WireMockTestClient(proxyingService.port());
    wireMockServer.stubFor(any(anyUrl()).willReturn(ok()));
}
Also used : WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient)

Example 17 with WireMockTestClient

use of com.github.tomakehurst.wiremock.testsupport.WireMockTestClient in project wiremock by wiremock.

the class StubRequestLoggingAcceptanceTest method doesNotLogEventsToNotifierWhenDisabled.

@Test
public void doesNotLogEventsToNotifierWhenDisabled() {
    TestNotifier notifier = new TestNotifier();
    WireMockServer wm = new WireMockServer(wireMockConfig().dynamicPort().stubRequestLoggingDisabled(true).notifier(notifier));
    wm.start();
    testClient = new WireMockTestClient(wm.port());
    wm.stubFor(get("/log-me").willReturn(ok("body")));
    testClient.get("/log-me");
    assertThat(notifier.infoMessages.size(), is(0));
}
Also used : WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient) Test(org.junit.jupiter.api.Test)

Example 18 with WireMockTestClient

use of com.github.tomakehurst.wiremock.testsupport.WireMockTestClient in project wiremock by wiremock.

the class TransferEncodingAcceptanceTest method startWithChunkedEncodingPolicy.

private void startWithChunkedEncodingPolicy(Options.ChunkedEncodingPolicy chunkedEncodingPolicy) {
    wm = new WireMockServer(wireMockConfig().dynamicPort().withRootDirectory(filePath("test-file-root")).useChunkedTransferEncoding(chunkedEncodingPolicy));
    wm.start();
    testClient = new WireMockTestClient(wm.port());
}
Also used : WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient)

Example 19 with WireMockTestClient

use of com.github.tomakehurst.wiremock.testsupport.WireMockTestClient in project wiremock by wiremock.

the class WarDeploymentAcceptanceTest method init.

@BeforeEach
public void init() throws Exception {
    String webAppRootPath = sampleWarRootDir() + "/src/main/webapp";
    WebAppContext context = new WebAppContext(webAppRootPath, "/wiremock");
    int port = attemptToStartOnRandomPort(context);
    WireMock.configureFor("localhost", port, "/wiremock");
    testClient = new WireMockTestClient(port);
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient) Matchers.containsString(org.hamcrest.Matchers.containsString) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 20 with WireMockTestClient

use of com.github.tomakehurst.wiremock.testsupport.WireMockTestClient in project wiremock by wiremock.

the class WarDeploymentParameterAcceptanceTest method init.

/**
 * Start jetty and wiremock. This is not an @Before method since we need to pass a parameter
 *
 * @param webInfPath Path where the WEB-INF directory for jetty resides
 * @param mappingPath Path where wiremock is mapped
 */
private void init(String webInfPath, String mappingPath) throws Exception {
    int port = Network.findFreePort();
    jetty = new Server(port);
    WebAppContext context = new WebAppContext(webInfPath, "/wiremock");
    jetty.setHandler(context);
    jetty.start();
    WireMock.configureFor("localhost", port, "/wiremock" + mappingPath);
    testClient = new WireMockTestClient(port);
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient) Server(org.eclipse.jetty.server.Server)

Aggregations

WireMockTestClient (com.github.tomakehurst.wiremock.testsupport.WireMockTestClient)43 Test (org.junit.jupiter.api.Test)16 BeforeEach (org.junit.jupiter.api.BeforeEach)10 WireMockResponse (com.github.tomakehurst.wiremock.testsupport.WireMockResponse)9 WireMockServer (com.github.tomakehurst.wiremock.WireMockServer)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 BeforeAll (org.junit.jupiter.api.BeforeAll)3 SingleRootFileSource (com.github.tomakehurst.wiremock.common.SingleRootFileSource)2 WebAppContext (org.eclipse.jetty.webapp.WebAppContext)2 FileSource (com.github.tomakehurst.wiremock.common.FileSource)1 ProxySettings (com.github.tomakehurst.wiremock.common.ProxySettings)1 Request (com.github.tomakehurst.wiremock.http.Request)1 X509KeyStore (com.github.tomakehurst.wiremock.http.ssl.X509KeyStore)1 WireMockServerRunner (com.github.tomakehurst.wiremock.standalone.WireMockServerRunner)1 Stopwatch (com.google.common.base.Stopwatch)1 Certificate (java.security.cert.Certificate)1 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 ExecutorService (java.util.concurrent.ExecutorService)1 Future (java.util.concurrent.Future)1