Search in sources :

Example 51 with Module

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

the class AbstractTest method installDummyModule.

protected Module installDummyModule(String manifestFile, String location, String alias, String extraExports, String extraCapabilities, ModuleContainer container) throws BundleException, IOException {
    Map<String, String> manifest = getManifest(manifestFile);
    ModuleRevisionBuilder builder = OSGiManifestBuilderFactory.createBuilder(manifest, alias, extraExports, extraCapabilities);
    Module system = container.getModule(0);
    return container.install(system, location, builder, null);
}
Also used : ModuleRevisionBuilder(org.eclipse.osgi.container.ModuleRevisionBuilder) Module(org.eclipse.osgi.container.Module)

Example 52 with Module

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

the class ResolutionReportTest method testResolutionReportEntryUnresolvedProvider02.

@Test
public void testResolutionReportEntryUnresolvedProvider02() throws Exception {
    DummyResolverHook hook = new DummyResolverHook();
    DummyContainerAdaptor adaptor = createDummyAdaptor(hook);
    ModuleContainer container = adaptor.getContainer();
    Module resolutionReportE = installDummyModule("resolution.report.e.MF", "resolution.report.e", container);
    Module resolutionReportF = installDummyModule("resolution.report.f.MF", "resolution.report.f", container);
    Module resolutionReportG = installDummyModule("resolution.report.g.MF", "resolution.report.g", container);
    assertResolutionSucceeds(container, Arrays.asList(resolutionReportG, resolutionReportE, resolutionReportF));
    ResolutionReport report = hook.getResolutionReports().get(0);
    Map<Resource, List<ResolutionReport.Entry>> resourceToEntries = report.getEntries();
    assertResolutionReportEntriesSize(resourceToEntries, 2);
    List<ResolutionReport.Entry> entries = resourceToEntries.get(resolutionReportG.getCurrentRevision());
    assertResolutionReportEntriesSize(entries, 1);
    ResolutionReport.Entry entry = entries.get(0);
    assertResolutionReportEntryTypeUnresolvedProvider(entry.getType());
    assertResolutionReportEntryDataUnresolvedProvider(entry.getData(), new UnresolvedProviderEntryBuilder().requirement(resolutionReportG.getCurrentRevision().getRequirements(PackageNamespace.PACKAGE_NAMESPACE).get(1)).capability(resolutionReportF.getCurrentRevision().getCapabilities(PackageNamespace.PACKAGE_NAMESPACE).get(0)).build());
    entries = resourceToEntries.get(resolutionReportF.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 53 with Module

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

the class ResolutionReportTest method testResolutionReportEntrySingletonSelectionNoneResolved.

@Test
public void testResolutionReportEntrySingletonSelectionNoneResolved() throws Exception {
    DummyResolverHook hook = new DummyResolverHook();
    DummyContainerAdaptor adaptor = createDummyAdaptor(hook);
    ModuleContainer container = adaptor.getContainer();
    Module resolutionReporta = installDummyModule("resolution.report.a.MF", "resolution.report.a", container);
    Module resolutionReportaV1 = installDummyModule("resolution.report.a.v1.MF", "resolution.report.a.v1", container);
    assertResolutionDoesNotSucceed(container, Arrays.asList(resolutionReporta, resolutionReportaV1));
    ResolutionReport report = hook.getResolutionReports().get(0);
    Map<Resource, List<ResolutionReport.Entry>> resourceToEntries = report.getEntries();
    assertResolutionReportEntriesSize(resourceToEntries, 1);
    List<ResolutionReport.Entry> entries = resourceToEntries.get(resolutionReporta.getCurrentRevision());
    assertResolutionReportEntriesSize(entries, 1);
    ResolutionReport.Entry entry = entries.get(0);
    assertResolutionReportEntryTypeSingletonSelection(entry.getType());
    assertResolutionReportEntryDataNotNull(entry.getData());
}
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 54 with Module

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

the class ResolutionReportTest method testResolutionReportEntrySingletonSelectionHighestVersionResolved.

@Test
public void testResolutionReportEntrySingletonSelectionHighestVersionResolved() throws Exception {
    DummyResolverHook hook = new DummyResolverHook();
    DummyContainerAdaptor adaptor = createDummyAdaptor(hook);
    ModuleContainer container = adaptor.getContainer();
    Module resolutionReporta = installDummyModule("resolution.report.a.MF", "resolution.report.a", container);
    Module resolutionReportaV1 = installDummyModule("resolution.report.a.v1.MF", "resolution.report.a.v1", container);
    container.resolve(Arrays.asList(resolutionReportaV1), true);
    clearResolutionReports(hook);
    assertResolutionDoesNotSucceed(container, Arrays.asList(resolutionReporta));
    ResolutionReport report = hook.getResolutionReports().get(0);
    Map<Resource, List<ResolutionReport.Entry>> resourceToEntries = report.getEntries();
    assertResolutionReportEntriesSize(resourceToEntries, 1);
    List<ResolutionReport.Entry> entries = resourceToEntries.get(resolutionReporta.getCurrentRevision());
    assertResolutionReportEntriesSize(entries, 1);
    ResolutionReport.Entry entry = entries.get(0);
    assertResolutionReportEntryTypeSingletonSelection(entry.getType());
    assertResolutionReportEntryDataNotNull(entry.getData());
}
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 55 with Module

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

the class ResolutionReportTest method testResolutionReportListenerModule.

@Test
public void testResolutionReportListenerModule() throws Exception {
    DummyResolverHook hook = new DummyResolverHook();
    DummyContainerAdaptor adaptor = createDummyAdaptor(hook);
    ModuleContainer container = adaptor.getContainer();
    Module systemBundle = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, container);
    container.resolve(Arrays.asList(systemBundle), true);
    assertEquals("No resolution report listener callback", 1, hook.getResolutionReports().size());
    assertNotNull("Resolution report was null", hook.getResolutionReports().get(0));
}
Also used : ModuleContainer(org.eclipse.osgi.container.ModuleContainer) Module(org.eclipse.osgi.container.Module) 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