use of org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor 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());
}
use of org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor 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.tests.container.dummys.DummyContainerAdaptor 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.tests.container.dummys.DummyContainerAdaptor in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testResolveInstallBundles01.
// Disabled @Test
public void testResolveInstallBundles01() throws BundleException, IOException {
setupModuleDatabase();
DummyContainerAdaptor adaptor = createDummyAdaptor();
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
resolvedModuleDatabase.store(new DataOutputStream(bytes), false);
bytes.close();
adaptor.getDatabase().load(new DataInputStream(new ByteArrayInputStream(bytes.toByteArray())));
for (int i = 0; i < 50; i++) {
adaptor.getContainer().refresh(adaptor.getContainer().getModules());
}
}
use of org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor 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);
}
Aggregations