@Override public AsyncContext startAsync(ServletRequest request, @Nullable ServletResponse response) { Assert.state(this.asyncSupported, "Async not supported"); this.asyncStarted = true; this.asyncContext = new MockAsyncContext(request, response); return this.asyncContext; }
@Override public void dispatch(String path) { dispatch(null, path); }
@Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { registerAsyncResultInterceptors(request); super.service(request, response); if (request.getAsyncContext() != null) { MockAsyncContext asyncContext; if (request.getAsyncContext() instanceof MockAsyncContext) { asyncContext = (MockAsyncContext) request.getAsyncContext(); } else { MockHttpServletRequest mockRequest = WebUtils.getNativeRequest(request, MockHttpServletRequest.class); Assert.notNull(mockRequest, "Expected MockHttpServletRequest"); asyncContext = (MockAsyncContext) mockRequest.getAsyncContext(); Assert.notNull(asyncContext, () -> "Outer request wrapper " + request.getClass().getName() + " has an AsyncContext," + "but it is not a MockAsyncContext, while the nested " + mockRequest.getClass().getName() + " does not have an AsyncContext at all."); } CountDownLatch dispatchLatch = new CountDownLatch(1); asyncContext.addDispatchHandler(dispatchLatch::countDown); getMvcResult(request).setAsyncDispatchLatch(dispatchLatch); } }
@Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { registerAsyncResultInterceptors(request); super.service(request, response); if (request.getAsyncContext() != null) { MockAsyncContext asyncContext; if (request.getAsyncContext() instanceof MockAsyncContext) { asyncContext = (MockAsyncContext) request.getAsyncContext(); } else { MockHttpServletRequest mockRequest = WebUtils.getNativeRequest(request, MockHttpServletRequest.class); Assert.notNull(mockRequest, "Expected MockHttpServletRequest"); asyncContext = (MockAsyncContext) mockRequest.getAsyncContext(); Assert.notNull(asyncContext, () -> "Outer request wrapper " + request.getClass().getName() + " has an AsyncContext," + "but it is not a MockAsyncContext, while the nested " + mockRequest.getClass().getName() + " does not have an AsyncContext at all."); } CountDownLatch dispatchLatch = new CountDownLatch(1); asyncContext.addDispatchHandler(dispatchLatch::countDown); getMvcResult(request).setAsyncDispatchLatch(dispatchLatch); } }
@Override public void dispatch() { dispatch(this.request.getRequestURI()); }
@Override public AsyncContext startAsync(ServletRequest request, ServletResponse response) { if (!this.asyncSupported) { throw new IllegalStateException("Async not supported"); } this.asyncStarted = true; this.asyncContext = new MockAsyncContext(request, response); return this.asyncContext; }
@Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { registerAsyncResultInterceptors(request); super.service(request, response); if (request.getAsyncContext() != null) { MockAsyncContext asyncContext; if (request.getAsyncContext() instanceof MockAsyncContext) { asyncContext = (MockAsyncContext) request.getAsyncContext(); } else { MockHttpServletRequest mockRequest = WebUtils.getNativeRequest(request, MockHttpServletRequest.class); Assert.notNull(mockRequest, "Expected MockHttpServletRequest"); asyncContext = (MockAsyncContext) mockRequest.getAsyncContext(); Assert.notNull(asyncContext, "Outer request wrapper " + request.getClass().getName() + " has an AsyncContext,but it is not a MockAsyncContext, while the nested " + mockRequest.getClass().getName() + " does not have an AsyncContext at all."); } final CountDownLatch dispatchLatch = new CountDownLatch(1); asyncContext.addDispatchHandler(new Runnable() { @Override public void run() { dispatchLatch.countDown(); } }); getMvcResult(request).setAsyncDispatchLatch(dispatchLatch); } }
@Override public void dispatch(String path) { dispatch(null, path); }
@Override public AsyncContext startAsync(ServletRequest request, @Nullable ServletResponse response) { Assert.state(this.asyncSupported, "Async not supported"); this.asyncStarted = true; this.asyncContext = new MockAsyncContext(request, response); return this.asyncContext; }
@Override public void dispatch(String path) { dispatch(null, path); }
@Override public void dispatch() { dispatch(this.request.getRequestURI()); }
@Override public void dispatch() { dispatch(this.request.getRequestURI()); }