Search in sources :

Example 1 with DummyResolverHook

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());
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) ModuleWire(org.eclipse.osgi.container.ModuleWire) ModuleContainer(org.eclipse.osgi.container.ModuleContainer) Module(org.eclipse.osgi.container.Module) DummyResolverHookFactory(org.eclipse.osgi.tests.container.dummys.DummyResolverHookFactory) DummyResolverHook(org.eclipse.osgi.tests.container.dummys.DummyResolverHook) Test(org.junit.Test)

Aggregations

Module (org.eclipse.osgi.container.Module)1 ModuleContainer (org.eclipse.osgi.container.ModuleContainer)1 ModuleWire (org.eclipse.osgi.container.ModuleWire)1 DummyContainerAdaptor (org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor)1 DummyResolverHook (org.eclipse.osgi.tests.container.dummys.DummyResolverHook)1 DummyResolverHookFactory (org.eclipse.osgi.tests.container.dummys.DummyResolverHookFactory)1 Test (org.junit.Test)1