Package com.github.tomakehurst.wiremock.testsupport

Examples of com.github.tomakehurst.wiremock.testsupport.WireMockResponse


        proxyingServiceAdmin.register(any(urlEqualTo("/proxied/resource?param=value")).atPriority(10)
        .willReturn(aResponse()
        .proxiedFrom(TARGET_SERVICE_BASE_URL)));
   
    WireMockResponse response = testClient.get("/proxied/resource?param=value");
   
    assertThat(response.content(), is("Proxied content"));
    assertThat(response.firstHeader("Content-Type"), is("text/plain"));
  }
View Full Code Here


        proxyingServiceAdmin.register(any(urlEqualTo("/proxied/resource")).atPriority(10)
        .willReturn(aResponse()
        .proxiedFrom(TARGET_SERVICE_BASE_URL)));
   
    WireMockResponse response = testClient.postWithBody("/proxied/resource", "Post content", "text/plain", "utf-8");
   
    assertThat(response.statusCode(), is(204));
    targetServiceAdmin.verifyThat(postRequestedFor(urlEqualTo("/proxied/resource")).withRequestBody(matching("Post content")));
  }
View Full Code Here

        proxyingServiceAdmin.register(any(urlEqualTo("/%26%26The%20Lord%20of%20the%20Rings%26%26")).atPriority(10)
                .willReturn(aResponse()
                        .proxiedFrom(TARGET_SERVICE_BASE_URL)));
   
    WireMockResponse response = testClient.get("/%26%26The%20Lord%20of%20the%20Rings%26%26");
   
    assertThat(response.statusCode(), is(200));
  }
View Full Code Here

        proxyingServiceAdmin.register(any(urlEqualTo("/extra/headers"))
                .willReturn(aResponse()
                        .withHeader("X-Additional-Header", "Yep")
                        .proxiedFrom(TARGET_SERVICE_BASE_URL)));

        WireMockResponse response = testClient.get("/extra/headers");

        assertThat(response.firstHeader("Content-Type"), is("text/plain"));
        assertThat(response.firstHeader("X-Additional-Header"), is("Yep"));
    }
View Full Code Here

 
  @Test
  public void mappingWithExactUrlMethodAndHeaderMatchingIsCreatedAndReturned() {
    testClient.addResponse(MappingJsonSamples.MAPPING_REQUEST_WITH_EXACT_HEADERS);
   
    WireMockResponse response = testClient.get("/header/dependent",
        withHeader("Accept", "text/xml"),
        withHeader("If-None-Match", "abcd1234"));
   
    assertThat(response.statusCode(), is(304));
  }
View Full Code Here

  @Test
  public void mappingMatchedWithRegexHeaders() {
    testClient.addResponse(MappingJsonSamples.MAPPING_REQUEST_WITH_REGEX_HEADERS);
   
    WireMockResponse response = testClient.get("/header/match/dependent",
        withHeader("Accept", "text/xml"),
        withHeader("If-None-Match", "abcd1234"));
   
    assertThat(response.statusCode(), is(304));
  }
View Full Code Here

 
  @Test
  public void mappingMatchedWithNegativeRegexHeader() {
    testClient.addResponse(MappingJsonSamples.MAPPING_REQUEST_WITH_NEGATIVE_REGEX_HEADERS);
   
    WireMockResponse response = testClient.get("/header/match/dependent",
        withHeader("Accept", "text/xml"));
    assertThat(response.statusCode(), is(HTTP_NOT_FOUND));
   
    response = testClient.get("/header/match/dependent",
        withHeader("Accept", "application/json"));
    assertThat(response.statusCode(), is(200));
  }
View Full Code Here

        WireMockServer wireMockServer = createServer(wireMockConfig().port(8090));
        wireMockServer.start();
        WireMockTestClient wireMockClient = new WireMockTestClient(8090);

        wireMockClient.addResponse(MappingJsonSamples.BASIC_MAPPING_REQUEST_WITH_RESPONSE_HEADER);
        WireMockResponse response = wireMockClient.get("/a/registered/resource");
        assertThat(response.statusCode(), is(401));
    }
View Full Code Here

  @Test
  public void servesFileFromFilesDir() {
    writeFileToFilesDir("test-1.xml", "<content>Blah</content>");
    startRunner();
    WireMockResponse response = testClient.get("/test-1.xml");
    assertThat(response.statusCode(), is(200));
    assertThat(response.content(), is("<content>Blah</content>"));
    assertThat(response.firstHeader("Content-Type"), is("application/xml"));
  }
View Full Code Here

  @Test
  public void servesFileFromSpecifiedRecordingsPath() {
    String differentRoot = FILE_SOURCE_ROOT + separator + "differentRoot";
    writeFile(differentRoot + separator + underFiles("test-1.xml"), "<content>Blah</content>");
    startRunner("--root-dir", differentRoot);
    WireMockResponse response = testClient.get("/test-1.xml");
    assertThat(response.statusCode(), is(200));
    assertThat(response.content(), is("<content>Blah</content>"));
    assertThat(response.firstHeader("Content-Type"), is("application/xml"));
  }
View Full Code Here

TOP

Related Classes of com.github.tomakehurst.wiremock.testsupport.WireMockResponse

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.