use of io.restassured.filter.log.RequestLoggingFilter in project rest-assured by rest-assured.
the class URLITest method fullyQualifiedUrlIncludingPortWorks.
@Test
public void fullyQualifiedUrlIncludingPortWorks() throws Exception {
// Given
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
// When
given().contentType(JSON).filter(new RequestLoggingFilter(captor)).filter(new Filter() {
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
return new ResponseBuilder().setStatusCode(200).setBody("changed").build();
}
}).expect().statusCode(200).body(equalTo("changed")).when().get("http://tototiti.alarmesomfy.net:8080/");
// Then
assertThat(loggedRequestPathIn(writer), equalTo("http://tototiti.alarmesomfy.net:8080/"));
}
use of io.restassured.filter.log.RequestLoggingFilter in project rest-assured by rest-assured.
the class URLITest method takesNonStaticSpecificationPortIntoAccountWhenHostIsSpecified.
@Test
public void takesNonStaticSpecificationPortIntoAccountWhenHostIsSpecified() throws Exception {
// Given
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
// When
given().port(9093).contentType(JSON).filter(new RequestLoggingFilter(captor)).filter(new Filter() {
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
return new ResponseBuilder().setStatusCode(200).setBody("changed").build();
}
}).expect().statusCode(200).body(equalTo("changed")).when().get("http://something.com");
// Then
assertThat(loggedRequestPathIn(writer), equalTo("http://something.com:9093"));
}
use of io.restassured.filter.log.RequestLoggingFilter in project rest-assured by rest-assured.
the class URLITest method fullyQualifiedLocalhostUrlIncludingPortWorks.
@Test
public void fullyQualifiedLocalhostUrlIncludingPortWorks() throws Exception {
// Given
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
// When
given().contentType(JSON).filter(new RequestLoggingFilter(captor)).filter(new Filter() {
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
return new ResponseBuilder().setStatusCode(200).setBody("changed").build();
}
}).expect().statusCode(200).body(equalTo("changed")).when().get("http://localhost:8082/");
// Then
assertThat(loggedRequestPathIn(writer), equalTo("http://localhost:8082/"));
}
use of io.restassured.filter.log.RequestLoggingFilter in project rest-assured by rest-assured.
the class URLITest method takesPortIntoAccountWhenSpecifiedInTheURLUsingLocalhostHost.
@Test
public void takesPortIntoAccountWhenSpecifiedInTheURLUsingLocalhostHost() throws Exception {
// Given
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
// When
try {
given().contentType(JSON).auth().digest("username", "password").filter(new RequestLoggingFilter(captor)).filter(new Filter() {
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
return new ResponseBuilder().setStatusCode(200).setBody("changed").build();
}
}).expect().statusCode(200).body(equalTo("changed")).when().head("http://localhost:8084/something");
} finally {
RestAssured.reset();
}
// Then
assertThat(loggedRequestPathIn(writer), equalTo("http://localhost:8084/something"));
}
use of io.restassured.filter.log.RequestLoggingFilter in project rest-assured by rest-assured.
the class URLITest method fullyQualifiedUrlIsHandledCorrectlyInLog.
/**
* See issue 304 & 305
*/
@Test
public void fullyQualifiedUrlIsHandledCorrectlyInLog() throws Exception {
// Given
final StringWriter writer = new StringWriter();
final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
// When
given().filter(new RequestLoggingFilter(captor)).filter(new Filter() {
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
return new ResponseBuilder().setStatusCode(200).setBody("changed").build();
}
}).expect().statusCode(200).body(equalTo("changed")).when().get("http://ya.ru/bla/?param=value=");
// Then
assertThat(loggedRequestPathIn(writer), equalTo("http://ya.ru/bla/?param=value%3D"));
}
Aggregations