类 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 ContentResultMatcherscontent()Access to response body assertions.static CookieResultMatcherscookie()Access to response cookie assertions.static FlashAttributeResultMatchersflash()Access to flash attribute assertions.static ResultMatcherforwardedUrl(String expectedUrl)Asserts the request was forwarded to the given URL.static ResultMatcherforwardedUrlPattern(String urlPattern)Asserts the request was forwarded to the given URL.static HandlerResultMatchershandler()Access to assertions for the handler that handled the request.static HeaderResultMatchersheader()Access to response header assertions.static JsonPathResultMatchersjsonPath(String expression, Object... args)Access to response body assertions using a JsonPath expression to inspect a specific subset of the body.static <T> ResultMatcherjsonPath(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 ModelResultMatchersmodel()Access to model-related assertions.static ResultMatcherredirectedUrl(String expectedUrl)Asserts the request was redirected to the given URL.static ResultMatcherredirectedUrlPattern(String expectedUrl)Asserts the request was redirected to the given URL.static RequestResultMatchersrequest()Access to request-related assertions.static StatusResultMatchersstatus()Access to response status assertions.static ViewResultMatchersview()Access to assertions on the selected view.static XpathResultMatchersxpath(String expression, Object... args)Access to response body assertions using an XPath expression to inspect a specific subset of the body.static XpathResultMatchersxpath(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
AntPathMatcherexpressions.- 参数:
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
AntPathMatcherexpressions.- 参数:
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.