You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by jw...@apache.org on 2013/03/07 20:28:27 UTC
svn commit: r1454036 - in
/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests:
AriesSubsystemTest.java SubsystemTest.java
Author: jwross
Date: Thu Mar 7 19:28:26 2013
New Revision: 1454036
URL: http://svn.apache.org/r1454036
Log:
[ARIES-1021] Implementation of AriesSubsystem.addRequirements must not assume the region only has edges to the parent subsystem's region.
Additional test.
Modified:
aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/AriesSubsystemTest.java
aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java
Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/AriesSubsystemTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/AriesSubsystemTest.java?rev=1454036&r1=1454035&r2=1454036&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/AriesSubsystemTest.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/AriesSubsystemTest.java Thu Mar 7 19:28:26 2013
@@ -1,5 +1,6 @@
package org.apache.aries.subsystem.itests;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.fail;
@@ -15,6 +16,7 @@ import org.apache.aries.subsystem.core.i
import org.apache.aries.util.filesystem.FileSystem;
import org.apache.aries.util.filesystem.IDirectory;
import org.easymock.EasyMock;
+import org.eclipse.equinox.region.Region;
import org.eclipse.equinox.region.RegionFilter;
import org.junit.Before;
import org.junit.Test;
@@ -127,6 +129,64 @@ public class AriesSubsystemTest extends
}
/*
+ * The region copy process when adding additional requirements should
+ * keep all edges, not just the ones running between parent and child. This
+ * is of particular concern with regard to the connections all subsystem
+ * regions have with the root region to allow the subsystem services
+ * through. However, it may also be of concern if the region digraph is
+ * modified outside of the subsystems API.
+ */
+ @Test
+ public void testAddRequirementsKeepsEdgesOtherThanParentChild() throws Exception {
+ AriesSubsystem compositeA = (AriesSubsystem)installSubsystemFromFile(COMPOSITE_A);
+ AriesSubsystem applicationB = (AriesSubsystem)getConstituentAsSubsystem(compositeA, APPLICATION_B, null, SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION);
+ Region bRegion = getRegion(applicationB);
+ // One edge to parent for import package. One edge to root for subsystem
+ // service.
+ assertEquals("Wrong number of edges", 2, bRegion.getEdges().size());
+ Requirement requirement = new BasicRequirement.Builder()
+ .namespace(PackageNamespace.PACKAGE_NAMESPACE)
+ .directive(
+ PackageNamespace.REQUIREMENT_FILTER_DIRECTIVE,
+ "(osgi.wiring.package=org.osgi.framework)")
+ .resource(EasyMock.createMock(Resource.class))
+ .build();
+ applicationB.addRequirements(Collections.singleton(requirement));
+ bRegion = getRegion(applicationB);
+ // Still one edge to parent for import package. One edge to root for
+ // subsystem service.
+ assertEquals("Wrong number of edges", 2, bRegion.getEdges().size());
+ Region rootRegion = getRegion(getRootSubsystem());
+ // The root region won't be the tail region for any connection unless
+ // manually added.
+ assertEquals("Wrong number of edges", 0, rootRegion.getEdges().size());
+ // Manually add a connection from root to application B.
+ rootRegion.connectRegion(
+ bRegion,
+ rootRegion.getRegionDigraph().createRegionFilterBuilder().allow(
+ "com.foo",
+ "(bar=b)").build());
+ // The root region should now have an edge.
+ assertEquals("Wrong number of edges", 1, rootRegion.getEdges().size());
+ // Add another requirement to force a copy.
+ requirement = new BasicRequirement.Builder()
+ .namespace(PackageNamespace.PACKAGE_NAMESPACE)
+ .directive(
+ PackageNamespace.REQUIREMENT_FILTER_DIRECTIVE,
+ "(osgi.wiring.package=org.osgi.framework.wiring)")
+ .resource(EasyMock.createMock(Resource.class))
+ .build();
+ applicationB.addRequirements(Collections.singleton(requirement));
+ rootRegion = getRegion(getRootSubsystem());
+ // The root region should still have its edge.
+ assertEquals("Wrong number of edges", 1, rootRegion.getEdges().size());
+ bRegion = getRegion(applicationB);
+ // Still one edge to parent for import package. One edge to root for
+ // subsystem service.
+ assertEquals("Wrong number of edges", 2, bRegion.getEdges().size());
+ }
+
+ /*
* Test the AriesSubsystem.addRequirements(Collection<Requirement>) method.
*
* There are several things to consider for this test.
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=1454036&r1=1454035&r2=1454036&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 Thu Mar 7 19:28:26 2013
@@ -704,7 +704,7 @@ public abstract class SubsystemTest exte
protected Region getRegion(Subsystem subsystem) {
RegionDigraph digraph = getOsgiService(RegionDigraph.class);
- String name = subsystem.getSymbolicName() + ';' + subsystem.getVersion() + ';' + subsystem.getType() + ';' + subsystem.getSubsystemId();
+ String name = getRegionName(subsystem);
Region region = digraph.getRegion(name);
assertNotNull("Region not found: " + name, region);
return region;
@@ -716,6 +716,12 @@ public abstract class SubsystemTest exte
return bc.getBundle();
}
+ protected String getRegionName(Subsystem subsystem) {
+ if (subsystem.getSubsystemId() == 0)
+ return "org.eclipse.equinox.region.kernel";
+ return subsystem.getSymbolicName() + ';' + subsystem.getVersion() + ';' + subsystem.getType() + ';' + subsystem.getSubsystemId();
+ }
+
protected AriesSubsystem getRootAriesSubsystem() {
return getOsgiService(AriesSubsystem.class);
}