Search in sources :

Example 11 with WireMockTestClient

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

the class ResponseDefinitionTransformerAcceptanceTest method supportsSpecifiyingExtensionsByInstance.

@Test
public void supportsSpecifiyingExtensionsByInstance() {
    wm = new WireMockServer(wireMockConfig().dynamicPort().extensions(new ExampleTransformer(), new MultiTransformer2()));
    wm.start();
    client = new WireMockTestClient(wm.port());
    createStub("/to-instance-transform");
    WireMockResponse response = client.get("/to-instance-transform");
    assertThat(response.statusCode(), is(200));
    assertThat(response.content(), is("Expect this"));
}
Also used : WireMockResponse(com.github.tomakehurst.wiremock.testsupport.WireMockResponse) WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient) Test(org.junit.jupiter.api.Test)

Example 12 with WireMockTestClient

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

the class ResponseDefinitionTransformerAcceptanceTest method supportsSpecifiyingExtensionsByClass.

@Test
public void supportsSpecifiyingExtensionsByClass() {
    wm = new WireMockServer(wireMockConfig().dynamicPort().extensions(ExampleTransformer.class, MultiTransformer1.class));
    wm.start();
    client = new WireMockTestClient(wm.port());
    createStub("/to-class-transform");
    WireMockResponse response = client.get("/to-class-transform");
    assertThat(response.statusCode(), is(201));
    assertThat(response.content(), is("Transformed body"));
}
Also used : WireMockResponse(com.github.tomakehurst.wiremock.testsupport.WireMockResponse) WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient) Test(org.junit.jupiter.api.Test)

Example 13 with WireMockTestClient

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

the class NotMatchedPageAcceptanceTest method configure.

private void configure(WireMockConfiguration options) {
    options.dynamicPort().withRootDirectory("src/test/resources/empty");
    wm = new WireMockServer(options);
    wm.start();
    testClient = new WireMockTestClient(wm.port());
    WireMock.configureFor(wm.port());
}
Also used : WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient)

Example 14 with WireMockTestClient

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

the class PortNumberTest method canRunOnAnotherPortThan8080.

@Test
public void canRunOnAnotherPortThan8080() {
    int port = Network.findFreePort();
    WireMockServer wireMockServer = createServer(wireMockConfig().port(port));
    wireMockServer.start();
    WireMockTestClient wireMockClient = new WireMockTestClient(port);
    wireMockClient.addResponse(MappingJsonSamples.BASIC_MAPPING_REQUEST_WITH_RESPONSE_HEADER);
    WireMockResponse response = wireMockClient.get("/a/registered/resource");
    assertThat(response.statusCode(), is(401));
}
Also used : WireMockResponse(com.github.tomakehurst.wiremock.testsupport.WireMockResponse) WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient) Test(org.junit.jupiter.api.Test)

Example 15 with WireMockTestClient

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

the class ProxyAcceptanceTest method init.

void init(WireMockConfiguration proxyingServiceOptions) {
    targetService = new WireMockServer(wireMockConfig().dynamicPort().dynamicHttpsPort().bindAddress("127.0.0.1").stubCorsEnabled(true));
    targetService.start();
    target = WireMock.create().host("localhost").port(targetService.port()).build();
    targetServiceBaseUrl = "http://localhost:" + targetService.port();
    proxyingServiceOptions.dynamicPort().bindAddress("127.0.0.1");
    proxyingService = new WireMockServer(proxyingServiceOptions);
    proxyingService.start();
    proxy = WireMock.create().port(proxyingService.port()).build();
    testClient = new WireMockTestClient(proxyingService.port());
    WireMock.configureFor(targetService.port());
}
Also used : WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient)

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