Package com.github.tomakehurst.wiremock.client

Examples of com.github.tomakehurst.wiremock.client.WireMock


                requestDelayControl
        );

        Log.setLog(new LoggerAdapter(notifier));

        client = new WireMock(wireMockApp);
    }
View Full Code Here


    WireMockTestClient testClient;

  void init(Options proxyingServiceOptions) {
    targetService = new WireMockServer(wireMockConfig().port(TARGET_SERVICE_PORT).httpsPort(TARGET_SERVICE_HTTPS_PORT));
    targetService.start();
    targetServiceAdmin = new WireMock("localhost", TARGET_SERVICE_PORT);

        proxyingService = new WireMockServer(proxyingServiceOptions);
        proxyingService.start();
        proxyingServiceAdmin = new WireMock();
        testClient = new WireMockTestClient();
        WireMock.configure();
  }
View Full Code Here

    WireMockTestClient testClient;

  void init(Options proxyingServiceOptions) {
    targetService = new WireMockServer(wireMockConfig().port(TARGET_SERVICE_PORT).httpsPort(TARGET_SERVICE_HTTPS_PORT));
    targetService.start();
    targetServiceAdmin = new WireMock("localhost", TARGET_SERVICE_PORT);

        proxyingService = new WireMockServer(proxyingServiceOptions);
        proxyingService.start();
        proxyingServiceAdmin = new WireMock();
        testClient = new WireMockTestClient();
        WireMock.configure();
  }
View Full Code Here

  }
 
  @Test
  public void startsOnPortSpecifiedOnCommandLine() {
    startRunner("--port", "8086");
    WireMock client = new WireMock("localhost", 8086);
    client.verifyThat(0, getRequestedFor(urlEqualTo("/bling/blang/blong"))); //Would throw an exception if couldn't connect
  }
View Full Code Here

    client.verifyThat(0, getRequestedFor(urlEqualTo("/bling/blang/blong"))); //Would throw an exception if couldn't connect
  }
 
  @Test
  public void proxiesToHostSpecifiedOnCommandLine() {
    WireMock otherServerClient = start8084ServerAndCreateClient();
    otherServerClient.register(get(urlEqualTo("/proxy/ok?working=yes")).willReturn(aResponse().withStatus(HTTP_OK)));
    startRunner("--proxy-all", "http://localhost:8084");
   
    WireMockResponse response = testClient.get("/proxy/ok?working=yes");
    assertThat(response.statusCode(), is(HTTP_OK));
  }
View Full Code Here

  @Test
  public void respondsWithPreExistingRecordingInProxyMode() {
    writeMappingFile("test-mapping-2.json", BODY_FILE_MAPPING_REQUEST);
    writeFileToFilesDir("body-test.xml", "Existing recorded body");

    WireMock otherServerClient = start8084ServerAndCreateClient();
    otherServerClient.register(
                get(urlEqualTo("/body/file"))
                        .willReturn(aResponse().withStatus(HTTP_OK).withBody("Proxied body")));

    startRunner("--proxy-all", "http://localhost:8084");
View Full Code Here

    assertThat(testClient.get("/body/file").content(), is("Existing recorded body"));
  }

  @Test
  public void recordsProxiedRequestsWhenSpecifiedOnCommandLine() throws Exception {
      WireMock otherServerClient = start8084ServerAndCreateClient();
    startRunner("--record-mappings");
    givenThat(get(urlEqualTo("/please/record-this"))
            .willReturn(aResponse().proxiedFrom("http://localhost:8084")));
    otherServerClient.register(
            get(urlEqualTo("/please/record-this"))
            .willReturn(aResponse().withStatus(HTTP_OK).withBody("Proxied body")));

    testClient.get("/please/record-this");
   
View Full Code Here

            containsString("bodyFileName\" : \"body-please-record-this"));
  }
 
  @Test
  public void recordsRequestHeadersWhenSpecifiedOnCommandLine() throws Exception {
      WireMock otherServerClient = start8084ServerAndCreateClient();
    startRunner("--record-mappings", "--match-headers", "Accept");
    givenThat(get(urlEqualTo("/please/record-headers"))
            .willReturn(aResponse().proxiedFrom("http://localhost:8084")));
    otherServerClient.register(
            get(urlEqualTo("/please/record-headers"))
            .willReturn(aResponse().withStatus(HTTP_OK).withBody("Proxied body")));
   
    testClient.get("/please/record-headers", withHeader("accept", "application/json"));
   
View Full Code Here

    assertThat(contentsOfFirstFileNamedLike("please-record-headers"), containsString("\"Accept\" : {"));
  }
 
  @Test
  public void performsBrowserProxyingWhenEnabled() {
    WireMock otherServerClient = start8084ServerAndCreateClient();
    startRunner("--enable-browser-proxying");
    otherServerClient.register(
            get(urlEqualTo("/from/browser/proxy"))
            .willReturn(aResponse().withStatus(HTTP_OK).withBody("Proxied body")));

    assertThat(testClient.getViaProxy("http://localhost:8084/from/browser/proxy").content(), is("Proxied body"));
  }
View Full Code Here

  }
 
  private WireMock start8084ServerAndCreateClient() {
        otherServer = new WireMockServer(8084);
        otherServer.start();
        return new WireMock("localhost", 8084);
    }
View Full Code Here

TOP

Related Classes of com.github.tomakehurst.wiremock.client.WireMock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.