类 RequestResultMatchers

java.lang.Object
cn.taketoday.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().

从以下版本开始:
4.0
作者:
Rossen Stoyanchev, Sam Brannen
  • 构造器详细资料

  • 方法详细资料

    • 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.

      另请参阅:
    • asyncNotStarted

      public ResultMatcher asyncNotStarted()
      Assert that asynchronous processing was not started.
      另请参阅:
    • asyncResult

      public <T> ResultMatcher asyncResult(org.hamcrest.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, org.hamcrest.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, org.hamcrest.Matcher<? super T> matcher)
      Assert a session attribute value with the given Hamcrest Matcher.
    • getSession

      private static cn.taketoday.session.WebSession getSession(MvcResult result)
    • 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.
    • request

      public ResultMatcher request(Consumer<cn.taketoday.web.RequestContext> contextConsumer)
      Assert the given RequestContext.
    • assertAsyncStarted

      private static void assertAsyncStarted(jakarta.servlet.http.HttpServletRequest request)