public interface MockMvcResponse extends ResponseBody<MockMvcResponse>, ResponseOptions<MockMvcResponse>
Usage example:
Response response = get("/lotto"); String body = response.getBody().asString(); String headerValue = response.getHeader("headerName"); String cookieValue = response.getCookie("cookieName");
You can also map the response body to a Java object automatically. REST Assured will use Jackson, Gson and JAXB to accommodate this:
Message message = get("/message").as(Message.class);
Modifier and Type | Method and Description |
---|---|
ValidatableMockMvcResponse |
then()
Returns a validatable response that's lets you validate the response.
|
peek, prettyPeek, prettyPrint, print
as, as, as, htmlPath, jsonPath, jsonPath, path, xmlPath, xmlPath, xmlPath
asByteArray, asInputStream, asString
andReturn, body, contentType, cookie, cookies, detailedCookie, detailedCookies, getBody, getContentType, getCookie, getCookies, getDetailedCookie, getDetailedCookies, getHeader, getHeaders, getSessionId, getStatusCode, getStatusLine, header, headers, sessionId, statusCode, statusLine, thenReturn
ValidatableMockMvcResponse then()
given(). param("firstName", "John"). param("lastName", "Doe"). when(). get("/greet"). then(). body("greeting", equalTo("John Doe"));
Copyright © 2010–2014. All rights reserved.