Search in sources :

Example 16 with ResolutionReport

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

the class TestModuleContainer method testSimpleUnResolveable.

@Test
public void testSimpleUnResolveable() throws BundleException, IOException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    Module systemBundle = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, container);
    container.resolve(Arrays.asList(systemBundle), true);
    Module c7 = installDummyModule("c7_v1.MF", "c7", container);
    installDummyModule("c6_v1.MF", "c6", container);
    ResolutionReport report = container.resolve(Arrays.asList(c7), true);
    Assert.assertNotNull("Expected a resolution exception", report.getResolutionException());
    // Should resolve now
    installDummyModule("c4_v1.MF", "c4", container);
    report = container.resolve(Arrays.asList(c7), true);
    Assert.assertNull("Unexpected resoltuion exception", report.getResolutionException());
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) ModuleContainer(org.eclipse.osgi.container.ModuleContainer) Module(org.eclipse.osgi.container.Module) ResolutionReport(org.eclipse.osgi.report.resolution.ResolutionReport) Test(org.junit.Test)

Example 17 with ResolutionReport

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

the class TestModuleContainer method testSystemBundleFragmentsNonPayloadRequirements.

@Test
public void testSystemBundleFragmentsNonPayloadRequirements() throws BundleException, IOException {
    // install the system.bundle
    Module systemBundle = createContainerWithSystemBundle(true);
    ModuleContainer container = systemBundle.getContainer();
    // install an system.bundle fragment that imports framework package
    Map<String, String> systemFragManifest = new HashMap<String, String>();
    systemFragManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    systemFragManifest.put(Constants.BUNDLE_SYMBOLICNAME, "systemFrag");
    systemFragManifest.put(Constants.FRAGMENT_HOST, Constants.SYSTEM_BUNDLE_SYMBOLICNAME);
    systemFragManifest.put(Constants.REQUIRE_CAPABILITY, "osgi.ee; filter:=\"(osgi.ee=JavaSE)\"");
    Module systemFrag = installDummyModule(systemFragManifest, "systemFrag", container);
    ResolutionReport report = container.resolve(Arrays.asList(systemFrag), true);
    Assert.assertNull("Failed to resolve system.bundle.", report.getResolutionException());
    List<ModuleWire> hostWires = systemBundle.getCurrentRevision().getWiring().getProvidedModuleWires(HostNamespace.HOST_NAMESPACE);
    assertEquals("Wrong number of fragments.", 1, hostWires.size());
    Assert.assertEquals("Unexpected fragment revision: " + hostWires, systemFrag.getCurrentRevision(), hostWires.get(0).getRequirer());
    List<ModuleWire> systemBundleRequiredWires = systemBundle.getCurrentRevision().getWiring().getRequiredModuleWires(null);
    assertEquals("No required wires expected.", 0, systemBundleRequiredWires.size());
    List<ModuleWire> fragRequiredWires = systemFrag.getCurrentRevision().getWiring().getRequiredModuleWires(null);
    assertEquals("Wrong number of required wires.", 2, fragRequiredWires.size());
    assertWires(fragRequiredWires, systemBundle.getCurrentRevision().getWiring().getProvidedModuleWires(null));
}
Also used : ModuleWire(org.eclipse.osgi.container.ModuleWire) 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 18 with ResolutionReport

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

the class ResolutionReportTest method assertResolutionSucceeds.

private void assertResolutionSucceeds(ModuleContainer container, Collection<Module> modules) {
    ResolutionReport report = container.resolve(modules, false);
    assertNull("Unexpected resolution exception", report.getResolutionException());
}
Also used : ResolutionReport(org.eclipse.osgi.report.resolution.ResolutionReport)

Example 19 with ResolutionReport

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

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

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