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

org.springframework.test.web.client.response

## Class MockRestResponseCreators

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

-     public abstract class MockRestResponseCreators
      extends Object

  Static factory methods for obtaining a `ResponseCreator` instance.

  Eclipse users: consider adding this class as a Java editor favorite. To navigate, open the Preferences and type "favorites".

  Since:
    3.2
  Author:
    Rossen Stoyanchev

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static DefaultResponseCreator` | `withBadRequest()` `ResponseCreator` for a 400 response (BAD_REQUEST).
    `static DefaultResponseCreator` | `withCreatedEntity(URI location)` `ResponseCreator` for a 201 response (CREATED) with a 'Location' header.
    `static DefaultResponseCreator` | `withNoContent()` `ResponseCreator` for a 204 response (NO_CONTENT).
    `static DefaultResponseCreator` | `withServerError()` `ResponseCreator` for a 500 response (SERVER_ERROR).
    `static DefaultResponseCreator` | `withStatus(HttpStatus status)` `ResponseCreator` with a specific HTTP status.
    `static DefaultResponseCreator` | `withSuccess()` `ResponseCreator` for a 200 response (OK).
    `static DefaultResponseCreator` | `withSuccess(byte[] body, MediaType contentType)` `ResponseCreator` for a 200 response (OK) with byte[] body.
    `static DefaultResponseCreator` | `withSuccess(Resource body, MediaType contentType)` `ResponseCreator` for a 200 response (OK) content with `Resource`-based body.
    `static DefaultResponseCreator` | `withSuccess(String body, MediaType mediaType)` `ResponseCreator` for a 200 response (OK) with String body.
    `static DefaultResponseCreator` | `withUnauthorizedRequest()` `ResponseCreator` for a 401 response (UNAUTHORIZED).

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

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

- - ### Method Detail

    - #### withSuccess

          public static DefaultResponseCreator withSuccess()

      `ResponseCreator` for a 200 response (OK).

    - #### withSuccess

          public static DefaultResponseCreator withSuccess(String body,
                                           MediaType mediaType)

      `ResponseCreator` for a 200 response (OK) with String body.
      Parameters:
        `body` - the response body, a "UTF-8" string
        `mediaType` - the type of the content, may be `null`

    - #### withSuccess

          public static DefaultResponseCreator withSuccess(byte[] body,
                                           MediaType contentType)

      `ResponseCreator` for a 200 response (OK) with byte[] body.
      Parameters:
        `body` - the response body
        `contentType` - the type of the content, may be `null`

    - #### withSuccess

          public static DefaultResponseCreator withSuccess(Resource body,
                                           MediaType contentType)

      `ResponseCreator` for a 200 response (OK) content with `Resource`-based body.
      Parameters:
        `body` - the response body
        `contentType` - the type of the content, may be `null`

    - #### withCreatedEntity

          public static DefaultResponseCreator withCreatedEntity(URI location)

      `ResponseCreator` for a 201 response (CREATED) with a 'Location' header.
      Parameters:
        `location` - the value for the `Location` header

    - #### withNoContent

          public static DefaultResponseCreator withNoContent()

      `ResponseCreator` for a 204 response (NO_CONTENT).

    - #### withBadRequest

          public static DefaultResponseCreator withBadRequest()

      `ResponseCreator` for a 400 response (BAD_REQUEST).

    - #### withUnauthorizedRequest

          public static DefaultResponseCreator withUnauthorizedRequest()

      `ResponseCreator` for a 401 response (UNAUTHORIZED).

    - #### withServerError

          public static DefaultResponseCreator withServerError()

      `ResponseCreator` for a 500 response (SERVER_ERROR).

    - #### withStatus

          public static DefaultResponseCreator withStatus(HttpStatus status)

      `ResponseCreator` with a specific HTTP status.
      Parameters:
        `status` - the response status