spring-framework / org.springframework.test.web.servlet.result / RequestResultMatchers

RequestResultMatchers

open class RequestResultMatchers

Factory for assertions on the request.

An instance of this class is typically accessed via MockMvcResultMatchers#request.

Author
Rossen Stoyanchev

Author
Sam Brannen

Since
3.2

Functions

asyncNotStarted

open fun asyncNotStarted(): ResultMatcher

Assert that asynchronous processing was not started.

asyncResult

open fun <T : Any> asyncResult(matcher: Matcher<T>): ResultMatcher

Assert the result from asynchronous processing with the given matcher.

This method can be used when a controller method returns Callable or WebAsyncTask.

open fun <T : Any> asyncResult(expectedResult: Any): ResultMatcher

Assert the result from asynchronous processing.

This method can be used when a controller method returns Callable or WebAsyncTask. The value matched is the value returned from the Callable or the exception raised.

asyncStarted

open fun asyncStarted(): ResultMatcher

Assert whether asynchronous processing started, usually as a result of a controller method returning Callable or DeferredResult.

The test will await the completion of a Callable so that #asyncResult(Matcher) can be used to assert the resulting value. Neither a Callable nor a DeferredResult will complete processing all the way since a MockHttpServletRequest does not perform asynchronous dispatches.

attribute

open fun <T : Any> attribute(name: String, matcher: Matcher<T>): ResultMatcher

Assert a request attribute value with the given Hamcrest Matcher.

open fun <T : Any> attribute(name: String, expectedValue: Any): ResultMatcher

Assert a request attribute value.

sessionAttribute

open fun <T : Any> sessionAttribute(name: String, matcher: Matcher<T>): ResultMatcher

Assert a session attribute value with the given Hamcrest Matcher.

open fun <T : Any> sessionAttribute(name: String, value: Any): ResultMatcher

Assert a session attribute value.