クラス MockMvcRequestBuilders
java.lang.ObjectSE
org.springframework.test.web.servlet.request.MockMvcRequestBuilders
RequestBuilders
の静的ファクトリメソッド。Spring TestContext フレームワークとの統合
このクラスのメソッドは、Spring TestContext フレームワークによって作成された MockServletContext
を再利用します。
Eclipse ユーザー
このクラスを Java エディターのお気に入りとして追加することを検討してください。この設定に移動するには、設定を開き、「お気に入り」と入力します。
- 導入:
- 3.2
- 作成者:
- Arjen Poutsma, Rossen Stoyanchev, Greg Turnquist, Sebastien Deleuze, Sam Brannen, Kamill Sokol
コンストラクターの概要
コンストラクターメソッドのサマリー
修飾子と型メソッド説明static RequestBuilder
asyncDispatch
(MvcResult mvcResult) 非同期処理を開始したリクエストのMvcResult
から非同期ディスパッチ用のRequestBuilder
を作成します。DELETE リクエストのMockHttpServletRequestBuilder
を作成します。DELETE リクエストのMockHttpServletRequestBuilder
を作成します。GET リクエストのMockHttpServletRequestBuilder
を作成します。GET リクエストのMockHttpServletRequestBuilder
を作成します。HEAD リクエストのMockHttpServletRequestBuilder
を作成します。HEAD リクエストのMockHttpServletRequestBuilder
を作成します。HTTP メソッドとして POST を使用して、マルチパートリクエストのMockMultipartHttpServletRequestBuilder
を作成します。URI
SE を使用したmultipart(String, Object...)
のバリアント。multipart
(HttpMethod httpMethod, StringSE uriTemplate, @Nullable ObjectSE... uriVariables) HttpMethod
も受け入れるmultipart(String, Object...)
のバリアント。multipart
(HttpMethod httpMethod, URISE uri) OPTIONS リクエストのMockHttpServletRequestBuilder
を作成します。OPTIONS リクエストのMockHttpServletRequestBuilder
を作成します。PATCH リクエストのMockHttpServletRequestBuilder
を作成します。PATCH リクエストのMockHttpServletRequestBuilder
を作成します。POST リクエストのMockHttpServletRequestBuilder
を作成します。POST リクエストのMockHttpServletRequestBuilder
を作成します。PUT リクエストのMockHttpServletRequestBuilder
を作成します。PUT リクエストのMockHttpServletRequestBuilder
を作成します。使用すべきではありません。request
(HttpMethod method, StringSE uriTemplate, @Nullable ObjectSE... uriVariables) 指定された HTTP メソッドでリクエストのMockHttpServletRequestBuilder
を作成します。request
(HttpMethod httpMethod, URISE uri) 指定された HTTP メソッドでリクエストのMockHttpServletRequestBuilder
を作成します。
コンストラクターの詳細
MockMvcRequestBuilders
public MockMvcRequestBuilders()
メソッドの詳細
get
public static MockHttpServletRequestBuilder get(StringSE uriTemplate, @Nullable ObjectSE... uriVariables) GET リクエストのMockHttpServletRequestBuilder
を作成します。- パラメーター:
uriTemplate
- URI テンプレート。結果の URI はエンコードされますuriVariables
- 0 個以上の URI 変数
get
GET リクエストのMockHttpServletRequestBuilder
を作成します。- パラメーター:
uri
- URI- 導入:
- 4.0.3
post
public static MockHttpServletRequestBuilder post(StringSE uriTemplate, @Nullable ObjectSE... uriVariables) POST リクエストのMockHttpServletRequestBuilder
を作成します。- パラメーター:
uriTemplate
- URI テンプレート。結果の URI はエンコードされますuriVariables
- 0 個以上の URI 変数
post
POST リクエストのMockHttpServletRequestBuilder
を作成します。- パラメーター:
uri
- URI- 導入:
- 4.0.3
put
public static MockHttpServletRequestBuilder put(StringSE uriTemplate, @Nullable ObjectSE... uriVariables) PUT リクエストのMockHttpServletRequestBuilder
を作成します。- パラメーター:
uriTemplate
- URI テンプレート。結果の URI はエンコードされますuriVariables
- 0 個以上の URI 変数
put
PUT リクエストのMockHttpServletRequestBuilder
を作成します。- パラメーター:
uri
- URI- 導入:
- 4.0.3
patch
public static MockHttpServletRequestBuilder patch(StringSE uriTemplate, @Nullable ObjectSE... uriVariables) PATCH リクエストのMockHttpServletRequestBuilder
を作成します。- パラメーター:
uriTemplate
- URI テンプレート。結果の URI はエンコードされますuriVariables
- 0 個以上の URI 変数
patch
PATCH リクエストのMockHttpServletRequestBuilder
を作成します。- パラメーター:
uri
- URI- 導入:
- 4.0.3
delete
public static MockHttpServletRequestBuilder delete(StringSE uriTemplate, @Nullable ObjectSE... uriVariables) DELETE リクエストのMockHttpServletRequestBuilder
を作成します。- パラメーター:
uriTemplate
- URI テンプレート。結果の URI はエンコードされますuriVariables
- 0 個以上の URI 変数
delete
DELETE リクエストのMockHttpServletRequestBuilder
を作成します。- パラメーター:
uri
- URI- 導入:
- 4.0.3
options
public static MockHttpServletRequestBuilder options(StringSE uriTemplate, @Nullable ObjectSE... uriVariables) OPTIONS リクエストのMockHttpServletRequestBuilder
を作成します。- パラメーター:
uriTemplate
- URI テンプレート。結果の URI はエンコードされますuriVariables
- 0 個以上の URI 変数
options
OPTIONS リクエストのMockHttpServletRequestBuilder
を作成します。- パラメーター:
uri
- URI- 導入:
- 4.0.3
head
public static MockHttpServletRequestBuilder head(StringSE uriTemplate, @Nullable ObjectSE... uriVariables) HEAD リクエストのMockHttpServletRequestBuilder
を作成します。- パラメーター:
uriTemplate
- URI テンプレート。結果の URI はエンコードされますuriVariables
- 0 個以上の URI 変数- 導入:
- 4.1
head
HEAD リクエストのMockHttpServletRequestBuilder
を作成します。- パラメーター:
uri
- URI- 導入:
- 4.1
request
public static MockHttpServletRequestBuilder request(HttpMethod method, StringSE uriTemplate, @Nullable ObjectSE... uriVariables) 指定された HTTP メソッドでリクエストのMockHttpServletRequestBuilder
を作成します。- パラメーター:
method
- HTTP メソッド (GET、POST など)uriTemplate
- URI テンプレート。結果の URI はエンコードされますuriVariables
- 0 個以上の URI 変数
request
指定された HTTP メソッドでリクエストのMockHttpServletRequestBuilder
を作成します。- パラメーター:
httpMethod
- HTTP メソッド (GET、POST など)uri
- URI- 導入:
- 4.0.3
request
@DeprecatedSE(since="6.2") public static MockHttpServletRequestBuilder request(StringSE httpMethod, URISE uri) 使用すべきではありません。カスタム HTTP 動詞 (WebDAV など) を許可する代替ファクトリメソッド。- パラメーター:
httpMethod
- HTTP メソッドuri
- URI- 導入:
- 4.3
multipart
public static MockMultipartHttpServletRequestBuilder multipart(StringSE uriTemplate, @Nullable ObjectSE... uriVariables) HTTP メソッドとして POST を使用して、マルチパートリクエストのMockMultipartHttpServletRequestBuilder
を作成します。- パラメーター:
uriTemplate
- URI テンプレート。結果の URI はエンコードされますuriVariables
- 0 個以上の URI 変数- 導入:
- 5.0
multipart
public static MockMultipartHttpServletRequestBuilder multipart(HttpMethod httpMethod, StringSE uriTemplate, @Nullable ObjectSE... uriVariables) HttpMethod
も受け入れるmultipart(String, Object...)
のバリアント。- パラメーター:
httpMethod
- 使用する HTTP メソッドuriTemplate
- URI テンプレート。結果の URI はエンコードされますuriVariables
- 0 個以上の URI 変数- 導入:
- 5.3.22
multipart
URI
SE を使用したmultipart(String, Object...)
のバリアント。- パラメーター:
uri
- URI- 導入:
- 5.0
multipart
- パラメーター:
httpMethod
- 使用する HTTP メソッドuri
- URI- 導入:
- 5.3.21
asyncDispatch
非同期処理を開始したリクエストのMvcResult
から非同期ディスパッチ用のRequestBuilder
を作成します。使用箇所には、非同期処理を最初に開始するリクエストの実行が含まれます。
MvcResult mvcResult = this.mockMvc.perform(get("/1")) .andExpect(request().asyncStarted()) .andReturn();
そして、
MvcResult
を再使用して非同期ディスパッチを実行します。this.mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(content().string("{\"name\":\"Joe\",\"someDouble\":0.0,\"someBoolean\":false}"));
- パラメーター:
mvcResult
- 非同期処理を開始したリクエストの結果
request(HttpMethod, URI)
を推奨