use of org.eclipse.osgi.report.resolution.ResolutionReport 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.report.resolution.ResolutionReport 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.report.resolution.ResolutionReport 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.report.resolution.ResolutionReport in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testSystemBundleOnDemandFragments.
@Test
public void testSystemBundleOnDemandFragments() 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);
// install an equinox fragment
Map<String, String> equinoxFragManifest = new HashMap<String, String>();
equinoxFragManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
equinoxFragManifest.put(Constants.BUNDLE_SYMBOLICNAME, "equinoxFrag");
equinoxFragManifest.put(Constants.FRAGMENT_HOST, "org.eclipse.osgi");
Module equinoxFrag = installDummyModule(equinoxFragManifest, "equinoxFrag", container);
// install a system.bundle fragment
Map<String, String> systemFragManifest = new HashMap<String, String>();
systemFragManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
systemFragManifest.put(Constants.BUNDLE_SYMBOLICNAME, "systemFrag");
systemFragManifest.put(Constants.FRAGMENT_HOST, "system.bundle");
Module systemFrag = installDummyModule(systemFragManifest, "systemFrag", container);
ResolutionReport report = container.resolve(Arrays.asList(systemBundle), true);
Assert.assertNull("Failed to resolve system.bundle.", report.getResolutionException());
List<ModuleWire> hostWires = systemBundle.getCurrentRevision().getWiring().getProvidedModuleWires(HostNamespace.HOST_NAMESPACE);
assertEquals("Wrong number of fragments.", 2, hostWires.size());
Set<ModuleRevision> fragmentRevisions = new HashSet(Arrays.asList(equinoxFrag.getCurrentRevision(), systemFrag.getCurrentRevision()));
for (ModuleWire hostWire : hostWires) {
if (!fragmentRevisions.remove(hostWire.getRequirer())) {
Assert.fail("Unexpected fragment revision: " + hostWire.getRequirer());
}
}
}
use of org.eclipse.osgi.report.resolution.ResolutionReport 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());
}
Aggregations