use of com.github.tomakehurst.wiremock.testsupport.WireMockResponse in project wiremock by wiremock.
the class MappingsAcceptanceTest method notFoundResponseIsReturnedForUnregisteredUrl.
@Test
public void notFoundResponseIsReturnedForUnregisteredUrl() {
WireMockResponse response = testClient.get("/non-existent/resource");
assertThat(response.statusCode(), is(HTTP_NOT_FOUND));
}
use of com.github.tomakehurst.wiremock.testsupport.WireMockResponse in project wiremock by wiremock.
the class MappingsAcceptanceTest method readsJsonMapping.
@Test
public void readsJsonMapping() {
WireMockResponse response = testClient.get("/testjsonmapping");
assertThat(response.statusCode(), is(200));
assertThat(response.content(), is("{\"bignumber\":1234567890.12,\"array\":[1,2,3],\"key\":\"value\"}"));
}
use of com.github.tomakehurst.wiremock.testsupport.WireMockResponse in project wiremock by wiremock.
the class MappingsAcceptanceTest method basicMappingWithExactUrlAndMethodMatchIsCreatedAndReturned.
@Test
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"));
}
use of com.github.tomakehurst.wiremock.testsupport.WireMockResponse in project wiremock by wiremock.
the class MappingsLoaderAcceptanceTest method mappingsLoadedFromJsonFiles.
@Test
public void mappingsLoadedFromJsonFiles() {
buildWireMock(configuration);
wireMockServer.loadMappingsUsing(new JsonFileMappingsSource(new SingleRootFileSource(filePath("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));
}
use of com.github.tomakehurst.wiremock.testsupport.WireMockResponse in project wiremock by wiremock.
the class MultipartBodyMatchingAcceptanceTest method multipartBodiesCanBeMatchedWhenStubsWithOtherBodyMatchTypesArePresent.
// https://github.com/tomakehurst/wiremock/issues/1179
@Test
public void multipartBodiesCanBeMatchedWhenStubsWithOtherBodyMatchTypesArePresent() {
stubFor(post("/multipart").withMultipartRequestBody(aMultipart().withHeader("Content-Disposition", containing("wiremocktest"))).willReturn(ok()));
stubFor(post("/json").withRequestBody(equalToJson("{ \"stuff\": 123 }")).willReturn(ok()));
WireMockResponse response = testClient.postWithMultiparts("/multipart", singletonList(part("wiremocktest", "Whatever", TEXT_PLAIN)));
assertThat(response.statusCode(), is(200));
}
Aggregations