public class ContentResultMatchers extends ObjectSE
このクラスのインスタンスは通常、MockMvcResultMatchers.content()
を介してアクセスされます。
修飾子 | コンストラクターと説明 |
---|---|
protected | ContentResultMatchers() protected コンストラクター。 |
修飾子と型 | メソッドと説明 |
---|---|
ResultMatcher | bytes(byte[] expectedContent) レスポンス本文のコンテンツをバイト配列としてアサートします。 |
ResultMatcher | contentType(MediaType contentType) MediaType として解析した後、ServletResponse コンテンツ型をアサートします。 |
ResultMatcher | contentType(StringSE contentType) ServletResponse コンテンツ型をアサートします。 |
ResultMatcher | contentTypeCompatibleWith(MediaType contentType) ServletResponse コンテンツ型が MediaType.isCompatibleWith(MediaType) で定義された特定のコンテンツ型と互換性があることをアサートします。 |
ResultMatcher | contentTypeCompatibleWith(StringSE contentType) ServletResponse コンテンツ型が MediaType.isCompatibleWith(MediaType) で定義された特定のコンテンツ型と互換性があることをアサートします。 |
ResultMatcher | encoding(CharsetSE characterEncoding) ServletResponse で文字エンコードをアサートします。 |
ResultMatcher | encoding(StringSE characterEncoding) ServletResponse で文字エンコードをアサートします。 |
ResultMatcher | json(StringSE jsonContent) 期待される文字列と実際の文字列を JSON として解析し、2 つが「類似している」ことを表明します。 |
ResultMatcher | json(StringSE jsonContent, boolean strict) レスポンスコンテンツと指定された文字列を JSON として解析し、2 つが「類似している」ことを表明します。 |
ResultMatcher | node(Matcher<? super NodeSE> matcher) |
ResultMatcher | source(Matcher<? super SourceSE> matcher) レスポンスコンテンツを DOMSource SE として解析し、指定された Hamcrest Matcher を適用します。 |
ResultMatcher | string(Matcher<? super StringSE> matcher) Hamcrest Matcher を使用してレスポンス本文のコンテンツをアサートします。 |
ResultMatcher | string(StringSE expectedContent) レスポンス本文のコンテンツを文字列としてアサートします。 |
ResultMatcher | xml(StringSE xmlContent) レスポンスコンテンツと指定された文字列を XML として解析し、2 つが「類似している」ことを表明します。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
protected ContentResultMatchers()
MockMvcResultMatchers.content()
を使用します。public ResultMatcher contentType(StringSE contentType)
contentTypeCompatibleWith(String)
を参照してください。public ResultMatcher contentType(MediaType contentType)
contentTypeCompatibleWith(MediaType)
を参照してください。public ResultMatcher contentTypeCompatibleWith(StringSE contentType)
MediaType.isCompatibleWith(MediaType)
で定義された特定のコンテンツ型と互換性があることをアサートします。public ResultMatcher contentTypeCompatibleWith(MediaType contentType)
MediaType.isCompatibleWith(MediaType)
で定義された特定のコンテンツ型と互換性があることをアサートします。public ResultMatcher encoding(CharsetSE characterEncoding)
StandardCharsets
SE, encoding(String)
public ResultMatcher encoding(StringSE characterEncoding)
public ResultMatcher string(Matcher<? super StringSE> matcher)
Matcher
を使用してレスポンス本文のコンテンツをアサートします。mockMvc.perform(get("/path")) .andExpect(content().string(containsString("text")));
public ResultMatcher string(StringSE expectedContent)
public ResultMatcher bytes(byte[] expectedContent)
public ResultMatcher xml(StringSE xmlContent)
このマッチャーを使用するには、XMLUnit ライブラリが必要です。
xmlContent
- 予期される XML コンテンツ MockMvcResultMatchers.xpath(String, Object...)
, MockMvcResultMatchers.xpath(String, Map, Object...)
public ResultMatcher node(Matcher<? super NodeSE> matcher)
public ResultMatcher source(Matcher<? super SourceSE> matcher)
DOMSource
SE として解析し、指定された Hamcrest Matcher
を適用します。public ResultMatcher json(StringSE jsonContent)
jsonContent
- 予期される JSON コンテンツ public ResultMatcher json(StringSE jsonContent, boolean strict)
strict
パラメーター値に応じて、2 つのモードで比較できます。
true
: 厳格なチェック。拡張可能ではなく、厳密な配列順序。false
: 寛大なチェック。拡張可能な、厳密でない配列の順序。このマッチャーを使用するには、JSONassert ライブラリが必要です。
jsonContent
- 予期される JSON コンテンツ strict
- 厳密なチェックを可能にします