aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwr...@apache.org
Subject svn commit: r1297702 - in /aries/trunk/subsystem: subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/ subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ subsystem-core/src/main/java/org/apache/aries/subsystem/core/...
Date Tue, 06 Mar 2012 20:42:28 GMT
Author: jwross
Date: Tue Mar  6 20:42:27 2012
New Revision: 1297702

URL: http://svn.apache.org/viewvc?rev=1297702&view=rev
Log:
ARIES-825: Update subsystems to latest Subsystem, Resolver, and Repository APIs.

Initial support for Require-Bundle header in applications.

Modified:
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/DeploymentManifest.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/RequireBundleHeader.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/AriesSubsystem.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/BundleResource.java
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ApplicationTest.java
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/BasicTest.java
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/CompositeTest.java
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/FeatureTest.java
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/InstallTest.java
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/DeploymentManifest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/DeploymentManifest.java?rev=1297702&r1=1297701&r2=1297702&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/DeploymentManifest.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/DeploymentManifest.java
Tue Mar  6 20:42:27 2012
@@ -22,6 +22,7 @@ import org.apache.aries.subsystem.core.i
 import org.apache.aries.subsystem.core.obr.SubsystemEnvironment;
 import org.apache.aries.util.manifest.ManifestProcessor;
 import org.osgi.framework.Constants;
+import org.osgi.framework.namespace.BundleNamespace;
 import org.osgi.framework.namespace.PackageNamespace;
 import org.osgi.framework.wiring.BundleRevision;
 import org.osgi.resource.Requirement;
@@ -119,6 +120,9 @@ public class DeploymentManifest {
 					header = computeRequireCapabilityHeader(resolution, deployedContent, acceptDependencies);
 					if (header != null)
 						headers.put(REQUIRE_CAPABILITY, header);
+					header = computeRequireBundleHeader(resolution, deployedContent, acceptDependencies);
+					if (header != null)
+						headers.put(REQUIRE_BUNDLE, header);
 				}
 				// TODO Compute additional headers for an application.
 			}
@@ -238,6 +242,34 @@ public class DeploymentManifest {
 		return new ImportPackageHeader(clauses);
 	}
 	
+	private static RequireBundleHeader computeRequireBundleHeader(
+			Map<Resource, List<Wire>> resolution, 
+			Collection<Resource> content,
+			boolean acceptDependencies) {
+		Collection<RequireBundleHeader.Clause> clauses = new ArrayList<RequireBundleHeader.Clause>();
+		for (Entry<Resource, List<Wire>> entry : resolution.entrySet()) {
+			for (Wire wire : entry.getValue()) {
+				Resource provider = wire.getProvider();
+				if (content.contains(provider))
+					// If the provider is a content resource, we don't need an import.
+					continue;
+				// The provider is a dependency that is already provisioned or needs provisioning.
+				if (acceptDependencies && !((provider instanceof BundleRevision) || (provider
instanceof AriesSubsystem)))
+					// If the application accepts dependencies and the provider is a dependency that needs
provisioning,
+					// we don't need an import.
+					continue;
+				// For all other cases, we need an import.
+				Requirement requirement = wire.getRequirement();
+				if (BundleNamespace.BUNDLE_NAMESPACE.equals(requirement.getNamespace())) {
+					clauses.add(new RequireBundleHeader.Clause(requirement));
+				}
+			}
+		}
+		if (clauses.isEmpty())
+			return null;
+		return new RequireBundleHeader(clauses);
+	}
+	
 	private static RequireCapabilityHeader computeRequireCapabilityHeader(
 			Map<Resource, List<Wire>> resolution, 
 			Collection<Resource> content,

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/RequireBundleHeader.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/RequireBundleHeader.java?rev=1297702&r1=1297701&r2=1297702&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/RequireBundleHeader.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/RequireBundleHeader.java
Tue Mar  6 20:42:27 2012
@@ -11,6 +11,8 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.osgi.framework.Constants;
+import org.osgi.framework.namespace.PackageNamespace;
+import org.osgi.resource.Requirement;
 
 public class RequireBundleHeader implements Header<RequireBundleHeader.Clause> {
 	public static class Clause implements org.apache.aries.subsystem.core.archive.Clause {
@@ -46,6 +48,31 @@ public class RequireBundleHeader impleme
 			fillInDefaults(parameters);
 		}
 		
+		private static final String REGEX = "\\((" + RequireBundleRequirement.NAMESPACE + ")(=)([^\\)]+)\\)";
+		private static final Pattern PATTERN = Pattern.compile(REGEX);
+		
+		public Clause(Requirement requirement) {
+			if (!RequireBundleRequirement.NAMESPACE.equals(requirement.getNamespace()))
+				throw new IllegalArgumentException("Requirement must be in the '" + RequireBundleRequirement.NAMESPACE
+ "' namespace");
+			String filter = requirement.getDirectives().get(RequireBundleRequirement.DIRECTIVE_FILTER);
+			String path = null;
+			Matcher matcher = PATTERN.matcher(filter);
+			while (matcher.find()) {
+				String name = matcher.group(1);
+				String operator = matcher.group(2);
+				String value = matcher.group(3);
+				if (RequireBundleRequirement.NAMESPACE.equals(name)) {
+					path = value;
+				}
+				else if (ATTRIBUTE_BUNDLEVERSION.equals(name)) {
+					// TODO Parse the version range from the filter.
+				}
+			}
+			if (path == null)
+				throw new IllegalArgumentException("Missing filter key: " + RequireBundleRequirement.NAMESPACE);
+			this.path = path;
+		}
+		
 		@Override
 		public Attribute getAttribute(String name) {
 			Parameter result = parameters.get(name);
@@ -122,14 +149,24 @@ public class RequireBundleHeader impleme
 
 	private static final Pattern PATTERN = Pattern.compile('(' + Grammar.BUNDLE_DESCRIPTION
+ ")(?=,|\\z)");
 	
-	private final Set<Clause> clauses = new HashSet<Clause>();
-	
-	public RequireBundleHeader(String value) {
-		Matcher matcher = PATTERN.matcher(value);
+	private static Collection<Clause> processHeader(String header) {
+		Matcher matcher = PATTERN.matcher(header);
+		Set<Clause> clauses = new HashSet<Clause>();
 		while (matcher.find())
 			clauses.add(new Clause(matcher.group()));
+		return clauses;
+	}
+	
+	private final Set<Clause> clauses;
+	
+	public RequireBundleHeader(Collection<Clause> clauses) {
 		if (clauses.isEmpty())
 			throw new IllegalArgumentException("A " + NAME + " header must have at least one clause");
+		this.clauses = new HashSet<Clause>(clauses);
+	}
+	
+	public RequireBundleHeader(String value) {
+		this(processHeader(value));
 	}
 	
 	@Override

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/AriesSubsystem.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/AriesSubsystem.java?rev=1297702&r1=1297701&r2=1297702&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/AriesSubsystem.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/AriesSubsystem.java
Tue Mar  6 20:42:27 2012
@@ -1140,6 +1140,8 @@ public class AriesSubsystem implements S
 			// In the case of applications, the header is generated.
 			header = getDeploymentManifest().getSubsystemImportServiceHeader();
 			setImportIsolationPolicy(builder, (SubsystemImportServiceHeader)header);
+			header = getDeploymentManifest().getRequireBundleHeader();
+			setImportIsolationPolicy(builder, (RequireBundleHeader)header);
 		}
 		if (isApplication()) {
 			// TODO Implement import isolation policy for applications.
@@ -1148,8 +1150,6 @@ public class AriesSubsystem implements S
 		else if (isComposite()) {
 			// TODO Implement import isolation policy for composites.
 			// Composites specify an explicit import policy in their subsystem and deployment manifests.
-			Header<?> header = getDeploymentManifest().getRequireBundleHeader();
-			setImportIsolationPolicy(builder, (RequireBundleHeader)header);
 		}
 		RegionFilter regionFilter = builder.build();
 		if (LOGGER.isDebugEnabled())

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/BundleResource.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/BundleResource.java?rev=1297702&r1=1297701&r2=1297702&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/BundleResource.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/BundleResource.java
Tue Mar  6 20:42:27 2012
@@ -24,6 +24,8 @@ import java.util.jar.Manifest;
 import org.apache.aries.subsystem.core.archive.BundleManifest;
 import org.apache.aries.subsystem.core.archive.ExportPackageHeader;
 import org.apache.aries.subsystem.core.archive.ImportPackageHeader;
+import org.apache.aries.subsystem.core.archive.RequireBundleHeader;
+import org.apache.aries.subsystem.core.archive.RequireBundleRequirement;
 import org.apache.aries.subsystem.core.archive.RequireCapabilityHeader;
 import org.apache.aries.subsystem.core.archive.RequireCapabilityRequirement;
 import org.apache.aries.subsystem.core.internal.OsgiIdentityCapability;
@@ -69,6 +71,10 @@ public class BundleResource implements R
 		if (rch != null)
 			for (RequireCapabilityHeader.Clause clause : rch.getClauses())
 				requirements.add(new RequireCapabilityRequirement(clause));
+		RequireBundleHeader rbh = (RequireBundleHeader)manifest.getHeader(RequireBundleHeader.NAME);
+		if (rbh != null)
+			for (RequireBundleHeader.Clause clause : rbh.getClauses())
+				requirements.add(new RequireBundleRequirement(clause));
 	}
 	
 	private BundleResource(String content) throws IOException {

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ApplicationTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ApplicationTest.java?rev=1297702&r1=1297701&r2=1297702&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ApplicationTest.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ApplicationTest.java
Tue Mar  6 20:42:27 2012
@@ -53,9 +53,14 @@ import org.osgi.service.subsystem.Subsys
 public class ApplicationTest extends SubsystemTest {
 	/*
 	 * Subsystem-SymbolicName: application.a.esa
+	 * Subsystem-Content: bundle.a.jar
 	 */
 	private static final String APPLICATION_A = "application.a.esa";
-	
+	/*
+	 * Subsystem-SymbolicName: application.b.esa
+	 * Subsystem-Content: bundle.c.jar
+	 */
+	private static final String APPLICATION_B = "application.b.esa";
 	/*
 	 * Bundle-SymbolicName: bundle.a.jar
 	 * Require-Capability: foo; filter:="(foo=bar)"
@@ -66,6 +71,11 @@ public class ApplicationTest extends Sub
 	 * Provide-Capability: foo; foo=bar
 	 */
 	private static final String BUNDLE_B = "bundle.b.jar";
+	/*
+	 * Bundle-SymbolicName: bundle.c.jar
+	 * Require-Bundle: bundle.b.jar
+	 */
+	private static final String BUNDLE_C = "bundle.c.jar";
 	
 	private static boolean createdTestFiles;
 	
@@ -75,7 +85,9 @@ public class ApplicationTest extends Sub
 			return;
 		createBundleA();
 		createBundleB();
+		createBundleC();
 		createApplicationA();
+		createApplicationB();
 		createdTestFiles = true;
 	}
 	
@@ -91,11 +103,22 @@ public class ApplicationTest extends Sub
 		createBundle(BUNDLE_B, "1.0.0", headers);
 	}
 	
+	private static void createBundleC() throws IOException {
+		Map<String, String> headers = new HashMap<String, String>();
+		headers.put(Constants.REQUIRE_BUNDLE, BUNDLE_B);
+		createBundle(BUNDLE_C, "1.0.0", headers);
+	}
+	
 	private static void createApplicationA() throws IOException {
 		createApplicationAManifest();
 		createSubsystem(APPLICATION_A, BUNDLE_A);
 	}
 	
+	private static void createApplicationB() throws IOException {
+		createApplicationBManifest();
+		createSubsystem(APPLICATION_B, BUNDLE_C);
+	}
+	
 	private static void createApplicationAManifest() throws IOException {
 		Map<String, String> attributes = new HashMap<String, String>();
 		attributes.put(SubsystemConstants.SUBSYSTEM_SYMBOLICNAME, APPLICATION_A);
@@ -103,6 +126,13 @@ public class ApplicationTest extends Sub
 		createManifest(APPLICATION_A + ".mf", attributes);
 	}
 	
+	private static void createApplicationBManifest() throws IOException {
+		Map<String, String> attributes = new HashMap<String, String>();
+		attributes.put(SubsystemConstants.SUBSYSTEM_SYMBOLICNAME, APPLICATION_B);
+		attributes.put(SubsystemConstants.SUBSYSTEM_CONTENT, BUNDLE_C);
+		createManifest(APPLICATION_B + ".mf", attributes);
+	}
+	
 	private static void createApplication(String name, String[] content) throws Exception {
 		ZipFixture feature = ArchiveFixture
 				.newZip()
@@ -169,8 +199,27 @@ public class ApplicationTest extends Sub
 			assertBundleState(Bundle.RESOLVED|Bundle.ACTIVE, "org.apache.aries.subsystem.itests.tb3",
getRootSubsystem());
     	}
     	finally {
-    		stopSubsystem(application1);
-    		uninstallScopedSubsystem(application1);
+    		stopSubsystemSilently(application1);
+    		uninstallSubsystemSilently(application1);
+    	}
+    }
+    
+    @Test
+    public void testRequireBundle() throws Exception {
+    	File file = new File(BUNDLE_B);
+    	Bundle b = getRootSubsystem().getBundleContext().installBundle(file.toURI().toString(),
new FileInputStream(file));
+    	try {
+	    	Subsystem application = installSubsystemFromFile(APPLICATION_B);
+	    	try {
+	    		startSubsystem(application);
+	    	}
+	    	finally {
+	    		stopSubsystemSilently(application);
+	    		uninstallSubsystemSilently(application);
+	    	}
+    	}
+    	finally {
+    		b.uninstall();
     	}
     }
     
@@ -184,8 +233,8 @@ public class ApplicationTest extends Sub
 	    		startSubsystem(application);
 	    	}
 	    	finally {
-	    		stopSubsystem(application);
-	    		uninstallScopedSubsystem(application);
+	    		stopSubsystemSilently(application);
+	    		uninstallSubsystemSilently(application);
 	    	}
     	}
     	finally {

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/BasicTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/BasicTest.java?rev=1297702&r1=1297701&r2=1297702&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/BasicTest.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/BasicTest.java
Tue Mar  6 20:42:27 2012
@@ -115,7 +115,7 @@ public class BasicTest extends Subsystem
 		}
 		finally {
 			try {
-				uninstallUnscopedSubsystem(emptyFeature);
+				uninstallSubsystemSilently(emptyFeature);
 			}
 			catch (AssertionError e) {
 				if (error == null)
@@ -152,7 +152,7 @@ public class BasicTest extends Subsystem
 		}
 		finally {
 			try {
-				uninstallScopedSubsystem(emptySubsystem);
+				uninstallSubsystemSilently(emptySubsystem);
 			}
 			catch (AssertionError e) {
 				if (error == null)

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/CompositeTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/CompositeTest.java?rev=1297702&r1=1297701&r2=1297702&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/CompositeTest.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/CompositeTest.java
Tue Mar  6 20:42:27 2012
@@ -146,8 +146,8 @@ public class CompositeTest extends Subsy
 			}
 		}
 		finally {
-			stopSubsystem(composite);
-			uninstallScopedSubsystem(composite);
+			stopSubsystemSilently(composite);
+			uninstallSubsystemSilently(composite);
 		}
 	}
 	
@@ -166,7 +166,7 @@ public class CompositeTest extends Subsy
 				}
 			}
 			finally {
-				uninstallScopedSubsystem(compositeC);
+				uninstallSubsystemSilently(compositeC);
 			}
 		}
 		finally {
@@ -189,7 +189,7 @@ public class CompositeTest extends Subsy
 				}
 			}
 			finally {
-				uninstallScopedSubsystem(compositeB);
+				uninstallSubsystemSilently(compositeB);
 			}
 		}
 		finally {
@@ -212,7 +212,7 @@ public class CompositeTest extends Subsy
 				}
 			}
 			finally {
-				uninstallScopedSubsystem(compositeD);
+				uninstallSubsystemSilently(compositeD);
 			}
 		}
 		finally {

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/FeatureTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/FeatureTest.java?rev=1297702&r1=1297701&r2=1297702&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/FeatureTest.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/FeatureTest.java
Tue Mar  6 20:42:27 2012
@@ -112,7 +112,7 @@ public class FeatureTest extends Subsyst
 		}
 		finally {
 			try {
-				uninstallUnscopedSubsystem(feature1);
+				uninstallSubsystem(feature1);
 				if (feature2 != null) {
 					assertEvent(feature2, Subsystem.State.UNINSTALLING, 5000);
 					assertEvent(feature2, Subsystem.State.UNINSTALLED, 5000);
@@ -135,7 +135,7 @@ public class FeatureTest extends Subsyst
 		try {
 			assertFeature3(feature3Before);
 			// Uninstall then reinstall the subsystem for a more robust test of the subsystem ID persistence.
-			uninstallUnscopedSubsystem(feature3Before);
+			uninstallSubsystem(feature3Before);
 			feature3Before = installSubsystemFromFile("feature3.esa");
 			assertLastId(2);
 			assertFeature3(feature3Before);
@@ -156,7 +156,7 @@ public class FeatureTest extends Subsyst
 			try {
 				if (feature3After != null) {
 					stopSubsystem(feature3After);
-					uninstallUnscopedSubsystem(feature3After);
+					uninstallSubsystem(feature3After);
 				}
 			}
 			catch (AssertionError e) {
@@ -178,7 +178,7 @@ public class FeatureTest extends Subsyst
 			while (!feature2.getState().equals(Subsystem.State.INSTALLED))
 				Thread.sleep(100);
 			assertConstituent(feature2, "org.apache.aries.subsystem.itests.tb3", Version.parseVersion("1.0.0"),
IdentityNamespace.TYPE_BUNDLE);
-			uninstallUnscopedSubsystem(feature2);
+			uninstallSubsystem(feature2);
 			assertNotChild(feature1, feature2);
 			assertConstituent(feature1, "org.apache.aries.subsystem.itests.tb3", Version.parseVersion("1.0.0"),
IdentityNamespace.TYPE_BUNDLE);
 		}
@@ -188,7 +188,7 @@ public class FeatureTest extends Subsyst
 		}
 		finally {
 			try {
-				uninstallUnscopedSubsystem(feature1);
+				uninstallSubsystem(feature1);
 			}
 			catch (AssertionError e) {
 				if (error == null)

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/InstallTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/InstallTest.java?rev=1297702&r1=1297701&r2=1297702&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/InstallTest.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/InstallTest.java
Tue Mar  6 20:42:27 2012
@@ -77,7 +77,7 @@ public class InstallTest extends Subsyst
 			assertSame(subsystem1, subsystem2);
 		}
 		finally {
-			uninstallUnscopedSubsystem(subsystem1);
+			uninstallSubsystemSilently(subsystem1);
 		}
 	}
 }

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java?rev=1297702&r1=1297701&r2=1297702&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java
Tue Mar  6 20:42:27 2012
@@ -600,16 +600,23 @@ public abstract class SubsystemTest exte
 		assertState(State.RESOLVED, subsystem);
 	}
 	
-	protected void uninstallScopedSubsystem(Subsystem subsystem) throws Exception {
-		Bundle b = getRegionContextBundle(subsystem);
-		uninstallSubsystem(subsystem);
-		assertEquals("Region context bundle not uninstalled", Bundle.UNINSTALLED, b.getState());
+	protected void stopSubsystemSilently(Subsystem subsystem) {
+		try {
+			stopSubsystem(subsystem);
+		}
+		catch (Throwable t) {
+			t.printStackTrace();
+		}
 	}
 	
 	protected void uninstallSubsystem(Subsystem subsystem) throws Exception {
 		assertState(EnumSet.of(State.INSTALLED, State.RESOLVED), subsystem);
 		subsystemEvents.clear();
 		Collection<Subsystem> parents = subsystem.getParents();
+		Bundle b = null;
+		if (subsystem.getType().equals(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION)
+				|| subsystem.getType().equals(SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE))
+			b = getRegionContextBundle(subsystem);
 		subsystem.uninstall();
 		assertEvent(subsystem, State.UNINSTALLING, 5000);
 		assertEvent(subsystem, State.UNINSTALLED, 5000);
@@ -617,10 +624,17 @@ public abstract class SubsystemTest exte
 		for (Subsystem parent : parents)
 			assertNotChild(parent, subsystem);
 		assertNotDirectory(subsystem);
+		if (b != null)
+			assertEquals("Region context bundle not uninstalled", Bundle.UNINSTALLED, b.getState());
 	}
 	
-	protected void uninstallUnscopedSubsystem(Subsystem subsystem) throws Exception {
-		uninstallSubsystem(subsystem);
+	protected void uninstallSubsystemSilently(Subsystem subsystem) {
+		try {
+			uninstallSubsystem(subsystem);
+		}
+		catch (Throwable t) {
+			t.printStackTrace();
+		}
 	}
 	
 	protected static void write(String file, ArchiveFixture.AbstractFixture fixture) throws
IOException {



Mime
View raw message