Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.CountDownLatch |
asyncDispatchLatch |
private java.util.concurrent.atomic.AtomicReference<java.lang.Object> |
asyncResult |
private java.lang.Object |
handler |
private HandlerInterceptor[] |
interceptors |
private MockHttpServletRequest |
mockRequest |
private MockHttpServletResponse |
mockResponse |
private ModelAndView |
modelAndView |
private java.lang.Exception |
resolvedException |
private static java.lang.Object |
RESULT_NONE |
Constructor and Description |
---|
DefaultMvcResult(MockHttpServletRequest request,
MockHttpServletResponse response)
Create a new instance with the given request and response.
|
Modifier and Type | Method and Description |
---|---|
private boolean |
awaitAsyncDispatch(long timeout)
True if the latch count reached 0 within the specified timeout.
|
java.lang.Object |
getAsyncResult()
Get the result of async execution.
|
java.lang.Object |
getAsyncResult(long timeToWait)
Get the result of async execution and wait if necessary.
|
FlashMap |
getFlashMap()
Return the "output" flash attributes saved during request processing.
|
java.lang.Object |
getHandler()
Return the executed handler.
|
HandlerInterceptor[] |
getInterceptors()
Return interceptors around the handler.
|
ModelAndView |
getModelAndView()
Return the
ModelAndView prepared by the handler. |
MockHttpServletRequest |
getRequest()
Return the performed request.
|
java.lang.Exception |
getResolvedException()
Return any exception raised by a handler and successfully resolved
through a
HandlerExceptionResolver . |
MockHttpServletResponse |
getResponse()
Return the resulting response.
|
(package private) void |
setAsyncDispatchLatch(java.util.concurrent.CountDownLatch asyncDispatchLatch) |
void |
setAsyncResult(java.lang.Object asyncResult) |
void |
setHandler(java.lang.Object handler) |
void |
setInterceptors(HandlerInterceptor... interceptors) |
void |
setModelAndView(ModelAndView mav) |
void |
setResolvedException(java.lang.Exception resolvedException) |
private static final java.lang.Object RESULT_NONE
private final MockHttpServletRequest mockRequest
private final MockHttpServletResponse mockResponse
@Nullable private java.lang.Object handler
@Nullable private HandlerInterceptor[] interceptors
@Nullable private ModelAndView modelAndView
@Nullable private java.lang.Exception resolvedException
private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> asyncResult
@Nullable private java.util.concurrent.CountDownLatch asyncDispatchLatch
public DefaultMvcResult(MockHttpServletRequest request, MockHttpServletResponse response)
public MockHttpServletRequest getRequest()
MvcResult
getRequest
in interface MvcResult
null
public MockHttpServletResponse getResponse()
MvcResult
getResponse
in interface MvcResult
null
public void setHandler(@Nullable java.lang.Object handler)
@Nullable public java.lang.Object getHandler()
MvcResult
getHandler
in interface MvcResult
null
if none were executedpublic void setInterceptors(@Nullable HandlerInterceptor... interceptors)
@Nullable public HandlerInterceptor[] getInterceptors()
MvcResult
getInterceptors
in interface MvcResult
null
if none were selectedpublic void setResolvedException(java.lang.Exception resolvedException)
@Nullable public java.lang.Exception getResolvedException()
MvcResult
HandlerExceptionResolver
.getResolvedException
in interface MvcResult
null
if nonepublic void setModelAndView(@Nullable ModelAndView mav)
@Nullable public ModelAndView getModelAndView()
MvcResult
ModelAndView
prepared by the handler.getModelAndView
in interface MvcResult
ModelAndView
, or null
if nonepublic FlashMap getFlashMap()
MvcResult
getFlashMap
in interface MvcResult
FlashMap
, possibly emptypublic void setAsyncResult(java.lang.Object asyncResult)
public java.lang.Object getAsyncResult()
MvcResult
This method will wait for the async result to be set within the
timeout value associated with the async request, see
MockAsyncContext#setTimeout
. Alternatively, use
MvcResult.getAsyncResult(long)
to specify the amount of time to wait.
getAsyncResult
in interface MvcResult
public java.lang.Object getAsyncResult(long timeToWait)
MvcResult
getAsyncResult
in interface MvcResult
timeToWait
- how long to wait for the async result to be set, in
milliseconds; if -1, then fall back on the timeout value associated with
the async request, see
MockAsyncContext#setTimeout
for more details.private boolean awaitAsyncDispatch(long timeout)
void setAsyncDispatchLatch(java.util.concurrent.CountDownLatch asyncDispatchLatch)