use of org.eclipse.osgi.report.resolution.ResolutionReport in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testSubstitutableExport.
@Test
public void testSubstitutableExport() throws BundleException, IOException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
// install the system.bundle
Module systemBundle = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, Constants.SYSTEM_BUNDLE_SYMBOLICNAME, null, null, container);
ResolutionReport report = container.resolve(Arrays.asList(systemBundle), true);
Assert.assertNull("Failed to resolve system.bundle.", report.getResolutionException());
// install an exporter with substitutable export.
Map<String, String> exporterManifest = new HashMap<String, String>();
exporterManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
exporterManifest.put(Constants.BUNDLE_SYMBOLICNAME, "exporter");
exporterManifest.put(Constants.EXPORT_PACKAGE, "exporter");
exporterManifest.put(Constants.IMPORT_PACKAGE, "exporter");
Module moduleSubsExport = installDummyModule(exporterManifest, "exporter", container);
report = container.resolve(Arrays.asList(moduleSubsExport), true);
Assert.assertNull("Failed to resolve", report.getResolutionException());
List<BundleRequirement> reqs = moduleSubsExport.getCurrentRevision().getWiring().getRequirements(PackageNamespace.PACKAGE_NAMESPACE);
assertEquals("Wrong number of imports.", 0, reqs.size());
container.uninstall(moduleSubsExport);
exporterManifest = new HashMap<String, String>();
exporterManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
exporterManifest.put(Constants.BUNDLE_SYMBOLICNAME, "substitutableExporter");
exporterManifest.put(Constants.EXPORT_PACKAGE, "exporter");
exporterManifest.put(Constants.IMPORT_PACKAGE, "exporter; pickme=true");
moduleSubsExport = installDummyModule(exporterManifest, "substitutableExporter", container);
exporterManifest = new HashMap<String, String>();
exporterManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
exporterManifest.put(Constants.BUNDLE_SYMBOLICNAME, "exporter");
exporterManifest.put(Constants.EXPORT_PACKAGE, "exporter; pickme=true");
Module moduleExport = installDummyModule(exporterManifest, "exporter", container);
report = container.resolve(Arrays.asList(moduleSubsExport), true);
Assert.assertNull("Failed to resolve", report.getResolutionException());
List<BundleCapability> caps = moduleSubsExport.getCurrentRevision().getWiring().getCapabilities(PackageNamespace.PACKAGE_NAMESPACE);
assertEquals("Wrong number of capabilities.", 0, caps.size());
reqs = moduleSubsExport.getCurrentRevision().getWiring().getRequirements(PackageNamespace.PACKAGE_NAMESPACE);
assertEquals("Wrong number of imports.", 1, reqs.size());
ModuleWiring wiring = moduleSubsExport.getCurrentRevision().getWiring();
List<ModuleWire> packageWires = wiring.getRequiredModuleWires(PackageNamespace.PACKAGE_NAMESPACE);
Assert.assertEquals("Unexpected number of wires", 1, packageWires.size());
Assert.assertEquals("Wrong exporter", packageWires.get(0).getProviderWiring().getRevision(), moduleExport.getCurrentRevision());
}
use of org.eclipse.osgi.report.resolution.ResolutionReport in project rt.equinox.framework by eclipse.
the class TestModuleContainer method doTestStartOnResolve.
private void doTestStartOnResolve(boolean enabled) throws BundleException, IOException {
Map<String, String> configuration = new HashMap<String, String>();
if (!enabled) {
configuration.put(EquinoxConfiguration.PROP_MODULE_AUTO_START_ON_RESOLVE, Boolean.toString(false));
}
DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(false), configuration);
ModuleContainer container = adaptor.getContainer();
// install the system.bundle
Module systemBundle = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, Constants.SYSTEM_BUNDLE_SYMBOLICNAME, null, null, container);
ResolutionReport report = container.resolve(Arrays.asList(systemBundle), true);
Assert.assertNull("Failed to resolve system.bundle.", report.getResolutionException());
systemBundle.start();
// install a bunch of modules
Map<String, String> manifest = new HashMap<String, String>();
List<Module> modules = new ArrayList<Module>();
for (int i = 0; i < 5; i++) {
manifest.clear();
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "module." + i);
manifest.put(Constants.IMPORT_PACKAGE, "export");
Module module = installDummyModule(manifest, manifest.get(Constants.BUNDLE_SYMBOLICNAME), container);
try {
module.start();
fail("expected a bundle exception.");
} catch (BundleException e) {
// do nothing
}
modules.add(module);
}
manifest.clear();
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "exporter");
manifest.put(Constants.EXPORT_PACKAGE, "export");
installDummyModule(manifest, manifest.get(Constants.BUNDLE_SYMBOLICNAME), container);
report = container.resolve(Collections.<Module>emptySet(), false);
Assert.assertNull("Found a error.", report.getResolutionException());
State expectedState = enabled ? State.ACTIVE : State.RESOLVED;
for (Module module : modules) {
Assert.assertEquals("Wrong state.", expectedState, module.getState());
}
}
use of org.eclipse.osgi.report.resolution.ResolutionReport in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testSubstitutionWithMoreThan2Providers.
@Test
public void testSubstitutionWithMoreThan2Providers() throws BundleException, IOException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
Module systemBundle = installDummyModule(//
"system.bundle.MF", //
Constants.SYSTEM_BUNDLE_LOCATION, //
Constants.SYSTEM_BUNDLE_SYMBOLICNAME, //
"javax.crypto, javax.crypto.spec, javax.net, javax.net.ssl, javax.security.auth.x500, org.ietf.jgss", //
"osgi.ee; osgi.ee=JavaSE; version:List<Version>=\"1.3, 1.4, 1.5, 1.6, 1.7\"", container);
ResolutionReport report = container.resolve(Arrays.asList(systemBundle), true);
Assert.assertNull("Failed to resolve test.", report.getResolutionException());
List<Module> modules = new ArrayList<Module>();
for (String manifest : HTTPCOMPS_AND_EATHER) {
modules.add(installDummyModule(manifest, manifest, container));
}
report = container.resolve(modules, true);
Assert.assertNull("Failed to resolve test.", report.getResolutionException());
}
use of org.eclipse.osgi.report.resolution.ResolutionReport in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testModuleIDSetting.
@Test
public void testModuleIDSetting() throws BundleException, IOException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
// install the system.bundle
Module systemBundle = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, Constants.SYSTEM_BUNDLE_SYMBOLICNAME, null, null, container);
ResolutionReport report = container.resolve(Arrays.asList(systemBundle), true);
Assert.assertNull("Failed to resolve system.bundle.", report.getResolutionException());
Map<String, String> manifest = new HashMap<String, String>();
// test by installing bundles with decreasing IDs
List<Module> modules = new ArrayList<Module>();
for (int i = 5; i > 0; i--) {
manifest.clear();
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
manifest.put(Constants.BUNDLE_SYMBOLICNAME, String.valueOf(i));
modules.add(installDummyModule(manifest, i, manifest.get(Constants.BUNDLE_SYMBOLICNAME), container));
}
// test that the modules have decreasing ID starting at 5
long id = 5;
for (Module module : modules) {
Assert.assertEquals("Wrong ID found.", id--, module.getId().longValue());
}
// test that error occurs when trying to use an existing ID
manifest.clear();
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
manifest.put(Constants.BUNDLE_SYMBOLICNAME, String.valueOf("test.dup.id"));
try {
installDummyModule(manifest, 5, manifest.get(Constants.BUNDLE_SYMBOLICNAME), container);
fail("Expected to fail installation with duplicate ID.");
} catch (IllegalStateException e) {
// expected
}
}
use of org.eclipse.osgi.report.resolution.ResolutionReport in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testUses6FragConflicts.
@Test
public void testUses6FragConflicts() throws BundleException, IOException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
Module systemBundle = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, container);
container.resolve(Arrays.asList(systemBundle), true);
Module uses_n1 = installDummyModule("uses.n1.MF", "n1", container);
installDummyModule("uses.n2.MF", "n2", container);
Module uses_n2_frag = installDummyModule("uses.n2.frag.MF", "n2.frag", container);
Module uses_n3 = installDummyModule("uses.n3.MF", "n3", container);
ResolutionReport report = container.resolve(null, false);
Assert.assertNull("resolution report has a resolution exception.", report.getResolutionException());
Assert.assertEquals("n1 should resolve.", State.RESOLVED, uses_n1.getState());
// TODO The following should be true, but on the current resolver in Mars the host is thrown away also
// Assert.assertEquals("n2 should resolve.", State.RESOLVED, uses_n2.getState());
Assert.assertEquals("n2.frag should not resolve.", State.INSTALLED, uses_n2_frag.getState());
Assert.assertEquals("n3 should resolve.", State.RESOLVED, uses_n3.getState());
}
Aggregations