DefaultResponseCreator (Spring Framework 3.2.1.RELEASE API)
Date: 2013-01-24

org.springframework.test.web.client.response

## Class DefaultResponseCreator

- java.lang.Object
- - org.springframework.test.web.client.response.DefaultResponseCreator

- All Implemented Interfaces:
    ResponseCreator

      public class DefaultResponseCreator
      extends Object
      implements ResponseCreator

  A `ResponseCreator` with builder-style methods for adding response details.
  Since:
    3.2
  Author:
    Rossen Stoyanchev

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `DefaultResponseCreator(HttpStatus statusCode)` Protected constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `DefaultResponseCreator` | `body(byte[] content)` Set the body as a byte array.
    `DefaultResponseCreator` | `body(Resource resource)` Set the body as a `Resource`.
    `DefaultResponseCreator` | `body(String content)` Set the body as a UTF-8 String.
    `DefaultResponseCreator` | `contentType(MediaType mediaType)` Set the `Content-Type` header.
    `ClientHttpResponse` | `createResponse(ClientHttpRequest request)` Create a response for the given request.
    `DefaultResponseCreator` | `headers(HttpHeaders headers)` Copy all given headers.
    `DefaultResponseCreator` | `location(URI location)` Set the `Location` header.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DefaultResponseCreator

          protected DefaultResponseCreator(HttpStatus statusCode)

      Protected constructor. Use static factory methods in `MockRestResponseCreators`.

  - ### Method Detail

    - #### createResponse

          public ClientHttpResponse createResponse(ClientHttpRequest request)
                                            throws IOException

      Description copied from interface: `ResponseCreator`
      Create a response for the given request.
      Specified by:
        `createResponse` in interface `ResponseCreator`
      Parameters:
        `request` - the request
      Throws:
        `IOException`

    - #### body

          public DefaultResponseCreator body(String content)

      Set the body as a UTF-8 String.

    - #### body

          public DefaultResponseCreator body(byte[] content)

      Set the body as a byte array.

    - #### body

          public DefaultResponseCreator body(Resource resource)

      Set the body as a `Resource`.

    - #### contentType

          public DefaultResponseCreator contentType(MediaType mediaType)

      Set the `Content-Type` header.

    - #### location

          public DefaultResponseCreator location(URI location)

      Set the `Location` header.

    - #### headers

          public DefaultResponseCreator headers(HttpHeaders headers)

      Copy all given headers.