use of io.restassured.filter.log.ResponseLoggingFilter in project rest-assured by rest-assured.
the class LoggingITest method prettifying_empty_xml_body_doesnt_log_premature_end_of_file.
// This was previously a bug (https://github.com/rest-assured/rest-assured/issues/960)
@Test
public void prettifying_empty_xml_body_doesnt_log_premature_end_of_file() {
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
given().filter(new ResponseLoggingFilter(LogDetail.ALL, true, captor)).filter((requestSpec, responseSpec, ctx) -> new ResponseBuilder().setStatusCode(200).setContentType(ContentType.XML).setBody("").build()).when().get("/xml-empty-body").then().statusCode(200);
assertThat(writer.toString(), equalTo("200" + LINE_SEPARATOR + "Content-Type: application/xml" + LINE_SEPARATOR));
}
use of io.restassured.filter.log.ResponseLoggingFilter in project rest-assured by rest-assured.
the class LoggingITest method loggingRequestAndResponseAtTheSameTimeWhenResponseFilterIsAddedBeforeRequestFilter.
@Test
public void loggingRequestAndResponseAtTheSameTimeWhenResponseFilterIsAddedBeforeRequestFilter() throws Exception {
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
final ScalatraObject object = new ScalatraObject();
object.setHello("Hello world");
given().filters(new ResponseLoggingFilter(captor), new RequestLoggingFilter(captor)).body(object).expect().defaultParser(JSON).when().post("/reflect");
assertThat(writer.toString(), equalTo("Request method:\tPOST\nRequest URI:\thttp://localhost:8080/reflect\nProxy:\t\t\t<none>\nRequest params:\t<none>\nQuery params:\t<none>\nForm params:\t<none>\nPath params:\t<none>\nHeaders:\t\tAccept=*/*\n\t\t\t\tContent-Type=text/plain; charset=" + RestAssured.config().getEncoderConfig().defaultContentCharset() + "\nCookies:\t\t<none>\nMultiparts:\t\t<none>\nBody:\n{\"hello\":\"Hello world\"}" + LINE_SEPARATOR + "HTTP/1.1 200 OK\nContent-Type: text/plain;charset=iso-8859-1\nContent-Length: 23\nServer: Jetty(9.3.2.v20150730)\n\n{\"hello\":\"Hello world\"}" + LINE_SEPARATOR));
}
use of io.restassured.filter.log.ResponseLoggingFilter in project rest-assured by rest-assured.
the class LoggingITest method loggingRequestAndResponseAtTheSameTimeWhenRequestFilterIsAddedBeforeResponseFilter.
@Test
public void loggingRequestAndResponseAtTheSameTimeWhenRequestFilterIsAddedBeforeResponseFilter() throws Exception {
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
final ScalatraObject object = new ScalatraObject();
object.setHello("Hello world");
given().filters(new RequestLoggingFilter(captor), new ResponseLoggingFilter(captor)).body(object).expect().defaultParser(JSON).when().post("/reflect");
assertThat(writer.toString(), equalTo("Request method:\tPOST\nRequest URI:\thttp://localhost:8080/reflect\nProxy:\t\t\t<none>\nRequest params:\t<none>\nQuery params:\t<none>\nForm params:\t<none>\nPath params:\t<none>\nHeaders:\t\tAccept=*/*\n\t\t\t\tContent-Type=text/plain; charset=" + RestAssured.config().getEncoderConfig().defaultContentCharset() + "\nCookies:\t\t<none>\nMultiparts:\t\t<none>\nBody:\n{\"hello\":\"Hello world\"}" + LINE_SEPARATOR + "HTTP/1.1 200 OK\nContent-Type: text/plain;charset=iso-8859-1\nContent-Length: 23\nServer: Jetty(9.3.2.v20150730)\n\n{\"hello\":\"Hello world\"}" + LINE_SEPARATOR));
}
Aggregations