public abstract class MockMvcResultMatchers extends 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(String expectedUrl)
Asserts the request was forwarded to the given URL.
|
static ResultMatcher |
forwardedUrlPattern(String urlPattern)
Asserts the request was forwarded to the given URL.
|
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(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 match for asserting
the value found at the JSON path.
|
static JsonPathResultMatchers |
jsonPath(String expression,
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(String expectedUrl)
Asserts the request was redirected to the given URL.
|
static ResultMatcher |
redirectedUrlPattern(String expectedUrl)
Asserts the request was redirected to the given URL.
|
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(String expression,
Map<String,String> namespaces,
Object... args)
Access to response body assertions using an XPath to inspect a specific
subset of the body.
|
static XpathResultMatchers |
xpath(String expression,
Object... args)
Access to response body assertions using an XPath 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(String expectedUrl)
expectedUrl
- the exact URL expectedpublic static ResultMatcher forwardedUrlPattern(String urlPattern)
AntPathMatcher
expressions.urlPattern
- an AntPath expression to match againstAntPathMatcher
public static ResultMatcher redirectedUrl(String expectedUrl)
expectedUrl
- the exact URL expectedpublic static ResultMatcher redirectedUrlPattern(String expectedUrl)
AntPathMatcher
expressions.expectedUrl
- an AntPath expression to match againstAntPathMatcher
public static StatusResultMatchers status()
public static HeaderResultMatchers header()
public static ContentResultMatchers content()
public static JsonPathResultMatchers jsonPath(String expression, Object... args)
String.format(String, Object...)
.expression
- the JSON path optionally parameterized with argumentsargs
- arguments to parameterize the JSON path expression withpublic static <T> ResultMatcher jsonPath(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(String expression, Object... args) throws XPathExpressionException
String.format(String, Object...)
.expression
- the XPath optionally parameterized with argumentsargs
- arguments to parameterize the XPath expression withXPathExpressionException
public static XpathResultMatchers xpath(String expression, Map<String,String> namespaces, Object... args) throws XPathExpressionException
String.format(String, Object...)
.expression
- the XPath optionally parameterized with argumentsnamespaces
- namespaces referenced in the XPath expressionargs
- arguments to parameterize the XPath expression withXPathExpressionException
public static CookieResultMatchers cookie()