Search in sources :

Example 36 with WireMockTestClient

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

the class ResponseDelayAcceptanceTest method init.

@BeforeEach
public void init() {
    httpClient = HttpClientFactory.createClient(SOCKET_TIMEOUT_MILLISECONDS);
    testClient = new WireMockTestClient(wireMockRule.getPort());
}
Also used : WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 37 with WireMockTestClient

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

the class BindAddressTest method executeGetIn.

private void executeGetIn(String address) {
    WireMockTestClient wireMockClient = new WireMockTestClient(wireMockServer.port(), address);
    WireMockResponse response = wireMockClient.get("/bind-test");
    assertThat(response.statusCode(), is(200));
}
Also used : WireMockResponse(com.github.tomakehurst.wiremock.testsupport.WireMockResponse) WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient)

Example 38 with WireMockTestClient

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

the class BrowserProxyAcceptanceTest method init.

@BeforeEach
public void init() {
    testClient = new WireMockTestClient(target.getPort());
    proxy = new WireMockServer(wireMockConfig().dynamicPort().enableBrowserProxying(true));
    proxy.start();
}
Also used : WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 39 with WireMockTestClient

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

the class ConcurrentProxyingTest method concurrent.

@Test
public void concurrent() throws Exception {
    client = new WireMockTestClient(wm.getPort());
    wm.stubFor(any(anyUrl()).atPriority(10).willReturn(aResponse().proxiedFrom(target.baseUrl())));
    ExecutorService executor = Executors.newFixedThreadPool(20);
    List<Future<?>> results = newArrayList();
    for (int i = 0; i < 100; i++) {
        results.add(executor.submit(new Runnable() {

            @Override
            public void run() {
                assertThat(client.get("/plain-example1.txt").content(), is("Example 1"));
                assertThat(client.get("/plain-example2.txt").content(), is("Example 2"));
                assertThat(client.get("/plain-example3.txt").content(), is("Example 3"));
                assertThat(client.get("/plain-example4.txt").content(), is("Example 4"));
                assertThat(client.get("/plain-example5.txt").content(), is("Example 5"));
            }
        }));
    }
    for (Future<?> result : results) {
        result.get();
    }
}
Also used : WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient) ExecutorService(java.util.concurrent.ExecutorService) Future(java.util.concurrent.Future) Test(org.junit.jupiter.api.Test)

Example 40 with WireMockTestClient

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

the class CustomMatchingAcceptanceTest method init.

@BeforeEach
public void init() {
    client = new WireMockTestClient(wmRule.getPort());
    wm = WireMock.create().port(wmRule.getPort()).build();
}
Also used : WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient) BeforeEach(org.junit.jupiter.api.BeforeEach)

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