类 RequestResultMatchers
- java.lang.Object
- org.springframework.test.web.servlet.result.RequestResultMatchers
public class RequestResultMatchers extends Object
Factory for assertions on the request.An instance of this class is typically accessed via
MockMvcResultMatchers.request()
.- 从以下版本开始:
- 3.2
- 作者:
- Rossen Stoyanchev, Sam Brannen
构造器概要
构造器 限定符 构造器 说明 protected
RequestResultMatchers()
Protected constructor.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 ResultMatcher
asyncNotStarted()
Assert that asynchronous processing was not started.ResultMatcher
asyncResult(Object expectedResult)
Assert the result from asynchronous processing.<T> ResultMatcher
asyncResult(Matcher<T> matcher)
Assert the result from asynchronous processing with the given matcher.ResultMatcher
asyncStarted()
Assert whether asynchronous processing started, usually as a result of a controller method returningCallable
orDeferredResult
.ResultMatcher
attribute(String name, Object expectedValue)
Assert a request attribute value.<T> ResultMatcher
attribute(String name, Matcher<T> matcher)
Assert a request attribute value with the given HamcrestMatcher
.ResultMatcher
sessionAttribute(String name, Object value)
Assert a session attribute value.<T> ResultMatcher
sessionAttribute(String name, Matcher<T> matcher)
Assert a session attribute value with the given HamcrestMatcher
.ResultMatcher
sessionAttributeDoesNotExist(String... names)
Assert the given session attributes do not exist.
构造器详细资料
RequestResultMatchers
protected RequestResultMatchers()
Protected constructor.
方法详细资料
asyncStarted
public ResultMatcher asyncStarted()
Assert whether asynchronous processing started, usually as a result of a controller method returningCallable
orDeferredResult
.The test will await the completion of a
Callable
so thatasyncResult(Matcher)
orasyncResult(Object)
can be used to assert the resulting value.Neither a
Callable
nor aDeferredResult
will complete processing all the way since aMockHttpServletRequest
does not perform asynchronous dispatches.- 另请参阅:
asyncNotStarted()
asyncNotStarted
public ResultMatcher asyncNotStarted()
Assert that asynchronous processing was not started.- 另请参阅:
asyncStarted()
asyncResult
public <T> ResultMatcher asyncResult(Matcher<T> matcher)
Assert the result from asynchronous processing with the given matcher.This method can be used when a controller method returns
Callable
orWebAsyncTask
.
asyncResult
public ResultMatcher asyncResult(Object expectedResult)
Assert the result from asynchronous processing.This method can be used when a controller method returns
Callable
orWebAsyncTask
. The value matched is the value returned from theCallable
or the exception raised.
attribute
public <T> ResultMatcher attribute(String name, Matcher<T> matcher)
Assert a request attribute value with the given HamcrestMatcher
.
attribute
public ResultMatcher attribute(String name, Object expectedValue)
Assert a request attribute value.
sessionAttribute
public <T> ResultMatcher sessionAttribute(String name, Matcher<T> matcher)
Assert a session attribute value with the given HamcrestMatcher
.
sessionAttribute
public ResultMatcher sessionAttribute(String name, Object value)
Assert a session attribute value.
sessionAttributeDoesNotExist
public ResultMatcher sessionAttributeDoesNotExist(String... names)
Assert the given session attributes do not exist.- 从以下版本开始:
- 5.2.1