use of io.restassured.filter.log.RequestLoggingFilter in project rest-assured by rest-assured.
the class LoggingITest method loggingRequestFilterWithBody.
@Test
public void loggingRequestFilterWithBody() 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().filter(new RequestLoggingFilter(captor)).and().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));
}
use of io.restassured.filter.log.RequestLoggingFilter in project rest-assured by rest-assured.
the class ProxyITest method proxy_details_are_shown_in_the_request_log.
@Test
public void proxy_details_are_shown_in_the_request_log() {
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
given().filter(new RequestLoggingFilter(captor)).proxy("127.0.0.1").param("firstName", "John").param("lastName", "Doe").when().get("/greetJSON").then().header("Via", not(isEmptyOrNullString()));
assertThat(writer.toString(), equalTo("Request method:\tGET\nRequest URI:\thttp://localhost:8080/greetJSON?firstName=John&lastName=Doe\nProxy:\t\t\thttp://127.0.0.1:8888\nRequest params:\tfirstName=John\n\t\t\t\tlastName=Doe\nQuery params:\t<none>\nForm params:\t<none>\nPath params:\t<none>\nHeaders:\t\tAccept=*/*\nCookies:\t\t<none>\nMultiparts:\t\t<none>\nBody:\t\t\t<none>\n"));
}
Aggregations