use of org.apache.commons.io.output.WriterOutputStream in project rest-assured by rest-assured.
the class URLITest method query_param_name_with_empty_value_is_not_treated_as_no_value_query_param.
/**
* Asserts that issue 314 is resolved
*/
@Test
public void query_param_name_with_empty_value_is_not_treated_as_no_value_query_param() {
// Given
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
// When
given().filter(new RequestLoggingFilter(captor)).when().get("/requestUrl?param1=1&voidparam=¶m3=3").then().statusCode(200).body(equalTo("http://localhost:8080/requestUrl?param1=1&voidparam=¶m3=3"));
// Then
assertThat(loggedRequestPathIn(writer), equalTo("http://localhost:8080/requestUrl?param1=1&voidparam=¶m3=3"));
}
use of org.apache.commons.io.output.WriterOutputStream 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));
}
use of org.apache.commons.io.output.WriterOutputStream in project rest-assured by rest-assured.
the class LoggingITest method shows_request_log_as_url_encoded_when_explicitly_instructing_request_logging_filter_to_do_so.
@Test
public void shows_request_log_as_url_encoded_when_explicitly_instructing_request_logging_filter_to_do_so() throws UnsupportedEncodingException {
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
given().filter(new RequestLoggingFilter(LogDetail.URI, true, captor, true)).queryParam("firstName", "John#€").queryParam("lastName", "Doe").when().get("/greet").then().statusCode(200);
assertThat(writer.toString(), equalTo("Request URI:\thttp://localhost:8080/greet?firstName=John" + URLEncoder.encode("#€", "UTF-8") + "&lastName=Doe" + LINE_SEPARATOR));
}
use of org.apache.commons.io.output.WriterOutputStream in project rest-assured by rest-assured.
the class LoggingITest method logCookiesUsingRequestLogSpec.
@Test
public void logCookiesUsingRequestLogSpec() 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().cookies().cookie("myCookie1", "myCookieValue1").cookie("myCookie2", "myCookieValue2").cookie("myMultiCookie", "myMultiCookieValue1", "myMultiCookieValue2").when().post("/reflect");
assertThat(writer.toString(), equalTo("Cookies:\t\tmyCookie1=myCookieValue1\n\t\t\t\tmyCookie2=myCookieValue2\n\t\t\t\tmyMultiCookie=myMultiCookieValue1\n\t\t\t\tmyMultiCookie=myMultiCookieValue2" + LINE_SEPARATOR));
}
use of org.apache.commons.io.output.WriterOutputStream in project rest-assured by rest-assured.
the class LoggingITest method loggingResponseFilterLogsNonErrors.
@Test
public void loggingResponseFilterLogsNonErrors() throws Exception {
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
given().filter(logResponseTo(captor)).expect().body("greeting", equalTo("Greetings John Doe")).when().get("/greet?firstName=John&lastName=Doe");
assertThat(writer.toString(), containsString("{\"greeting\":\"Greetings John Doe\"}"));
}
Aggregations