org.springframework.mock.web

## Class MockAsyncContext

- java.lang.Object
- - org.springframework.mock.web.MockAsyncContext

- All Implemented Interfaces:
    AsyncContext

      public class MockAsyncContext
      extends Object
      implements AsyncContext

  Mock implementation of the `AsyncContext` interface.
  Since:
    3.2
  Author:
    Rossen Stoyanchev

- - ### Field Summary

    - ### Fields inherited from interface javax.servlet.AsyncContext

      `ASYNC_CONTEXT_PATH, ASYNC_PATH_INFO, ASYNC_QUERY_STRING, ASYNC_REQUEST_URI, ASYNC_SERVLET_PATH`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MockAsyncContext(ServletRequest request, ServletResponse response)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addDispatchHandler(Runnable handler)`
    `void` | `addListener(AsyncListener listener)`
    `void` | `addListener(AsyncListener listener, ServletRequest request, ServletResponse response)`
    `void` | `complete()`
    `<T extends AsyncListener> T` | `createListener(Class<T> clazz)`
    `void` | `dispatch()`
    `void` | `dispatch(ServletContext context, String path)`
    `void` | `dispatch(String path)`
    `String` | `getDispatchedPath()`
    `List<AsyncListener>` | `getListeners()`
    `ServletRequest` | `getRequest()`
    `ServletResponse` | `getResponse()`
    `long` | `getTimeout()`
    `boolean` | `hasOriginalRequestAndResponse()`
    `void` | `setTimeout(long timeout)`
    `void` | `start(Runnable runnable)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### MockAsyncContext

          public MockAsyncContext(ServletRequest request,
                                  ServletResponse response)

  - ### Method Detail

    - #### addDispatchHandler

          public void addDispatchHandler(Runnable handler)

    - #### getRequest

          public ServletRequest getRequest()

      Specified by:
        `getRequest` in interface `AsyncContext`

    - #### getResponse

          public ServletResponse getResponse()

      Specified by:
        `getResponse` in interface `AsyncContext`

    - #### hasOriginalRequestAndResponse

          public boolean hasOriginalRequestAndResponse()

      Specified by:
        `hasOriginalRequestAndResponse` in interface `AsyncContext`

    - #### dispatch

          public void dispatch()

      Specified by:
        `dispatch` in interface `AsyncContext`

    - #### dispatch

          public void dispatch(String path)

      Specified by:
        `dispatch` in interface `AsyncContext`

    - #### dispatch

          public void dispatch(ServletContext context,
                               String path)

      Specified by:
        `dispatch` in interface `AsyncContext`

    - #### getDispatchedPath

          public String getDispatchedPath()

    - #### complete

          public void complete()

      Specified by:
        `complete` in interface `AsyncContext`

    - #### start

          public void start(Runnable runnable)

      Specified by:
        `start` in interface `AsyncContext`

    - #### addListener

          public void addListener(AsyncListener listener)

      Specified by:
        `addListener` in interface `AsyncContext`

    - #### addListener

          public void addListener(AsyncListener listener,
                                  ServletRequest request,
                                  ServletResponse response)

      Specified by:
        `addListener` in interface `AsyncContext`

    - #### getListeners

          public List<AsyncListener> getListeners()

    - #### createListener

          public <T extends AsyncListener> T createListener(Class<T> clazz)
                                                     throws ServletException

      Specified by:
        `createListener` in interface `AsyncContext`
      Throws:
        `ServletException`

    - #### setTimeout

          public void setTimeout(long timeout)

      Specified by:
        `setTimeout` in interface `AsyncContext`

    - #### getTimeout

          public long getTimeout()

      Specified by:
        `getTimeout` in interface `AsyncContext`