クラス MockRestResponseCreators

java.lang.ObjectSE
org.springframework.test.web.client.response.MockRestResponseCreators

public abstract class MockRestResponseCreators extends ObjectSE
固定レスポンスで ResponseCreator を取得する静的ファクトリメソッド。

さらに、リモートサービスへの実際のリクエストを実行する ExecutingResponseCreator 実装も参照してください。

導入:
3.2
作成者:
Rossen Stoyanchev
関連事項:
  • コンストラクターの詳細

    • MockRestResponseCreators

      public MockRestResponseCreators()
  • メソッドの詳細

    • withSuccess

      public static DefaultResponseCreator withSuccess()
      200 レスポンスの ResponseCreator (OK)。
    • withSuccess

      public static DefaultResponseCreator withSuccess(StringSE body, @Nullable MediaType contentType)
      ストリング本体の 200 レスポンス(OK)の ResponseCreator
      パラメーター:
      body - レスポンス本文、"UTF-8" 文字列
      contentType - コンテンツの種類 (null の場合があります)
    • withSuccess

      public static DefaultResponseCreator withSuccess(byte[] body, @Nullable MediaType contentType)
      byte[] 本体の 200 レスポンス(OK)の ResponseCreator
      パラメーター:
      body - レスポンス本文
      contentType - コンテンツの種類 (null の場合があります)
    • withSuccess

      public static DefaultResponseCreator withSuccess(Resource body, @Nullable MediaType contentType)
      Resource ベースのボディを持つ 200 レスポンス(OK)コンテンツの ResponseCreator
      パラメーター:
      body - レスポンス本文
      contentType - コンテンツの種類 (null の場合があります)
    • withCreatedEntity

      public static DefaultResponseCreator withCreatedEntity(URISE location)
      'Location' ヘッダーを持つ 201 レスポンス(作成済み)の ResponseCreator
      パラメーター:
      location - Location ヘッダーの値
    • withAccepted

      public static DefaultResponseCreator withAccepted()
      202 レスポンス (ACCEPTED) の場合は ResponseCreator
      導入:
      6.0
    • withNoContent

      public static DefaultResponseCreator withNoContent()
      204 レスポンスの場合は ResponseCreator (NO_CONTENT)。
    • withBadRequest

      public static DefaultResponseCreator withBadRequest()
      400 レスポンスの ResponseCreator (BAD_REQUEST)。
    • withUnauthorizedRequest

      public static DefaultResponseCreator withUnauthorizedRequest()
      401 レスポンス用の ResponseCreator (未承認)。
    • withForbiddenRequest

      public static DefaultResponseCreator withForbiddenRequest()
      403 レスポンス (FORBIDDEN) の場合は ResponseCreator
      導入:
      6.0
    • withResourceNotFound

      public static DefaultResponseCreator withResourceNotFound()
      404 レスポンス (NOT_FOUND) の場合は ResponseCreator
      導入:
      6.0
    • withRequestConflict

      public static DefaultResponseCreator withRequestConflict()
      409 レスポンス (CONFLICT) の場合は ResponseCreator
      導入:
      6.0
    • withTooManyRequests

      public static DefaultResponseCreator withTooManyRequests()
      レート制限された 429 レスポンス (TOO_MANY_REQUESTS) の ResponseCreator
      導入:
      6.0
    • withTooManyRequests

      public static DefaultResponseCreator withTooManyRequests(int retryAfter)
      秒単位の Retry-After ヘッダーを含む 429 レート制限レスポンス (TOO_MANY_REQUESTS) の ResponseCreator
      導入:
      6.0
    • withServerError

      public static DefaultResponseCreator withServerError()
      500 レスポンスの ResponseCreator (SERVER_ERROR)。
    • withBadGateway

      public static DefaultResponseCreator withBadGateway()
      502 レスポンス (BAD_GATEWAY) の場合は ResponseCreator
      導入:
      6.0
    • withServiceUnavailable

      public static DefaultResponseCreator withServiceUnavailable()
      503 レスポンス (SERVICE_UNAVAILABLE) の場合は ResponseCreator
      導入:
      6.0
    • withGatewayTimeout

      public static DefaultResponseCreator withGatewayTimeout()
      504 レスポンスの場合は ResponseCreator (GATEWAY_TIMEOUT)。
      導入:
      6.0
    • withStatus

      public static DefaultResponseCreator withStatus(HttpStatusCode status)
      特定の HTTP ステータスを持つ ResponseCreator
      パラメーター:
      status - レスポンスステータス
    • withRawStatus

      public static DefaultResponseCreator withRawStatus(int status)
      整数を持つ withStatus(HttpStatusCode) のバリアント。
      パラメーター:
      status - レスポンスステータス
      導入:
      5.3.17
    • withException

      public static ResponseCreator withException(IOExceptionSE ex)
      ResponseCreator と内部アプリケーション IOException

      例: これを使用して SocketTimeoutException をシミュレートできます。

      パラメーター:
      ex - HTTP 呼び出し時にスローされる Exception 
      導入:
      5.2.2