use of io.restassured.response.Response in project rest-assured by rest-assured.
the class ResponseITest method pathThrowsExceptionWhenTryingToUseJsonPathAfterHavingUsedXmlPath.
@Test
public void pathThrowsExceptionWhenTryingToUseJsonPathAfterHavingUsedXmlPath() throws Exception {
exception.expect(JsonPathException.class);
exception.expectMessage("Failed to parse the JSON document");
Response response = get("/videos");
response.path("videos.music[0].title.toString().trim()");
response.jsonPath().get("videos");
}
use of io.restassured.response.Response in project rest-assured by rest-assured.
the class ResponseITest method canParsePathAfterPrettyPeek.
@Test
public void canParsePathAfterPrettyPeek() throws Exception {
Response response = get("/videos").prettyPeek();
String title = response.path("videos.music[0].title.toString().trim()");
String artist = response.path("videos.music[0].artist.toString().trim()");
assertThat(title, equalTo("Video Title 1"));
assertThat(artist, equalTo("Artist 1"));
}
use of io.restassured.response.Response in project rest-assured by rest-assured.
the class AcceptHeaderITest method accept_headers_are_merged_from_request_spec_and_request_when_configured_to.
@Test
public void accept_headers_are_merged_from_request_spec_and_request_when_configured_to() {
RequestSpecification spec = new RequestSpecBuilder().setAccept("text/jux").build();
final MutableObject<List<String>> headers = new MutableObject<List<String>>();
RestAssured.given().config(RestAssuredConfig.config().headerConfig(HeaderConfig.headerConfig().mergeHeadersWithName("Accept"))).accept(ContentType.JSON).spec(spec).body("{ \"message\" : \"hello world\"}").filter(new Filter() {
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
headers.setValue(requestSpec.getHeaders().getValues("Accept"));
return ctx.next(requestSpec, responseSpec);
}
}).when().post("/jsonBodyAcceptHeader").then().body(equalTo("hello world"));
assertThat(headers.getValue(), contains("application/json, application/javascript, text/javascript, text/json", "text/jux"));
}
use of io.restassured.response.Response in project rest-assured by rest-assured.
the class CookieITest method getDetailedCookieWorks.
@Test
public void getDetailedCookieWorks() throws Exception {
final Response response = get("/html_with_cookie");
final Cookie detailedCookieJsessionId = response.getDetailedCookie("JSESSIONID");
assertThat(detailedCookieJsessionId, notNullValue());
assertThat(detailedCookieJsessionId.getPath(), equalTo("/"));
assertThat(detailedCookieJsessionId.getValue(), equalTo("B3134D534F40968A3805968207273EF5"));
}
use of io.restassured.response.Response in project rest-assured by rest-assured.
the class CookieITest method multipleCookiesWithSameKey.
@Test
public void multipleCookiesWithSameKey() throws Exception {
final Response response = get("/setCommonIdCookies");
Map<String, String> map = new HashMap<String, String>();
map = response.cookies();
assertThat(map.get("key1"), equalTo("value3"));
}
Aggregations