Package com.github.tomakehurst.wiremock.testsupport

Examples of com.github.tomakehurst.wiremock.testsupport.WireMockResponse.statusCode()


  public void mappingWithStatusOnlyResponseIsCreatedAndReturned() {
    testClient.addResponse(MappingJsonSamples.STATUS_ONLY_MAPPING_REQUEST);
   
    WireMockResponse response = testClient.put("/status/only");
   
    assertThat(response.statusCode(), is(204));
    assertNull(response.content());
  }
 
  @Test
  public void notFoundResponseIsReturnedForUnregisteredUrl() {
View Full Code Here


  }
 
  @Test
  public void notFoundResponseIsReturnedForUnregisteredUrl() {
    WireMockResponse response = testClient.get("/non-existent/resource");
    assertThat(response.statusCode(), is(HTTP_NOT_FOUND));
  }
 
  @Test
  public void multipleMappingsSupported() {
    add200ResponseFor("/resource/1");
View Full Code Here

        assertThat(testClient.get("/bytecompressed/resource/from/file").binaryContent(), is(BINARY_COMPRESSED_CONTENT));
    }
 
  private void getResponseAndAssert200Status(String url) {
    WireMockResponse response = testClient.get(url);
    assertThat(response.statusCode(), is(200));
  }
 
  private void getResponseAndAssert404Status(String url) {
    WireMockResponse response = testClient.get(url);
    assertThat(response.statusCode(), is(404));
View Full Code Here

    assertThat(response.statusCode(), is(200));
  }
 
  private void getResponseAndAssert404Status(String url) {
    WireMockResponse response = testClient.get(url);
    assertThat(response.statusCode(), is(404));
  }
 
  private void add200ResponseFor(String url) {
    testClient.addResponse(String.format(MappingJsonSamples.STATUS_ONLY_GET_MAPPING_TEMPLATE, url));
  }
View Full Code Here

        .withHeader("Content-Type", "text/plain")
        .withBody("Not allowed!")));
   
    WireMockResponse response = testClient.get("/a/registered/resource");
   
    assertThat(response.statusCode(), is(401));
    assertThat(response.content(), is("Not allowed!"));
    assertThat(response.firstHeader("Content-Type"), is("text/plain"));
  }
 
  @Test
View Full Code Here

        .withHeader("Location", "/nowhere")
        .withStatus(302)));
   
    WireMockResponse response = testClient.get("/search?name=John&postcode=N44LL");
   
    assertThat(response.statusCode(), is(302));
  }
 
  @Test
  public void mappingWithHeaderMatchers() {
    stubFor(put(urlEqualTo("/some/url"))
View Full Code Here

    WireMockResponse response = testClient.put("/some/url",
        withHeader("One", "abcd1234"),
        withHeader("Two", "thing"),
        withHeader("Three", "something"));
   
    assertThat(response.statusCode(), is(204));
  }
 
  @Test
  public void mappingWithCaseInsensitiveHeaderMatchers() {
    stubFor(put(urlEqualTo("/case/insensitive"))
View Full Code Here

    WireMockResponse response = testClient.put("/case/insensitive",
        withHeader("one", "abcd1234"),
        withHeader("TWO", "thing"),
        withHeader("tHrEe", "something"));
   
    assertThat(response.statusCode(), is(204));
  }

    @Test
    public void doesNotMatchOnAbsentHeader() {
        stubFor(post(urlEqualTo("/some/url"))
View Full Code Here

        WireMockResponse response = testClient.get("/some/extra/header",
                withHeader("ExpectedHeader", "expected-value"),
                withHeader("UnexpectedHeader", "unexpected-value"));

        assertThat(response.statusCode(), is(200));
    }

    @Test
    public void matchesOnUrlPathAndQueryParameters() {
        stubFor(get(urlPathEqualTo("/path-and-query/match"))
View Full Code Here

              .willReturn(aResponse()
                .withStatus(HTTP_OK)
                .withBodyFile("plain-example.txt")));
       
        WireMockResponse response = testClient.putWithBody("/match/this/body", "Blah...but not the rest", "text/plain");
        assertThat(response.statusCode(), is(HTTP_NOT_FOUND));
        response = testClient.putWithBody("/match/this/body", "@12345@...but not the rest", "text/plain");
        assertThat(response.statusCode(), is(HTTP_NOT_FOUND));
       
        response = testClient.putWithBody("/match/this/body", "BlahBlah@56565@Blah", "text/plain");
        assertThat(response.statusCode(), is(HTTP_OK));
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.