类 MockMvcResultMatchers
- java.lang.Object
- org.springframework.test.web.servlet.result.MockMvcResultMatchers
public abstract class MockMvcResultMatchers extends Object
Static factory methods forResultMatcher
-based result actions.Eclipse Users
Consider adding this class as a Java editor favorite. To navigate to this setting, open the Preferences and type "favorites".
- 从以下版本开始:
- 3.2
- 作者:
- Rossen Stoyanchev, Brian Clozel, Sam Brannen
构造器概要
构造器 构造器 说明 MockMvcResultMatchers()
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 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 JsonPathResultMatchers
jsonPath(String expression, Object... args)
Access to response body assertions using a JsonPath expression to inspect a specific subset of the body.static <T> ResultMatcher
jsonPath(String expression, 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 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, Object... args)
Access to response body assertions using an XPath expression to inspect a specific subset of the body.static XpathResultMatchers
xpath(String expression, Map<String,String> namespaces, Object... args)
Access to response body assertions using an XPath expression to inspect a specific subset of the body.
构造器详细资料
MockMvcResultMatchers
public MockMvcResultMatchers()
方法详细资料
request
public static RequestResultMatchers request()
Access to request-related assertions.
handler
public static HandlerResultMatchers handler()
Access to assertions for the handler that handled the request.
model
public static ModelResultMatchers model()
Access to model-related assertions.
view
public static ViewResultMatchers view()
Access to assertions on the selected view.
flash
public static FlashAttributeResultMatchers flash()
Access to flash attribute assertions.
forwardedUrl
public static ResultMatcher forwardedUrl(String expectedUrl)
Asserts the request was forwarded to the given URL.This methods accepts only exact matches.
- 参数:
expectedUrl
- the exact URL expected
forwardedUrlPattern
public static ResultMatcher forwardedUrlPattern(String urlPattern)
Asserts the request was forwarded to the given URL.This methods accepts
AntPathMatcher
expressions.- 参数:
urlPattern
- an AntPath expression to match against- 从以下版本开始:
- 4.0
- 另请参阅:
AntPathMatcher
redirectedUrl
public static ResultMatcher redirectedUrl(String expectedUrl)
Asserts the request was redirected to the given URL.This methods accepts only exact matches.
- 参数:
expectedUrl
- the exact URL expected
redirectedUrlPattern
public static ResultMatcher redirectedUrlPattern(String expectedUrl)
Asserts the request was redirected to the given URL.This method accepts
AntPathMatcher
expressions.- 参数:
expectedUrl
- an AntPath expression to match against- 从以下版本开始:
- 4.0
- 另请参阅:
AntPathMatcher
status
public static StatusResultMatchers status()
Access to response status assertions.
header
public static HeaderResultMatchers header()
Access to response header assertions.
content
public static ContentResultMatchers content()
Access to response body assertions.
jsonPath
public static JsonPathResultMatchers jsonPath(String expression, Object... args)
Access to response body assertions using a JsonPath expression to inspect a specific subset of the body.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 with
jsonPath
public static <T> ResultMatcher jsonPath(String expression, 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.- 参数:
expression
- the JSON path expressionmatcher
- a matcher for the value expected at the JSON path
xpath
public static XpathResultMatchers xpath(String expression, Object... args) throws XPathExpressionException
Access to response body assertions using an XPath expression to inspect a specific subset of the body.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 with- 抛出:
XPathExpressionException
xpath
public static XpathResultMatchers xpath(String expression, Map<String,String> namespaces, Object... args) throws XPathExpressionException
Access to response body assertions using an XPath expression to inspect a specific subset of the body.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 with- 抛出:
XPathExpressionException
cookie
public static CookieResultMatchers cookie()
Access to response cookie assertions.