You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by mn...@apache.org on 2012/07/10 15:34:03 UTC
svn commit: r1359660 - in
/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem:
ctt/itests/ itests/
Author: mnuttall
Date: Tue Jul 10 13:34:02 2012
New Revision: 1359660
URL: http://svn.apache.org/viewvc?rev=1359660&view=rev
Log:
Aries-865: Add tests for OSGi Subsystem CTT section 4C.
Modified:
aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependencyTestBase.java
aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4BTest.java
aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4CTest.java
aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/IntegrationTest.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/ctt/itests/SubsystemDependencyTestBase.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependencyTestBase.java?rev=1359660&r1=1359659&r2=1359660&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependencyTestBase.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependencyTestBase.java Tue Jul 10 13:34:02 2012
@@ -83,13 +83,6 @@ public abstract class SubsystemDependenc
}
}
- @After
- public void tearDown()
- {
- super.tearDown();
- }
-
-
private static void createBundleA() throws Exception
{
Map<String, String> headers = new HashMap<String, String>();
@@ -102,7 +95,7 @@ public abstract class SubsystemDependenc
{
Map<String, String> headers = new HashMap<String, String>();
headers.put(Constants.BUNDLE_VERSION, "1.0.0");
- headers.put(Constants.PROVIDE_CAPABILITY, "y;bug=true"); // TODO: see comment below about bug=true
+ headers.put(Constants.PROVIDE_CAPABILITY, "y;y=randomNamespace"); // TODO: see comment below about bug=true
createBundle(BUNDLE_B, headers);
}
@@ -126,7 +119,7 @@ public abstract class SubsystemDependenc
{
Map<String, String> headers = new HashMap<String, String>();
headers.put(Constants.BUNDLE_VERSION, "1.0.0");
- headers.put(Constants.REQUIRE_CAPABILITY, "y;filter:=\"(bug=true)\"");
+ headers.put(Constants.REQUIRE_CAPABILITY, "y");
// TODO:
/*
* According to the OSGi Core Release 5 spec section 3.3.6 page 35,
@@ -156,7 +149,7 @@ public abstract class SubsystemDependenc
{
Map<String, String> headers = new HashMap<String, String>();
headers.put(Constants.BUNDLE_VERSION, "1.0.0");
- headers.put(Constants.PROVIDE_CAPABILITY, "y;bug=true"); // TODO: see comment above about bug=true
+ headers.put(Constants.PROVIDE_CAPABILITY, "y;y=randomNamespace"); // TODO: see comment above about bug=true
createBundle(BUNDLE_G, headers);
}
Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4BTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4BTest.java?rev=1359660&r1=1359659&r2=1359660&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4BTest.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4BTest.java Tue Jul 10 13:34:02 2012
@@ -58,6 +58,7 @@ public class SubsystemDependency_4BTest
}
assertTrue ("Bundle A should have been provisioned to the root region", bundleNames.contains(BUNDLE_A));
assertTrue ("Bundle B should have been provisioned to the root region", bundleNames.contains(BUNDLE_B));
+ stopSubsystem(s);
}
@Test
Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4CTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4CTest.java?rev=1359660&r1=1359659&r2=1359660&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4CTest.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4CTest.java Tue Jul 10 13:34:02 2012
@@ -1,38 +1,40 @@
package org.apache.aries.subsystem.ctt.itests;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.osgi.framework.namespace.PackageNamespace.PACKAGE_NAMESPACE;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
-import org.osgi.framework.wiring.BundleWire;
-import org.osgi.framework.wiring.BundleWiring;
import org.osgi.service.subsystem.Subsystem;
import org.osgi.service.subsystem.SubsystemConstants;
+/*
+C) Test with pre-installed transitive resources
+- Register repository R1
+- Using the Root subsystem, install a composite subsystem S1 with the following content bundles (with no import/export policy)
+ - Bundle A
+ - Bundle B
+- Using the subsystem S1, install a composite S2 that imports package x, requires bundle A and required capability y
+- Verify the wiring of C, D and E wire to A->x, A, B->y respectively
+- Verify no new bundles are installed into the Root or S1 subsystems
+*/
+
public class SubsystemDependency_4CTest extends SubsystemDependencyTestBase
{
- /*
- C) Test with pre-installed transitive resources
- - Register repository R1
- - Using the Root subsystem, install a composite subsystem S1 with the following content bundles (with no import/export policy)
- - Bundle A
- - Bundle B
- - Using the subsystem S1, install a composite S2 that imports package x, requires bundle A and required capability y
- - Verify the wiring of C, D and E wire to A->x, A, B->y respectively
- - Verify no new bundles are installed into the Root or S1 subsystems
- */
private static final String SUBSYSTEM_S1 = "sdt_composite.s1.esa";
private static final String SUBSYSTEM_S2 = "sdt_composite.s2.esa";
-
private static boolean _testSubsystemCreated = false;
+ private Subsystem s1;
+ private Subsystem s2;
+
@Before
public void setUp() throws Exception
{
@@ -43,6 +45,38 @@ public class SubsystemDependency_4CTest
_testSubsystemCreated = true;
}
registerRepositoryR1();
+
+ }
+
+ // doing this within @Before doesn't work :(
+ private void startSubsystems() throws Exception
+ {
+ System.out.println ("into verifyCinS1WiresToAxInS2");
+
+ s1 = installSubsystemFromFile(SUBSYSTEM_S1);
+ startSubsystem(s1);
+
+ System.out.println ("s1 started");
+
+ s2 = installSubsystemFromFile(s1, SUBSYSTEM_S2);
+ startSubsystem(s2);
+
+ System.out.println ("s2 started");
+ }
+
+ private void stopSubsystems() throws Exception
+ {
+ stopSubsystem(s2);
+ System.out.println ("s2 stopped");
+
+ stopSubsystem(s1);
+ System.out.println ("s1 stopped");
+
+ uninstallSubsystem(s2);
+ System.out.println ("s2 uninstalled");
+
+ uninstallSubsystem(s1);
+ System.out.println ("s1 uninstalled");
}
// Using the subsystem S1, install a composite S2 that
@@ -54,15 +88,69 @@ public class SubsystemDependency_4CTest
@Test
public void verifyCinS1WiresToAxInS2() throws Exception
{
- Subsystem s1 = installSubsystemFromFile(SUBSYSTEM_S1);
- startSubsystem(s1);
- Subsystem s2 = installSubsystemFromFile(s1, SUBSYSTEM_S2);
- startSubsystem(s2);
-
+ startSubsystems();
verifySinglePackageWiring (s2, BUNDLE_C, "x", BUNDLE_A);
-
- stopSubsystem(s2);
- stopSubsystem(s1);
+ stopSubsystems();
+ }
+
+ @Test
+ public void verifyBundleDWiredToBundleA() throws Exception
+ {
+ startSubsystems();
+ verifyRequireBundleWiring (s2, BUNDLE_D, BUNDLE_A);
+ stopSubsystems();
+ }
+
+ @Test
+ public void verifyBundleEWiredToCapability_yFromBundleB() throws Exception
+ {
+ startSubsystems();
+ verifyCapabilityWiring (s2, BUNDLE_E, "y", BUNDLE_B);
+ stopSubsystems();
+ }
+
+ /*
+ * Verify no new bundles are installed into the Root or S1 subsystems
+ */
+
+ private static final Collection<String> _expectedRootRegionBundles = Arrays.asList(new String[]{
+ "org.eclipse.osgi", "org.ops4j.pax.exam", "org.ops4j.pax.exam.junit.extender",
+ "org.ops4j.pax.exam.junit.extender.impl", "org.ops4j.pax.logging.pax-logging-api",
+ "org.ops4j.pax.logging.pax-logging-service", "org.ops4j.pax.url.mvn",
+ "org.eclipse.osgi.services", "org.eclipse.equinox.region",
+ "org.apache.aries.testsupport.unit", "org.apache.aries.application.api",
+ "org.apache.aries.util", "org.apache.aries.application.utils",
+ "org.apache.felix.bundlerepository", "org.apache.felix.resolver",
+ "org.eclipse.equinox.coordinator", "org.eclipse.equinox.event",
+ "org.apache.aries.subsystem.api", "org.apache.aries.subsystem.core",
+ "com.springsource.org.junit", "org.ops4j.pax.exam.rbc",
+ "org.osgi.service.subsystem.region.context.0", "pax-exam-probe"});
+
+ private static final Collection<String> _expectedS1RegionBundles = Arrays.asList(new String[] {
+ BUNDLE_A, BUNDLE_B, "org.osgi.service.subsystem.region.context.1"});
+
+ @Test
+ public void verifyNoUnexpectedBundlesProvisioned() throws Exception
+ {
+ startSubsystems();
+ checkSubsystemContents ("Root", bundleContext,_expectedRootRegionBundles);
+ BundleContext s1Context = s1.getBundleContext();
+ checkSubsystemContents ("S1", s1Context, _expectedS1RegionBundles);
+ stopSubsystems();
+ }
+
+ private void checkSubsystemContents (String subsystemName, BundleContext subsystemContext, Collection<String> expectedBundleNames )
+ {
+ Bundle[] regionBundles = subsystemContext.getBundles();
+ if (expectedBundleNames.size() != regionBundles.length) {
+ fail ("Wrong number of bundles in the " + subsystemName + " subsystem."
+ + " Expected " + expectedBundleNames.size() + " bundles: " + expectedBundleNames
+ + " Found " + regionBundles.length + " bundles: " + Arrays.toString(regionBundles));
+ }
+ for (Bundle b: regionBundles) {
+ String bsn = b.getSymbolicName();
+ assertTrue ("Unexpected bundle found in " + subsystemName + " subsystem: " + bsn, expectedBundleNames.contains(bsn));
+ }
}
/*
@@ -103,8 +191,7 @@ public class SubsystemDependency_4CTest
attributes.put(Constants.IMPORT_PACKAGE, "x");
attributes.put(Constants.REQUIRE_BUNDLE, BUNDLE_A);
- attributes.put(Constants.REQUIRE_CAPABILITY, "y;filter:=\"(bug=true)\"");
- // ;filter:=\"(bug=true)\" still required even after ARIES-825 revision 1356872
+ attributes.put(Constants.REQUIRE_CAPABILITY, "y");
createManifest(SUBSYSTEM_S2 + ".mf", attributes);
createSubsystem(SUBSYSTEM_S2);
Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/IntegrationTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/IntegrationTest.java?rev=1359660&r1=1359659&r2=1359660&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/IntegrationTest.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/IntegrationTest.java Tue Jul 10 13:34:02 2012
@@ -58,7 +58,7 @@ public abstract class IntegrationTest {
}
@After
- public void tearDown() {
+ public void tearDown() throws Exception {
for (ServiceTracker st : srs.values()) {
if (st != null) {
st.close();
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=1359660&r1=1359659&r2=1359660&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 Jul 10 13:34:02 2012
@@ -221,7 +221,8 @@ public abstract class SubsystemTest exte
assertSubsystemNotNull(getRootSubsystem());
}
- public void tearDown() {
+ public void tearDown() throws Exception
+ {
bundleContext.removeServiceListener(subsystemEvents);
for (ServiceRegistration<?> registration : serviceRegistrations)
Utils.unregisterQuietly(registration);