use of io.restassured.specification.ResponseSpecification in project rest-assured by rest-assured.
the class XMLGetITest method supportsRegisteringCustomParserForAGivenMimeTypeUsingResponseSpec.
@Test
public void supportsRegisteringCustomParserForAGivenMimeTypeUsingResponseSpec() throws Exception {
final String mimeType = "application/something-custom";
final ResponseSpecification specification = new ResponseSpecBuilder().registerParser(mimeType, Parser.XML).build();
RestAssured.expect().specification(specification).and().body("body.message", equalTo("Custom mime-type")).when().get("/customMimeType");
}
use of io.restassured.specification.ResponseSpecification in project rest-assured by rest-assured.
the class ResponseTimeITest method response_time_validation_can_be_specified_in_specification.
@Test
public void response_time_validation_can_be_specified_in_specification() {
ResponseSpecification spec = new ResponseSpecBuilder().expectResponseTime(lessThanOrEqualTo(3000L)).build();
given().param("firstName", "John").param("lastName", "Doe").when().get("/greet").then().spec(spec);
}
use of io.restassured.specification.ResponseSpecification in project rest-assured by rest-assured.
the class ResponseTimeITest method response_time_validation_can_fail_when_specified_in_specification.
@Test
public void response_time_validation_can_fail_when_specified_in_specification() {
exception.expect(AssertionError.class);
exception.expectMessage("Expected response time was not a value less than or equal to <3L> nanoseconds, was");
ResponseSpecification spec = new ResponseSpecBuilder().expectResponseTime(lessThanOrEqualTo(3L), NANOSECONDS).build();
given().param("firstName", "John").param("lastName", "Doe").when().get("/greet").then().spec(spec);
}
use of io.restassured.specification.ResponseSpecification in project rest-assured by rest-assured.
the class SpecificationBuilderITest method bodyExpectationsAreNotOverwritten.
@Test
public void bodyExpectationsAreNotOverwritten() throws Exception {
final ResponseSpecBuilder builder = new ResponseSpecBuilder();
builder.expectBody("store.book.size()", is(4)).expectStatusCode(200);
final ResponseSpecification responseSpecification = builder.build();
expect().body("store.book.author", hasItems("Nigel Rees", "Evelyn Waugh", "Herman Melville", "J. R. R. Tolkien")).spec(responseSpecification).body("store.book[0].author", equalTo("Nigel Rees")).when().get("/jsonStore");
}
use of io.restassured.specification.ResponseSpecification in project rest-assured by rest-assured.
the class SpecificationsDemoITest method demoResponseSpecification.
@Test
public void demoResponseSpecification() throws Exception {
final ResponseSpecification spec = new ResponseSpecBuilder().expectStatusCode(200).expectBody("responseType", equalTo("simple")).build();
given().param("name", "John Doe").expect().specification(spec).body("firstName", is("John")).body("lastName", is("Doe")).when().get("/demoResponseSpecification");
}
Aggregations