use of org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testDynamicImportMiss01.
@Test
public void testDynamicImportMiss01() throws BundleException, IOException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
Module systemBundle = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, null, null, "osgi.ee; osgi.ee=JavaSE; version:Version=\"1.5.0\"", container);
container.resolve(Arrays.asList(systemBundle), true);
Module c1 = installDummyModule("c1_v1.MF", "c1_v1", container);
Module dynamic1 = installDummyModule("dynamic1_v1.MF", "dynamic1_v1", container);
container.resolve(Arrays.asList(c1, dynamic1), true);
DummyResolverHookFactory factory = (DummyResolverHookFactory) adaptor.getResolverHookFactory();
DummyResolverHook hook = (DummyResolverHook) factory.getHook();
hook.getResolutionReports().clear();
ModuleWire dynamicWire = container.resolveDynamic("org.osgi.framework", dynamic1.getCurrentRevision());
Assert.assertNotNull("No dynamic wire found.", dynamicWire);
Assert.assertEquals("Wrong package found.", "org.osgi.framework", dynamicWire.getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
Assert.assertEquals("Wrong provider for the wire found.", systemBundle.getCurrentRevision(), dynamicWire.getProvider());
Assert.assertEquals("Wrong number of reports.", 1, hook.getResolutionReports().size());
hook.getResolutionReports().clear();
dynamicWire = container.resolveDynamic("does.not.exist", dynamic1.getCurrentRevision());
Assert.assertNull("Unexpected Dynamic wire found.", dynamicWire);
Assert.assertEquals("Wrong number of reports.", 1, hook.getResolutionReports().size());
// Try again; no report should be generated a second time
hook.getResolutionReports().clear();
dynamicWire = container.resolveDynamic("does.not.exist", dynamic1.getCurrentRevision());
Assert.assertNull("Unexpected Dynamic wire found.", dynamicWire);
Assert.assertEquals("Wrong number of reports.", 0, hook.getResolutionReports().size());
}
use of org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testMultiHost.
@Test
public void testMultiHost() throws BundleException, IOException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, container);
Module h1v1 = installDummyModule("h1_v1.MF", "h1_v1", container);
Module h1v2 = installDummyModule("h1_v2.MF", "h1_v2", container);
Module f1v1 = installDummyModule("f1_v1.MF", "f1_v1", container);
Module b3 = installDummyModule("b3_v1.MF", "b3_v1", container);
ResolutionReport report = container.resolve(Arrays.asList(h1v1, h1v2, f1v1, b3), true);
Assert.assertNull("Expected no resolution exception.", report.getResolutionException());
}
use of org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testInstallCollision01.
@Test
public void testInstallCollision01() throws BundleException, IOException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, container);
installDummyModule("b1_v1.MF", "b1_a", container);
try {
installDummyModule("b1_v1.MF", "b1_b", container);
Assert.fail("Expected to fail installation because of a collision.");
} catch (BundleException e) {
// expected
Assert.assertEquals("Wrong exception type.", BundleException.DUPLICATE_BUNDLE_ERROR, e.getType());
}
}
use of org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testDynamicWithExport.
@Test
public void testDynamicWithExport() 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 importer
Map<String, String> optionalImporterManifest = new HashMap<String, String>();
optionalImporterManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
optionalImporterManifest.put(Constants.BUNDLE_SYMBOLICNAME, "importer");
optionalImporterManifest.put(Constants.EXPORT_PACKAGE, "exporter");
optionalImporterManifest.put(Constants.DYNAMICIMPORT_PACKAGE, "exporter");
Module optionalImporterModule = installDummyModule(optionalImporterManifest, "optionalImporter", container);
// unsatisfied optional and dynamic imports do not fail a resolve.
report = container.resolve(Arrays.asList(optionalImporterModule), true);
Assert.assertNull("Failed to resolve system.bundle.", report.getResolutionException());
// dynamic and optional imports are same. Optional import is not satisfied we should only see the dynamic import
List<BundleRequirement> importReqsList = optionalImporterModule.getCurrentRevision().getWiring().getRequirements(PackageNamespace.PACKAGE_NAMESPACE);
assertEquals("Wrong number of imports.", 1, importReqsList.size());
assertEquals("Import was not dynamic", PackageNamespace.RESOLUTION_DYNAMIC, importReqsList.get(0).getDirectives().get(Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE));
ModuleWire dynamicWire = container.resolveDynamic("exporter", optionalImporterModule.getCurrentRevision());
Assert.assertNull("Expected no dynamic wire.", dynamicWire);
}
use of org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testUpdateCollision01.
@Test
public void testUpdateCollision01() throws BundleException, IOException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
Module b1_v1 = installDummyModule("b1_v1.MF", "b1_v1", container);
installDummyModule("b1_v2.MF", "b1_v2", container);
try {
container.update(b1_v1, OSGiManifestBuilderFactory.createBuilder(getManifest("b1_v2.MF")), null);
Assert.fail("Expected to fail update because of a collision.");
} catch (BundleException e) {
// expected
Assert.assertEquals("Wrong exception type.", BundleException.DUPLICATE_BUNDLE_ERROR, e.getType());
}
}
Aggregations