Search in sources :

Example 56 with DummyContainerAdaptor

use of org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor 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 57 with DummyContainerAdaptor

use of org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor 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 58 with DummyContainerAdaptor

use of org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor 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 59 with DummyContainerAdaptor

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

Example 60 with DummyContainerAdaptor

use of org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor in project rt.equinox.framework by eclipse.

the class TestModuleContainer method testUpdateCollision02.

@Test
public void testUpdateCollision02() throws BundleException, IOException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    Module b1_v1 = installDummyModule("b1_v1.MF", "b1_v1", container);
    try {
        container.update(b1_v1, OSGiManifestBuilderFactory.createBuilder(getManifest("b1_v1.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) ModuleContainer(org.eclipse.osgi.container.ModuleContainer) BundleException(org.osgi.framework.BundleException) Module(org.eclipse.osgi.container.Module) Test(org.junit.Test)

Aggregations

DummyContainerAdaptor (org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor)85 ModuleContainer (org.eclipse.osgi.container.ModuleContainer)80 Module (org.eclipse.osgi.container.Module)79 Test (org.junit.Test)73 ModuleWire (org.eclipse.osgi.container.ModuleWire)25 ResolutionReport (org.eclipse.osgi.report.resolution.ResolutionReport)23 ModuleWiring (org.eclipse.osgi.container.ModuleWiring)20 HashMap (java.util.HashMap)18 ArrayList (java.util.ArrayList)15 DummyModuleDatabase (org.eclipse.osgi.tests.container.dummys.DummyModuleDatabase)12 ByteArrayOutputStream (java.io.ByteArrayOutputStream)9 DummyModuleEvent (org.eclipse.osgi.tests.container.dummys.DummyModuleDatabase.DummyModuleEvent)9 ByteArrayInputStream (java.io.ByteArrayInputStream)8 DataInputStream (java.io.DataInputStream)8 DataOutputStream (java.io.DataOutputStream)8 ModuleRevision (org.eclipse.osgi.container.ModuleRevision)8 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