aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwr...@apache.org
Subject svn commit: r1353336 - 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-itests/src/test/java/org/apache/aries/subsystem/ite...
Date Sun, 24 Jun 2012 21:35:04 GMT
Author: jwross
Date: Sun Jun 24 21:35:03 2012
New Revision: 1353336

URL: http://svn.apache.org/viewvc?rev=1353336&view=rev
Log:
ARIES-825: Fixed issue where optional package imports were causing installation failures.
Added new test for optional package imports.

Added:
    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/ImportPackageRequirement.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResource.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceHelper.java

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/ImportPackageRequirement.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/ImportPackageRequirement.java?rev=1353336&r1=1353335&r2=1353336&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/ImportPackageRequirement.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/ImportPackageRequirement.java
Sun Jun 24 21:35:03 2012
@@ -13,10 +13,14 @@ public class ImportPackageRequirement ex
 	public static final String DIRECTIVE_FILTER = PackageNamespace.REQUIREMENT_FILTER_DIRECTIVE;
 	public static final String NAMESPACE = PackageNamespace.PACKAGE_NAMESPACE;
 	
-	private final Map<String, String> directives = new HashMap<String, String>(1);
+	private final Map<String, String> directives;
 	private final Resource resource;
 	
 	public ImportPackageRequirement(ImportPackageHeader.Clause clause, Resource resource) {
+		Collection<Directive> clauseDirectives = clause.getDirectives();
+		directives = new HashMap<String, String>(clauseDirectives.size() + 1);
+		for (Directive directive : clauseDirectives)
+			directives.put(directive.getName(), directive.getValue());
 		Collection<String> packageNames = clause.getPackageNames();
 		if (packageNames.isEmpty() || packageNames.size() > 1)
 			throw new IllegalArgumentException("Only one package name per requirement allowed");

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResource.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResource.java?rev=1353336&r1=1353335&r2=1353336&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResource.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResource.java
Sun Jun 24 21:35:03 2012
@@ -142,4 +142,9 @@ public class BundleResource implements R
 		}
 		return result;
 	}
+	
+	@Override
+	public String toString() {
+        return content.toExternalForm();
+    }
 }

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceHelper.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceHelper.java?rev=1353336&r1=1353335&r2=1353336&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceHelper.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceHelper.java
Sun Jun 24 21:35:03 2012
@@ -13,9 +13,6 @@
  */
 package org.apache.aries.subsystem.core.internal;
 
-import static org.apache.aries.application.utils.AppConstants.LOG_ENTRY;
-import static org.apache.aries.application.utils.AppConstants.LOG_EXIT;
-
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
@@ -91,8 +88,8 @@ public class ResourceHelper {
 	}
 	
 	public static boolean matches(Requirement requirement, Capability capability) {
-		if (logger.isDebugEnabled())
-			logger.debug(LOG_ENTRY, "matches", new Object[]{requirement, capability});
+//		if (logger.isDebugEnabled())
+//			logger.debug(LOG_ENTRY, "matches", new Object[]{requirement, capability});
 		boolean result = false;
 		if (requirement == null && capability == null)
 			result = true;
@@ -116,7 +113,7 @@ public class ResourceHelper {
 			}
 		}
 		// TODO Check directives.
-		logger.debug(LOG_EXIT, "matches", result);
+//		logger.debug(LOG_EXIT, "matches", result);
 		return result;
 	}
 }

Added: 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=1353336&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/OptionalDependenciesTest.java
(added)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/OptionalDependenciesTest.java
Sun Jun 24 21:35:03 2012
@@ -0,0 +1,72 @@
+package org.apache.aries.subsystem.itests;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.framework.Constants;
+import org.osgi.service.subsystem.Subsystem;
+import org.osgi.service.subsystem.SubsystemConstants;
+
+@RunWith(JUnit4TestRunner.class)
+public class OptionalDependenciesTest extends SubsystemTest {
+	/*
+	 * Subsystem-SymbolicName: application.a.esa
+	 * Subsystem-Content: bundle.a.jar
+	 */
+	private static final String APPLICATION_A = "application.a.esa";
+	/*
+	 * Bundle-SymbolicName: bundle.a.jar
+	 * Import-Package: x;resolution:=optional
+	 */
+	private static final String BUNDLE_A = "bundle.a.jar";
+	
+	private static void createApplicationA() throws IOException {
+		createApplicationAManifest();
+		createSubsystem(APPLICATION_A, BUNDLE_A);
+	}
+	
+	private static void createApplicationAManifest() throws IOException {
+		Map<String, String> attributes = new HashMap<String, String>();
+		attributes.put(SubsystemConstants.SUBSYSTEM_SYMBOLICNAME, APPLICATION_A);
+		attributes.put(SubsystemConstants.SUBSYSTEM_CONTENT, BUNDLE_A);
+		createManifest(APPLICATION_A + ".mf", attributes);
+	}
+	
+	private static void createBundleA() throws IOException {
+		Map<String, String> headers = new HashMap<String, String>();
+		headers.put(Constants.IMPORT_PACKAGE, "x;resolution:=optional");
+		createBundle(BUNDLE_A, headers);
+	}
+	
+	private static boolean createdTestFiles;
+	@Before
+	public static void createTestFiles() throws Exception {
+		if (createdTestFiles)
+			return;
+		createBundleA();
+		createApplicationA();
+		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);
+		}
+		finally {
+			uninstallSubsystemSilently(subsystem);
+		}
+	}
+}



Mime
View raw message