Interface MockMvcResponse

All Superinterfaces:
io.restassured.response.ResponseBody<MockMvcResponse>, io.restassured.response.ResponseBodyData, io.restassured.response.ResponseBodyExtractionOptions, io.restassured.response.ResponseOptions<MockMvcResponse>, io.restassured.response.Validatable<ValidatableMockMvcResponse,MockMvcResponse>
All Known Implementing Classes:
MockMvcRestAssuredResponseImpl

public interface MockMvcResponse extends io.restassured.response.ResponseBody<MockMvcResponse>, io.restassured.response.ResponseOptions<MockMvcResponse>, io.restassured.response.Validatable<ValidatableMockMvcResponse,MockMvcResponse>
The response of a request made by REST Assured Mock MVC.

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);
 

  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.mock.web.MockHttpServletResponse
    Return the MockHttpServletResponse as returned by Spring MockMvc.
    org.springframework.test.web.servlet.MvcResult
    Return the MvcResult as returned by Spring MockMvc.
    org.springframework.mock.web.MockHttpServletResponse
    Return the MockHttpServletResponse as returned by Spring MockMvc.
    org.springframework.test.web.servlet.MvcResult
    Return the MvcResult as returned by Spring MockMvc.

    Methods inherited from interface io.restassured.response.ResponseBody

    peek, prettyPeek, prettyPrint, print

    Methods inherited from interface io.restassured.response.ResponseBodyData

    asByteArray, asInputStream, asPrettyString, asString

    Methods inherited from interface io.restassured.response.ResponseBodyExtractionOptions

    as, as, as, as, as, as, as, htmlPath, jsonPath, jsonPath, path, xmlPath, xmlPath, xmlPath

    Methods inherited from interface io.restassured.response.ResponseOptions

    andReturn, body, contentType, cookie, cookies, detailedCookie, detailedCookies, getBody, getContentType, getCookie, getCookies, getDetailedCookie, getDetailedCookies, getHeader, getHeaders, getSessionId, getStatusCode, getStatusLine, getTime, getTimeIn, header, headers, sessionId, statusCode, statusLine, thenReturn, time, timeIn

    Methods inherited from interface io.restassured.response.Validatable

    then
  • Method Details

    • mvcResult

      org.springframework.test.web.servlet.MvcResult mvcResult()
      Return the MvcResult as returned by Spring MockMvc.

      This method is the same as getMvcResult() except for syntactic differences.

      Returns:
      The MvcResult as returned by Spring MockMvc.
    • getMvcResult

      org.springframework.test.web.servlet.MvcResult getMvcResult()
      Return the MvcResult as returned by Spring MockMvc.

      This method is the same as mvcResult() except for syntactic differences.

      Returns:
      The MvcResult as returned by Spring MockMvc.
    • mockHttpServletResponse

      org.springframework.mock.web.MockHttpServletResponse mockHttpServletResponse()
      Return the MockHttpServletResponse as returned by Spring MockMvc.

      This method is the same as getMockHttpServletResponse() except for syntactic differences.

      Returns:
      The MockHttpServletResponse as returned by Spring MockMvc.
    • getMockHttpServletResponse

      org.springframework.mock.web.MockHttpServletResponse getMockHttpServletResponse()
      Return the MockHttpServletResponse as returned by Spring MockMvc.

      This method is the same as mockHttpServletResponse() except for syntactic differences.

      Returns:
      The MockHttpServletResponse as returned by Spring MockMvc.