Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff McAffer2010-09-21 17:46:53 +0000
committerJeff McAffer2010-09-21 17:46:53 +0000
commit8747ea28aa893264d82890bab3159e57798cdd16 (patch)
tree82270cbb35596c9716e96c09ed004f2830402647 /bundles/org.eclipse.osgi.tests
parentca7bf1a0c97b212e07e97bf298e11332a893a3c1 (diff)
downloadrt.equinox.framework-8747ea28aa893264d82890bab3159e57798cdd16.tar.gz
rt.equinox.framework-8747ea28aa893264d82890bab3159e57798cdd16.tar.xz
rt.equinox.framework-8747ea28aa893264d82890bab3159e57798cdd16.zip
Bug 324618 Dynamic import resolver bug backport
Diffstat (limited to 'bundles/org.eclipse.osgi.tests')
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java44
-rw-r--r--bundles/org.eclipse.osgi.tests/test_files/resolverTests/c1.MF5
-rw-r--r--bundles/org.eclipse.osgi.tests/test_files/resolverTests/p1.MF8
-rw-r--r--bundles/org.eclipse.osgi.tests/test_files/resolverTests/p2.MF7
4 files changed, 64 insertions, 0 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java
index addedf103..60799d77a 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java
@@ -12,9 +12,11 @@ package org.eclipse.osgi.tests.services.resolver;
import java.io.File;
import java.io.IOException;
+import java.net.URL;
import java.util.*;
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.eclipse.osgi.framework.util.Headers;
import org.eclipse.osgi.service.resolver.*;
import org.eclipse.osgi.tests.OSGiTestsActivator;
import org.osgi.framework.*;
@@ -3288,6 +3290,20 @@ public class StateResolverTest extends AbstractStateTest {
return false;
}
+ private static final String MANIFEST_ROOT = "test_files/resolverTests/";
+
+ private Dictionary loadManifest(String manifest) {
+ URL url = getContext().getBundle().getEntry(MANIFEST_ROOT + manifest);
+ try {
+ return Headers.parseManifest(url.openStream());
+ } catch (IOException e) {
+ fail("Unexpected error loading manifest: " + manifest, e);
+ } catch (BundleException e) {
+ fail("Unexpected error loading manifest: " + manifest, e);
+ }
+ return null;
+ }
+
public void testSelectionPolicy() throws BundleException {
State state = buildEmptyState();
Resolver resolver = state.getResolver();
@@ -3746,6 +3762,34 @@ public class StateResolverTest extends AbstractStateTest {
return true;
}
}
+
+ public void testBug324618() throws BundleException {
+ State state = buildEmptyState();
+ long bundleID = 0;
+ Dictionary manifest;
+
+ manifest = loadManifest("p1.MF");
+ BundleDescription p1 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME), bundleID++);
+ manifest = loadManifest("p2.MF");
+ BundleDescription p2 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME), bundleID++);
+ manifest = loadManifest("c1.MF");
+ BundleDescription c1 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME), bundleID++);
+
+ state.addBundle(p1);
+ state.addBundle(p2);
+ state.addBundle(c1);
+
+ state.resolve();
+
+ ExportPackageDescription x = state.linkDynamicImport(c1, "x");
+ assertNotNull("x dynamic import is null", x);
+ ExportPackageDescription xSub = state.linkDynamicImport(c1, "x.sub");
+ assertNotNull("x.sub dynamic import is null", xSub);
+ assertEquals("The exporter is not the same for x and x.sub", x.getExporter(), xSub.getExporter());
+
+ ExportPackageDescription xExtra = state.linkDynamicImport(c1, "x.extra");
+ assertNotNull("x.extra dynamic import is null", xExtra);
+ }
}
//testFragmentUpdateNoVersionChanged()
//testFragmentUpdateVersionChanged()
diff --git a/bundles/org.eclipse.osgi.tests/test_files/resolverTests/c1.MF b/bundles/org.eclipse.osgi.tests/test_files/resolverTests/c1.MF
new file mode 100644
index 000000000..ba4d7b305
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/test_files/resolverTests/c1.MF
@@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: c1
+Bundle-Version: 1.0
+DynamicImport-Package: *
diff --git a/bundles/org.eclipse.osgi.tests/test_files/resolverTests/p1.MF b/bundles/org.eclipse.osgi.tests/test_files/resolverTests/p1.MF
new file mode 100644
index 000000000..ed8eb8c51
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/test_files/resolverTests/p1.MF
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: p1
+Bundle-Version: 1.0
+Export-Package:
+ x; version="1.0"; uses:="x.sub",
+ x.sub; version="2.0",
+ x.extra
diff --git a/bundles/org.eclipse.osgi.tests/test_files/resolverTests/p2.MF b/bundles/org.eclipse.osgi.tests/test_files/resolverTests/p2.MF
new file mode 100644
index 000000000..e97cb83d8
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/test_files/resolverTests/p2.MF
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: p2
+Bundle-Version: 1.0
+Export-Package:
+ x; version="2.0"; uses:="x.sub",
+ x.sub; version="1.0" \ No newline at end of file

Back to the top