Class MockRestResponse

java.lang.Object
org.apache.juneau.rest.client.classic.RestResponse
org.apache.juneau.rest.mock.classic.MockRestResponse
All Implemented Interfaces:
AutoCloseable, HttpMessage, HttpResponse

public class MockRestResponse extends RestResponse
A subclass of RestResponse with additional features for mocked testing.
See Also:
  • Constructor Details

    • MockRestResponse

      public MockRestResponse(RestClient client, RestRequest request, HttpResponse response, Parser parser)
      Constructor.
      Parameters:
      client - The RestClient that created this response.
      request - The REST request.
      response - The HTTP response. Can be null (a default empty response with a status code of 0 is substituted).
      parser - The overridden parser passed into RestRequest.parser(Parser).
  • Method Details

    • cacheContent

      Description copied from class: RestResponse
      Caches the response body so that it can be read as a stream multiple times. This is equivalent to calling the following:

      getContent().cache();

      Overrides:
      cacheContent in class RestResponse
      Returns:
      The body of the response.
    • consume

      Description copied from class: RestResponse
      Consumes the response body.

      This is equivalent to closing the input stream.

      Any exceptions thrown during close are logged but not propagated.

      Overrides:
      consume in class RestResponse
      Returns:
      This object.