aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mnutt...@apache.org
Subject svn commit: r1367550 - in /aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests: SubsystemDependencyTestBase.java SubsystemDependency_4ATest.java SubsystemDependency_4CTest.java
Date Tue, 31 Jul 2012 13:48:26 GMT
Author: mnuttall
Date: Tue Jul 31 13:48:25 2012
New Revision: 1367550

URL: http://svn.apache.org/viewvc?rev=1367550&view=rev
Log:
Aries-893: org.apache.aries.subsystem.ctt.itests.SubsystemDependency_4CTest fails. Change
4A and 4B to check that no _new_ bundles get provisioned, regardless of how many we started
with. 

Modified:
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependencyTestBase.java
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4ATest.java
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4CTest.java

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependencyTestBase.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependencyTestBase.java?rev=1367550&r1=1367549&r2=1367550&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependencyTestBase.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependencyTestBase.java
Tue Jul 31 13:48:25 2012
@@ -3,12 +3,15 @@ package org.apache.aries.subsystem.ctt.i
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 import static org.osgi.framework.namespace.BundleNamespace.BUNDLE_NAMESPACE;
 import static org.osgi.framework.namespace.PackageNamespace.PACKAGE_NAMESPACE;
 
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.aries.subsystem.itests.SubsystemTest;
 import org.junit.After;
@@ -273,4 +276,25 @@ public abstract class SubsystemDependenc
 			assertTrue ("Bundle " + bundleName + " not found in subsystem " + subsystemName, bundleFound);
 		}
 	}
+	
+	/**
+	 * Check that no new bundles have been provisioned by [x]
+	 * @param failText where the failure occurred
+	 * @param rootBundlesBefore Bundles before [x]
+	 * @param rootBundlesAfter Bundles after [x]
+	 */
+	protected void checkNoNewBundles(String failText, Bundle[] rootBundlesBefore, Bundle[] rootBundlesAfter)
{
+		if (rootBundlesBefore.length != rootBundlesAfter.length) { 
+			Set<String> bundlesBefore = new HashSet<String>();
+			for (Bundle b : rootBundlesBefore) { 
+				bundlesBefore.add(b.getSymbolicName() + "_" + b.getVersion().toString());
+			}
+			Set<String> bundlesAfter = new HashSet<String>();
+			for (Bundle b : rootBundlesAfter) { 
+				bundlesAfter.add(b.getSymbolicName() + "_" + b.getVersion().toString());
+			}
+			bundlesAfter.removeAll(bundlesBefore);
+			fail ("Extra bundles provisioned in " + failText + " : " + bundlesAfter);
+		}
+	}
 }

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4ATest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4ATest.java?rev=1367550&r1=1367549&r2=1367550&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4ATest.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4ATest.java
Tue Jul 31 13:48:25 2012
@@ -2,9 +2,12 @@ package org.apache.aries.subsystem.ctt.i
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -53,6 +56,7 @@ public class SubsystemDependency_4ATest 
 		verifySinglePackageWiring (s, BUNDLE_C, "x", BUNDLE_A);
  
 		stopSubsystem(s);
+		uninstallSubsystem(s);
 	}
 	
 	@Test
@@ -62,6 +66,7 @@ public class SubsystemDependency_4ATest 
 		startSubsystem(s);
 		verifyRequireBundleWiring (s, BUNDLE_D, BUNDLE_A);
 		stopSubsystem(s);
+		uninstallSubsystem(s);
 	}
 	
 	@Test
@@ -71,51 +76,30 @@ public class SubsystemDependency_4ATest 
 		startSubsystem(s);
 		verifyCapabilityWiring (s, BUNDLE_E, "y", BUNDLE_B);
 		stopSubsystem(s);
+		uninstallSubsystem(s);
 	}
 	
 	/*
 	 * Verify no new bundles are installed into the Root subsystem 
 	 * (particularly bundles F and G)
- 	 * 
- 	 * As of the time of writing, the Root subsystem should contain 23 bundles: 
- 	 * org.eclipse.osgi
-     * org.ops4j.pax.exam
-     * org.ops4j.pax.exam.junit.extender
-     * org.ops4j.pax.exam.junit.extender.impl
-     * wrap_mvn_org.ops4j.pax.exam_pax-exam-junit
-     * org.ops4j.pax.logging.pax-logging-api
-     * org.ops4j.pax.logging.pax-logging-service
-     * org.ops4j.pax.url.mvn
-     * org.eclipse.osgi.services
-     * org.eclipse.equinox.region
-     * org.apache.aries.testsupport.unit
-     * org.apache.aries.application.api
-     * org.apache.aries.util
-     * org.apache.aries.application.utils
-     * org.apache.felix.bundlerepository
-     * org.apache.felix.resolver
-     * org.eclipse.equinox.coordinator
-     * org.eclipse.equinox.event
-     * org.apache.aries.subsystem.api
-     * org.apache.aries.subsystem.core
-     * org.apache.aries.subsystem.itest.interfaces
-     * com.springsource.org.junit
-     * org.ops4j.pax.exam.rbc
-     * org.osgi.service.subsystem.region.context.0
-     * pax-exam-probe
      * 
 	 */
 	@Test
-	public void verifyNoUnexpectedBundlesProvisioned() 
+	public void verifyNoUnexpectedBundlesProvisioned() throws Exception
 	{ 
-		Bundle[] bundles = bundleContext.getBundles();
-		assertEquals ("Wrong number of bundles in the Root subsystem", 25, bundles.length);
-		for (Bundle b: bundles) {
+		Bundle[] rootBundlesBefore = bundleContext.getBundles();
+		Subsystem s = installSubsystemFromFile(APPLICATION_A);
+		startSubsystem(s);
+		Bundle[] rootBundlesAfter = bundleContext.getBundles();
+		for (Bundle b: rootBundlesAfter) {
 			assertTrue ("Bundle F should not have been provisioned!", !b.getSymbolicName().equals(BUNDLE_F));
 			assertTrue ("Bundle G should not have been provisioned!", !b.getSymbolicName().equals(BUNDLE_G));
 		}
+		checkNoNewBundles("SubsystemDependency_4ATest", rootBundlesBefore, rootBundlesAfter);
+		stopSubsystem(s);
+		uninstallSubsystem(s);
 	}
-
+	
 	private static void createTestApplicationA() throws Exception
 	{
 		Map<String, String> attributes = new HashMap<String, String>();

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4CTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4CTest.java?rev=1367550&r1=1367549&r2=1367550&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4CTest.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4CTest.java
Tue Jul 31 13:48:25 2012
@@ -94,52 +94,23 @@ public class SubsystemDependency_4CTest 
 		verifyCapabilityWiring (s2, BUNDLE_E, "y", BUNDLE_B);
 		stopSubsystems();
 	}
-	
-	/*
-	 *  Verify no new bundles are installed into the Root or S1 subsystems 
-	 */
-	
-	private static final Collection<String> _expectedRootRegionBundles = Arrays.asList(new
String[]{ 
-		"org.eclipse.osgi", "org.ops4j.pax.exam", "org.ops4j.pax.exam.junit.extender", 
-		"org.ops4j.pax.exam.junit.extender.impl", "org.ops4j.pax.logging.pax-logging-api", 
-		"org.ops4j.pax.logging.pax-logging-service", "org.ops4j.pax.url.mvn", 
-		"org.eclipse.osgi.services", "org.eclipse.equinox.region", 
-		"org.apache.aries.testsupport.unit", "org.apache.aries.application.api", 
-		"org.apache.aries.util", "org.apache.aries.application.utils", 
-		"org.apache.felix.bundlerepository", "org.apache.felix.resolver", 
-		"org.eclipse.equinox.coordinator", "org.eclipse.equinox.event", 
-		"org.apache.aries.subsystem.api", "org.apache.aries.subsystem.core", 
-		"com.springsource.org.junit", "org.ops4j.pax.exam.rbc", 
-		"org.osgi.service.subsystem.region.context.0", "pax-exam-probe",
-		"wrap_mvn_org.ops4j.pax.exam_pax-exam-junit_1.2.3", "org.apache.aries.subsystem.itest.interfaces"});
-	
-	private static final Collection<String> _expectedS1RegionBundles = Arrays.asList(new
String[] { 
-			BUNDLE_A, BUNDLE_B, "org.osgi.service.subsystem.region.context.1"});
 
 	@Test
 	public void verifyNoUnexpectedBundlesProvisioned() throws Exception 
 	{ 
-		startSubsystems();
-		checkSubsystemContents ("Root", bundleContext,_expectedRootRegionBundles);
-		BundleContext s1Context = s1.getBundleContext();
-		checkSubsystemContents ("S1", s1Context, _expectedS1RegionBundles);
+		Bundle[] rootBundlesBefore = bundleContext.getBundles();
+		s1 = installSubsystemFromFile(SUBSYSTEM_S1);
+		startSubsystem(s1);
+		Bundle[] s1BundlesBefore = bundleContext.getBundles();
+		s2 = installSubsystemFromFile(s1, SUBSYSTEM_S2);
+		startSubsystem(s2);
+		Bundle[] rootBundlesAfter = bundleContext.getBundles();
+		Bundle[] s1BundlesAfter = bundleContext.getBundles();
+		checkNoNewBundles ("rootBundles", rootBundlesBefore, rootBundlesAfter);
+		checkNoNewBundles ("s1Bundles", s1BundlesBefore, s1BundlesAfter);
 		stopSubsystems();
 	}
 	
-	private void checkSubsystemContents (String subsystemName, BundleContext subsystemContext,
Collection<String> expectedBundleNames ) 
-	{ 
-		Bundle[] regionBundles = subsystemContext.getBundles();
-		if (expectedBundleNames.size() != regionBundles.length) { 
-			fail ("Wrong number of bundles in the " + subsystemName + " subsystem." 
-				+ " Expected " + expectedBundleNames.size() + " bundles: " + expectedBundleNames
-				+ " Found " + regionBundles.length + " bundles: " + Arrays.toString(regionBundles));
-		}
-		for (Bundle b: regionBundles) {
-			String bsn = b.getSymbolicName();
-			assertTrue ("Unexpected bundle found in " + subsystemName + " subsystem: " + bsn, expectedBundleNames.contains(bsn));
-		}
-	}
-	
 	/*
 	 * a composite subsystem S1 with the following content bundles (with no import/export policy)
        - Bundle A



Mime
View raw message