use of io.restassured.specification.RequestSpecification in project rest-assured by rest-assured.
the class JSONGetITest method contentTypeSpecification.
@Test
public void contentTypeSpecification() throws Exception {
final RequestSpecification requestSpecification = given().contentType(ContentType.TEXT).with().parameters("firstName", "John", "lastName", "Doe");
final ResponseSpecification responseSpecification = expect().contentType(ContentType.JSON).and().body("greeting", equalTo("Greetings John Doe"));
given(requestSpecification, responseSpecification).get("/greet");
}
use of io.restassured.specification.RequestSpecification in project rest-assured by rest-assured.
the class JSONGetITest method contentTypeSpecificationWithHamcrestMatcher.
@Test
public void contentTypeSpecificationWithHamcrestMatcher() throws Exception {
final RequestSpecification requestSpecification = given().contentType(ContentType.TEXT).with().parameters("firstName", "John", "lastName", "Doe");
final ResponseSpecification responseSpecification = expect().contentType(equalTo("application/json;charset=utf-8")).and().body("greeting", equalTo("Greetings John Doe"));
given(requestSpecification, responseSpecification).get("/greet");
}
use of io.restassured.specification.RequestSpecification in project rest-assured by rest-assured.
the class SpecificationBuilderITest method supportsSpecifyingQueryParametersInRequestSpecBuilderWhenPost.
@Test
public void supportsSpecifyingQueryParametersInRequestSpecBuilderWhenPost() throws Exception {
final RequestSpecification spec = new RequestSpecBuilder().addQueryParameter("firstName", "John").addQueryParam("lastName", "Doe").build();
given().spec(spec).expect().body("greeting.firstName", equalTo("John")).body("greeting.lastName", equalTo("Doe")).when().post("/greetXML");
}
use of io.restassured.specification.RequestSpecification in project rest-assured by rest-assured.
the class SpecificationBuilderITest method supportsMergingCookiesWhenUsingRequestSpecBuilder.
@Test
public void supportsMergingCookiesWhenUsingRequestSpecBuilder() throws Exception {
final RequestSpecification spec1 = new RequestSpecBuilder().addCookie("cookie3", "value3").build();
final RequestSpecification spec2 = new RequestSpecBuilder().addCookie("cookie1", "value1").addRequestSpecification(spec1).build();
given().spec(spec2).cookie("cookie2", "value2").expect().body(equalTo("cookie1, cookie3, cookie2")).when().get("/cookie");
}
use of io.restassured.specification.RequestSpecification in project rest-assured by rest-assured.
the class SpecificationBuilderITest method mergesStaticallyDefinedRequestSpecificationsCorrectly.
@Test
public void mergesStaticallyDefinedRequestSpecificationsCorrectly() throws Exception {
RestAssured.requestSpecification = new RequestSpecBuilder().addCookie("Cookie1", "Value1").build();
RequestSpecification reqSpec1 = new RequestSpecBuilder().addCookie("Cookie2", "Value2").build();
RequestSpecification reqSpec2 = new RequestSpecBuilder().addCookie("Cookie3", "Value3").build();
try {
Cookies cookies = given().spec(reqSpec1).when().get("/reflect").then().extract().detailedCookies();
assertThat(cookies.size(), is(2));
assertThat(cookies.hasCookieWithName("Cookie1"), is(true));
assertThat(cookies.hasCookieWithName("Cookie2"), is(true));
cookies = given().spec(reqSpec2).when().get("/reflect").then().extract().detailedCookies();
assertThat(cookies.size(), is(2));
assertThat(cookies.hasCookieWithName("Cookie1"), is(true));
assertThat(cookies.hasCookieWithName("Cookie3"), is(true));
} finally {
RestAssured.reset();
}
}
Aggregations