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