use of io.restassured.module.mockmvc.http.PostController in project rest-assured by rest-assured.
the class MockMvcResponseTimeTest method can_extract_response_time_in_mock_mvc_extension.
@Test
public void can_extract_response_time_in_mock_mvc_extension() {
long time = RestAssuredMockMvc.given().standaloneSetup(new PostController()).param("name", "Johan").when().post("/greetingPost").then().extract().time();
assertThat(time).isGreaterThan(-1).isLessThan(3000L);
}
use of io.restassured.module.mockmvc.http.PostController in project rest-assured by rest-assured.
the class RequestLoggingTest method logging_param_works.
@Test
public void logging_param_works() {
RestAssuredMockMvc.given().log().all().standaloneSetup(new PostController()).param("name", "Johan").when().post("/greetingPost").then().body("id", equalTo(1)).body("content", equalTo("Hello, Johan!"));
assertThat(writer.toString(), equalTo("Request method:\tPOST\nRequest URI:\thttp://localhost:8080/greetingPost\nProxy:\t\t\t<none>\nRequest params:\tname=Johan\nQuery params:\t<none>\nForm params:\t<none>\nPath params:\t<none>\nHeaders:\t\tContent-Type=application/x-www-form-urlencoded;charset=" + RestAssuredMockMvcConfig.config().getEncoderConfig().defaultContentCharset() + "\nCookies:\t\t<none>\nMultiparts:\t\t<none>\nBody:\t\t\t<none>\n"));
}
use of io.restassured.module.mockmvc.http.PostController in project rest-assured by rest-assured.
the class RequestLoggingTest method logging_form_param_works.
@Test
public void logging_form_param_works() {
RestAssuredMockMvc.given().log().all().standaloneSetup(new PostController()).formParam("name", "Johan").when().post("/greetingPost").then().body("id", equalTo(1)).body("content", equalTo("Hello, Johan!"));
assertThat(writer.toString(), equalTo("Request method:\tPOST\nRequest URI:\thttp://localhost:8080/greetingPost\nProxy:\t\t\t<none>\nRequest params:\t<none>\nQuery params:\t<none>\nForm params:\tname=Johan\nPath params:\t<none>\nHeaders:\t\tContent-Type=application/x-www-form-urlencoded;charset=" + RestAssuredMockMvcConfig.config().getEncoderConfig().defaultContentCharset() + "\nCookies:\t\t<none>\nMultiparts:\t\t<none>\nBody:\t\t\t<none>\n"));
}
use of io.restassured.module.mockmvc.http.PostController in project rest-assured by rest-assured.
the class RequestLoggingTest method logging_if_request_validation_fails_works.
@Test
public void logging_if_request_validation_fails_works() {
try {
RestAssuredMockMvc.given().log().ifValidationFails().standaloneSetup(new PostController()).param("name", "Johan").when().post("/greetingPost").then().body("id", equalTo(1)).body("content", equalTo("Hello, Johan2!"));
fail("Should throw AssertionError");
} catch (AssertionError e) {
assertThat(writer.toString(), equalTo("Request method:\tPOST\nRequest URI:\thttp://localhost:8080/greetingPost\nProxy:\t\t\t<none>\nRequest params:\tname=Johan\nQuery params:\t<none>\nForm params:\t<none>\nPath params:\t<none>\nHeaders:\t\tContent-Type=application/x-www-form-urlencoded;charset=" + RestAssuredMockMvcConfig.config().getEncoderConfig().defaultContentCharset() + "\nCookies:\t\t<none>\nMultiparts:\t\t<none>\nBody:\t\t\t<none>\n"));
}
}
use of io.restassured.module.mockmvc.http.PostController in project rest-assured by rest-assured.
the class ResponseLoggingTest method logging_if_response_validation_fails_doesnt_log_anything_if_validation_succeeds.
@Test
public void logging_if_response_validation_fails_doesnt_log_anything_if_validation_succeeds() {
RestAssuredMockMvc.given().standaloneSetup(new PostController()).param("name", "Johan").when().post("/greetingPost").then().log().ifValidationFails().body("id", equalTo(1)).body("content", equalTo("Hello, Johan!"));
assertThat(writer.toString(), isEmptyString());
}
Aggregations