Class MockAsyncContext

  • All Implemented Interfaces:
    javax.servlet.AsyncContext

    public class MockAsyncContext
    extends java.lang.Object
    implements javax.servlet.AsyncContext
    Mock implementation of the AsyncContext interface.
    • Field Summary

      • Fields inherited from interface javax.servlet.AsyncContext

        ASYNC_CONTEXT_PATH, ASYNC_MAPPING, ASYNC_PATH_INFO, ASYNC_QUERY_STRING, ASYNC_REQUEST_URI, ASYNC_SERVLET_PATH
    • Constructor Summary

      Constructors 
      Constructor Description
      MockAsyncContext​(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addDispatchHandler​(java.lang.Runnable handler)  
      void addListener​(javax.servlet.AsyncListener listener)  
      void addListener​(javax.servlet.AsyncListener listener, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)  
      void complete()  
      <T extends javax.servlet.AsyncListener>
      T
      createListener​(java.lang.Class<T> clazz)  
      void dispatch()  
      void dispatch​(java.lang.String path)  
      void dispatch​(javax.servlet.ServletContext context, java.lang.String path)  
      java.lang.String getDispatchedPath()  
      java.util.List<javax.servlet.AsyncListener> getListeners()  
      javax.servlet.ServletRequest getRequest()  
      javax.servlet.ServletResponse getResponse()  
      long getTimeout()  
      boolean hasOriginalRequestAndResponse()  
      static void makeAccessible​(java.lang.reflect.Constructor<?> ctor)
      Make the given constructor accessible, explicitly setting it accessible if necessary.
      void setTimeout​(long timeout)  
      void start​(java.lang.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​(javax.servlet.ServletRequest request,
                                javax.servlet.ServletResponse response)
    • Method Detail

      • addDispatchHandler

        public void addDispatchHandler​(java.lang.Runnable handler)
      • getRequest

        public javax.servlet.ServletRequest getRequest()
        Specified by:
        getRequest in interface javax.servlet.AsyncContext
      • getResponse

        public javax.servlet.ServletResponse getResponse()
        Specified by:
        getResponse in interface javax.servlet.AsyncContext
      • hasOriginalRequestAndResponse

        public boolean hasOriginalRequestAndResponse()
        Specified by:
        hasOriginalRequestAndResponse in interface javax.servlet.AsyncContext
      • dispatch

        public void dispatch()
        Specified by:
        dispatch in interface javax.servlet.AsyncContext
      • dispatch

        public void dispatch​(java.lang.String path)
        Specified by:
        dispatch in interface javax.servlet.AsyncContext
      • dispatch

        public void dispatch​(javax.servlet.ServletContext context,
                             java.lang.String path)
        Specified by:
        dispatch in interface javax.servlet.AsyncContext
      • getDispatchedPath

        public java.lang.String getDispatchedPath()
      • complete

        public void complete()
        Specified by:
        complete in interface javax.servlet.AsyncContext
      • start

        public void start​(java.lang.Runnable runnable)
        Specified by:
        start in interface javax.servlet.AsyncContext
      • addListener

        public void addListener​(javax.servlet.AsyncListener listener)
        Specified by:
        addListener in interface javax.servlet.AsyncContext
      • addListener

        public void addListener​(javax.servlet.AsyncListener listener,
                                javax.servlet.ServletRequest request,
                                javax.servlet.ServletResponse response)
        Specified by:
        addListener in interface javax.servlet.AsyncContext
      • getListeners

        public java.util.List<javax.servlet.AsyncListener> getListeners()
      • createListener

        public <T extends javax.servlet.AsyncListener> T createListener​(java.lang.Class<T> clazz)
                                                                 throws javax.servlet.ServletException
        Specified by:
        createListener in interface javax.servlet.AsyncContext
        Throws:
        javax.servlet.ServletException
      • setTimeout

        public void setTimeout​(long timeout)
        Specified by:
        setTimeout in interface javax.servlet.AsyncContext
      • getTimeout

        public long getTimeout()
        Specified by:
        getTimeout in interface javax.servlet.AsyncContext
      • makeAccessible

        public static void makeAccessible​(java.lang.reflect.Constructor<?> ctor)
        Make the given constructor accessible, explicitly setting it accessible if necessary. The setAccessible(true) method is only called when actually necessary, to avoid unnecessary conflicts with a JVM SecurityManager (if active).
        Parameters:
        ctor - the constructor to make accessible
        See Also:
        Constructor.setAccessible(boolean)