aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mnutt...@apache.org
Subject svn commit: r1360152 - in /aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests: SubsystemDependency_4BTest.java SubsystemDependency_4ETest.java
Date Wed, 11 Jul 2012 12:48:39 GMT
Author: mnuttall
Date: Wed Jul 11 12:48:38 2012
New Revision: 1360152

URL: http://svn.apache.org/viewvc?rev=1360152&view=rev
Log:
Aries-865: Work on test for OSGi Subsystem CTT section 4E. Fix to 4B. 

Modified:
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4BTest.java
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4ETest.java

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4BTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4BTest.java?rev=1360152&r1=1360151&r2=1360152&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4BTest.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4BTest.java
Wed Jul 11 12:48:38 2012
@@ -99,7 +99,7 @@ public class SubsystemDependency_4BTest 
 		attributes.put(SubsystemConstants.SUBSYSTEM_CONTENT, appContent);
 		attributes.put(Constants.IMPORT_PACKAGE, "x");
 		attributes.put(Constants.REQUIRE_BUNDLE, BUNDLE_A);
-		attributes.put(Constants.REQUIRE_CAPABILITY, "y;filter:=\"(bug=true)\"");
+		attributes.put(Constants.REQUIRE_CAPABILITY, "y");
 		createManifest(APPLICATION_B + ".mf", attributes);
 		createSubsystem(APPLICATION_B);
 	}

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4ETest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4ETest.java?rev=1360152&r1=1360151&r2=1360152&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4ETest.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4ETest.java
Wed Jul 11 12:48:38 2012
@@ -1,8 +1,16 @@
 package org.apache.aries.subsystem.ctt.itests;
 
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 
+import static org.osgi.service.subsystem.SubsystemConstants.SUBSYSTEM_TYPE;
+import static org.osgi.service.subsystem.SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION;
+import static org.osgi.service.subsystem.SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE;
+import static org.osgi.service.subsystem.SubsystemConstants.SUBSYSTEM_TYPE_FEATURE;
+import static org.osgi.service.subsystem.SubsystemConstants.SUBSYSTEM_SYMBOLICNAME;
+
+
 import org.junit.Before;
 import org.junit.Test;
 import org.osgi.framework.Constants;
@@ -75,10 +83,11 @@ public class SubsystemDependency_4ETest 
        - There are 6 combinations to test
          - app_app, app_comp, app_feat, comp_app, comp_comp, comp_feat
 	*/
-	private static final String SUBSYSTEM_4E_S1 = "sdt_composite4e_s1.esa";
-	private static final String SUBSYSTEM_4E_S2 = "sdt_application4e_s1.esa";
+	private static final String SUBSYSTEM_4E_S1_COMP = "sdt_composite4e_s1.esa";
+	private static final String SUBSYSTEM_4E_S2_APP = "sdt_application4e_s2.esa";
+	private static final String SUBSYSTEM_4E_S2_COMP = "sdt_composite4e_s2.esa";
+	private static final String SUBSYSTEM_4E_S2_FEATURE = "sdt_feature4e_s2.esa";
 	private static boolean _testSubsystemsCreated = false;
-	private Subsystem subsystem_s1;
 	
 	@Before
 	public void setUp() throws Exception
@@ -87,6 +96,8 @@ public class SubsystemDependency_4ETest 
 		if (!_testSubsystemsCreated) { 
 			createComposite4E_S1();
 			createApplication4E_S2();
+			createComposite4E_S2();
+			createFeature4E_S2();
 		}
 		registerRepositoryR2();
 	}
@@ -99,21 +110,175 @@ public class SubsystemDependency_4ETest 
 	@Test
 	public void verifyBundlesAandBInstalledIntoRootSubsystem() throws Exception
 	{
-		Subsystem s1 = installSubsystemFromFile(SUBSYSTEM_4E_S1);
+		Subsystem s1 = installSubsystemFromFile(SUBSYSTEM_4E_S1_COMP);
 		startSubsystem(s1);
-		
-		Subsystem s2 = installSubsystemFromFile(s1, SUBSYSTEM_4E_S2);
+		Subsystem s2 = installSubsystemFromFile(s1, SUBSYSTEM_4E_S2_APP);
 		startSubsystem(s2);
 		
 		verifyBundlesInstalled (bundleContext, "Root", BUNDLE_A, BUNDLE_B);
 		
+		stop(s1, s2);
+	}
+	
+	
+	@Test
+	public void verifyExpectedWiringsForS2_App() throws Exception
+	{
+		Subsystem s1 = installSubsystemFromFile(SUBSYSTEM_4E_S1_COMP);
+		startSubsystem(s1);
+		Subsystem s2 = installSubsystemFromFile(s1, SUBSYSTEM_4E_S2_APP);
+		startSubsystem(s2);
+		
+		// - Verify the wiring of C, D and E wire to A->x, A, B->y respectively
+		verifySinglePackageWiring (s2, BUNDLE_C, "x", BUNDLE_A);
+		verifyRequireBundleWiring (s2, BUNDLE_D, BUNDLE_A);
+		verifyCapabilityWiring (s2, BUNDLE_E, "y", BUNDLE_B);
+
+		stop(s1, s2);
+	}
+	
+	// - Repeat test with S2 as a composite that 
+	//     imports package x, requires bundle A and required capability y
+	@Test
+	public void verifyExpectedWiringsForS2_Composite() throws Exception
+	{
+		Subsystem s1 = installSubsystemFromFile(SUBSYSTEM_4E_S1_COMP);
+		startSubsystem(s1);
+		Subsystem s2 = installSubsystemFromFile(s1, SUBSYSTEM_4E_S2_COMP);
+		startSubsystem(s2);
+		
+		// - Verify the wiring of C, D and E wire to A->x, A, B->y respectively
+		/*verifySinglePackageWiring (s2, BUNDLE_C, "x", BUNDLE_A);
+		verifyRequireBundleWiring (s2, BUNDLE_D, BUNDLE_A);
+		verifyCapabilityWiring (s2, BUNDLE_E, "y", BUNDLE_B);*/
+		runChecks(s2);
+		
+		stop(s1, s2);
+	}
+	
+	// - Repeat test with S2 as a feature
+	@Test
+	public void verifyExpectedWiringsForS2_Feature() throws Exception
+	{
+		Subsystem s1 = installSubsystemFromFile(SUBSYSTEM_4E_S1_COMP);
+		startSubsystem(s1);
+		Subsystem s2 = installSubsystemFromFile(s1, SUBSYSTEM_4E_S2_FEATURE);
+		startSubsystem(s2);
+		runChecks (s2);
+		stop(s1, s2);
+	}
+	
+	// b. - same as 4E1a except S2 is a content resource of S1
+    //  - There are 6 combinations to test
+    //   - app_app, app_comp, app_feat, comp_app, comp_comp, comp_feat
+
+	@Test
+	public void FourE1b_App_App() throws Exception
+	{
+		combinationTest ("4eS1_App_App.esa", SUBSYSTEM_TYPE_APPLICATION, SUBSYSTEM_4E_S2_APP, SUBSYSTEM_TYPE_APPLICATION);
+	}
+	
+	@Test
+	public void FourE1b_App_Comp() throws Exception
+	{
+		combinationTest ("4eS1_App_Comp.esa", SUBSYSTEM_TYPE_APPLICATION, SUBSYSTEM_4E_S2_COMP,
SUBSYSTEM_TYPE_COMPOSITE);
+	}
+	
+	@Test
+	public void FourE1b_App_Feature() throws Exception
+	{
+		combinationTest ("4eS1_App_Feature.esa", SUBSYSTEM_TYPE_APPLICATION, SUBSYSTEM_4E_S2_FEATURE,
SUBSYSTEM_TYPE_FEATURE);
+	}
+	
+	@Test
+	public void FourE1b_Comp_App() throws Exception
+	{
+		combinationTest ("4eS1_Comp_App.esa", SUBSYSTEM_TYPE_COMPOSITE, SUBSYSTEM_4E_S2_APP, SUBSYSTEM_TYPE_APPLICATION);
+	}
+	
+	@Test
+	public void FourE1b_Comp_Comp() throws Exception
+	{
+		combinationTest ("4eS1_Comp_Comp.esa", SUBSYSTEM_TYPE_COMPOSITE, SUBSYSTEM_4E_S2_COMP,
SUBSYSTEM_TYPE_COMPOSITE);
+	}
+	
+	@Test
+	public void FourE1b_Comp_Feature() throws Exception
+	{
+		combinationTest ("4eS1_Comp_Feature.esa", SUBSYSTEM_TYPE_COMPOSITE, SUBSYSTEM_4E_S2_FEATURE,
SUBSYSTEM_TYPE_FEATURE);
+	}
+	
+	/*
+	 * Build a subsystem called combinedSubsystemName with a parent of parentType and a child
of childType
+	 * Start the subsystem
+	 * runChecks on the comination
+	 * Stop and uninstall the combination
+	 */
+	private void combinationTest (String combinedSubsystemName, String parentType, String childName,
String childType) throws Exception
+	{
+		createCombinedSubsystem (combinedSubsystemName, parentType, childName, childType);
+		Subsystem s = installSubsystemFromFile(combinedSubsystemName);
+		startSubsystem(s);
+		
+		Collection<Subsystem> children = s.getChildren();  
+		// we only expect one child
+		Subsystem child = children.iterator().next();
+		runChecks (child);
+		
+		stopSubsystem(s);
+		uninstallSubsystem(s);
+	}
+	
+	
+	private void runChecks (Subsystem child) 
+	{
+		// - Verify the wiring of C, D and E wire to A->x, A, B->y respectively
+		verifySinglePackageWiring (child, BUNDLE_C, "x", BUNDLE_A);
+		verifyRequireBundleWiring (child, BUNDLE_D, BUNDLE_A);
+		verifyCapabilityWiring (child, BUNDLE_E, "y", BUNDLE_B);
+	}
+	
+
+	/*
+	 * Create a nested parent/child subsystem with symbolicName, where parent is of type and
child is the 
+	 * previously-created childSubsystem
+	 */
+	private void createCombinedSubsystem (String symbolicName, String parentType, String childSubsystem,
String childSubsystemType) throws Exception
+	{
+		Map<String, String> attributes = new HashMap<String, String>();
+		attributes.put(SUBSYSTEM_SYMBOLICNAME, symbolicName);
+		attributes.put(SubsystemConstants.SUBSYSTEM_VERSION, "1.0.0");
+		attributes.put(SUBSYSTEM_TYPE, parentType);
+		
+		if (parentType == SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE) { 
+			attributes.put(Constants.IMPORT_PACKAGE, "x");
+			attributes.put(Constants.REQUIRE_BUNDLE, BUNDLE_A);
+			attributes.put(Constants.REQUIRE_CAPABILITY, "y");
+		}
+		
+		StringBuffer subsystemContent = new StringBuffer();
+		subsystemContent.append (childSubsystem + ";" + Constants.VERSION_ATTRIBUTE 
+				+ "=\"[1.0.0,1.0.0]\";");
+		// TODO: possible spec bug - subsystem-content needs a ;type= attribute
+		// but there's no constant for TYPE_ATTRIBUTE ...?
+		subsystemContent.append("type=");
+		subsystemContent.append(childSubsystemType);
+		attributes.put(SubsystemConstants.SUBSYSTEM_CONTENT, subsystemContent.toString());
+		
+		createManifest(symbolicName + ".mf", attributes);
+		createSubsystem(symbolicName, childSubsystem);
+	}
+
+	
+	private void stop(Subsystem s1, Subsystem s2) throws Exception
+	{
 		stopSubsystem(s2);
 		stopSubsystem(s1);
 		uninstallSubsystem(s2);
 		uninstallSubsystem(s1);
-		
 	}
 	
+	
 	/*
 	 * a composite subsystem S1 with 
          - no content bundles 
@@ -122,13 +287,14 @@ public class SubsystemDependency_4ETest 
 	private static void createComposite4E_S1() throws Exception
 	{
 		Map<String, String> attributes = new HashMap<String, String>();
-		attributes.put(SubsystemConstants.SUBSYSTEM_SYMBOLICNAME, SUBSYSTEM_4E_S1);
-		attributes.put(SubsystemConstants.SUBSYSTEM_TYPE, SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE);
+		attributes.put(SUBSYSTEM_SYMBOLICNAME, SUBSYSTEM_4E_S1_COMP);
+		attributes.put(SubsystemConstants.SUBSYSTEM_VERSION, "1.0.0");
+		attributes.put(SUBSYSTEM_TYPE, SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE);
 		attributes.put(Constants.IMPORT_PACKAGE, "x");
 		attributes.put(Constants.REQUIRE_BUNDLE, BUNDLE_A);
 		attributes.put(Constants.REQUIRE_CAPABILITY, "y"); 
-		createManifest(SUBSYSTEM_4E_S1 + ".mf", attributes);
-		createSubsystem(SUBSYSTEM_4E_S1);
+		createManifest(SUBSYSTEM_4E_S1_COMP + ".mf", attributes);
+		createSubsystem(SUBSYSTEM_4E_S1_COMP);
 	}
 
 	/* an application S2 with
@@ -136,12 +302,46 @@ public class SubsystemDependency_4ETest 
 	private static void createApplication4E_S2() throws Exception
 	{
 		Map<String, String> attributes = new HashMap<String, String>();
-		attributes.put(SubsystemConstants.SUBSYSTEM_SYMBOLICNAME, SUBSYSTEM_4E_S2);
-		attributes.put(SubsystemConstants.SUBSYSTEM_TYPE, SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION);
+		attributes.put(SUBSYSTEM_SYMBOLICNAME, SUBSYSTEM_4E_S2_APP);
+		attributes.put(SubsystemConstants.SUBSYSTEM_VERSION, "1.0.0");
+		attributes.put(SUBSYSTEM_TYPE, SUBSYSTEM_TYPE_APPLICATION);
 		String appContent = BUNDLE_C + ", " + BUNDLE_D + ", " + BUNDLE_E;
 		attributes.put(SubsystemConstants.SUBSYSTEM_CONTENT, appContent);
-		createManifest(SUBSYSTEM_4E_S2 + ".mf", attributes);
-		createSubsystem(SUBSYSTEM_4E_S2);
+		createManifest(SUBSYSTEM_4E_S2_APP + ".mf", attributes);
+		createSubsystem(SUBSYSTEM_4E_S2_APP);
+	}
+	
+	/* a feature S2 with
+    - content bundles C, D and E */
+	private static void createFeature4E_S2() throws Exception
+	{
+		Map<String, String> attributes = new HashMap<String, String>();
+		attributes.put(SUBSYSTEM_SYMBOLICNAME, SUBSYSTEM_4E_S2_FEATURE);
+		attributes.put(SubsystemConstants.SUBSYSTEM_VERSION, "1.0.0");
+		attributes.put(SUBSYSTEM_TYPE, SubsystemConstants.SUBSYSTEM_TYPE_FEATURE);
+		String appContent = BUNDLE_C + ", " + BUNDLE_D + ", " + BUNDLE_E;
+		attributes.put(SubsystemConstants.SUBSYSTEM_CONTENT, appContent);
+		createManifest(SUBSYSTEM_4E_S2_FEATURE + ".mf", attributes);
+		createSubsystem(SUBSYSTEM_4E_S2_FEATURE);
+	}
+	
+	/* a composite S2 that 
+	//     imports package x, requires bundle A and required capability y */
+	private static void createComposite4E_S2() throws Exception
+	{
+		Map<String, String> attributes = new HashMap<String, String>();
+		attributes.put(SUBSYSTEM_SYMBOLICNAME, SUBSYSTEM_4E_S2_COMP);
+		attributes.put(SubsystemConstants.SUBSYSTEM_VERSION, "1.0.0");
+		attributes.put(SUBSYSTEM_TYPE, SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE);
+		String appContent = BUNDLE_C + ";" + Constants.VERSION_ATTRIBUTE + "=\"[1.0.0,1.0.0]\""
+			+ ", " + BUNDLE_D + ";" + Constants.VERSION_ATTRIBUTE + "=\"[1.0.0,1.0.0]\""
+			+ ", " + BUNDLE_E + ";" + Constants.VERSION_ATTRIBUTE + "=\"[1.0.0,1.0.0]\"";
+		attributes.put(SubsystemConstants.SUBSYSTEM_CONTENT, appContent);
+		attributes.put(Constants.IMPORT_PACKAGE, "x");
+		attributes.put(Constants.REQUIRE_BUNDLE, BUNDLE_A);
+		attributes.put(Constants.REQUIRE_CAPABILITY, "y"); 
+		createManifest(SUBSYSTEM_4E_S2_COMP + ".mf", attributes);
+		createSubsystem(SUBSYSTEM_4E_S2_COMP);
 	}
 
 



Mime
View raw message