Search in sources :

Example 56 with Module

use of org.eclipse.osgi.container.Module in project rt.equinox.framework by eclipse.

the class ResolutionReportTest method testResolutionReportEntryUnresolvedProvider01.

@Test
public void testResolutionReportEntryUnresolvedProvider01() throws Exception {
    DummyResolverHook hook = new DummyResolverHook();
    DummyContainerAdaptor adaptor = createDummyAdaptor(hook);
    ModuleContainer container = adaptor.getContainer();
    Module resolutionReportC = installDummyModule("resolution.report.c.MF", "resolution.report.c", container);
    Module resolutionReportD = installDummyModule("resolution.report.d.MF", "resolution.report.d", container);
    assertResolutionDoesNotSucceed(container, Arrays.asList(resolutionReportC, resolutionReportD));
    ResolutionReport report = hook.getResolutionReports().get(0);
    Map<Resource, List<ResolutionReport.Entry>> resourceToEntries = report.getEntries();
    assertResolutionReportEntriesSize(resourceToEntries, 2);
    List<ResolutionReport.Entry> entries = resourceToEntries.get(resolutionReportC.getCurrentRevision());
    assertResolutionReportEntriesSize(entries, 1);
    ResolutionReport.Entry entry = entries.get(0);
    assertResolutionReportEntryTypeUnresolvedProvider(entry.getType());
    assertResolutionReportEntryDataUnresolvedProvider(entry.getData(), new UnresolvedProviderEntryBuilder().requirement(resolutionReportC.getCurrentRevision().getRequirements("resolution.report.d").get(0)).capability(resolutionReportD.getCurrentRevision().getCapabilities("resolution.report.d").get(0)).build());
    entries = resourceToEntries.get(resolutionReportD.getCurrentRevision());
    assertResolutionReportEntriesSize(entries, 1);
    entry = entries.get(0);
    assertResolutionReportEntryTypeMissingCapability(entry.getType());
    assertResolutionReportEntryDataMissingCapability(entry.getData(), "does.not.exist", null);
}
Also used : ModuleContainer(org.eclipse.osgi.container.ModuleContainer) Module(org.eclipse.osgi.container.Module) ResolutionReport(org.eclipse.osgi.report.resolution.ResolutionReport) Test(org.junit.Test)

Example 57 with Module

use of org.eclipse.osgi.container.Module in project rt.equinox.framework by eclipse.

the class TestModuleContainer method testSingleton01.

@Test
public void testSingleton01() throws BundleException, IOException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    Module s1 = installDummyModule("singleton1_v1.MF", "s1_v1", container);
    Module s2 = installDummyModule("singleton1_v2.MF", "s1_v2", container);
    Module s3 = installDummyModule("singleton1_v3.MF", "s1_v3", container);
    container.resolve(null, false);
    Assert.assertFalse("Singleton v1 is resolved.", Module.RESOLVED_SET.contains(s1.getState()));
    Assert.assertFalse("Singleton v2 is resolved.", Module.RESOLVED_SET.contains(s2.getState()));
    Assert.assertTrue("Singleton v3 is not resolved.", Module.RESOLVED_SET.contains(s3.getState()));
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) ModuleContainer(org.eclipse.osgi.container.ModuleContainer) Module(org.eclipse.osgi.container.Module) Test(org.junit.Test)

Example 58 with Module

use of org.eclipse.osgi.container.Module in project rt.equinox.framework by eclipse.

the class TestModuleContainer method testEventsInstall.

@Test
public void testEventsInstall() throws BundleException, IOException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    Module c1 = installDummyModule("c1_v1.MF", "c1_v1", container);
    Module c2 = installDummyModule("c2_v1.MF", "c2_v1", container);
    Module c3 = installDummyModule("c3_v1.MF", "c3_v1", container);
    Module c4 = installDummyModule("c4_v1.MF", "c4_v1", container);
    Module c5 = installDummyModule("c5_v1.MF", "c5_v1", container);
    Module c6 = installDummyModule("c6_v1.MF", "c6_v1", container);
    Module c7 = installDummyModule("c7_v1.MF", "c7_v1", container);
    List<DummyModuleEvent> actual = adaptor.getDatabase().getModuleEvents();
    List<DummyModuleEvent> expected = Arrays.asList(new DummyModuleEvent(c1, ModuleEvent.INSTALLED, State.INSTALLED), new DummyModuleEvent(c2, ModuleEvent.INSTALLED, State.INSTALLED), new DummyModuleEvent(c3, ModuleEvent.INSTALLED, State.INSTALLED), new DummyModuleEvent(c4, ModuleEvent.INSTALLED, State.INSTALLED), new DummyModuleEvent(c5, ModuleEvent.INSTALLED, State.INSTALLED), new DummyModuleEvent(c6, ModuleEvent.INSTALLED, State.INSTALLED), new DummyModuleEvent(c7, ModuleEvent.INSTALLED, State.INSTALLED));
    Assert.assertEquals("Wrong install events.", expected, actual);
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) ModuleContainer(org.eclipse.osgi.container.ModuleContainer) Module(org.eclipse.osgi.container.Module) DummyModuleEvent(org.eclipse.osgi.tests.container.dummys.DummyModuleDatabase.DummyModuleEvent) Test(org.junit.Test)

Example 59 with Module

use of org.eclipse.osgi.container.Module in project rt.equinox.framework by eclipse.

the class TestModuleContainer method testMultiHostFragmentWithOverlapImport.

@Test
public void testMultiHostFragmentWithOverlapImport() throws BundleException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    // install an exporter
    Map<String, String> exporterManifest = new HashMap<String, String>();
    exporterManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    exporterManifest.put(Constants.BUNDLE_SYMBOLICNAME, "exporter");
    exporterManifest.put(Constants.BUNDLE_VERSION, "1.0");
    exporterManifest.put(Constants.EXPORT_PACKAGE, "exporter");
    installDummyModule(exporterManifest, "exporter", container);
    // install a fragment to the exporter
    Map<String, String> exporterFragManifest = new HashMap<String, String>();
    exporterFragManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    exporterFragManifest.put(Constants.BUNDLE_SYMBOLICNAME, "exporter.frag");
    exporterFragManifest.put(Constants.EXPORT_PACKAGE, "exporter.frag");
    exporterFragManifest.put(Constants.FRAGMENT_HOST, "exporter");
    installDummyModule(exporterFragManifest, "exporter.frag", container);
    // install a host that imports the exporter
    Map<String, String> hostManifest = new HashMap<String, String>();
    hostManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    hostManifest.put(Constants.BUNDLE_SYMBOLICNAME, "host");
    hostManifest.put(Constants.BUNDLE_VERSION, "1.0");
    hostManifest.put(Constants.IMPORT_PACKAGE, "exporter");
    installDummyModule(hostManifest, "host10", container);
    hostManifest.put(Constants.BUNDLE_VERSION, "1.1");
    installDummyModule(hostManifest, "host11", container);
    hostManifest.put(Constants.BUNDLE_VERSION, "1.2");
    installDummyModule(hostManifest, "host12", container);
    // install a fragment that also imports the exporter
    Map<String, String> hostFragManifest = new HashMap<String, String>();
    hostFragManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    hostFragManifest.put(Constants.BUNDLE_SYMBOLICNAME, "host.frag");
    hostFragManifest.put(Constants.FRAGMENT_HOST, "host");
    hostFragManifest.put(Constants.IMPORT_PACKAGE, "exporter; version=0.0");
    Module hostFrag = installDummyModule(hostFragManifest, "host.frag", container);
    ResolutionReport report = container.resolve(Arrays.asList(hostFrag), true);
    Assert.assertNull("Failed to resolve test.", report.getResolutionException());
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) ModuleContainer(org.eclipse.osgi.container.ModuleContainer) HashMap(java.util.HashMap) Module(org.eclipse.osgi.container.Module) ResolutionReport(org.eclipse.osgi.report.resolution.ResolutionReport) Test(org.junit.Test)

Example 60 with Module

use of org.eclipse.osgi.container.Module in project rt.equinox.framework by eclipse.

the class TestModuleContainer method testDynamicImport04.

@Test
public void testDynamicImport04() 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);
    Module dynamic3 = installDummyModule("dynamic2_v1.MF", "dynamic2_v1", container);
    container.resolve(Arrays.asList(systemBundle, dynamic3), true);
    ModuleWire dynamicWire = container.resolveDynamic("h1.a", dynamic3.getCurrentRevision());
    Assert.assertNull("Dynamic wire found.", dynamicWire);
    Module h1 = installDummyModule("h1_v1.MF", "h1_v1", container);
    Module f1 = installDummyModule("f1_v1.MF", "f1_v1", container);
    database.getModuleEvents();
    dynamicWire = container.resolveDynamic("h1.a", dynamic3.getCurrentRevision());
    Assert.assertNotNull("Dynamic wire not found.", dynamicWire);
    Assert.assertEquals("Wrong package found.", "h1.a", dynamicWire.getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
    Assert.assertEquals("Wrong provider for the wire found.", h1.getCurrentRevision(), dynamicWire.getProvider());
    dynamicWire = container.resolveDynamic("f1.a", dynamic3.getCurrentRevision());
    Assert.assertNotNull("Dynamic wire not found.", dynamicWire);
    Assert.assertEquals("Wrong package found.", "f1.a", dynamicWire.getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
    Assert.assertEquals("Wrong provider for the wire found.", h1.getCurrentRevision(), dynamicWire.getProvider());
    ModuleWiring h1Wiring = h1.getCurrentRevision().getWiring();
    Assert.assertNotNull("h1 wiring is null.", h1Wiring);
    ModuleWiring f1Wiring = f1.getCurrentRevision().getWiring();
    Assert.assertNotNull("f1 wiring is null.", f1Wiring);
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) ModuleWire(org.eclipse.osgi.container.ModuleWire) ModuleContainer(org.eclipse.osgi.container.ModuleContainer) ModuleWiring(org.eclipse.osgi.container.ModuleWiring) Module(org.eclipse.osgi.container.Module) DummyModuleDatabase(org.eclipse.osgi.tests.container.dummys.DummyModuleDatabase) Test(org.junit.Test)

Aggregations

Module (org.eclipse.osgi.container.Module)119 ModuleContainer (org.eclipse.osgi.container.ModuleContainer)92 Test (org.junit.Test)84 DummyContainerAdaptor (org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor)79 ResolutionReport (org.eclipse.osgi.report.resolution.ResolutionReport)36 ModuleWire (org.eclipse.osgi.container.ModuleWire)32 HashMap (java.util.HashMap)23 ArrayList (java.util.ArrayList)22 ModuleWiring (org.eclipse.osgi.container.ModuleWiring)22 ModuleRevision (org.eclipse.osgi.container.ModuleRevision)21 DummyModuleDatabase (org.eclipse.osgi.tests.container.dummys.DummyModuleDatabase)12 Generation (org.eclipse.osgi.storage.BundleInfo.Generation)10 BundleException (org.osgi.framework.BundleException)10 DummyModuleEvent (org.eclipse.osgi.tests.container.dummys.DummyModuleDatabase.DummyModuleEvent)9 ModuleRevisionBuilder (org.eclipse.osgi.container.ModuleRevisionBuilder)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 DataInputStream (java.io.DataInputStream)6 ModuleCapability (org.eclipse.osgi.container.ModuleCapability)6 DummyCollisionHook (org.eclipse.osgi.tests.container.dummys.DummyCollisionHook)6