Skip to content

Commit 87eb3f9

Browse files
committed
store a static WebApplicationContext reference if the Spring jars get deployed in the same web application as the ContextLoader (SPR-5652)
1 parent db2d323 commit 87eb3f9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

org.springframework.web.servlet/src/test/java/org/springframework/web/context/ContextLoaderTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2009 the original author or authors.
2+
* Copyright 2002-2010 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -61,6 +61,7 @@ public void testContextLoaderListenerWithDefaultContext() {
6161
listener.contextInitialized(event);
6262
WebApplicationContext context = (WebApplicationContext) sc.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
6363
assertTrue("Correct WebApplicationContext exposed in ServletContext", context instanceof XmlWebApplicationContext);
64+
assertTrue(ContextLoader.getCurrentWebApplicationContext() instanceof XmlWebApplicationContext);
6465
LifecycleBean lb = (LifecycleBean) context.getBean("lifecycle");
6566
assertTrue("Has father", context.containsBean("father"));
6667
assertTrue("Has rod", context.containsBean("rod"));
@@ -70,6 +71,8 @@ public void testContextLoaderListenerWithDefaultContext() {
7071
assertFalse(context.containsBean("beans1.bean2"));
7172
listener.contextDestroyed(event);
7273
assertTrue("Destroyed", lb.isDestroyed());
74+
assertNull(sc.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE));
75+
assertNull(ContextLoader.getCurrentWebApplicationContext());
7376
}
7477

7578
/**

0 commit comments

Comments
 (0)