Set ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE in DefaultMockMvcBuilder

Issue: SPR-12553
This commit is contained in:
Sebastien Deleuze
2014-12-22 11:53:45 +01:00
parent c4049a989a
commit 32aafb21ff
3 changed files with 30 additions and 1 deletions

View File

@@ -16,6 +16,8 @@
package org.springframework.test.web.servlet.setup;
import javax.servlet.ServletContext;
import org.springframework.util.Assert;
import org.springframework.web.context.WebApplicationContext;
@@ -25,6 +27,7 @@ import org.springframework.web.context.WebApplicationContext;
*
* @author Rossen Stoyanchev
* @author Rob Winch
* @author Sebastien Deleuze
* @since 3.2
*/
public class DefaultMockMvcBuilder extends AbstractMockMvcBuilder<DefaultMockMvcBuilder> {
@@ -45,6 +48,8 @@ public class DefaultMockMvcBuilder extends AbstractMockMvcBuilder<DefaultMockMvc
@Override
protected WebApplicationContext initWebAppContext() {
ServletContext servletContext = this.webAppContext.getServletContext();
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.webAppContext);
return this.webAppContext;
}