use of org.eclipse.osgi.container.ModuleContainer 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());
}
use of org.eclipse.osgi.container.ModuleContainer in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testStartLevelDeadlock.
@Test
public void testStartLevelDeadlock() throws BundleException, IOException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
container.getFrameworkStartLevel().setInitialBundleStartLevel(2);
// 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 module
Map<String, String> manifest = new HashMap<String, String>();
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "module.test");
Module module = installDummyModule(manifest, manifest.get(Constants.BUNDLE_SYMBOLICNAME), container);
adaptor.setSlowdownEvents(true);
module.setStartLevel(1);
module.start();
List<DummyContainerEvent> events = adaptor.getDatabase().getContainerEvents();
for (DummyContainerEvent event : events) {
Assert.assertNotEquals("Found an error: " + event.error, ContainerEvent.ERROR, event.type);
}
}
use of org.eclipse.osgi.container.ModuleContainer in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testDynamicWithOptionalImport.
@Test
public void testDynamicWithOptionalImport() 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.IMPORT_PACKAGE, "exporter; resolution:=optional");
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));
// install a exporter to satisfy existing optional import
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");
installDummyModule(exporterManifest, "exporter", container);
ModuleWire dynamicWire = container.resolveDynamic("exporter", optionalImporterModule.getCurrentRevision());
Assert.assertNotNull("Expected to find a dynamic wire.", dynamicWire);
// re-resolve importer
container.refresh(Collections.singleton(optionalImporterModule));
report = container.resolve(Arrays.asList(optionalImporterModule), true);
Assert.assertNull("Failed to resolve system.bundle.", report.getResolutionException());
importReqsList = optionalImporterModule.getCurrentRevision().getWiring().getRequirements(PackageNamespace.PACKAGE_NAMESPACE);
assertEquals("Wrong number of imports.", 2, importReqsList.size());
}
use of org.eclipse.osgi.container.ModuleContainer in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testNativeWithFilterChars.
@Test
public void testNativeWithFilterChars() throws BundleException, IOException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
// install the system.bundle
String extraCapabilities = "osgi.native; osgi.native.osname=\"Windows NT (unknown)\"";
Module systemBundle = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, Constants.SYSTEM_BUNDLE_SYMBOLICNAME, null, extraCapabilities, container);
ResolutionReport report = container.resolve(Arrays.asList(systemBundle), true);
Assert.assertNull("Failed to resolve system.bundle.", report.getResolutionException());
// install bundle with Bundle-NativeCode
Map<String, String> nativeCodeManifest = new HashMap<String, String>();
nativeCodeManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
nativeCodeManifest.put(Constants.BUNDLE_SYMBOLICNAME, "importer");
//
nativeCodeManifest.put(//
Constants.BUNDLE_NATIVECODE, //
"/lib/mylib.dll; osname=\"win32\"; osname=\"Windows NT (unknown)\"," + "/lib/mylib.lib; osname=\"Linux\"");
Module nativeCodeModule = installDummyModule(nativeCodeManifest, "nativeCodeBundle", container);
// unsatisfied optional and dynamic imports do not fail a resolve.
report = container.resolve(Arrays.asList(nativeCodeModule), true);
Assert.assertNull("Failed to resolve nativeCodeBundle.", report.getResolutionException());
}
use of org.eclipse.osgi.container.ModuleContainer in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testSubstitutableExports03.
@Test
public void testSubstitutableExports03() throws BundleException, IOException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
// install order does not really matter
Module g = installDummyModule("sub.g.MF", "g", container);
Module f = installDummyModule("sub.f.MF", "f", container);
Module e = installDummyModule("sub.e.MF", "e", container);
// resolve order does matter so that transitive dependencies are pulled in
// and cause substitution to happen in a certain way
container.resolve(Arrays.asList(g, f, e), true);
ModuleWiring wiringE = e.getCurrentRevision().getWiring();
ModuleWiring wiringF = f.getCurrentRevision().getWiring();
List<ModuleWire> providedWiresE = wiringE.getProvidedModuleWires(PackageNamespace.PACKAGE_NAMESPACE);
Assert.assertEquals("Wrong number of provided wires.", 3, providedWiresE.size());
Collection<ModuleRevision> requirers = new HashSet<ModuleRevision>();
for (ModuleWire wire : providedWiresE) {
requirers.add(wire.getRequirer());
}
Assert.assertTrue("f does not require.", requirers.remove(f.getCurrentRevision()));
Assert.assertTrue("g does not require.", requirers.remove(g.getCurrentRevision()));
Assert.assertTrue("No requirers should be left: " + requirers, requirers.isEmpty());
List<ModuleWire> providedWiresF = wiringF.getProvidedModuleWires(PackageNamespace.PACKAGE_NAMESPACE);
Assert.assertEquals("Wrong number of provided wires: " + providedWiresF, 0, providedWiresF.size());
}
Aggregations