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 Details

  • Method Details

    • asyncStarted

      public ResultMatcher asyncStarted()
      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) or asyncResult(Object) 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.

      See Also:
    • asyncNotStarted

      public ResultMatcher asyncNotStarted()
      Assert that asynchronous processing was not started.
      See Also:
    • asyncResult

      public <T> ResultMatcher asyncResult(Matcher<? super T> matcher)
      Assert the result from asynchronous processing with the given matcher.

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

    • asyncResult

      public ResultMatcher asyncResult(@Nullable Object expectedResult)
      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.

    • attribute

      public <T> ResultMatcher attribute(String name, Matcher<? super T> matcher)
      Assert a request attribute value with the given Hamcrest Matcher.
    • attribute

      public ResultMatcher attribute(String name, @Nullable Object expectedValue)
      Assert a request attribute value.
    • sessionAttribute

      public <T> ResultMatcher sessionAttribute(String name, Matcher<? super T> matcher)
      Assert a session attribute value with the given Hamcrest Matcher.
    • sessionAttribute

      public ResultMatcher sessionAttribute(String name, @Nullable Object value)
      Assert a session attribute value.
    • sessionAttributeDoesNotExist

      public ResultMatcher sessionAttributeDoesNotExist(String... names)
      Assert the given session attributes do not exist.
      Since:
      5.2.1