Search in sources :

Example 1 with WireMockTestClient

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

the class AdminRequestHandlerTest method shouldLogInfoOnRequest.

@Test
public void shouldLogInfoOnRequest() throws UnsupportedEncodingException {
    WireMockTestClient client = new WireMockTestClient(wm.getPort());
    String postHeaderABCName = "ABC";
    String postHeaderABCValue = "abc123";
    String postBody = "{\n" + "    \"request\": {\n" + "        \"method\": \"GET\",\n" + "        \"url\": \"/some/thing\"\n" + "    },\n" + "    \"response\": {\n" + "        \"status\": 200,\n" + "        \"body\": \"Hello world!\",\n" + "        \"headers\": {\n" + "            \"Content-Type\": \"text/plain\"\n" + "        }\n" + "    }\n" + "}";
    client.post("/__admin/mappings", new StringEntity(postBody), withHeader(postHeaderABCName, postHeaderABCValue));
    verify(notifier).info(contains("Admin request received:\n127.0.0.1 - POST /mappings\n"));
    verify(notifier).info(contains(postHeaderABCName + ": [" + postHeaderABCValue + "]\n"));
    verify(notifier).info(contains(postBody));
}
Also used : StringEntity(org.apache.hc.core5.http.io.entity.StringEntity) WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient) Test(org.junit.jupiter.api.Test)

Example 2 with WireMockTestClient

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

the class AcceptanceTestBase method setupServer.

public static void setupServer(WireMockConfiguration options) {
    System.out.println("Configuring WireMockServer with root directory: " + options.filesRoot().getPath());
    if (options.portNumber() == Options.DEFAULT_PORT) {
        options.dynamicPort();
    }
    wireMockServer = new WireMockServer(options);
    wireMockServer.start();
    testClient = new WireMockTestClient(wireMockServer.port());
    WireMock.configureFor(wireMockServer.port());
    wm = wireMockServer;
}
Also used : WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient)

Example 3 with WireMockTestClient

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

the class ResponseTransformerAcceptanceTest method startWithExtensions.

@SuppressWarnings("unchecked")
private void startWithExtensions(Class<? extends Extension> extensionClasses) {
    wm = new WireMockServer(wireMockConfig().dynamicPort().extensions(extensionClasses));
    wm.start();
    client = new WireMockTestClient(wm.port());
}
Also used : WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient)

Example 4 with WireMockTestClient

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

the class SnapshotDslAcceptanceTest method init.

@BeforeEach
public void init() {
    proxyingService = new WireMockServer(wireMockConfig().dynamicPort().extensions(new TestParameterisedTransformer()).withRootDirectory(setupTempFileRoot().getAbsolutePath()));
    proxyingService.start();
    proxyingService.stubFor(proxyAllTo("http://localhost:" + wireMockServer.port()));
    targetService = wireMockServer;
    proxyStub = targetService.stubFor(any(anyUrl()).willReturn(ok()));
    client = new WireMockTestClient(proxyingService.port());
    WireMock.configureFor(proxyingService.port());
    adminClient = WireMock.create().port(proxyingService.port()).build();
}
Also used : WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with WireMockTestClient

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

the class StandaloneAcceptanceTest method startRunner.

private void startRunner(String... args) {
    runner = new WireMockServerRunner();
    runner.run(argsWithPort(argsWithRecordingsPath(args)));
    int port = runner.port();
    testClient = new WireMockTestClient(port);
    WireMock.configureFor(port);
}
Also used : WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient) WireMockServerRunner(com.github.tomakehurst.wiremock.standalone.WireMockServerRunner)

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