use of org.eclipse.osgi.container.Module 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.container.Module in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testUses1.
/*
* Test that a resolve process does not blow up because of one unresolvable uses constraint issue
*/
@Test
public void testUses1() 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_a = installDummyModule("uses.a.MF", "a", container);
Module uses_b = installDummyModule("uses.b.MF", "b", container);
Module uses_c = installDummyModule("uses.c.MF", "c", container);
container.resolve(null, false);
Assert.assertEquals("a should resolve.", State.RESOLVED, uses_a.getState());
Assert.assertEquals("b should resolve.", State.RESOLVED, uses_b.getState());
Assert.assertEquals("c should not resolve.", State.INSTALLED, uses_c.getState());
}
use of org.eclipse.osgi.container.Module in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testPlatformFilter02.
@Test
public void testPlatformFilter02() throws BundleException, IOException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
String extraCapabilities = EclipsePlatformNamespace.ECLIPSE_PLATFORM_NAMESPACE + "; osgi.os=baz; osgi.arch=boz";
installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, null, null, extraCapabilities, container);
container.resolve(null, false);
Module platformFilter1 = installDummyModule("platformFilter1_v1.MF", "ee1", container);
container.resolve(Arrays.asList(platformFilter1), false);
ModuleWiring platformFilter1Wiring = platformFilter1.getCurrentRevision().getWiring();
Assert.assertNull("platformFilter1 is resolved", platformFilter1Wiring);
}
use of org.eclipse.osgi.container.Module 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.container.Module 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