From 87eb3f970ebc59983b1cfc39dff77e244f596823 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 15 Feb 2010 18:02:19 +0000 Subject: [PATCH] store a static WebApplicationContext reference if the Spring jars get deployed in the same web application as the ContextLoader (SPR-5652) --- .../org/springframework/web/context/ContextLoaderTests.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/org.springframework.web.servlet/src/test/java/org/springframework/web/context/ContextLoaderTests.java b/org.springframework.web.servlet/src/test/java/org/springframework/web/context/ContextLoaderTests.java index caf913c083..971e66941e 100644 --- a/org.springframework.web.servlet/src/test/java/org/springframework/web/context/ContextLoaderTests.java +++ b/org.springframework.web.servlet/src/test/java/org/springframework/web/context/ContextLoaderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,6 +61,7 @@ public final class ContextLoaderTests { listener.contextInitialized(event); WebApplicationContext context = (WebApplicationContext) sc.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); assertTrue("Correct WebApplicationContext exposed in ServletContext", context instanceof XmlWebApplicationContext); + assertTrue(ContextLoader.getCurrentWebApplicationContext() instanceof XmlWebApplicationContext); LifecycleBean lb = (LifecycleBean) context.getBean("lifecycle"); assertTrue("Has father", context.containsBean("father")); assertTrue("Has rod", context.containsBean("rod")); @@ -70,6 +71,8 @@ public final class ContextLoaderTests { assertFalse(context.containsBean("beans1.bean2")); listener.contextDestroyed(event); assertTrue("Destroyed", lb.isDestroyed()); + assertNull(sc.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE)); + assertNull(ContextLoader.getCurrentWebApplicationContext()); } /**