aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwr...@apache.org
Subject svn commit: r1731249 - in /aries/trunk/subsystem: subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BasicSubsystem.java subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1442Test.java
Date Fri, 19 Feb 2016 14:29:43 GMT
Author: jwross
Date: Fri Feb 19 14:29:43 2016
New Revision: 1731249

URL: http://svn.apache.org/viewvc?rev=1731249&view=rev
Log:
[ARIES-1442] Subsystem impersonates bundles that are a constituent through sharing the osgi.identity
capability

The osgi.identity capabilities of constituents must also be filtered out when the SubsystemResource
is null.

Plus updated test.

Modified:
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BasicSubsystem.java
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1442Test.java

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BasicSubsystem.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BasicSubsystem.java?rev=1731249&r1=1731248&r2=1731249&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BasicSubsystem.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BasicSubsystem.java
Fri Feb 19 14:29:43 2016
@@ -184,6 +184,12 @@ public class BasicSubsystem implements R
 			for (Resource constituent : getConstituents()) {
 				if (header.contains(constituent)) {
 					for (Capability capability : constituent.getCapabilities(namespace)) {
+						if (namespace == null && IdentityNamespace.IDENTITY_NAMESPACE.equals(capability.getNamespace()))
{
+							// Don't want to include the osgi.identity capabilities of
+							// content. Need a second check here in case the namespace
+							// is null.
+							continue;
+						}
 						result.add(new BasicCapability(capability, this));
 					}
 				}

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1442Test.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1442Test.java?rev=1731249&r1=1731248&r2=1731249&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1442Test.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1442Test.java
Fri Feb 19 14:29:43 2016
@@ -20,18 +20,44 @@ package org.apache.aries.subsystem.itest
 
 import static org.junit.Assert.assertEquals;
 
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.aries.subsystem.core.internal.Activator;
+import org.apache.aries.subsystem.core.internal.SystemRepository;
 import org.apache.aries.subsystem.itests.SubsystemTest;
 import org.apache.aries.subsystem.itests.util.BundleArchiveBuilder;
 import org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder;
+import org.apache.aries.subsystem.itests.util.TestRequirement;
 import org.junit.Test;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
 import org.osgi.framework.namespace.IdentityNamespace;
+import org.osgi.resource.Capability;
+import org.osgi.resource.Requirement;
 import org.osgi.resource.Resource;
 import org.osgi.service.subsystem.Subsystem;
 import org.osgi.service.subsystem.SubsystemConstants;
 
+@ExamReactorStrategy(PerMethod.class)
 public class Aries1442Test extends SubsystemTest {
 	@Test
-	public void test() throws Exception {
+	public void testNewlyInstalledFeature() throws Exception {
+		assertFeature(createFeature());
+	}
+	
+	@Test
+	public void testPersistedFeature() throws Exception {
+		createFeature();
+		restartSubsystemsImplBundle();
+		Subsystem root = getRootSubsystem();
+		Subsystem feature = getChild(root, "feature", null, SubsystemConstants.SUBSYSTEM_TYPE_FEATURE);
+		assertFeature(feature);
+	}
+	
+	private Subsystem createFeature() throws Exception {
 		Subsystem root = getRootSubsystem();
 		Subsystem feature = installSubsystem(
 				root,
@@ -49,7 +75,32 @@ public class Aries1442Test extends Subsy
 				true
 		);
 		uninstallableSubsystems.add(feature);
-		assertEquals("Wrong number of osgi.identity capabilities",
-				1, ((Resource)feature).getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE).size());
+		startSubsystem(feature, true);
+		stoppableSubsystems.add(feature);
+		return feature;
+	}
+	
+	private void assertFeature(Subsystem feature) {
+		Resource resource = (Resource)feature;
+		List<Capability> identityCapabilities = resource.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE);
+		String message = "Wrong number of osgi.identity capabilities";
+		assertEquals(message, 1, identityCapabilities.size());
+		Collection<Capability> capabilities = resource.getCapabilities(null);
+		int count = 0;
+		for (Capability capability : capabilities) {
+			if (IdentityNamespace.IDENTITY_NAMESPACE.equals(capability.getNamespace())) {
+					count++;
+			}
+		}
+		assertEquals(message, 1, count);
+		SystemRepository repository = Activator.getInstance().getSystemRepository();
+		Requirement requirement = new TestRequirement.Builder()
+				.namespace("osgi.identity")
+				.directive("filter", "(osgi.identity=a)")
+				.build();
+		Map<Requirement, Collection<Capability>> providers = repository.findProviders(
+				Collections.singleton(requirement));
+		capabilities = providers.get(requirement);
+		assertEquals(message, 1, capabilities.size());
 	}
 }



Mime
View raw message