public interface WebTestClient
WebClient
と同様の API を使用して WebFlux サーバーエンドポイントをテストし、実際には WebClient
インスタンスに委譲するが、テストに重点を置くためのメインエントリポイント WebTestClient
には、サーバーを実行せずに 3 つのセットアップオプションがあります。
bindToController(java.lang.Object...)
bindToApplicationContext(org.springframework.context.ApplicationContext)
bindToRouterFunction(org.springframework.web.reactive.function.server.RouterFunction<?>)
ソケットの実際のリクエストに対する 1 つのオプション:
修飾子と型 | インターフェースと説明 |
---|---|
static interface | WebTestClient.BodyContentSpec レスポンス本文の内容に対する期待の仕様。 |
static interface | WebTestClient.BodySpec<B, S extends WebTestClient.BodySpec<B, S>> 単一のオブジェクトにデコードされたレスポンス本文に対する期待の仕様。 |
static interface | WebTestClient.Builder 内部的に WebClient.Builder に委譲してテストするために使用される WebClient をカスタマイズするための手順。 |
static interface | WebTestClient.ControllerSpec WebFluxConfigurer と同等で内部的に委譲するコントローラー構成をカスタマイズするための仕様。 |
static interface | WebTestClient.ListBodySpec<E> リストにデコードされたレスポンス本文に対する期待の仕様。 |
static interface | WebTestClient.MockServerSpec<B extends WebTestClient.MockServerSpec<B>> サーバーなしでテストをセットアップするための基本仕様。 |
static interface | WebTestClient.RequestBodySpec |
static interface | WebTestClient.RequestBodyUriSpec |
static interface | WebTestClient.RequestHeadersSpec<S extends WebTestClient.RequestHeadersSpec<S>> リクエストヘッダーを追加し、交換を実行するための仕様。 |
static interface | WebTestClient.RequestHeadersUriSpec<S extends WebTestClient.RequestHeadersSpec<S>> |
static interface | WebTestClient.ResponseSpec レスポンスに対する期待を宣言するための仕様。 |
static interface | WebTestClient.RouterFunctionSpec ルーター関数の構成をカスタマイズするための仕様。 |
static interface | WebTestClient.UriSpec<S extends WebTestClient.RequestHeadersSpec<?>> リクエストの URI を提供するための仕様。 |
修飾子と型 | フィールドと説明 |
---|---|
static StringSE | WEBTESTCLIENT_REQUEST_ID WebTestClient を介して実行されるすべてのリクエストに一意の ID を割り当てるために使用されるリクエストヘッダーの名前。 |
修飾子と型 | メソッドと説明 |
---|---|
static WebTestClient.MockServerSpec<?> | bindToApplicationContext(ApplicationContext applicationContext) @EnableWebFlux Java 構成やアノテーション付きコントローラー Spring Bean などの ApplicationContext から検出された WebFlux インフラストラクチャーを備えた「モック」サーバーとの統合テスト。 |
static WebTestClient.ControllerSpec | bindToController(ObjectSE... controllers) 特定のアノテーション付き WebFlux コントローラーを対象とした「モック」サーバーとの統合テスト。 |
static WebTestClient.RouterFunctionSpec | bindToRouterFunction(RouterFunction<?> routerFunction) WebFlux 関数エンドポイントをターゲットとするサーバーを使用しない統合テスト。 |
static WebTestClient.Builder | bindToServer() 実行中のサーバーに対する実際のリクエストを使用して、エンドツーエンドの統合テストを完了します。 |
static WebTestClient.MockServerSpec<?> | bindToWebHandler(WebHandler webHandler) 特定の WebHandler をターゲットとする「モック」サーバーとの統合テスト。 |
WebTestClient.RequestHeadersUriSpec<?> | delete() HTTP DELETE リクエストを準備します。 |
WebTestClient.RequestHeadersUriSpec<?> | get() HTTP GET リクエストを準備します。 |
WebTestClient.RequestHeadersUriSpec<?> | head() HTTP HEAD リクエストを準備します。 |
WebTestClient.RequestBodyUriSpec | method(HttpMethod method) 指定された HttpMethod のリクエストを準備します。 |
WebTestClient.Builder | mutate() この Web テストクライアントのプロパティを変更するビルダーを返します。 |
WebTestClient | mutateWith(WebTestClientConfigurer configurer) WebTestClient を変更し、指定されたコンフィギュレーターを適用して、新しいインスタンスを構築します。 |
WebTestClient.RequestHeadersUriSpec<?> | options() HTTP OPTIONS リクエストを準備します。 |
WebTestClient.RequestBodyUriSpec | patch() HTTP PATCH リクエストを準備します。 |
WebTestClient.RequestBodyUriSpec | post() HTTP POST リクエストを準備します。 |
WebTestClient.RequestBodyUriSpec | put() HTTP PUT リクエストを準備します。 |
static final StringSE WEBTESTCLIENT_REQUEST_ID
WebTestClient
を介して実行されるすべてのリクエストに一意の ID を割り当てるために使用されるリクエストヘッダーの名前。これは、その ID で(たとえばサーバー側コンポーネントからの)リクエスト処理のすべての段階でコンテキスト情報を保存し、ExchangeResult
が利用可能になったときにその情報を検索できます。WebTestClient.RequestHeadersUriSpec<?> get()
WebTestClient.RequestHeadersUriSpec<?> head()
WebTestClient.RequestBodyUriSpec post()
WebTestClient.RequestBodyUriSpec put()
WebTestClient.RequestBodyUriSpec patch()
WebTestClient.RequestHeadersUriSpec<?> delete()
WebTestClient.RequestHeadersUriSpec<?> options()
WebTestClient.RequestBodyUriSpec method(HttpMethod method)
HttpMethod
のリクエストを準備します。WebTestClient.Builder mutate()
WebTestClient mutateWith(WebTestClientConfigurer configurer)
WebTestClient
を変更し、指定された設定プログラムを適用して、新しいインスタンスを作成します。基本的には次のショートカットです。mutate().apply(configurer).build();
configurer
- 適用するコンフィギュレーター static WebTestClient.ControllerSpec bindToController(ObjectSE... controllers)
@EnableWebFlux
の場合と同じですが、返された仕様を使用してさらにカスタマイズすることもできます。controllers
- テストするコントローラー static WebTestClient.MockServerSpec<?> bindToApplicationContext(ApplicationContext applicationContext)
@EnableWebFlux
Java 構成やアノテーション付きコントローラー Spring Bean などの ApplicationContext
から検出された WebFlux インフラストラクチャーを備えた「モック」サーバーとの統合テスト。applicationContext
- コンテキスト WebTestClient
ビルダー EnableWebFlux
static WebTestClient.RouterFunctionSpec bindToRouterFunction(RouterFunction<?> routerFunction)
routerFunction
- テストする RouterFunctionWebTestClient
ビルダー static WebTestClient.MockServerSpec<?> bindToWebHandler(WebHandler webHandler)
webHandler
- テストするハンドラー WebTestClient
ビルダー static WebTestClient.Builder bindToServer()
WebTestClient
ビルダー