Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2014-04-01 09:25:15 -0400
committerThomas Watson2014-04-03 09:14:57 -0400
commit59f35c1b6de6ee2a847e04697fe290ebd6aee0d3 (patch)
tree3dfbfbd713c4acbdb3387aa166f4892cd5ccb62c
parent011467683f36c2161bee717d1c05bd07fc0d51fe (diff)
downloadrt.equinox.framework-59f35c1b6de6ee2a847e04697fe290ebd6aee0d3.tar.gz
rt.equinox.framework-59f35c1b6de6ee2a847e04697fe290ebd6aee0d3.tar.xz
rt.equinox.framework-59f35c1b6de6ee2a847e04697fe290ebd6aee0d3.zip
Bug 431708 - Invalid wirings may result from substitutable exports
- Add a test cases for invalid wiring from substituted exports
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java59
-rw-r--r--bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.e.MF7
-rw-r--r--bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.f.MF6
-rw-r--r--bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.g.MF5
-rw-r--r--bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.h.MF7
-rw-r--r--bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.i.MF7
-rw-r--r--bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.j.MF7
-rw-r--r--bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.k.MF5
8 files changed, 103 insertions, 0 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java
index 48e20cd58..86578bbd5 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java
@@ -863,6 +863,65 @@ public class TestModuleContainer extends AbstractTest {
}
@Test
+ public void testSubstitutableExports03() throws BundleException, IOException {
+ DummyContainerAdaptor adaptor = createDummyAdaptor();
+ ModuleContainer container = adaptor.getContainer();
+
+ // install order does not really matter
+ Module g = installDummyModule("sub.g.MF", "g", container);
+ Module f = installDummyModule("sub.f.MF", "f", container);
+ Module e = installDummyModule("sub.e.MF", "e", container);
+
+ // resolve order does matter so that transitive dependencies are pulled in
+ // and cause substitution to happen in a certain way
+ container.resolve(Arrays.asList(g, f, e), true);
+
+ ModuleWiring wiringE = e.getCurrentRevision().getWiring();
+ ModuleWiring wiringF = f.getCurrentRevision().getWiring();
+
+ List<ModuleWire> providedWiresE = wiringE.getProvidedModuleWires(PackageNamespace.PACKAGE_NAMESPACE);
+ Assert.assertEquals("Wrong number of provided wires.", 3, providedWiresE.size());
+
+ Collection<ModuleRevision> requirers = new HashSet<ModuleRevision>();
+ for (ModuleWire wire : providedWiresE) {
+ requirers.add(wire.getRequirer());
+ }
+ Assert.assertTrue("f does not require.", requirers.remove(f.getCurrentRevision()));
+ Assert.assertTrue("g does not require.", requirers.remove(g.getCurrentRevision()));
+ Assert.assertTrue("No requirers should be left: " + requirers, requirers.isEmpty());
+
+ List<ModuleWire> providedWiresF = wiringF.getProvidedModuleWires(PackageNamespace.PACKAGE_NAMESPACE);
+ Assert.assertEquals("Wrong number of provided wires: " + providedWiresF, 0, providedWiresF.size());
+ }
+
+ @Test
+ public void testSubstitutableExports04() throws BundleException, IOException {
+ DummyContainerAdaptor adaptor = createDummyAdaptor();
+ ModuleContainer container = adaptor.getContainer();
+
+ // install order does not really matter
+ installDummyModule("sub.h.MF", "h", container);
+ Module i = installDummyModule("sub.i.MF", "i", container);
+ installDummyModule("sub.j.MF", "j", container);
+ Module k = installDummyModule("sub.k.MF", "k", container);
+
+ // resolve order does matter so that transitive dependencies are pulled in
+ // and cause substitution to happen in a certain way
+ container.resolve(Arrays.asList(k), true);
+
+ ModuleWiring wiringI = i.getCurrentRevision().getWiring();
+ ModuleWiring wiringK = k.getCurrentRevision().getWiring();
+
+ List<ModuleWire> requiredWiresK = wiringK.getRequiredModuleWires(PackageNamespace.PACKAGE_NAMESPACE);
+
+ // I should be the provider for all of K
+ Assert.assertEquals("Wrong number of required wires: " + requiredWiresK, 2, requiredWiresK.size());
+ for (ModuleWire moduleWire : requiredWiresK) {
+ Assert.assertEquals("Wrong provider: " + moduleWire.getProviderWiring(), wiringI, moduleWire.getProviderWiring());
+ }
+ }
+
+ @Test
public void testLazy01() throws BundleException, IOException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
diff --git a/bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.e.MF b/bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.e.MF
new file mode 100644
index 000000000..c59d73637
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.e.MF
@@ -0,0 +1,7 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: sub.e
+Bundle-Version: 1.0.0
+Export-Package:
+ foo; version="1.0"; uses:="bar",
+ bar; version="1.0"
+
diff --git a/bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.f.MF b/bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.f.MF
new file mode 100644
index 000000000..38807c4a1
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.f.MF
@@ -0,0 +1,6 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: sub.f
+Bundle-Version: 1.0.0
+Export-Package: bar; version="1.0.1"
+Import-Package: bar; foo
+
diff --git a/bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.g.MF b/bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.g.MF
new file mode 100644
index 000000000..d348526c6
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.g.MF
@@ -0,0 +1,5 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: sub.g
+Bundle-Version: 1.0.0
+Import-Package: bar
+
diff --git a/bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.h.MF b/bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.h.MF
new file mode 100644
index 000000000..7c959311b
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.h.MF
@@ -0,0 +1,7 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: sub.h
+Bundle-Version: 1.0.0
+Export-Package:
+ a; version="1.0"; uses:="b",
+ b; version="1.0"
+
diff --git a/bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.i.MF b/bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.i.MF
new file mode 100644
index 000000000..7225fcac6
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.i.MF
@@ -0,0 +1,7 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: sub.i
+Bundle-Version: 1.0.0
+Export-Package:
+ a; version="1.1"; uses:="b",
+ b; version="1.0.1"
+Import-Package: a; version="1.1"
diff --git a/bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.j.MF b/bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.j.MF
new file mode 100644
index 000000000..2265b9496
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.j.MF
@@ -0,0 +1,7 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: sub.j
+Bundle-Version: 1.0.0
+Export-Package:
+ a; version="1.2"; uses:="b",
+ b; version="1.0"
+
diff --git a/bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.k.MF b/bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.k.MF
new file mode 100644
index 000000000..bc89a9793
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/test_files/containerTests/sub.k.MF
@@ -0,0 +1,5 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: sub.k
+Bundle-Version: 1.0.0
+Import-Package: a; version="[1.0, 1.2)",
+ b; version=1.0.1

Back to the top