クラス MockRestResponseCreators
java.lang.ObjectSE
org.springframework.test.web.client.response.MockRestResponseCreators
固定レスポンスで
ResponseCreator
を取得する静的ファクトリメソッド。 さらに、リモートサービスへの実際のリクエストを実行する ExecutingResponseCreator
実装も参照してください。
- 導入:
- 3.2
- 作成者:
- Rossen Stoyanchev
- 関連事項:
コンストラクターのサマリー
メソッドのサマリー
修飾子と型メソッド説明static DefaultResponseCreator
202 レスポンス (ACCEPTED) の場合はResponseCreator
。static DefaultResponseCreator
502 レスポンス (BAD_GATEWAY) の場合はResponseCreator
。static DefaultResponseCreator
400 レスポンスのResponseCreator
(BAD_REQUEST)。static DefaultResponseCreator
withCreatedEntity
(URISE location) 'Location' ヘッダーを持つ 201 レスポンス(作成済み)のResponseCreator
。static ResponseCreator
ResponseCreator
と内部アプリケーションIOException
static DefaultResponseCreator
403 レスポンス (FORBIDDEN) の場合はResponseCreator
。static DefaultResponseCreator
504 レスポンスの場合はResponseCreator
(GATEWAY_TIMEOUT)。static DefaultResponseCreator
204 レスポンスの場合はResponseCreator
(NO_CONTENT)。static DefaultResponseCreator
withRawStatus
(int status) 整数を持つwithStatus(HttpStatusCode)
のバリアント。static DefaultResponseCreator
409 レスポンス (CONFLICT) の場合はResponseCreator
。static DefaultResponseCreator
404 レスポンス (NOT_FOUND) の場合はResponseCreator
。static DefaultResponseCreator
500 レスポンスのResponseCreator
(SERVER_ERROR)。static DefaultResponseCreator
503 レスポンス (SERVICE_UNAVAILABLE) の場合はResponseCreator
。static DefaultResponseCreator
withStatus
(HttpStatusCode status) 特定の HTTP ステータスを持つResponseCreator
。static DefaultResponseCreator
200 レスポンスのResponseCreator
(OK)。static DefaultResponseCreator
withSuccess
(byte[] body, MediaType contentType) byte[] 本体の 200 レスポンス(OK)のResponseCreator
。static DefaultResponseCreator
withSuccess
(StringSE body, MediaType contentType) ストリング本体の 200 レスポンス(OK)のResponseCreator
。static DefaultResponseCreator
withSuccess
(Resource body, MediaType contentType) Resource
ベースのボディを持つ 200 レスポンス(OK)コンテンツのResponseCreator
。static DefaultResponseCreator
レート制限された 429 レスポンス (TOO_MANY_REQUESTS) のResponseCreator
。static DefaultResponseCreator
withTooManyRequests
(int retryAfter) 秒単位のRetry-After
ヘッダーを含む 429 レート制限レスポンス (TOO_MANY_REQUESTS) のResponseCreator
。static DefaultResponseCreator
401 レスポンス用のResponseCreator
(未承認)。
コンストラクターの詳細
MockRestResponseCreators
public MockRestResponseCreators()
メソッドの詳細
withSuccess
200 レスポンスのResponseCreator
(OK)。withSuccess
ストリング本体の 200 レスポンス(OK)のResponseCreator
。- パラメーター:
body
- レスポンス本文、"UTF-8" 文字列contentType
- コンテンツの種類 (null
の場合があります)
withSuccess
byte[] 本体の 200 レスポンス(OK)のResponseCreator
。- パラメーター:
body
- レスポンス本文contentType
- コンテンツの種類 (null
の場合があります)
withSuccess
Resource
ベースのボディを持つ 200 レスポンス(OK)コンテンツのResponseCreator
。- パラメーター:
body
- レスポンス本文contentType
- コンテンツの種類 (null
の場合があります)
withCreatedEntity
'Location' ヘッダーを持つ 201 レスポンス(作成済み)のResponseCreator
。- パラメーター:
location
-Location
ヘッダーの値
withAccepted
202 レスポンス (ACCEPTED) の場合はResponseCreator
。- 導入:
- 6.0
withNoContent
204 レスポンスの場合はResponseCreator
(NO_CONTENT)。withBadRequest
400 レスポンスのResponseCreator
(BAD_REQUEST)。withUnauthorizedRequest
401 レスポンス用のResponseCreator
(未承認)。withForbiddenRequest
403 レスポンス (FORBIDDEN) の場合はResponseCreator
。- 導入:
- 6.0
withResourceNotFound
404 レスポンス (NOT_FOUND) の場合はResponseCreator
。- 導入:
- 6.0
withRequestConflict
409 レスポンス (CONFLICT) の場合はResponseCreator
。- 導入:
- 6.0
withTooManyRequests
レート制限された 429 レスポンス (TOO_MANY_REQUESTS) のResponseCreator
。- 導入:
- 6.0
withTooManyRequests
秒単位のRetry-After
ヘッダーを含む 429 レート制限レスポンス (TOO_MANY_REQUESTS) のResponseCreator
。- 導入:
- 6.0
withServerError
500 レスポンスのResponseCreator
(SERVER_ERROR)。withBadGateway
502 レスポンス (BAD_GATEWAY) の場合はResponseCreator
。- 導入:
- 6.0
withGatewayTimeout
504 レスポンスの場合はResponseCreator
(GATEWAY_TIMEOUT)。- 導入:
- 6.0
withStatus
特定の HTTP ステータスを持つResponseCreator
。- パラメーター:
status
- レスポンスステータス
withRawStatus
整数を持つwithStatus(HttpStatusCode)
のバリアント。- パラメーター:
status
- レスポンスステータス- 導入:
- 5.3.17
withException
ResponseCreator
と内部アプリケーションIOException
例: これを使用して
SocketTimeoutException
をシミュレートできます。- パラメーター:
ex
- HTTP 呼び出し時にスローされるException
- 導入:
- 5.2.2