Package com.github.tomakehurst.wiremock.client

Examples of com.github.tomakehurst.wiremock.client.WireMock.register()


  }
 
  @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


  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

  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

  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

 
  @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

  }
 
  @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

  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

  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

  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

 
  @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

TOP
Copyright © 2018 www.massapi.com. 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.