diff options
author | Thomas Watson | 2017-02-03 16:08:29 +0000 |
---|---|---|
committer | Thomas Watson | 2017-02-03 17:23:24 +0000 |
commit | f9777863a046cb6516c5846f2d592ff6aa25fb15 (patch) | |
tree | 24cc6ab661c8f29caafaffd01a341cd1b690f9ae /bundles/org.eclipse.osgi.tests | |
parent | bd50cc83c991934e6891354e1849f2beec4ca48f (diff) | |
download | rt.equinox.framework-f9777863a046cb6516c5846f2d592ff6aa25fb15.tar.gz rt.equinox.framework-f9777863a046cb6516c5846f2d592ff6aa25fb15.tar.xz rt.equinox.framework-f9777863a046cb6516c5846f2d592ff6aa25fb15.zip |
Bug 511593 - Issue resolving split packages
Add testcase for substituted split a packages.
Change-Id: I3b937c6fa2b94122d02aa582027da361b8574bf5
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
Diffstat (limited to 'bundles/org.eclipse.osgi.tests')
-rw-r--r-- | bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java | 96 |
1 files changed, 95 insertions, 1 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 6741e52be..a61744438 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2016 IBM Corporation and others. + * Copyright (c) 2013, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -2838,6 +2838,100 @@ public class TestModuleContainer extends AbstractTest { } } + @Test + public void testSplitPackageUses01() throws BundleException { + DummyContainerAdaptor adaptor = createDummyAdaptor(); + ModuleContainer container = adaptor.getContainer(); + + // install a split exporter core that substitutes + Map<String, String> coreManifest = new HashMap<String, String>(); + coreManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2"); + coreManifest.put(Constants.BUNDLE_SYMBOLICNAME, "core"); + coreManifest.put(Constants.EXPORT_PACKAGE, "pkg1; core=split; mandatory:=core"); + coreManifest.put(Constants.IMPORT_PACKAGE, "pkg1; core=split"); + + // install a split exporter misc that requires core and substitutes + Map<String, String> miscManifest = new HashMap<String, String>(); + miscManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2"); + miscManifest.put(Constants.BUNDLE_SYMBOLICNAME, "misc"); + miscManifest.put(Constants.EXPORT_PACKAGE, "pkg1; misc=split; mandatory:=misc"); + miscManifest.put(Constants.REQUIRE_BUNDLE, "core"); + + // install a bundle that imports core and exports pkg2 that uses pkg1 from core + Map<String, String> importsCoreManifest = new HashMap<String, String>(); + importsCoreManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2"); + importsCoreManifest.put(Constants.BUNDLE_SYMBOLICNAME, "importsCore"); + importsCoreManifest.put(Constants.EXPORT_PACKAGE, "pkg2; uses:=pkg1"); + importsCoreManifest.put(Constants.IMPORT_PACKAGE, "pkg1; core=split"); + + // install a bundle that imports pkg2, but requires misc + Map<String, String> requiresMiscManifest = new HashMap<String, String>(); + requiresMiscManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2"); + requiresMiscManifest.put(Constants.BUNDLE_SYMBOLICNAME, "requiresMisc"); + requiresMiscManifest.put(Constants.IMPORT_PACKAGE, "pkg2"); + requiresMiscManifest.put(Constants.REQUIRE_BUNDLE, "misc"); + + installDummyModule(coreManifest, "core", container); + installDummyModule(miscManifest, "misc", container); + installDummyModule(importsCoreManifest, "importsCore", container); + Module requireMisc = installDummyModule(requiresMiscManifest, "requireMisc", container); + + ResolutionReport report = container.resolve(Arrays.asList(requireMisc), true); + Assert.assertNull("Failed to resolve test.", report.getResolutionException()); + + // now test by resolving the split exporters first + adaptor = createDummyAdaptor(); + container = adaptor.getContainer(); + + installDummyModule(coreManifest, "core", container); + Module misc = installDummyModule(miscManifest, "misc", container); + report = container.resolve(Arrays.asList(misc), true); + Assert.assertNull("Failed to resolve test.", report.getResolutionException()); + + installDummyModule(importsCoreManifest, "importsCore", container); + requireMisc = installDummyModule(requiresMiscManifest, "requireMisc", container); + report = container.resolve(Arrays.asList(requireMisc), true); + Assert.assertNull("Failed to resolve test.", report.getResolutionException()); + + // now test by resolving the split exporters first with a real substitution + adaptor = createDummyAdaptor(); + container = adaptor.getContainer(); + + // install a exporter that substitutes core's export + Map<String, String> substitutesCoreManifest = new HashMap<String, String>(); + substitutesCoreManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2"); + substitutesCoreManifest.put(Constants.BUNDLE_SYMBOLICNAME, "substitutesCore"); + substitutesCoreManifest.put(Constants.EXPORT_PACKAGE, "pkg1; substitutesCore=true; mandatory:=substitutesCore"); + + // change core's import to force it to the substitute + coreManifest.put(Constants.IMPORT_PACKAGE, "pkg1; substitutesCore=true"); + importsCoreManifest.put(Constants.IMPORT_PACKAGE, "pkg1; substitutesCore=true"); + + installDummyModule(substitutesCoreManifest, "substitutesCore", container); + installDummyModule(coreManifest, "core", container); + misc = installDummyModule(miscManifest, "misc", container); + report = container.resolve(Arrays.asList(misc), true); + Assert.assertNull("Failed to resolve test.", report.getResolutionException()); + + installDummyModule(importsCoreManifest, "importsCore", container); + requireMisc = installDummyModule(requiresMiscManifest, "requireMisc", container); + report = container.resolve(Arrays.asList(requireMisc), true); + Assert.assertNull("Failed to resolve test.", report.getResolutionException()); + + // not test by doing a full resolve with real substitution + adaptor = createDummyAdaptor(); + container = adaptor.getContainer(); + + installDummyModule(substitutesCoreManifest, "substitutesCore", container); + installDummyModule(coreManifest, "core", container); + installDummyModule(miscManifest, "misc", container); + installDummyModule(importsCoreManifest, "importsCore", container); + requireMisc = installDummyModule(requiresMiscManifest, "requireMisc", container); + + report = container.resolve(Arrays.asList(requireMisc), true); + Assert.assertNull("Failed to resolve test.", report.getResolutionException()); + } + private static void assertWires(List<ModuleWire> required, List<ModuleWire>... provided) { for (ModuleWire requiredWire : required) { for (List<ModuleWire> providedList : provided) { |