Package com.github.tomakehurst.wiremock.testsupport

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


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


    }

    @Test
    public void resetToDefaultRestoresOldMeaningOfDefault() {
        add200ResponseFor("/testmapping");
        WireMockResponse response1 = testClient.get("/testmapping");
        assertThat(response1.content(), is(""));

        testClient.resetDefaultMappings();

        WireMockResponse response2 = testClient.get("/testmapping");
        assertThat(response2.content(), is("default test mapping"));
    }
View Full Code Here

        testClient.addResponse(MAPPING_REQUEST_FOR_BINARY_BYTE_BODY);
        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));
  }
View Full Code Here

    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

        aResponse()
        .withStatus(401)
        .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"));
  }
View Full Code Here

    stubFor(get(urlEqualTo("/search?name=John&postcode=N44LL")).willReturn(
        aResponse()
        .withHeader("Location", "/nowhere")
        .withStatus(302)));
   
    WireMockResponse response = testClient.get("/search?name=John&postcode=N44LL");
   
    assertThat(response.statusCode(), is(302));
  }
View Full Code Here

      .withHeader("One", equalTo("abcd1234"))
      .withHeader("Two", matching("[a-z]{5}"))
      .withHeader("Three", notMatching("[A-Z]+"))
      .willReturn(aResponse().withStatus(204)));
   
    WireMockResponse response = testClient.put("/some/url",
        withHeader("One", "abcd1234"),
        withHeader("Two", "thing"),
        withHeader("Three", "something"));
   
    assertThat(response.statusCode(), is(204));
  }
View Full Code Here

      .withHeader("ONE", equalTo("abcd1234"))
      .withHeader("two", matching("[a-z]{5}"))
      .withHeader("Three", notMatching("[A-Z]+"))
      .willReturn(aResponse().withStatus(204)));
   
    WireMockResponse response = testClient.put("/case/insensitive",
        withHeader("one", "abcd1234"),
        withHeader("TWO", "thing"),
        withHeader("tHrEe", "something"));
   
    assertThat(response.statusCode(), is(204));
  }
View Full Code Here

    public void matchesIfRequestContainsHeaderNotSpecified() {
        stubFor(get(urlEqualTo("/some/extra/header"))
                .withHeader("ExpectedHeader", equalTo("expected-value"))
                .willReturn(aResponse().withStatus(200)));

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

        assertThat(response.statusCode(), is(200));
    }
View Full Code Here

    stubFor(get(urlEqualTo("/my/file")).willReturn(
        aResponse()
        .withStatus(200)
        .withBodyFile("plain-example.txt")));
   
    WireMockResponse response = testClient.get("/my/file");
   
    assertThat(response.content(), is("Some example test from a file"));
  }
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.