use of io.restassured.itest.java.objects.ScalatraObject in project rest-assured by rest-assured.
the class LoggingITest method loggingRequestAndResponseAtTheSameTimeWhenResponseFilterIsAddedBeforeRequestFilter.
@Test
public void loggingRequestAndResponseAtTheSameTimeWhenResponseFilterIsAddedBeforeRequestFilter() 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().filters(new ResponseLoggingFilter(captor), new RequestLoggingFilter(captor)).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 + "HTTP/1.1 200 OK\nContent-Type: text/plain;charset=iso-8859-1\nContent-Length: 23\nServer: Jetty(9.3.2.v20150730)\n\n{\"hello\":\"Hello world\"}" + LINE_SEPARATOR));
}
use of io.restassured.itest.java.objects.ScalatraObject in project rest-assured by rest-assured.
the class ObjectMappingITest method mapResponseToObjectUsingGsonWithGsonObjectMapperDefined.
@Test
public void mapResponseToObjectUsingGsonWithGsonObjectMapperDefined() throws Exception {
final ScalatraObject object = get("/hello").as(ScalatraObject.class, ObjectMapperType.GSON);
assertThat(object.getHello(), equalTo("Hello Scalatra"));
}
use of io.restassured.itest.java.objects.ScalatraObject in project rest-assured by rest-assured.
the class ObjectMappingITest method whenNoRequestContentTypeIsSpecifiedThenRestAssuredSerializesToJSON.
@Test
public void whenNoRequestContentTypeIsSpecifiedThenRestAssuredSerializesToJSON() throws Exception {
final ScalatraObject object = new ScalatraObject();
object.setHello("Hello world");
final ScalatraObject actual = expect().defaultParser(JSON).given().body(object).when().post("/reflect").as(ScalatraObject.class);
assertThat(object, equalTo(actual));
}
use of io.restassured.itest.java.objects.ScalatraObject in project rest-assured by rest-assured.
the class ObjectMappingITest method mapResponseToObjectUsingJackson.
@Test
public void mapResponseToObjectUsingJackson() throws Exception {
final ScalatraObject object = get("/hello").as(ScalatraObject.class);
assertThat(object.getHello(), equalTo("Hello Scalatra"));
}
use of io.restassured.itest.java.objects.ScalatraObject in project rest-assured by rest-assured.
the class LoggingITest method loggingRequestAndResponseAtTheSameTimeWhenRequestFilterIsAddedBeforeResponseFilter.
@Test
public void loggingRequestAndResponseAtTheSameTimeWhenRequestFilterIsAddedBeforeResponseFilter() 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().filters(new RequestLoggingFilter(captor), new ResponseLoggingFilter(captor)).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 + "HTTP/1.1 200 OK\nContent-Type: text/plain;charset=iso-8859-1\nContent-Length: 23\nServer: Jetty(9.3.2.v20150730)\n\n{\"hello\":\"Hello world\"}" + LINE_SEPARATOR));
}
Aggregations