diff options
author | Thomas Watson | 2018-06-19 16:19:11 +0000 |
---|---|---|
committer | Thomas Watson | 2018-06-19 16:19:11 +0000 |
commit | 1f5b39b749d49214e2383c1333cf8603a1da604e (patch) | |
tree | 761a04a48650be5de25274c4f43697d9c57ad97c | |
parent | 1ef3b47bd321f7178023e0998045c261e72cc837 (diff) | |
download | rt.equinox.framework-I20180629-0400.tar.gz rt.equinox.framework-I20180629-0400.tar.xz rt.equinox.framework-I20180629-0400.zip |
Bug 535351 - test dynamic import with version range wire correctlyY20180720-0300Y20180718-2200Y20180712-0200Y20180705-0105Y20180628-0525I20180722-2000I20180721-1500I20180720-2000I20180719-2000I20180718-2000I20180718-0130I20180717-2000I20180717-0320I20180716-2000I20180716-0715I20180715-2000I20180714-1500I20180713-2000I20180712-2000I20180711-2000I20180710-2000I20180709-2000I20180708-2000I20180707-1500I20180706-2000I20180705-2000I20180704-2000I20180704-0805I20180704-0605I20180704-0545I20180703-2000I20180702-2000I20180702-0435I20180701-2000I20180630-1500I20180629-2000I20180629-0420I20180629-0400I20180628-2000I20180628-0230I20180627-2020I20180627-2000I20180625-1545I20180621-2000
Test ensures that the version range is honored and does not wire to
the unversioned package from the system.bundle.
Change-Id: I449b8c35d055ed4fad5c1a0c70e5873dc502ce47
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rwxr-xr-x | bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java index df800f410..1737b73ba 100755 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java @@ -96,11 +96,13 @@ import org.osgi.framework.hooks.weaving.WovenClass; import org.osgi.framework.launch.Framework; import org.osgi.framework.launch.FrameworkFactory; import org.osgi.framework.namespace.NativeNamespace; +import org.osgi.framework.namespace.PackageNamespace; import org.osgi.framework.startlevel.BundleStartLevel; import org.osgi.framework.startlevel.FrameworkStartLevel; import org.osgi.framework.wiring.BundleCapability; import org.osgi.framework.wiring.BundleRequirement; import org.osgi.framework.wiring.BundleRevision; +import org.osgi.framework.wiring.BundleWire; import org.osgi.framework.wiring.BundleWiring; import org.osgi.framework.wiring.FrameworkWiring; import org.osgi.resource.Capability; @@ -3802,4 +3804,53 @@ public class SystemBundleTests extends AbstractBundleTests { } } } + + public void testDynamicImportFromSystemBundle() throws IOException { + File config = OSGiTestsActivator.getContext().getDataFile(getName()); //$NON-NLS-1$ + Map configuration = new HashMap(); + configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath()); + configuration.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, "some.system.pkg"); + Equinox equinox = null; + try { + equinox = new Equinox(configuration); + equinox.init(); + BundleContext bc = equinox.getBundleContext(); + + Map<String, String> h2 = new HashMap<String, String>(); + h2.put(Constants.BUNDLE_MANIFESTVERSION, "2"); + h2.put(Constants.BUNDLE_SYMBOLICNAME, getName() + ".dynamicimporter"); + h2.put(Constants.DYNAMICIMPORT_PACKAGE, "some.system.*; version=1.0"); + File f2 = SystemBundleTests.createBundle(config, getName() + ".importer", h2); + Bundle b2 = bc.installBundle("reference:file:///" + f2.getAbsolutePath()); //$NON-NLS-1$ + b2.getResource("does/not/exist.txt"); + + Map<String, String> h1 = new HashMap<String, String>(); + h1.put(Constants.BUNDLE_MANIFESTVERSION, "2"); + h1.put(Constants.BUNDLE_SYMBOLICNAME, getName() + ".exporter"); + h1.put(Constants.EXPORT_PACKAGE, "some.system.pkg; version=1.0"); + File f1 = SystemBundleTests.createBundle(config, getName() + ".exporter", h1); + Bundle b1 = bc.installBundle("reference:file:///" + f1.getAbsolutePath()); //$NON-NLS-1$ + + b2.getResource("some/system/pkg/Test"); + + BundleWiring w = b2.adapt(BundleWiring.class); + assertNotNull("Null wiring.", w); + List<BundleWire> pkgWires = w.getRequiredWires(PackageNamespace.PACKAGE_NAMESPACE); + assertFalse("Empty wires.", pkgWires.isEmpty()); + assertEquals("Wrong provider", b1.adapt(BundleRevision.class), pkgWires.iterator().next().getProvider()); + } catch (BundleException e) { + fail("Unexpected BundleException", e); + } finally { + try { + if (equinox != null) { + equinox.stop(); + equinox.waitForStop(1000); + } + } catch (BundleException e) { + fail("Failed to stop framework.", e); + } catch (InterruptedException e) { + fail("Failed to stop framework.", e); + } + } + } } |