use of io.restassured.config.LogConfig in project rest-assured by rest-assured.
the class LoggingITest method logOnlyResponseBodyWithPrettyPrintingWhenXml.
@Test
public void logOnlyResponseBodyWithPrettyPrintingWhenXml() 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("videos.music[0].title", is("Video Title 1")).when().get("/videos-not-formatted");
assertThat(writer.toString(), equalTo("<videos>\n <music>\n <title>Video Title 1</title>\n <artist>Artist 1</artist>\n </music>\n <music>\n <title>Video Title 2</title>\n <artist>Artist 2</artist>\n <artist>Artist 3</artist>\n </music>\n</videos>" + LINE_SEPARATOR));
}
use of io.restassured.config.LogConfig in project rest-assured by rest-assured.
the class LoggingITest method logBodyUsingRequestLogSpec.
@Test
public void logBodyUsingRequestLogSpec() 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().body().param("firstName", "John").queryParam("lastName", "Doe").when().get("/greetJSON");
assertThat(writer.toString(), equalTo("Body:\t\t\t<none>" + LINE_SEPARATOR));
}
use of io.restassured.config.LogConfig in project rest-assured by rest-assured.
the class LoggingITest method logBodyWithPrettyPrintingUsingDslAndRequestLogSpec.
@Test
public void logBodyWithPrettyPrintingUsingDslAndRequestLogSpec() 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, false))).log().body(true).body("{ \"something\" : \"else\" }").when().post("/body");
assertThat(writer.toString(), equalTo("Body:\n{\n \"something\": \"else\"\n}" + LINE_SEPARATOR));
}
use of io.restassured.config.LogConfig in project rest-assured by rest-assured.
the class LoggingITest method logBodyWithPrettyPrintingUsingRequestLogSpecAndObjectMapping.
@Test
public void logBodyWithPrettyPrintingUsingRequestLogSpecAndObjectMapping() throws Exception {
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
final Message message = new Message();
message.setMessage("My message");
given().contentType(ContentType.JSON).config(config().logConfig(new LogConfig(captor, true))).log().body().body(message).when().post("/body");
assertThat(writer.toString(), equalTo("Body:\n{\n \"message\": \"My message\"\n}" + LINE_SEPARATOR));
}
use of io.restassured.config.LogConfig in project rest-assured by rest-assured.
the class LoggingITest method logOnlyHeadersUsingResponseUsingLogSpec.
@Test
public void logOnlyHeadersUsingResponseUsingLogSpec() throws Exception {
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
given().config(config().logConfig(new LogConfig(captor, true))).pathParam("firstName", "John").pathParam("lastName", "Doe").expect().log().headers().body("fullName", equalTo("John Doe")).when().get("/{firstName}/{lastName}");
assertThat(writer.toString(), equalTo("Content-Type: application/json;charset=utf-8\nContent-Length: 59\nServer: Jetty(9.3.2.v20150730)" + LINE_SEPARATOR));
}
Aggregations