public abstract class MockMvcResultMatchers
extends java.lang.Object
ResultMatcher
-based result actions.
Consider adding this class as a Java editor favorite. To navigate to this setting, open the Preferences and type "favorites".
Constructor and Description |
---|
MockMvcResultMatchers() |
Modifier and Type | Method and Description |
---|---|
static ContentResultMatchers |
content()
Access to response body assertions.
|
static CookieResultMatchers |
cookie()
Access to response cookie assertions.
|
static FlashAttributeResultMatchers |
flash()
Access to flash attribute assertions.
|
static ResultMatcher |
forwardedUrl(java.lang.String expectedUrl)
Asserts the request was forwarded to the given URL.
|
static ResultMatcher |
forwardedUrlPattern(java.lang.String urlPattern)
Asserts the request was forwarded to the given URL.
|
static ResultMatcher |
forwardedUrlTemplate(java.lang.String urlTemplate,
java.lang.Object... uriVars)
Asserts the request was forwarded to the given URL template.
|
static HandlerResultMatchers |
handler()
Access to assertions for the handler that handled the request.
|
static HeaderResultMatchers |
header()
Access to response header assertions.
|
static <T> ResultMatcher |
jsonPath(java.lang.String expression,
org.hamcrest.Matcher<T> matcher)
Access to response body assertions using a
JsonPath expression
to inspect a specific subset of the body and a Hamcrest matcher for
asserting the value found at the JSON path.
|
static JsonPathResultMatchers |
jsonPath(java.lang.String expression,
java.lang.Object... args)
Access to response body assertions using a
JsonPath expression
to inspect a specific subset of the body.
|
static ModelResultMatchers |
model()
Access to model-related assertions.
|
static ResultMatcher |
redirectedUrl(java.lang.String expectedUrl)
Asserts the request was redirected to the given URL.
|
static ResultMatcher |
redirectedUrlPattern(java.lang.String urlPattern)
Asserts the request was redirected to the given URL.
|
static ResultMatcher |
redirectedUrlTemplate(java.lang.String urlTemplate,
java.lang.Object... uriVars)
Asserts the request was redirected to the given URL template.
|
static RequestResultMatchers |
request()
Access to request-related assertions.
|
static StatusResultMatchers |
status()
Access to response status assertions.
|
static ViewResultMatchers |
view()
Access to assertions on the selected view.
|
static XpathResultMatchers |
xpath(java.lang.String expression,
java.util.Map<java.lang.String,java.lang.String> namespaces,
java.lang.Object... args)
Access to response body assertions using an XPath expression to
inspect a specific subset of the body.
|
static XpathResultMatchers |
xpath(java.lang.String expression,
java.lang.Object... args)
Access to response body assertions using an XPath expression to
inspect a specific subset of the body.
|
public static RequestResultMatchers request()
public static HandlerResultMatchers handler()
public static ModelResultMatchers model()
public static ViewResultMatchers view()
public static FlashAttributeResultMatchers flash()
public static ResultMatcher forwardedUrl(java.lang.String expectedUrl)
This method accepts only exact matches.
expectedUrl
- the exact URL expectedpublic static ResultMatcher forwardedUrlTemplate(java.lang.String urlTemplate, java.lang.Object... uriVars)
This method accepts exact matches against the expanded and encoded URL template.
urlTemplate
- a URL template; the expanded URL will be encodeduriVars
- zero or more URI variables to populate the templateUriComponentsBuilder.fromUriString(String)
public static ResultMatcher forwardedUrlPattern(java.lang.String urlPattern)
This method accepts AntPathMatcher
patterns.
urlPattern
- an AntPath pattern to match againstAntPathMatcher
public static ResultMatcher redirectedUrl(java.lang.String expectedUrl)
This method accepts only exact matches.
expectedUrl
- the exact URL expectedpublic static ResultMatcher redirectedUrlTemplate(java.lang.String urlTemplate, java.lang.Object... uriVars)
This method accepts exact matches against the expanded and encoded URL template.
urlTemplate
- a URL template; the expanded URL will be encodeduriVars
- zero or more URI variables to populate the templateUriComponentsBuilder.fromUriString(String)
public static ResultMatcher redirectedUrlPattern(java.lang.String urlPattern)
This method accepts AntPathMatcher
patterns.
urlPattern
- an AntPath pattern to match againstAntPathMatcher
public static StatusResultMatchers status()
public static HeaderResultMatchers header()
public static ContentResultMatchers content()
public static JsonPathResultMatchers jsonPath(java.lang.String expression, java.lang.Object... args)
The JSON path expression can be a parameterized string using
formatting specifiers as defined in
String.format(String, Object...)
.
expression
- the JSON path expression, optionally parameterized with argumentsargs
- arguments to parameterize the JSON path expression withpublic static <T> ResultMatcher jsonPath(java.lang.String expression, org.hamcrest.Matcher<T> matcher)
expression
- the JSON path expressionmatcher
- a matcher for the value expected at the JSON pathpublic static XpathResultMatchers xpath(java.lang.String expression, java.lang.Object... args) throws javax.xml.xpath.XPathExpressionException
The XPath expression can be a parameterized string using formatting
specifiers as defined in String.format(String, Object...)
.
expression
- the XPath expression, optionally parameterized with argumentsargs
- arguments to parameterize the XPath expression withjavax.xml.xpath.XPathExpressionException
public static XpathResultMatchers xpath(java.lang.String expression, java.util.Map<java.lang.String,java.lang.String> namespaces, java.lang.Object... args) throws javax.xml.xpath.XPathExpressionException
The XPath expression can be a parameterized string using formatting
specifiers as defined in String.format(String, Object...)
.
expression
- the XPath expression, optionally parameterized with argumentsnamespaces
- namespaces referenced in the XPath expressionargs
- arguments to parameterize the XPath expression withjavax.xml.xpath.XPathExpressionException
public static CookieResultMatchers cookie()