Package org.springframework.mock.web
Class MockAsyncContext
java.lang.Object
org.springframework.mock.web.MockAsyncContext
- All Implemented Interfaces:
AsyncContext
Mock implementation of the
AsyncContext
interface.- Since:
- 3.2
- Author:
- Rossen Stoyanchev
-
Field Summary
Fields inherited from interface jakarta.servlet.AsyncContext
ASYNC_CONTEXT_PATH, ASYNC_MAPPING, ASYNC_PATH_INFO, ASYNC_QUERY_STRING, ASYNC_REQUEST_URI, ASYNC_SERVLET_PATH
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addDispatchHandler
(Runnable handler) void
addListener
(AsyncListener listener) void
addListener
(AsyncListener listener, ServletRequest request, ServletResponse response) void
complete()
<T extends AsyncListener>
TcreateListener
(Class<T> clazz) void
dispatch()
void
dispatch
(ServletContext context, String path) void
long
boolean
void
setTimeout
(long timeout) By default this is set to 10000 (10 seconds) even though the Servlet API specifies a default async request timeout of 30 seconds.void
-
Constructor Details
-
MockAsyncContext
-
-
Method Details
-
addDispatchHandler
-
getRequest
- Specified by:
getRequest
in interfaceAsyncContext
-
getResponse
- Specified by:
getResponse
in interfaceAsyncContext
-
hasOriginalRequestAndResponse
public boolean hasOriginalRequestAndResponse()- Specified by:
hasOriginalRequestAndResponse
in interfaceAsyncContext
-
dispatch
public void dispatch()- Specified by:
dispatch
in interfaceAsyncContext
-
dispatch
- Specified by:
dispatch
in interfaceAsyncContext
-
dispatch
- Specified by:
dispatch
in interfaceAsyncContext
-
getDispatchedPath
-
complete
public void complete()- Specified by:
complete
in interfaceAsyncContext
-
start
- Specified by:
start
in interfaceAsyncContext
-
addListener
- Specified by:
addListener
in interfaceAsyncContext
-
addListener
- Specified by:
addListener
in interfaceAsyncContext
-
getListeners
-
createListener
- Specified by:
createListener
in interfaceAsyncContext
- Throws:
ServletException
-
setTimeout
public void setTimeout(long timeout) By default this is set to 10000 (10 seconds) even though the Servlet API specifies a default async request timeout of 30 seconds. Keep in mind the timeout could further be impacted by global configuration through the MVC Java config or the XML namespace, as well as be overridden per request onDeferredResult
or onSseEmitter
.- Specified by:
setTimeout
in interfaceAsyncContext
- Parameters:
timeout
- the timeout value to use.- See Also:
-
getTimeout
public long getTimeout()- Specified by:
getTimeout
in interfaceAsyncContext
-