类 MockRestResponseCreators
java.lang.Object
cn.taketoday.test.web.client.response.MockRestResponseCreators
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".
- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static DefaultResponseCreatorResponseCreatorfor a 202 response (ACCEPTED).static DefaultResponseCreatorResponseCreatorfor a 502 response (BAD_GATEWAY).static DefaultResponseCreatorResponseCreatorfor a 400 response (BAD_REQUEST).static DefaultResponseCreatorwithCreatedEntity(URI location) ResponseCreatorfor a 201 response (CREATED) with a 'Location' header.static ResponseCreatorResponseCreatorwith an internal applicationIOException.static DefaultResponseCreatorResponseCreatorfor a 403 response (FORBIDDEN).static DefaultResponseCreatorResponseCreatorfor a 504 response (GATEWAY_TIMEOUT).static DefaultResponseCreatorResponseCreatorfor a 204 response (NO_CONTENT).static DefaultResponseCreatorwithRawStatus(int status) Variant ofwithStatus(HttpStatusCode)with an integer.static DefaultResponseCreatorResponseCreatorfor a 409 response (CONFLICT).static DefaultResponseCreatorResponseCreatorfor a 404 response (NOT_FOUND).static DefaultResponseCreatorResponseCreatorfor a 500 response (SERVER_ERROR).static DefaultResponseCreatorResponseCreatorfor a 503 response (SERVICE_UNAVAILABLE).static DefaultResponseCreatorwithStatus(cn.taketoday.http.HttpStatusCode status) ResponseCreatorwith a specific HTTP status.static DefaultResponseCreatorResponseCreatorfor a 200 response (OK).static DefaultResponseCreatorwithSuccess(byte[] body, cn.taketoday.http.MediaType contentType) ResponseCreatorfor a 200 response (OK) with byte[] body.static DefaultResponseCreatorwithSuccess(cn.taketoday.core.io.Resource body, cn.taketoday.http.MediaType contentType) ResponseCreatorfor a 200 response (OK) content withResource-based body.static DefaultResponseCreatorwithSuccess(String body, cn.taketoday.http.MediaType contentType) ResponseCreatorfor a 200 response (OK) with String body.static DefaultResponseCreatorResponseCreatorfor a 429 ratelimited response (TOO_MANY_REQUESTS).static DefaultResponseCreatorwithTooManyRequests(int retryAfter) ResponseCreatorfor a 429 rate-limited response (TOO_MANY_REQUESTS) with aRetry-Afterheader in seconds.static DefaultResponseCreatorResponseCreatorfor a 401 response (UNAUTHORIZED).
-
构造器详细资料
-
MockRestResponseCreators
public MockRestResponseCreators()
-
-
方法详细资料
-
withSuccess
ResponseCreatorfor a 200 response (OK). -
withSuccess
public static DefaultResponseCreator withSuccess(String body, @Nullable cn.taketoday.http.MediaType contentType) ResponseCreatorfor a 200 response (OK) with String body.- 参数:
body- the response body, a "UTF-8" stringcontentType- the type of the content (may benull)
-
withSuccess
public static DefaultResponseCreator withSuccess(byte[] body, @Nullable cn.taketoday.http.MediaType contentType) ResponseCreatorfor a 200 response (OK) with byte[] body.- 参数:
body- the response bodycontentType- the type of the content (may benull)
-
withSuccess
public static DefaultResponseCreator withSuccess(cn.taketoday.core.io.Resource body, @Nullable cn.taketoday.http.MediaType contentType) ResponseCreatorfor a 200 response (OK) content withResource-based body.- 参数:
body- the response bodycontentType- the type of the content (may benull)
-
withCreatedEntity
ResponseCreatorfor a 201 response (CREATED) with a 'Location' header.- 参数:
location- the value for theLocationheader
-
withAccepted
ResponseCreatorfor a 202 response (ACCEPTED). -
withNoContent
ResponseCreatorfor a 204 response (NO_CONTENT). -
withBadRequest
ResponseCreatorfor a 400 response (BAD_REQUEST). -
withUnauthorizedRequest
ResponseCreatorfor a 401 response (UNAUTHORIZED). -
withForbiddenRequest
ResponseCreatorfor a 403 response (FORBIDDEN). -
withResourceNotFound
ResponseCreatorfor a 404 response (NOT_FOUND). -
withRequestConflict
ResponseCreatorfor a 409 response (CONFLICT). -
withTooManyRequests
ResponseCreatorfor a 429 ratelimited response (TOO_MANY_REQUESTS). -
withTooManyRequests
ResponseCreatorfor a 429 rate-limited response (TOO_MANY_REQUESTS) with aRetry-Afterheader in seconds. -
withServerError
ResponseCreatorfor a 500 response (SERVER_ERROR). -
withBadGateway
ResponseCreatorfor a 502 response (BAD_GATEWAY). -
withGatewayTimeout
ResponseCreatorfor a 504 response (GATEWAY_TIMEOUT). -
withStatus
ResponseCreatorwith a specific HTTP status.- 参数:
status- the response status
-
withRawStatus
Variant ofwithStatus(HttpStatusCode)with an integer.- 参数:
status- the response status
-
withException
ResponseCreatorwith an internal applicationIOException.For example, one could use this to simulate a
SocketTimeoutException.- 参数:
ex- theExceptionto be thrown at HTTP call time
-