Package com.github.tomakehurst.wiremock.testsupport

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


       
        WireMockResponse response = testClient.putWithBody("/match/this/body/too", "Blah12345", "text/plain");
        assertThat(response.statusCode(), is(HTTP_NOT_FOUND));
       
        response = testClient.putWithBody("/match/this/body/too", "BlahBlahBlah", "text/plain");
        assertThat(response.statusCode(), is(HTTP_OK));
    }
 
  @Test
  public void responseWithFixedDelay() {
      stubFor(get(urlEqualTo("/delayed/resource")).willReturn(
View Full Code Here


        stubFor(patch(urlEqualTo("/a/registered/resource")).withRequestBody(equalTo("some body"))
                .willReturn(aResponse().withStatus(204)));

        WireMockResponse response = testClient.patchWithBody("/a/registered/resource", "some body", "text/plain");

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

  private void getAndAssertUnderlyingExceptionInstanceClass(String url, Class<?> expectedClass) {
    boolean thrown = false;
    try {
View Full Code Here

  public void mappingsLoadedFromJsonFiles() {
        buildWireMock(wireMockConfig());
        wireMockServer.loadMappingsUsing(new JsonFileMappingsLoader(new SingleRootFileSource("src/test/resources/test-requests")));

    WireMockResponse response = testClient.get("/canned/resource/1");
    assertThat(response.statusCode(), is(200));

    response = testClient.get("/canned/resource/2");
    assertThat(response.statusCode(), is(401));
  }
View Full Code Here

    WireMockResponse response = testClient.get("/canned/resource/1");
    assertThat(response.statusCode(), is(200));

    response = testClient.get("/canned/resource/2");
    assertThat(response.statusCode(), is(401));
  }

    @Test
    public void mappingsLoadedViaClasspath() {
        buildWireMock(wireMockConfig().usingFilesUnderClasspath("classpath-filesource"));
View Full Code Here

        WireMockResponse response = testClient.get("/todo/items");
        assertThat(response.content(), containsString("Buy milk"));
        assertThat(response.content(), not(containsString("Cancel newspaper subscription")));

        response = testClient.postWithBody("/todo/items", "Cancel newspaper subscription", "text/plain", "UTF-8");
        assertThat(response.statusCode(), is(201));

        response = testClient.get("/todo/items");
        assertThat(response.content(), containsString("Buy milk"));
        assertThat(response.content(), containsString("Cancel newspaper subscription"));
    }
View Full Code Here

        .willReturn(aResponse().withStatus(HTTP_OK))
        .inScenario("StateIndependent")
        .willSetStateTo("BodyModified"));
   
    WireMockResponse response = testClient.get("/state/independent/resource");
    assertThat(response.statusCode(), is(HTTP_OK));
    assertThat(response.content(), is("Some content"));
   
    testClient.put("/state/modifying/resource");
   
    response = testClient.get("/state/independent/resource");
View Full Code Here

    assertThat(response.content(), is("Some content"));
   
    testClient.put("/state/modifying/resource");
   
    response = testClient.get("/state/independent/resource");
    assertThat(response.statusCode(), is(HTTP_OK));
    assertThat(response.content(), is("Some content"));
  }
 
  @Test
  public void resetAllScenariosState() {
View Full Code Here

    private void executeGetIn(String address) {
        WireMockTestClient wireMockClient = new WireMockTestClient(port, address);
        wireMockClient.addResponse(MappingJsonSamples.BASIC_MAPPING_REQUEST_WITH_RESPONSE_HEADER);
        WireMockResponse response = wireMockClient.get("/a/registered/resource");
        assertThat(response.statusCode(), is(401));
    }

    private String getIpAddressOtherThan(String lopbackAddress) throws SocketException {
        Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
        for (NetworkInterface netInterface : Collections.list(networkInterfaces)) {
View Full Code Here

      "}                            ";
   
    testClient.addResponse(REGEX_URL_MAPPING_REQUEST);
    WireMockResponse response = testClient.get("/one/two/three");
   
    assertThat(response.statusCode(), is(200));
    assertThat(response.content(), is("Matched!"));
  }
}
View Full Code Here

  public void basicMappingWithExactUrlAndMethodMatchIsCreatedAndReturned() {
    testClient.addResponse(MappingJsonSamples.BASIC_MAPPING_REQUEST_WITH_RESPONSE_HEADER);
   
    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

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.