You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by mn...@apache.org on 2012/07/10 17:08:19 UTC

svn commit: r1359718 - in /aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests: SubsystemDependency_4CTest.java SubsystemDependency_4DTest.java

Author: mnuttall
Date: Tue Jul 10 15:08:19 2012
New Revision: 1359718

URL: http://svn.apache.org/viewvc?rev=1359718&view=rev
Log:
Aries-865: Add tests for OSGi Subsystem CTT section 4D.

Added:
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4DTest.java
Modified:
    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/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=1359718&r1=1359717&r2=1359718&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 10 15:08:19 2012
@@ -51,32 +51,18 @@ public class SubsystemDependency_4CTest 
 	// doing this within @Before doesn't work :(
 	private void startSubsystems() throws Exception
 	{ 
-		System.out.println ("into verifyCinS1WiresToAxInS2");
-		
 		s1 = installSubsystemFromFile(SUBSYSTEM_S1);
 		startSubsystem(s1);
-		
-		System.out.println ("s1 started");
-		
 		s2 = installSubsystemFromFile(s1, SUBSYSTEM_S2);
 		startSubsystem(s2);
-		
-		System.out.println ("s2 started");
 	}
 	
 	private void stopSubsystems() throws Exception
 	{
 		stopSubsystem(s2);
-		System.out.println ("s2 stopped");
-		
 		stopSubsystem(s1);
-		System.out.println ("s1 stopped");
-		
 		uninstallSubsystem(s2);
-		System.out.println ("s2 uninstalled");
-		
 		uninstallSubsystem(s1);
-		System.out.println ("s1 uninstalled");
 	}
 	
 	// Using the subsystem S1, install a composite S2 that 

Added: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4DTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4DTest.java?rev=1359718&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4DTest.java (added)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4DTest.java Tue Jul 10 15:08:19 2012
@@ -0,0 +1,115 @@
+package org.apache.aries.subsystem.ctt.itests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.service.subsystem.Subsystem;
+import org.osgi.service.subsystem.SubsystemConstants;
+
+/*
+ *  D) Test that Local Repository takes priority over registered repositories
+     - Register repository R2
+     - Using the Root subsystem, install a scoped subsystem with the following content bundles
+       - Bundle C
+       - Bundle E
+       and the following resources in the Local Repository
+       - Bundle F
+       - Bundle G
+     - Verify that bundles F and G got installed into the Root Subsystem
+     - Verify the wiring of C and E wire to F->x and G->y respectively
+     - Verify that bundles A and B did not get installed into the Root Subsystem
+ */
+
+public class SubsystemDependency_4DTest extends SubsystemDependencyTestBase 
+{
+	private static final String SUBSYSTEM_4D = "sdt_application4d.esa";
+	private static boolean _testSubsystemCreated = false;
+	private Subsystem subsystem;
+	
+	@Before
+	public void setUp() throws Exception
+	{
+		super.setUp();
+		if (!_testSubsystemCreated) { 
+			createApplication4d();
+		}
+		registerRepositoryR2();
+	}
+	
+	//  - Verify that bundles F and G got installed into the Root Subsystem
+	@Test
+	public void verifyBundesFandGinstalledIntoRootSubsystem() throws Exception
+	{
+		startSubsystem();
+		Bundle[] rootBundles = bundleContext.getBundles();
+		boolean bundleFinstalled = false;
+		boolean bundleGinstalled = false;
+		for (Bundle b : rootBundles) { 
+			if (b.getSymbolicName().equals(BUNDLE_F)) bundleFinstalled = true;
+			if (b.getSymbolicName().equals(BUNDLE_G)) bundleGinstalled = true;
+		}
+		assertTrue ("Bundle F not found in root subsystem", bundleFinstalled);
+		assertTrue ("Bundle G not found in root subsystem", bundleGinstalled);
+		stopSubsystem();
+	}
+	
+	// - Verify the wiring of C and E wire to F->x and G->y respectively
+	@Test
+	public void verifyBundleCWiredToPackageXFromBundleF() throws Exception
+	{
+		startSubsystem();
+		verifySinglePackageWiring (subsystem, BUNDLE_C, "x", BUNDLE_F);
+		stopSubsystem();
+	}
+	
+	@Test
+	public void verifyBundleEWiredToCapability_yFromBundleG() throws Exception
+	{
+		startSubsystem();
+		verifyCapabilityWiring (subsystem, BUNDLE_E, "y", BUNDLE_G);
+		stopSubsystem();
+	}
+	
+	// - Verify that bundles A and B did not get installed into the Root Subsystem
+	@Test
+	public void verifyBundlesAandBNotInstalledInRootSubsystem() throws Exception
+	{
+		startSubsystem();
+		Bundle[] bundles = bundleContext.getBundles();
+		for (Bundle b: bundles) {
+			assertTrue ("Bundle A should not have been provisioned!", !b.getSymbolicName().equals(BUNDLE_A));
+			assertTrue ("Bundle B should not have been provisioned!", !b.getSymbolicName().equals(BUNDLE_B));
+		}
+		stopSubsystem();
+	}
+	
+	// doing this within @Before doesn't work :(
+	private void startSubsystem() throws Exception
+	{ 
+		subsystem = installSubsystemFromFile(SUBSYSTEM_4D);
+		startSubsystem(subsystem);
+	}
+	
+	private void stopSubsystem() throws Exception
+	{
+		stopSubsystem(subsystem);
+		uninstallSubsystem(subsystem);
+	}
+	
+	private static void createApplication4d() throws Exception
+	{
+		Map<String, String> attributes = new HashMap<String, String>();
+		attributes.put(SubsystemConstants.SUBSYSTEM_SYMBOLICNAME, SUBSYSTEM_4D);
+		attributes.put(SubsystemConstants.SUBSYSTEM_TYPE, SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION);
+		String appContent = BUNDLE_C + "," + BUNDLE_E;
+		attributes.put(SubsystemConstants.SUBSYSTEM_CONTENT, appContent);
+		createManifest(SUBSYSTEM_4D + ".mf", attributes);
+		createSubsystem(SUBSYSTEM_4D, BUNDLE_F, BUNDLE_G);
+	}
+}