Class 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().- Since:
- 3.2
- Author:
- Rossen Stoyanchev, Sam Brannen
Constructor Summary
Constructors Modifier Constructor Description protectedRequestResultMatchers()Protected constructor.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResultMatcherasyncNotStarted()Assert that asynchronous processing was not started.<T> ResultMatcherasyncResult(Object expectedResult)Assert the result from asynchronous processing.<T> ResultMatcherasyncResult(Matcher<T> matcher)Assert the result from asynchronous processing with the given matcher.ResultMatcherasyncStarted()Assert whether asynchronous processing started, usually as a result of a controller method returningCallableorDeferredResult.<T> ResultMatcherattribute(String name, Object expectedValue)Assert a request attribute value.<T> ResultMatcherattribute(String name, Matcher<T> matcher)Assert a request attribute value with the given HamcrestMatcher.<T> ResultMatchersessionAttribute(String name, Object value)Assert a session attribute value.<T> ResultMatchersessionAttribute(String name, Matcher<T> matcher)Assert a session attribute value with the given HamcrestMatcher.
Constructor Detail
RequestResultMatchers
protected RequestResultMatchers()
Protected constructor.
Method Detail
asyncStarted
public ResultMatcher asyncStarted()
Assert whether asynchronous processing started, usually as a result of a controller method returningCallableorDeferredResult.The test will await the completion of a
Callableso thatasyncResult(Matcher)can be used to assert the resulting value. Neither aCallablenor aDeferredResultwill complete processing all the way since aMockHttpServletRequestdoes not perform asynchronous dispatches.
asyncNotStarted
public ResultMatcher asyncNotStarted()
Assert that asynchronous processing was not started.- See Also:
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
CallableorWebAsyncTask.
asyncResult
public <T> ResultMatcher asyncResult(Object expectedResult)
Assert the result from asynchronous processing.This method can be used when a controller method returns
CallableorWebAsyncTask. The value matched is the value returned from theCallableor the exception raised.
attribute
public <T> ResultMatcher attribute(String name, Matcher<T> matcher)
Assert a request attribute value with the given HamcrestMatcher.
attribute
public <T> 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 <T> ResultMatcher sessionAttribute(String name, Object value)
Assert a session attribute value.