Search in sources :

Example 46 with ModuleContainer

use of org.eclipse.osgi.container.ModuleContainer 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 47 with ModuleContainer

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

the class PlatformAdminImpl method createSystemState.

private State createSystemState() {
    State state = factory.createState(true);
    StateConverter converter = new StateConverter(state);
    ModuleDatabase database = equinoxContainer.getStorage().getModuleDatabase();
    database.readLock();
    try {
        ModuleContainer container = equinoxContainer.getStorage().getModuleContainer();
        List<Module> modules = equinoxContainer.getStorage().getModuleContainer().getModules();
        for (Module module : modules) {
            ModuleRevision current = module.getCurrentRevision();
            BundleDescription description = converter.createDescription(current);
            state.addBundle(description);
        }
        state.setPlatformProperties(asDictionary(equinoxContainer.getConfiguration().getInitialConfig()));
        synchronizer = new PlatformBundleListener(state, converter, database, container);
        state.setResolverHookFactory(synchronizer);
        bc.addBundleListener(synchronizer);
        bc.addFrameworkListener(synchronizer);
        state.resolve();
        state.setTimeStamp(database.getRevisionsTimestamp());
    } finally {
        database.readUnlock();
    }
    return state;
}
Also used : ModuleContainer(org.eclipse.osgi.container.ModuleContainer) State(org.eclipse.osgi.service.resolver.State) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription) ModuleDatabase(org.eclipse.osgi.container.ModuleDatabase) Module(org.eclipse.osgi.container.Module) ModuleRevision(org.eclipse.osgi.container.ModuleRevision)

Example 48 with ModuleContainer

use of org.eclipse.osgi.container.ModuleContainer 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 49 with ModuleContainer

use of org.eclipse.osgi.container.ModuleContainer 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)

Example 50 with ModuleContainer

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

the class ResolutionReportTest method testResolutionReportEntryMissingCapability.

@Test
public void testResolutionReportEntryMissingCapability() throws Exception {
    DummyResolverHook hook = new DummyResolverHook();
    DummyContainerAdaptor adaptor = createDummyAdaptor(hook);
    ModuleContainer container = adaptor.getContainer();
    Module resolutionReportB = installDummyModule("resolution.report.b.MF", "resolution.report.b", container);
    assertResolutionDoesNotSucceed(container, Arrays.asList(resolutionReportB));
    ResolutionReport report = hook.getResolutionReports().get(0);
    Map<Resource, List<ResolutionReport.Entry>> resourceToEntries = report.getEntries();
    assertResolutionReportEntriesSize(resourceToEntries, 1);
    List<ResolutionReport.Entry> entries = resourceToEntries.get(resolutionReportB.getCurrentRevision());
    assertResolutionReportEntriesSize(entries, 1);
    ResolutionReport.Entry entry = entries.get(0);
    assertResolutionReportEntryTypeMissingCapability(entry.getType());
    assertResolutionReportEntryDataMissingCapability(entry.getData(), "osgi.wiring.package", "resolution.report.a");
}
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

ModuleContainer (org.eclipse.osgi.container.ModuleContainer)95 Module (org.eclipse.osgi.container.Module)92 Test (org.junit.Test)87 DummyContainerAdaptor (org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor)80 ResolutionReport (org.eclipse.osgi.report.resolution.ResolutionReport)36 ModuleWire (org.eclipse.osgi.container.ModuleWire)31 HashMap (java.util.HashMap)24 ModuleWiring (org.eclipse.osgi.container.ModuleWiring)20 ArrayList (java.util.ArrayList)15 DummyModuleDatabase (org.eclipse.osgi.tests.container.dummys.DummyModuleDatabase)12 ModuleRevision (org.eclipse.osgi.container.ModuleRevision)9 DummyModuleEvent (org.eclipse.osgi.tests.container.dummys.DummyModuleDatabase.DummyModuleEvent)9 DummyCollisionHook (org.eclipse.osgi.tests.container.dummys.DummyCollisionHook)7 BundleException (org.osgi.framework.BundleException)7 BundleRequirement (org.osgi.framework.wiring.BundleRequirement)6 DummyContainerEvent (org.eclipse.osgi.tests.container.dummys.DummyModuleDatabase.DummyContainerEvent)5 BundleCapability (org.osgi.framework.wiring.BundleCapability)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 ModuleCapability (org.eclipse.osgi.container.ModuleCapability)4 DummyResolverHookFactory (org.eclipse.osgi.tests.container.dummys.DummyResolverHookFactory)4