|
|
|
@ -188,8 +188,7 @@ public class ServletTestExecutionListener extends AbstractTestExecutionListener |
|
|
|
|
|
|
|
|
|
|
|
ApplicationContext context = testContext.getApplicationContext(); |
|
|
|
ApplicationContext context = testContext.getApplicationContext(); |
|
|
|
|
|
|
|
|
|
|
|
if (context instanceof WebApplicationContext) { |
|
|
|
if (context instanceof WebApplicationContext wac) { |
|
|
|
WebApplicationContext wac = (WebApplicationContext) context; |
|
|
|
|
|
|
|
ServletContext servletContext = wac.getServletContext(); |
|
|
|
ServletContext servletContext = wac.getServletContext(); |
|
|
|
Assert.state(servletContext instanceof MockServletContext, () -> String.format( |
|
|
|
Assert.state(servletContext instanceof MockServletContext, () -> String.format( |
|
|
|
"The WebApplicationContext for test context %s must be configured with a MockServletContext.", |
|
|
|
"The WebApplicationContext for test context %s must be configured with a MockServletContext.", |
|
|
|
@ -211,9 +210,7 @@ public class ServletTestExecutionListener extends AbstractTestExecutionListener |
|
|
|
testContext.setAttribute(POPULATED_REQUEST_CONTEXT_HOLDER_ATTRIBUTE, Boolean.TRUE); |
|
|
|
testContext.setAttribute(POPULATED_REQUEST_CONTEXT_HOLDER_ATTRIBUTE, Boolean.TRUE); |
|
|
|
testContext.setAttribute(RESET_REQUEST_CONTEXT_HOLDER_ATTRIBUTE, Boolean.TRUE); |
|
|
|
testContext.setAttribute(RESET_REQUEST_CONTEXT_HOLDER_ATTRIBUTE, Boolean.TRUE); |
|
|
|
|
|
|
|
|
|
|
|
if (wac instanceof ConfigurableApplicationContext) { |
|
|
|
if (wac instanceof ConfigurableApplicationContext configurableApplicationContext) { |
|
|
|
@SuppressWarnings("resource") |
|
|
|
|
|
|
|
ConfigurableApplicationContext configurableApplicationContext = (ConfigurableApplicationContext) wac; |
|
|
|
|
|
|
|
ConfigurableListableBeanFactory bf = configurableApplicationContext.getBeanFactory(); |
|
|
|
ConfigurableListableBeanFactory bf = configurableApplicationContext.getBeanFactory(); |
|
|
|
bf.registerResolvableDependency(MockHttpServletResponse.class, response); |
|
|
|
bf.registerResolvableDependency(MockHttpServletResponse.class, response); |
|
|
|
bf.registerResolvableDependency(ServletWebRequest.class, servletWebRequest); |
|
|
|
bf.registerResolvableDependency(ServletWebRequest.class, servletWebRequest); |
|
|
|
|