aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwr...@apache.org
Subject svn commit: r1390654 - in /aries/trunk/subsystem: subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/ subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/
Date Wed, 26 Sep 2012 18:43:12 GMT
Author: jwross
Date: Wed Sep 26 18:43:11 2012
New Revision: 1390654

URL: http://svn.apache.org/viewvc?rev=1390654&view=rev
Log:
Fixed issue where optional Require-Bundle and Require-Capability requirements were being treated
as mandatory.

Modified:
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/RequireBundleRequirement.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/RequireCapabilityRequirement.java
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/OptionalDependenciesTest.java

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/RequireBundleRequirement.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/RequireBundleRequirement.java?rev=1390654&r1=1390653&r2=1390654&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/RequireBundleRequirement.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/RequireBundleRequirement.java
Wed Sep 26 18:43:11 2012
@@ -25,11 +25,14 @@ public class RequireBundleRequirement ex
 	public static final String DIRECTIVE_FILTER = BundleNamespace.REQUIREMENT_FILTER_DIRECTIVE;
 	public static final String NAMESPACE = BundleNamespace.BUNDLE_NAMESPACE;
 	
-	private final Map<String, String> directives = new HashMap<String, String>(1);
+	private final Map<String, String> directives;
 	private final Resource resource;
 	
 	public RequireBundleRequirement(
 			RequireBundleHeader.Clause clause, Resource resource) {
+		directives = new HashMap<String, String>(clause.getDirectives().size() + 1);
+		for (Directive directive : clause.getDirectives())
+			directives.put(directive.getName(), directive.getValue());
 		StringBuilder builder = new StringBuilder("(&(")
 				.append(NAMESPACE).append('=')
 				.append(clause.getSymbolicName()).append(')');

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/RequireCapabilityRequirement.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/RequireCapabilityRequirement.java?rev=1390654&r1=1390653&r2=1390654&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/RequireCapabilityRequirement.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/RequireCapabilityRequirement.java
Wed Sep 26 18:43:11 2012
@@ -24,15 +24,15 @@ import org.osgi.resource.Resource;
 public class RequireCapabilityRequirement extends AbstractRequirement {
 	public static final String DIRECTIVE_FILTER = Namespace.REQUIREMENT_FILTER_DIRECTIVE;
 	
-	private final Map<String, String> directives = new HashMap<String, String>(1);
+	private final Map<String, String> directives;
 	private final String namespace;
 	private final Resource resource;
 	
 	public RequireCapabilityRequirement(RequireCapabilityHeader.Clause clause, Resource resource)
{
 		namespace = clause.getNamespace();
-		Directive filter = clause.getDirective(RequireCapabilityHeader.Clause.DIRECTIVE_FILTER);
-		if (filter != null)
-			directives.put(DIRECTIVE_FILTER, filter.getValue());
+		directives = new HashMap<String, String>(clause.getDirectives().size());
+		for (Directive directive : clause.getDirectives())
+			directives.put(directive.getName(), directive.getValue());
 		this.resource = resource;
 	}
 

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/OptionalDependenciesTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/OptionalDependenciesTest.java?rev=1390654&r1=1390653&r2=1390654&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/OptionalDependenciesTest.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/OptionalDependenciesTest.java
Wed Sep 26 18:43:11 2012
@@ -13,6 +13,8 @@
  */
 package org.apache.aries.subsystem.itests;
 
+import static org.junit.Assert.fail;
+
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
@@ -35,6 +37,8 @@ public class OptionalDependenciesTest ex
 	/*
 	 * Bundle-SymbolicName: bundle.a.jar
 	 * Import-Package: x;resolution:=optional
+	 * Require-Bundle: x;resolution:=optional
+	 * Require-Capability: x;resolution:=optional
 	 */
 	private static final String BUNDLE_A = "bundle.a.jar";
 	
@@ -53,6 +57,8 @@ public class OptionalDependenciesTest ex
 	private static void createBundleA() throws IOException {
 		Map<String, String> headers = new HashMap<String, String>();
 		headers.put(Constants.IMPORT_PACKAGE, "x;resolution:=optional");
+		headers.put(Constants.REQUIRE_BUNDLE, "x;resolution:=optional");
+		headers.put(Constants.REQUIRE_CAPABILITY, "x;resolution:=optional");
 		createBundle(BUNDLE_A, headers);
 	}
 	
@@ -66,20 +72,26 @@ public class OptionalDependenciesTest ex
 		createdTestFiles = true;
 	}
 	
-	public void setUp() throws Exception {
-		super.setUp();
-		registerRepositoryService(BUNDLE_A);
-	}
-	
 	@Test
 	public void testOptionalImportPackage() throws Exception {
-		Subsystem subsystem = installSubsystemFromFile(APPLICATION_A);
 		try {
-			startSubsystem(subsystem);
-			stopSubsystem(subsystem);
+			Subsystem subsystem = installSubsystemFromFile(APPLICATION_A);
+			try {
+				try {
+					startSubsystem(subsystem);
+				}
+				catch (Exception e) {
+					e.printStackTrace();
+					fail("Missing optional requirements must not cause subsystem start failure");
+				}
+			}
+			finally {
+				stopAndUninstallSubsystemSilently(subsystem);
+			}
 		}
-		finally {
-			uninstallSubsystemSilently(subsystem);
+		catch (Exception e) {
+			e.printStackTrace();
+			fail("Missing optional requirements must not cause subsystem installation failure");
 		}
 	}
 }



Mime
View raw message