use of org.eclipse.osgi.tests.container.dummys.DummyResolverHook 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());
}
Aggregations