public class ContentResultMatchers
extends java.lang.Object
MockMvcResultMatchers.content()
.Modifier and Type | Field and Description |
---|---|
private XmlExpectationsHelper |
xmlHelper |
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(java.lang.String contentType)
Assert the ServletResponse content type.
|
ResultMatcher |
encoding(java.lang.String characterEncoding)
Assert the character encoding in the ServletResponse.
|
ResultMatcher |
node(
Parse the response content as
Node and apply the given Hamcrest
Matcher . |
ResultMatcher |
source(
Parse the response content as
DOMSource and apply the given
Hamcrest Matcher . |
ResultMatcher |
string(
Assert the response body content with a Hamcrest
Matcher . |
ResultMatcher |
xml(java.lang.String xmlContent)
Parse the response content and the given string as XML and assert the two
are "similar" - i.e.
|
private final XmlExpectationsHelper xmlHelper
protected ContentResultMatchers()
MockMvcResultMatchers.content()
.public ResultMatcher contentType(java.lang.String contentType)
public ResultMatcher contentType(MediaType contentType)
public ResultMatcher encoding(java.lang.String characterEncoding)
HttpServletResponse#getCharacterEncoding()
public ResultMatcher string(matcher)
Matcher
.
mockMvc.perform(get("/path")) .andExpect(content(containsString("text")));
public ResultMatcher bytes(byte[] expectedContent)
public ResultMatcher xml(java.lang.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(matcher)
Node
and apply the given Hamcrest
Matcher
.public ResultMatcher source(matcher)
DOMSource
and apply the given
Hamcrest Matcher
.