Search in sources :

Example 71 with Module

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

the class TestModuleContainer method testEventsRefresh.

@Test
public void testEventsRefresh() 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 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);
    container.resolve(Arrays.asList(c1, c2, c3, c4, c5, c6, c7), true);
    // throw away installed and resolved events
    database.getModuleEvents();
    container.refresh(Arrays.asList(systemBundle));
    List<DummyModuleEvent> actual = database.getModuleEvents();
    List<DummyModuleEvent> expected = new ArrayList<DummyModuleEvent>(Arrays.asList(new DummyModuleEvent(systemBundle, ModuleEvent.UNRESOLVED, State.INSTALLED), new DummyModuleEvent(c1, ModuleEvent.UNRESOLVED, State.INSTALLED), new DummyModuleEvent(c2, ModuleEvent.UNRESOLVED, State.INSTALLED), new DummyModuleEvent(c3, ModuleEvent.UNRESOLVED, State.INSTALLED), new DummyModuleEvent(c4, ModuleEvent.UNRESOLVED, State.INSTALLED), new DummyModuleEvent(c5, ModuleEvent.UNRESOLVED, State.INSTALLED), new DummyModuleEvent(c6, ModuleEvent.UNRESOLVED, State.INSTALLED), new DummyModuleEvent(c7, ModuleEvent.UNRESOLVED, State.INSTALLED), new DummyModuleEvent(systemBundle, ModuleEvent.RESOLVED, State.RESOLVED), new DummyModuleEvent(c1, ModuleEvent.RESOLVED, State.RESOLVED), new DummyModuleEvent(c2, ModuleEvent.RESOLVED, State.RESOLVED), new DummyModuleEvent(c3, ModuleEvent.RESOLVED, State.RESOLVED), new DummyModuleEvent(c4, ModuleEvent.RESOLVED, State.RESOLVED), new DummyModuleEvent(c5, ModuleEvent.RESOLVED, State.RESOLVED), new DummyModuleEvent(c6, ModuleEvent.RESOLVED, State.RESOLVED), new DummyModuleEvent(c7, ModuleEvent.RESOLVED, State.RESOLVED)));
    assertEvents(expected, actual, false);
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) ModuleContainer(org.eclipse.osgi.container.ModuleContainer) ArrayList(java.util.ArrayList) Module(org.eclipse.osgi.container.Module) DummyModuleEvent(org.eclipse.osgi.tests.container.dummys.DummyModuleDatabase.DummyModuleEvent) DummyModuleDatabase(org.eclipse.osgi.tests.container.dummys.DummyModuleDatabase) Test(org.junit.Test)

Example 72 with Module

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

the class TestModuleContainer method testUpdateCollision03.

@Test
public void testUpdateCollision03() throws BundleException, IOException {
    DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(true), Collections.<String, String>emptyMap());
    ModuleContainer container = adaptor.getContainer();
    Module b1_v1 = installDummyModule("b1_v1.MF", "b1_v1", container);
    installDummyModule("b1_v2.MF", "b1_v2", container);
    try {
        container.update(b1_v1, OSGiManifestBuilderFactory.createBuilder(getManifest("b1_v2.MF")), null);
    } catch (BundleException e) {
        Assert.assertNull("Expected to succeed update to same revision.", e);
    }
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) DummyCollisionHook(org.eclipse.osgi.tests.container.dummys.DummyCollisionHook) ModuleContainer(org.eclipse.osgi.container.ModuleContainer) BundleException(org.osgi.framework.BundleException) Module(org.eclipse.osgi.container.Module) Test(org.junit.Test)

Example 73 with Module

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

the class TestModuleContainer method testDynamicImport02.

@Test
public void testDynamicImport02() throws BundleException, IOException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    Module systemBundle = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, null, null, "osgi.ee; osgi.ee=JavaSE; version:Version=\"1.5.0\"", container);
    container.resolve(Arrays.asList(systemBundle), true);
    Module c1 = installDummyModule("c1_v1.MF", "c1_v1", container);
    Module c4 = installDummyModule("c4_v1.MF", "c4_v1", container);
    Module dynamic1 = installDummyModule("dynamic1_v1.MF", "dynamic1_v1", container);
    Module dynamic1Frag = installDummyModule("dynamic1.frag_v1.MF", "dynamic1.frag_v1", container);
    container.resolve(Arrays.asList(c1, c4, dynamic1, dynamic1Frag), true);
    ModuleWire dynamicWire = container.resolveDynamic("c1.b", dynamic1.getCurrentRevision());
    Assert.assertNotNull("No dynamic wire found.", dynamicWire);
    Assert.assertEquals("Wrong package found.", "c1.b", dynamicWire.getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
    Assert.assertEquals("Wrong provider for the wire found.", c1.getCurrentRevision(), dynamicWire.getProvider());
    dynamicWire = container.resolveDynamic("c4.a", dynamic1.getCurrentRevision());
    Assert.assertNotNull("No dynamic wire found.", dynamicWire);
    Assert.assertEquals("Wrong package found.", "c4.a", dynamicWire.getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
    Assert.assertEquals("Wrong provider for the wire found.", c4.getCurrentRevision(), dynamicWire.getProvider());
    dynamicWire = container.resolveDynamic("c4.b", dynamic1.getCurrentRevision());
    Assert.assertNotNull("No dynamic wire found.", dynamicWire);
    Assert.assertEquals("Wrong package found.", "c4.b", dynamicWire.getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
    Assert.assertEquals("Wrong provider for the wire found.", c4.getCurrentRevision(), dynamicWire.getProvider());
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) ModuleWire(org.eclipse.osgi.container.ModuleWire) ModuleContainer(org.eclipse.osgi.container.ModuleContainer) Module(org.eclipse.osgi.container.Module) Test(org.junit.Test)

Example 74 with Module

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

the class TestModuleContainer method testSplitPackageUses01.

@Test
public void testSplitPackageUses01() throws BundleException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    // install a split exporter core that substitutes
    Map<String, String> coreManifest = new HashMap<String, String>();
    coreManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    coreManifest.put(Constants.BUNDLE_SYMBOLICNAME, "core");
    coreManifest.put(Constants.EXPORT_PACKAGE, "pkg1; core=split; mandatory:=core");
    coreManifest.put(Constants.IMPORT_PACKAGE, "pkg1; core=split");
    // install a split exporter misc that requires core and substitutes
    Map<String, String> miscManifest = new HashMap<String, String>();
    miscManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    miscManifest.put(Constants.BUNDLE_SYMBOLICNAME, "misc");
    miscManifest.put(Constants.EXPORT_PACKAGE, "pkg1; misc=split; mandatory:=misc");
    miscManifest.put(Constants.REQUIRE_BUNDLE, "core");
    // install a bundle that imports core and exports pkg2 that uses pkg1 from core
    Map<String, String> importsCoreManifest = new HashMap<String, String>();
    importsCoreManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    importsCoreManifest.put(Constants.BUNDLE_SYMBOLICNAME, "importsCore");
    importsCoreManifest.put(Constants.EXPORT_PACKAGE, "pkg2; uses:=pkg1");
    importsCoreManifest.put(Constants.IMPORT_PACKAGE, "pkg1; core=split");
    // install a bundle that imports pkg2, but requires misc
    Map<String, String> requiresMiscManifest = new HashMap<String, String>();
    requiresMiscManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    requiresMiscManifest.put(Constants.BUNDLE_SYMBOLICNAME, "requiresMisc");
    requiresMiscManifest.put(Constants.IMPORT_PACKAGE, "pkg2");
    requiresMiscManifest.put(Constants.REQUIRE_BUNDLE, "misc");
    installDummyModule(coreManifest, "core", container);
    installDummyModule(miscManifest, "misc", container);
    installDummyModule(importsCoreManifest, "importsCore", container);
    Module requireMisc = installDummyModule(requiresMiscManifest, "requireMisc", container);
    ResolutionReport report = container.resolve(Arrays.asList(requireMisc), true);
    Assert.assertNull("Failed to resolve test.", report.getResolutionException());
    // now test by resolving the split exporters first
    adaptor = createDummyAdaptor();
    container = adaptor.getContainer();
    installDummyModule(coreManifest, "core", container);
    Module misc = installDummyModule(miscManifest, "misc", container);
    report = container.resolve(Arrays.asList(misc), true);
    Assert.assertNull("Failed to resolve test.", report.getResolutionException());
    installDummyModule(importsCoreManifest, "importsCore", container);
    requireMisc = installDummyModule(requiresMiscManifest, "requireMisc", container);
    report = container.resolve(Arrays.asList(requireMisc), true);
    Assert.assertNull("Failed to resolve test.", report.getResolutionException());
    // now test by resolving the split exporters first with a real substitution
    adaptor = createDummyAdaptor();
    container = adaptor.getContainer();
    // install a exporter that substitutes core's export
    Map<String, String> substitutesCoreManifest = new HashMap<String, String>();
    substitutesCoreManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    substitutesCoreManifest.put(Constants.BUNDLE_SYMBOLICNAME, "substitutesCore");
    substitutesCoreManifest.put(Constants.EXPORT_PACKAGE, "pkg1; substitutesCore=true; mandatory:=substitutesCore");
    // change core's import to force it to the substitute
    coreManifest.put(Constants.IMPORT_PACKAGE, "pkg1; substitutesCore=true");
    importsCoreManifest.put(Constants.IMPORT_PACKAGE, "pkg1; substitutesCore=true");
    installDummyModule(substitutesCoreManifest, "substitutesCore", container);
    installDummyModule(coreManifest, "core", container);
    misc = installDummyModule(miscManifest, "misc", container);
    report = container.resolve(Arrays.asList(misc), true);
    Assert.assertNull("Failed to resolve test.", report.getResolutionException());
    installDummyModule(importsCoreManifest, "importsCore", container);
    requireMisc = installDummyModule(requiresMiscManifest, "requireMisc", container);
    report = container.resolve(Arrays.asList(requireMisc), true);
    Assert.assertNull("Failed to resolve test.", report.getResolutionException());
    // not test by doing a full resolve with real substitution
    adaptor = createDummyAdaptor();
    container = adaptor.getContainer();
    installDummyModule(substitutesCoreManifest, "substitutesCore", container);
    installDummyModule(coreManifest, "core", container);
    installDummyModule(miscManifest, "misc", container);
    installDummyModule(importsCoreManifest, "importsCore", container);
    requireMisc = installDummyModule(requiresMiscManifest, "requireMisc", container);
    report = container.resolve(Arrays.asList(requireMisc), 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 75 with Module

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

the class TestModuleContainer method testPlatformFilter01.

@Test
public void testPlatformFilter01() throws BundleException, IOException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    String extraCapabilities = EclipsePlatformNamespace.ECLIPSE_PLATFORM_NAMESPACE + "; osgi.os=foo; osgi.arch=bar";
    installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, null, null, extraCapabilities, container);
    container.resolve(null, false);
    Module platformFilter1 = installDummyModule("platformFilter1_v1.MF", "ee1", container);
    container.resolve(Arrays.asList(platformFilter1), true);
    ModuleWiring platformFilter1Wiring = platformFilter1.getCurrentRevision().getWiring();
    Assert.assertNotNull("platformFilter1 is not resolved", platformFilter1Wiring);
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) ModuleContainer(org.eclipse.osgi.container.ModuleContainer) ModuleWiring(org.eclipse.osgi.container.ModuleWiring) 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