528188 Update to Spring 5

Explicitly added DisposableBean to OSGi application context as it was removed from the standard app context hierarchy

Improved test case to better document the expected behavior

Signed-off-by: ootto <olaf@x100.de>
diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/context/support/OsgiBundleXmlApplicationContext.java b/core/src/main/java/org/eclipse/gemini/blueprint/context/support/OsgiBundleXmlApplicationContext.java
index 2316352..25b961d 100644
--- a/core/src/main/java/org/eclipse/gemini/blueprint/context/support/OsgiBundleXmlApplicationContext.java
+++ b/core/src/main/java/org/eclipse/gemini/blueprint/context/support/OsgiBundleXmlApplicationContext.java
@@ -24,6 +24,7 @@
 import org.eclipse.gemini.blueprint.util.internal.BundleUtils;
 import org.osgi.framework.BundleContext;
 import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.DisposableBean;
 import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 import org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver;
 import org.springframework.beans.factory.xml.DelegatingEntityResolver;
@@ -52,7 +53,7 @@
  * @author Andy Piper
  * @author Hal Hildebrand
  */
-public class OsgiBundleXmlApplicationContext extends AbstractDelegatedExecutionApplicationContext {
+public class OsgiBundleXmlApplicationContext extends AbstractDelegatedExecutionApplicationContext implements DisposableBean {
 
 	/** Default config location for the root context(s) */
 	public static final String DEFAULT_CONFIG_LOCATION =
diff --git a/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/context/PublishedInterfacesTest.java b/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/context/PublishedInterfacesTest.java
index 691ef1a..04f20d9 100644
--- a/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/context/PublishedInterfacesTest.java
+++ b/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/context/PublishedInterfacesTest.java
@@ -14,12 +14,12 @@
 

 package org.eclipse.gemini.blueprint.iandt.context;

 

+import org.eclipse.gemini.blueprint.context.ConfigurableOsgiBundleApplicationContext;

+import org.eclipse.gemini.blueprint.context.support.OsgiBundleXmlApplicationContext;

 import org.eclipse.gemini.blueprint.iandt.BaseIntegrationTest;

 import org.osgi.framework.Constants;

 import org.osgi.framework.ServiceReference;

 import org.osgi.framework.Version;

-import org.eclipse.gemini.blueprint.context.ConfigurableOsgiBundleApplicationContext;

-import org.eclipse.gemini.blueprint.context.support.OsgiBundleXmlApplicationContext;

 

 /**

  * Test checking the context published interfaces.

@@ -29,18 +29,21 @@
  */

 public class PublishedInterfacesTest extends BaseIntegrationTest {

 

-	public void testEmptyApplicationContext() throws Exception {

-		checkedPublishedOSGiService(1);

-	}

-

 	public void testXmlOsgiContext() throws Exception {

+		// At this point, only the automatically generated test application context should be published as an OSGi service.

+		checkedPublishedOSGiService(1);

+

 		OsgiBundleXmlApplicationContext context = new OsgiBundleXmlApplicationContext(

 			new String[] { "/org/eclipse/gemini/blueprint/iandt/context/no-op-context.xml" });

 		context.setBundleContext(bundleContext);

 		context.refresh();

 

+		// Now, the default and the explicitly create application context should be present

 		checkedPublishedOSGiService(2);

 		context.close();

+

+		// When an application context is closed, the respective service must also be unpublished. Thus, there should only be one service again.

+		checkedPublishedOSGiService(1);

 	}

 

 	private void checkedPublishedOSGiService(int expectedContexts) throws Exception {