|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2018 the original author or authors. |
|
|
|
* Copyright 2002-2020 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -35,6 +35,7 @@ import org.springframework.web.context.request.async.CallableProcessingIntercept |
|
|
|
import org.springframework.web.context.request.async.DeferredResult; |
|
|
|
import org.springframework.web.context.request.async.DeferredResult; |
|
|
|
import org.springframework.web.context.request.async.DeferredResultProcessingInterceptor; |
|
|
|
import org.springframework.web.context.request.async.DeferredResultProcessingInterceptor; |
|
|
|
import org.springframework.web.context.request.async.WebAsyncUtils; |
|
|
|
import org.springframework.web.context.request.async.WebAsyncUtils; |
|
|
|
|
|
|
|
import org.springframework.web.multipart.support.StandardMultipartHttpServletRequest; |
|
|
|
import org.springframework.web.servlet.DispatcherServlet; |
|
|
|
import org.springframework.web.servlet.DispatcherServlet; |
|
|
|
import org.springframework.web.servlet.HandlerExecutionChain; |
|
|
|
import org.springframework.web.servlet.HandlerExecutionChain; |
|
|
|
import org.springframework.web.servlet.ModelAndView; |
|
|
|
import org.springframework.web.servlet.ModelAndView; |
|
|
|
@ -67,6 +68,10 @@ final class TestDispatcherServlet extends DispatcherServlet { |
|
|
|
protected void service(HttpServletRequest request, HttpServletResponse response) |
|
|
|
protected void service(HttpServletRequest request, HttpServletResponse response) |
|
|
|
throws ServletException, IOException { |
|
|
|
throws ServletException, IOException { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!request.getParts().isEmpty()) { |
|
|
|
|
|
|
|
request = new StandardMultipartHttpServletRequest(request); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
registerAsyncResultInterceptors(request); |
|
|
|
registerAsyncResultInterceptors(request); |
|
|
|
|
|
|
|
|
|
|
|
super.service(request, response); |
|
|
|
super.service(request, response); |
|
|
|
@ -80,8 +85,9 @@ final class TestDispatcherServlet extends DispatcherServlet { |
|
|
|
MockHttpServletRequest mockRequest = WebUtils.getNativeRequest(request, MockHttpServletRequest.class); |
|
|
|
MockHttpServletRequest mockRequest = WebUtils.getNativeRequest(request, MockHttpServletRequest.class); |
|
|
|
Assert.notNull(mockRequest, "Expected MockHttpServletRequest"); |
|
|
|
Assert.notNull(mockRequest, "Expected MockHttpServletRequest"); |
|
|
|
asyncContext = (MockAsyncContext) mockRequest.getAsyncContext(); |
|
|
|
asyncContext = (MockAsyncContext) mockRequest.getAsyncContext(); |
|
|
|
|
|
|
|
String requestClassName = request.getClass().getName(); |
|
|
|
Assert.notNull(asyncContext, () -> |
|
|
|
Assert.notNull(asyncContext, () -> |
|
|
|
"Outer request wrapper " + request.getClass().getName() + " has an AsyncContext," + |
|
|
|
"Outer request wrapper " + requestClassName + " has an AsyncContext," + |
|
|
|
"but it is not a MockAsyncContext, while the nested " + |
|
|
|
"but it is not a MockAsyncContext, while the nested " + |
|
|
|
mockRequest.getClass().getName() + " does not have an AsyncContext at all."); |
|
|
|
mockRequest.getClass().getName() + " does not have an AsyncContext at all."); |
|
|
|
} |
|
|
|
} |
|
|
|
|