Search in sources :

Example 26 with Module

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

the class TestModuleContainer method testSystemBundleOnDemandFragments.

@Test
public void testSystemBundleOnDemandFragments() throws BundleException, IOException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    // install the system.bundle
    Module systemBundle = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, Constants.SYSTEM_BUNDLE_SYMBOLICNAME, null, null, container);
    // install an equinox fragment
    Map<String, String> equinoxFragManifest = new HashMap<String, String>();
    equinoxFragManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    equinoxFragManifest.put(Constants.BUNDLE_SYMBOLICNAME, "equinoxFrag");
    equinoxFragManifest.put(Constants.FRAGMENT_HOST, "org.eclipse.osgi");
    Module equinoxFrag = installDummyModule(equinoxFragManifest, "equinoxFrag", container);
    // install a system.bundle fragment
    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, "system.bundle");
    Module systemFrag = installDummyModule(systemFragManifest, "systemFrag", container);
    ResolutionReport report = container.resolve(Arrays.asList(systemBundle), 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.", 2, hostWires.size());
    Set<ModuleRevision> fragmentRevisions = new HashSet(Arrays.asList(equinoxFrag.getCurrentRevision(), systemFrag.getCurrentRevision()));
    for (ModuleWire hostWire : hostWires) {
        if (!fragmentRevisions.remove(hostWire.getRequirer())) {
            Assert.fail("Unexpected fragment revision: " + hostWire.getRequirer());
        }
    }
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) 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) ModuleRevision(org.eclipse.osgi.container.ModuleRevision) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 27 with Module

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

the class TestModuleContainer method testUses1.

/*
	 * Test that a resolve process does not blow up because of one unresolvable uses constraint issue
	 */
@Test
public void testUses1() 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 uses_a = installDummyModule("uses.a.MF", "a", container);
    Module uses_b = installDummyModule("uses.b.MF", "b", container);
    Module uses_c = installDummyModule("uses.c.MF", "c", container);
    container.resolve(null, false);
    Assert.assertEquals("a should resolve.", State.RESOLVED, uses_a.getState());
    Assert.assertEquals("b should resolve.", State.RESOLVED, uses_b.getState());
    Assert.assertEquals("c should not resolve.", State.INSTALLED, uses_c.getState());
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) ModuleContainer(org.eclipse.osgi.container.ModuleContainer) Module(org.eclipse.osgi.container.Module) Test(org.junit.Test)

Example 28 with Module

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

the class TestModuleContainer method testPlatformFilter02.

@Test
public void testPlatformFilter02() throws BundleException, IOException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    String extraCapabilities = EclipsePlatformNamespace.ECLIPSE_PLATFORM_NAMESPACE + "; osgi.os=baz; osgi.arch=boz";
    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), false);
    ModuleWiring platformFilter1Wiring = platformFilter1.getCurrentRevision().getWiring();
    Assert.assertNull("platformFilter1 is 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 29 with Module

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

the class TestModuleContainer method testDynamicImportMiss01.

@Test
public void testDynamicImportMiss01() 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 dynamic1 = installDummyModule("dynamic1_v1.MF", "dynamic1_v1", container);
    container.resolve(Arrays.asList(c1, dynamic1), true);
    DummyResolverHookFactory factory = (DummyResolverHookFactory) adaptor.getResolverHookFactory();
    DummyResolverHook hook = (DummyResolverHook) factory.getHook();
    hook.getResolutionReports().clear();
    ModuleWire dynamicWire = container.resolveDynamic("org.osgi.framework", dynamic1.getCurrentRevision());
    Assert.assertNotNull("No dynamic wire found.", dynamicWire);
    Assert.assertEquals("Wrong package found.", "org.osgi.framework", dynamicWire.getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
    Assert.assertEquals("Wrong provider for the wire found.", systemBundle.getCurrentRevision(), dynamicWire.getProvider());
    Assert.assertEquals("Wrong number of reports.", 1, hook.getResolutionReports().size());
    hook.getResolutionReports().clear();
    dynamicWire = container.resolveDynamic("does.not.exist", dynamic1.getCurrentRevision());
    Assert.assertNull("Unexpected Dynamic wire found.", dynamicWire);
    Assert.assertEquals("Wrong number of reports.", 1, hook.getResolutionReports().size());
    // Try again; no report should be generated a second time
    hook.getResolutionReports().clear();
    dynamicWire = container.resolveDynamic("does.not.exist", dynamic1.getCurrentRevision());
    Assert.assertNull("Unexpected Dynamic wire found.", dynamicWire);
    Assert.assertEquals("Wrong number of reports.", 0, hook.getResolutionReports().size());
}
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) DummyResolverHookFactory(org.eclipse.osgi.tests.container.dummys.DummyResolverHookFactory) DummyResolverHook(org.eclipse.osgi.tests.container.dummys.DummyResolverHook) Test(org.junit.Test)

Example 30 with Module

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

the class TestModuleContainer method testMultiHost.

@Test
public void testMultiHost() throws BundleException, IOException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, container);
    Module h1v1 = installDummyModule("h1_v1.MF", "h1_v1", container);
    Module h1v2 = installDummyModule("h1_v2.MF", "h1_v2", container);
    Module f1v1 = installDummyModule("f1_v1.MF", "f1_v1", container);
    Module b3 = installDummyModule("b3_v1.MF", "b3_v1", container);
    ResolutionReport report = container.resolve(Arrays.asList(h1v1, h1v2, f1v1, b3), true);
    Assert.assertNull("Expected no resolution 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)

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