use of org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testCompatProvidePackage.
@Test
public void testCompatProvidePackage() throws BundleException, IOException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
Module b1 = installDummyModule("compatProvidePackage1.MF", "b1", container);
List<ModuleCapability> packageCaps = b1.getCurrentRevision().getModuleCapabilities(PackageNamespace.PACKAGE_NAMESPACE);
Assert.assertEquals("Wrong number of exports", 5, packageCaps.size());
Assert.assertEquals("Wrong package name.", "foo", packageCaps.get(0).getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
Assert.assertEquals("Wrong package name.", "faa", packageCaps.get(1).getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
Assert.assertEquals("Wrong package name.", "bar", packageCaps.get(2).getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
Assert.assertEquals("Wrong package name.", "baz", packageCaps.get(3).getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
Assert.assertEquals("Wrong package name.", "biz", packageCaps.get(4).getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
}
use of org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testUses1Dynamic.
@Test
public void testUses1Dynamic() throws BundleException, IOException {
DummyContainerAdaptor adaptor = createDummyAdaptor(new DummyDebugOptions(Collections.singletonMap("org.eclipse.osgi/resolver/report", "true")));
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_dynamic = installDummyModule("uses.c.dynamic.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 resolve.", State.RESOLVED, uses_c_dynamic.getState());
ModuleWire dynamicWire = container.resolveDynamic("uses1", uses_c_dynamic.getCurrentRevision());
Assert.assertNotNull("No dynamic wire.", dynamicWire);
PrintStream originalOut = Debug.out;
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
PrintStream testOut = new PrintStream(bytesOut);
Debug.out = testOut;
try {
dynamicWire = container.resolveDynamic("uses2", uses_c_dynamic.getCurrentRevision());
Assert.assertNull("Dynamic wire found.", dynamicWire);
} finally {
Debug.out = originalOut;
testOut.close();
}
String traceOutput = bytesOut.toString();
Assert.assertTrue("Wrong traceOutput: " + traceOutput, traceOutput.startsWith("org.osgi.service.resolver.ResolutionException"));
}
use of org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testLazy01.
@Test
public void testLazy01() throws BundleException, IOException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
DummyModuleDatabase database = adaptor.getDatabase();
Module systemBundle = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, container);
container.resolve(Arrays.asList(systemBundle), true);
// actually launch the container
systemBundle.start();
Module lazy1 = installDummyModule("lazy1_v1.MF", "lazy1", container);
// throw out installed and resolved events
database.getModuleEvents();
lazy1.start(StartOptions.USE_ACTIVATION_POLICY);
List<DummyModuleEvent> actual = database.getModuleEvents();
List<DummyModuleEvent> expected = new ArrayList<DummyModuleEvent>(Arrays.asList(new DummyModuleEvent(lazy1, ModuleEvent.RESOLVED, State.RESOLVED), new DummyModuleEvent(lazy1, ModuleEvent.LAZY_ACTIVATION, State.LAZY_STARTING)));
assertEvents(expected, actual, true);
lazy1.start(StartOptions.LAZY_TRIGGER);
actual = database.getModuleEvents();
expected = new ArrayList<DummyModuleEvent>(Arrays.asList(new DummyModuleEvent(lazy1, ModuleEvent.STARTING, State.STARTING), new DummyModuleEvent(lazy1, ModuleEvent.STARTED, State.ACTIVE)));
assertEvents(expected, actual, true);
container.refresh(Arrays.asList(lazy1));
actual = database.getModuleEvents();
expected = new ArrayList<DummyModuleEvent>(Arrays.asList(new DummyModuleEvent(lazy1, ModuleEvent.STOPPING, State.STOPPING), new DummyModuleEvent(lazy1, ModuleEvent.STOPPED, State.RESOLVED), new DummyModuleEvent(lazy1, ModuleEvent.UNRESOLVED, State.INSTALLED), new DummyModuleEvent(lazy1, ModuleEvent.RESOLVED, State.RESOLVED), new DummyModuleEvent(lazy1, ModuleEvent.LAZY_ACTIVATION, State.LAZY_STARTING)));
assertEvents(expected, actual, true);
container.update(lazy1, OSGiManifestBuilderFactory.createBuilder(getManifest("lazy1_v1.MF")), null);
actual = database.getModuleEvents();
expected = new ArrayList<DummyModuleEvent>(Arrays.asList(new DummyModuleEvent(lazy1, ModuleEvent.STOPPING, State.STOPPING), new DummyModuleEvent(lazy1, ModuleEvent.STOPPED, State.RESOLVED), new DummyModuleEvent(lazy1, ModuleEvent.UNRESOLVED, State.INSTALLED), new DummyModuleEvent(lazy1, ModuleEvent.UPDATED, State.INSTALLED), new DummyModuleEvent(lazy1, ModuleEvent.RESOLVED, State.RESOLVED), new DummyModuleEvent(lazy1, ModuleEvent.LAZY_ACTIVATION, State.LAZY_STARTING)));
assertEvents(expected, actual, true);
container.refresh(Arrays.asList(lazy1));
actual = database.getModuleEvents();
expected = new ArrayList<DummyModuleEvent>(Arrays.asList(new DummyModuleEvent(lazy1, ModuleEvent.STOPPING, State.STOPPING), new DummyModuleEvent(lazy1, ModuleEvent.STOPPED, State.RESOLVED), new DummyModuleEvent(lazy1, ModuleEvent.UNRESOLVED, State.INSTALLED), new DummyModuleEvent(lazy1, ModuleEvent.RESOLVED, State.RESOLVED), new DummyModuleEvent(lazy1, ModuleEvent.LAZY_ACTIVATION, State.LAZY_STARTING)));
assertEvents(expected, actual, true);
}
use of org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testBug457118.
@Test
public void testBug457118() 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 e = installDummyModule("bug457118.e.MF", "e", container);
Module a = installDummyModule("bug457118.a.MF", "a", container);
Module b = installDummyModule("bug457118.b.MF", "b", container);
Module c = installDummyModule("bug457118.c.MF", "c", container);
Module d = installDummyModule("bug457118.d.MF", "d", container);
installDummyModule("bug457118.a2.MF", "a2", container);
installDummyModule("bug457118.b2.MF", "b2", container);
installDummyModule("bug457118.c2.MF", "c2", container);
installDummyModule("bug457118.d2.MF", "d2", container);
container.resolve(null, true);
Assert.assertEquals("e should resolve.", State.RESOLVED, e.getState());
Assert.assertEquals("a should resolve.", State.RESOLVED, a.getState());
Assert.assertEquals("b should resolve.", State.RESOLVED, b.getState());
Assert.assertEquals("c should resolve.", State.RESOLVED, c.getState());
Assert.assertEquals("d should resolve.", State.RESOLVED, d.getState());
List<ModuleWire> bundleWires = e.getCurrentRevision().getWiring().getRequiredModuleWires(BundleNamespace.BUNDLE_NAMESPACE);
Assert.assertEquals("Wrong number of bundle wires: " + bundleWires, 1, bundleWires.size());
Assert.assertEquals("Wrong bundle provider", a.getCurrentRevision(), bundleWires.get(0).getProvider());
}
use of org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testRefreshSystemBundle.
// Disabled @Test
public void testRefreshSystemBundle() throws BundleException, IOException {
setupModuleDatabase();
DummyContainerAdaptor adaptor = createDummyAdaptor();
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
resolvedModuleDatabase.store(new DataOutputStream(bytes), true);
bytes.close();
adaptor.getDatabase().load(new DataInputStream(new ByteArrayInputStream(bytes.toByteArray())));
adaptor.getContainer().refresh(Arrays.asList(adaptor.getContainer().getModule(0)));
}
Aggregations