use of com.github.tomakehurst.wiremock.testsupport.WireMockResponse in project wiremock by wiremock.
the class ScenarioAcceptanceTest method mappingInScenarioIndependentOfCurrentState.
@Test
public void mappingInScenarioIndependentOfCurrentState() {
givenThat(get(urlEqualTo("/state/independent/resource")).willReturn(aResponse().withBody("Some content")).inScenario("StateIndependent"));
givenThat(put(urlEqualTo("/state/modifying/resource")).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");
assertThat(response.statusCode(), is(HTTP_OK));
assertThat(response.content(), is("Some content"));
}
use of com.github.tomakehurst.wiremock.testsupport.WireMockResponse in project wiremock by wiremock.
the class StandaloneAcceptanceTest method doesNotServeFileFromFilesDirWhenNotGET.
@Test
public void doesNotServeFileFromFilesDirWhenNotGET() {
writeFileToFilesDir("json/should-not-see-this.json", "{}");
startRunner();
WireMockResponse response = testClient.put("/json/should-not-see-this.json");
assertThat(response.statusCode(), // Default servlet returns 405 if PUT is forwarded to it
is(404));
}
use of com.github.tomakehurst.wiremock.testsupport.WireMockResponse in project wiremock by wiremock.
the class StandaloneAcceptanceTest method servesFileFromSpecifiedRecordingsPath.
@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"));
}
use of com.github.tomakehurst.wiremock.testsupport.WireMockResponse in project wiremock by wiremock.
the class StandaloneAcceptanceTest method proxiesToHostSpecifiedOnCommandLine.
@Test
public void proxiesToHostSpecifiedOnCommandLine() throws Exception {
WireMock otherServerClient = startOtherServerAndClient();
otherServerClient.register(get(urlEqualTo("/proxy/ok?working=yes")).willReturn(aResponse().withStatus(HTTP_OK)));
startRunner("--proxy-all", "http://localhost:" + otherServer.port());
WireMockResponse response = testClient.get("/proxy/ok?working=yes");
assertThat(response.statusCode(), is(HTTP_OK));
}
use of com.github.tomakehurst.wiremock.testsupport.WireMockResponse in project wiremock by wiremock.
the class StandaloneAcceptanceTest method servesFileAsJsonWhenNoFileExtension.
@Test
public void servesFileAsJsonWhenNoFileExtension() {
writeFileToFilesDir("json/12345", "{ \"key\": \"value\" }");
startRunner();
WireMockResponse response = testClient.get("/json/12345");
assertThat(response.statusCode(), is(200));
assertThat(response.content(), is("{ \"key\": \"value\" }"));
assertThat(response.firstHeader("Content-Type"), is("application/json"));
}
Aggregations