use of io.restassured.config.LogConfig in project rest-assured by rest-assured.
the class LoggingITest method logBodyPrettyPrintedUsingRequestLogSpecWhenContentTypeDoesntMatchContent.
@Test
public void logBodyPrettyPrintedUsingRequestLogSpecWhenContentTypeDoesntMatchContent() throws Exception {
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
given().config(config().logConfig(new LogConfig(captor, true))).log().everything().contentType("application/json").body("This is not 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=application/json; charset=" + RestAssured.config().getEncoderConfig().defaultCharsetForContentType(ContentType.JSON) + "\nCookies:\t\t<none>\nMultiparts:\t\t<none>\nBody:\nThis is not JSON" + LINE_SEPARATOR));
}
use of io.restassured.config.LogConfig in project rest-assured by rest-assured.
the class LoggingITest method logNoValueParamsUsingRequestLogSpec.
@Test
public void logNoValueParamsUsingRequestLogSpec() throws Exception {
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
given().config(config().logConfig(new LogConfig(captor, true))).log().parameters().formParam("formParam").queryParam("queryParam").when().post("/noValueParam");
assertThat(writer.toString(), equalTo("Request params:\t<none>\nQuery params:\tqueryParam\nForm params:\tformParam\nPath params:\t<none>\nMultiparts:\t\t<none>" + LINE_SEPARATOR));
}
use of io.restassured.config.LogConfig in project rest-assured by rest-assured.
the class LoggingITest method logOnlyResponseBodyWithPrettyPrintingWhenHtml.
@Test
public void logOnlyResponseBodyWithPrettyPrintingWhenHtml() throws Exception {
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
given().config(config().logConfig(new LogConfig(captor, true))).expect().log().body().body("html.head.title", is("my title")).when().get("/textHTML-not-formatted");
assertThat(writer.toString(), equalTo("<html>\n <head>\n <title>my title</title>\n </head>\n <body>\n <p>paragraph 1</p>\n <p>paragraph 2</p>\n </body>\n</html>" + LINE_SEPARATOR));
}
use of io.restassured.config.LogConfig in project rest-assured by rest-assured.
the class LoggingITest method logOnlyBodyUsingResponseUsingLogSpec.
@Test
public void logOnlyBodyUsingResponseUsingLogSpec() throws Exception {
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
given().config(config().logConfig(new LogConfig(captor, false))).pathParam("firstName", "John").pathParam("lastName", "Doe").expect().log().body().body("fullName", equalTo("John Doe")).when().get("/{firstName}/{lastName}");
assertThat(writer.toString(), equalTo("{\"firstName\":\"John\",\"lastName\":\"Doe\",\"fullName\":\"John Doe\"}" + LINE_SEPARATOR));
}
use of io.restassured.config.LogConfig in project rest-assured by rest-assured.
the class LoggingITest method logBodyWithPrettyPrintingUsingRequestLogSpec.
@Test
public void logBodyWithPrettyPrintingUsingRequestLogSpec() throws Exception {
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
given().contentType(ContentType.JSON).config(config().logConfig(new LogConfig(captor, true))).log().body().body("{ \"something\" : \"else\" }").when().post("/body");
assertThat(writer.toString(), equalTo("Body:\n{\n \"something\": \"else\"\n}" + LINE_SEPARATOR));
}
Aggregations