Search in sources :

Example 21 with ResolutionReport

use of org.eclipse.osgi.report.resolution.ResolutionReport 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 22 with ResolutionReport

use of org.eclipse.osgi.report.resolution.ResolutionReport 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 23 with ResolutionReport

use of org.eclipse.osgi.report.resolution.ResolutionReport in project rt.equinox.framework by eclipse.

the class ResolutionReportTest method testResolutionReportEntryFilteredByResolverHook.

@Test
public void testResolutionReportEntryFilteredByResolverHook() throws Exception {
    DummyResolverHook hook = new DummyResolverHook() {

        @Override
        public void filterResolvable(Collection<BundleRevision> candidates) {
            candidates.clear();
        }
    };
    DummyContainerAdaptor adaptor = createDummyAdaptor(hook);
    ModuleContainer container = adaptor.getContainer();
    Module module = installDummyModule("resolution.report.a.MF", "resolution.report.a", container);
    assertResolutionDoesNotSucceed(container, Arrays.asList(module));
    ResolutionReport report = hook.getResolutionReports().get(0);
    Map<Resource, List<ResolutionReport.Entry>> resourceToEntries = report.getEntries();
    assertResolutionReportEntriesSize(resourceToEntries, 1);
    List<ResolutionReport.Entry> entries = resourceToEntries.get(module.getCurrentRevision());
    assertResolutionReportEntriesSize(entries, 1);
    ResolutionReport.Entry entry = entries.get(0);
    assertResolutionReportEntryTypeFilteredByResolverHook(entry.getType());
    assertResolutionReportEntryDataNull(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 24 with ResolutionReport

use of org.eclipse.osgi.report.resolution.ResolutionReport in project rt.equinox.framework by eclipse.

the class ResolutionReportTest method assertResolutionDoesNotSucceed.

// TODO Need to test both mandatory and optional triggers.
private void assertResolutionDoesNotSucceed(ModuleContainer container, Collection<Module> modules) {
    ResolutionReport report = container.resolve(modules, true);
    assertNotNull("Resolution should not have succeeded", report.getResolutionException());
}
Also used : ResolutionReport(org.eclipse.osgi.report.resolution.ResolutionReport)

Example 25 with ResolutionReport

use of org.eclipse.osgi.report.resolution.ResolutionReport in project rt.equinox.framework by eclipse.

the class ResolutionReportTest method testResolutionReportEntrySingletonSelectionLowestVersionResolved.

@Test
public void testResolutionReportEntrySingletonSelectionLowestVersionResolved() 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);
    container.resolve(Arrays.asList(resolutionReporta), true);
    clearResolutionReports(hook);
    Module resolutionReportaV1 = installDummyModule("resolution.report.a.v1.MF", "resolution.report.a.v1", container);
    assertResolutionDoesNotSucceed(container, Arrays.asList(resolutionReportaV1));
    ResolutionReport report = hook.getResolutionReports().get(0);
    Map<Resource, List<ResolutionReport.Entry>> resourceToEntries = report.getEntries();
    assertResolutionReportEntriesSize(resourceToEntries, 1);
    List<ResolutionReport.Entry> entries = resourceToEntries.get(resolutionReportaV1.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)

Aggregations

ResolutionReport (org.eclipse.osgi.report.resolution.ResolutionReport)42 Module (org.eclipse.osgi.container.Module)37 ModuleContainer (org.eclipse.osgi.container.ModuleContainer)36 Test (org.junit.Test)33 DummyContainerAdaptor (org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor)23 HashMap (java.util.HashMap)22 ModuleWire (org.eclipse.osgi.container.ModuleWire)13 ModuleWiring (org.eclipse.osgi.container.ModuleWiring)6 ArrayList (java.util.ArrayList)4 BundleRequirement (org.osgi.framework.wiring.BundleRequirement)4 BundleException (org.osgi.framework.BundleException)3 HashSet (java.util.HashSet)2 ExecutorService (java.util.concurrent.ExecutorService)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 ModuleRevision (org.eclipse.osgi.container.ModuleRevision)2 DummyCollisionHook (org.eclipse.osgi.tests.container.dummys.DummyCollisionHook)2 DummyContainerEvent (org.eclipse.osgi.tests.container.dummys.DummyModuleDatabase.DummyContainerEvent)2 BundleCapability (org.osgi.framework.wiring.BundleCapability)2 ResolutionException (org.osgi.service.resolver.ResolutionException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1