public class ContentResultMatchers extends Object
MockMvcResultMatchers.content()
.Modifier | Constructor and Description |
---|---|
protected |
ContentResultMatchers()
Protected constructor.
|
Modifier and Type | Method and Description |
---|---|
ResultMatcher |
bytes(byte[] expectedContent)
Assert the response body content as a byte array.
|
ResultMatcher |
contentType(MediaType contentType)
Assert the ServletResponse content type after parsing it as a MediaType.
|
ResultMatcher |
contentType(String contentType)
Assert the ServletResponse content type.
|
ResultMatcher |
contentTypeCompatibleWith(MediaType contentType)
Assert the ServletResponse content type is compatible with the given
content type as defined by
MediaType.isCompatibleWith(MediaType) . |
ResultMatcher |
contentTypeCompatibleWith(String contentType)
Assert the ServletResponse content type is compatible with the given
content type as defined by
MediaType.isCompatibleWith(MediaType) . |
ResultMatcher |
encoding(String characterEncoding)
Assert the character encoding in the ServletResponse.
|
ResultMatcher |
node(org.hamcrest.Matcher<? super Node> matcher)
Parse the response content as
Node and apply the given Hamcrest
Matcher . |
ResultMatcher |
source(org.hamcrest.Matcher<? super Source> matcher)
Parse the response content as
DOMSource and apply the given
Hamcrest Matcher . |
ResultMatcher |
string(org.hamcrest.Matcher<? super String> matcher)
Assert the response body content with a Hamcrest
Matcher . |
ResultMatcher |
string(String expectedContent)
Assert the response body content as a String.
|
ResultMatcher |
xml(String xmlContent)
Parse the response content and the given string as XML and assert the two
are "similar" - i.e.
|
protected ContentResultMatchers()
MockMvcResultMatchers.content()
.public ResultMatcher contentType(String contentType)
contentTypeCompatibleWith(String)
.public ResultMatcher contentType(MediaType contentType)
contentTypeCompatibleWith(MediaType)
.public ResultMatcher contentTypeCompatibleWith(String contentType)
MediaType.isCompatibleWith(MediaType)
.public ResultMatcher contentTypeCompatibleWith(MediaType contentType)
MediaType.isCompatibleWith(MediaType)
.public ResultMatcher encoding(String characterEncoding)
ServletResponse.getCharacterEncoding()
public ResultMatcher string(org.hamcrest.Matcher<? super String> matcher)
Matcher
.
mockMvc.perform(get("/path")) .andExpect(content(containsString("text")));
public ResultMatcher string(String expectedContent)
public ResultMatcher bytes(byte[] expectedContent)
public ResultMatcher xml(String xmlContent)
Use of this matcher requires the XMLUnit library.
xmlContent
- the expected XML contentMockMvcResultMatchers.xpath(String, Object...)
,
MockMvcResultMatchers.xpath(String, Map, Object...)
public ResultMatcher node(org.hamcrest.Matcher<? super Node> matcher)
Node
and apply the given Hamcrest
Matcher
.public ResultMatcher source(org.hamcrest.Matcher<? super Source> matcher)
DOMSource
and apply the given
Hamcrest Matcher
.