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 |
|---|---|
org.springframework.mock.web.MockHttpServletResponse |
getMockHttpServletResponse()
Return the
MockHttpServletResponse as returned by Spring MockMvc. |
org.springframework.test.web.servlet.MvcResult |
getMvcResult()
Return the
MvcResult as returned by Spring MockMvc. |
org.springframework.mock.web.MockHttpServletResponse |
mockHttpServletResponse()
Return the
MockHttpServletResponse as returned by Spring MockMvc. |
org.springframework.test.web.servlet.MvcResult |
mvcResult()
Return the
MvcResult as returned by Spring MockMvc. |
ValidatableMockMvcResponse |
then()
Returns a validatable response that's lets you validate the response.
|
peek, prettyPeek, prettyPrint, printas, as, as, htmlPath, jsonPath, jsonPath, path, xmlPath, xmlPath, xmlPathasByteArray, asInputStream, asStringandReturn, body, contentType, cookie, cookies, detailedCookie, detailedCookies, getBody, getContentType, getCookie, getCookies, getDetailedCookie, getDetailedCookies, getHeader, getHeaders, getSessionId, getStatusCode, getStatusLine, header, headers, sessionId, statusCode, statusLine, thenReturnValidatableMockMvcResponse then()
given().
param("firstName", "John").
param("lastName", "Doe").
when().
get("/greet").
then().
body("greeting", equalTo("John Doe"));
org.springframework.test.web.servlet.MvcResult mvcResult()
MvcResult as returned by Spring MockMvc.
This method is the same as getMvcResult() except for syntactic differences.
MvcResult as returned by Spring MockMvc.org.springframework.test.web.servlet.MvcResult getMvcResult()
MvcResult as returned by Spring MockMvc.
This method is the same as mvcResult() except for syntactic differences.
MvcResult as returned by Spring MockMvc.org.springframework.mock.web.MockHttpServletResponse mockHttpServletResponse()
MockHttpServletResponse as returned by Spring MockMvc.
This method is the same as getMockHttpServletResponse() except for syntactic differences.
MockHttpServletResponse as returned by Spring MockMvc.org.springframework.mock.web.MockHttpServletResponse getMockHttpServletResponse()
MockHttpServletResponse as returned by Spring MockMvc.
This method is the same as mockHttpServletResponse() except for syntactic differences.
MockHttpServletResponse as returned by Spring MockMvc.Copyright © 2010–2014. All rights reserved.