类 MockRestResponseCreators
- java.lang.Object
- org.springframework.test.web.client.response.MockRestResponseCreators
public abstract class MockRestResponseCreators extends Object
Static factory methods for obtaining aResponseCreator
instance.Eclipse users: consider adding this class as a Java editor favorite. To navigate, open the Preferences and type "favorites".
- 从以下版本开始:
- 3.2
- 作者:
- Rossen Stoyanchev
构造器概要
构造器 构造器 说明 MockRestResponseCreators()
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 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(String body, MediaType mediaType)
ResponseCreator
for a 200 response (OK) with String body.static DefaultResponseCreator
withSuccess(Resource body, MediaType contentType)
ResponseCreator
for a 200 response (OK) content withResource
-based body.static DefaultResponseCreator
withUnauthorizedRequest()
ResponseCreator
for a 401 response (UNAUTHORIZED).
构造器详细资料
MockRestResponseCreators
public MockRestResponseCreators()
方法详细资料
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.- 参数:
body
- the response body, a "UTF-8" stringmediaType
- the type of the content, may benull
withSuccess
public static DefaultResponseCreator withSuccess(byte[] body, MediaType contentType)
ResponseCreator
for a 200 response (OK) with byte[] body.- 参数:
body
- the response bodycontentType
- the type of the content, may benull
withSuccess
public static DefaultResponseCreator withSuccess(Resource body, MediaType contentType)
ResponseCreator
for a 200 response (OK) content withResource
-based body.- 参数:
body
- the response bodycontentType
- the type of the content, may benull
withCreatedEntity
public static DefaultResponseCreator withCreatedEntity(URI location)
ResponseCreator
for a 201 response (CREATED) with a 'Location' header.- 参数:
location
- the value for theLocation
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.- 参数:
status
- the response status