Search in sources :

Example 36 with Module

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

the class TestModuleContainer method testMultiCardinalityUses.

@Test
public void testMultiCardinalityUses() 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 p5v100 = installDummyModule("p5_v100.MF", "p5_v100", container);
    Module p5v101 = installDummyModule("p5_v101.MF", "p5_v101", container);
    Module p5v110 = installDummyModule("p5_v110.MF", "p5_v110", container);
    Module p5v111 = installDummyModule("p5_v111.MF", "p5_v111", container);
    installDummyModule("p6_v100.MF", "p6_v100", container);
    installDummyModule("p6_v110.MF", "p6_v110", container);
    installDummyModule("p7_v100.MF", "p7_v100", container);
    installDummyModule("p7_v110.MF", "p7_v110", container);
    container.resolve(null, false);
    Module c6v100 = installDummyModule("c6_v100.MF", "c6_v100", container);
    Module c6v110 = installDummyModule("c6_v110.MF", "c6_v110", container);
    Module c6v130 = installDummyModule("c6_v130.MF", "c6_v130", container);
    Module c6v140 = installDummyModule("c6_v140.MF", "c6_v140", container);
    Module c6v150 = installDummyModule("c6_v150.MF", "c6_v150", container);
    Module c6v170 = installDummyModule("c6_v170.MF", "c6_v170", container);
    // Module c6v180 = installDummyModule("c6_v180.MF", "c6_v180", container);
    // Module c6v120 = installDummyModule("c6_v120.MF", "c6_v120", container);
    container.resolve(null, false);
    final String namespace5 = "namespace.5";
    List<ModuleWire> p5v100Provided = p5v100.getCurrentRevision().getWiring().getProvidedModuleWires(namespace5);
    List<ModuleWire> p5v101Provided = p5v101.getCurrentRevision().getWiring().getProvidedModuleWires(namespace5);
    List<ModuleWire> p5v110Provided = p5v110.getCurrentRevision().getWiring().getProvidedModuleWires(namespace5);
    List<ModuleWire> p5v111Provided = p5v111.getCurrentRevision().getWiring().getProvidedModuleWires(namespace5);
    ModuleWiring c6v100Wiring = c6v100.getCurrentRevision().getWiring();
    List<ModuleWire> c6v100Required = c6v100Wiring.getRequiredModuleWires(namespace5);
    Assert.assertEquals("Wrong number of capabilities", 2, c6v100Required.size());
    assertWires(c6v100Required, p5v100Provided, p5v101Provided);
    ModuleWiring c6v110Wiring = c6v110.getCurrentRevision().getWiring();
    List<ModuleWire> c6v110Required = c6v110Wiring.getRequiredModuleWires(namespace5);
    Assert.assertEquals("Wrong number of capabilities", 2, c6v110Required.size());
    assertWires(c6v110Required, p5v100Provided, p5v101Provided);
    ModuleWiring c6v130Wiring = c6v130.getCurrentRevision().getWiring();
    List<ModuleWire> c6v130Required = c6v130Wiring.getRequiredModuleWires(namespace5);
    Assert.assertEquals("Wrong number of capabilities", 2, c6v130Required.size());
    assertWires(c6v130Required, p5v100Provided, p5v101Provided);
    ModuleWiring c6v140Wiring = c6v140.getCurrentRevision().getWiring();
    List<ModuleWire> c6v140Required = c6v140Wiring.getRequiredModuleWires(namespace5);
    Assert.assertEquals("Wrong number of capabilities", 2, c6v140Required.size());
    assertWires(c6v140Required, p5v100Provided, p5v101Provided);
    ModuleWiring c6v150Wiring = c6v150.getCurrentRevision().getWiring();
    List<ModuleWire> c6v150Required = c6v150Wiring.getRequiredModuleWires(namespace5);
    Assert.assertEquals("Wrong number of capabilities", 2, c6v150Required.size());
    assertWires(c6v150Required, p5v110Provided, p5v111Provided);
    ModuleWiring c6v170Wiring = c6v170.getCurrentRevision().getWiring();
    List<ModuleWire> c6v170Required = c6v170Wiring.getRequiredModuleWires(namespace5);
    Assert.assertEquals("Wrong number of capabilities", 2, c6v170Required.size());
    assertWires(c6v170Required, p5v110Provided, p5v111Provided);
    Module c6v160 = installDummyModule("c6_v160.MF", "c6_v160", container);
    container.resolve(null, false);
    Assert.assertNull("Bundle should not be resolved: " + c6v160, c6v160.getCurrentRevision().getWiring());
    container.uninstall(c6v160);
    Module c6v180 = installDummyModule("c6_v180.MF", "c6_v180", container);
    container.resolve(null, false);
    Assert.assertNull("Bundle should not be resolved: " + c6v180, c6v180.getCurrentRevision().getWiring());
    container.uninstall(c6v180);
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) ModuleWire(org.eclipse.osgi.container.ModuleWire) ModuleContainer(org.eclipse.osgi.container.ModuleContainer) ModuleWiring(org.eclipse.osgi.container.ModuleWiring) Module(org.eclipse.osgi.container.Module) Test(org.junit.Test)

Example 37 with Module

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

the class TestModuleContainer method doTestUses5.

public void doTestUses5(String kManifest) 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_k = installDummyModule(kManifest, "k", container);
    Module uses_l = installDummyModule("uses.l.MF", "l", container);
    Module uses_m_conflict1 = installDummyModule("uses.m.conflict1.MF", "m.conflict1", container);
    Module uses_m_conflict2 = installDummyModule("uses.m.conflict2.MF", "m.conflict2", container);
    container.resolve(null, false);
    Assert.assertEquals("k should resolve.", State.RESOLVED, uses_k.getState());
    Assert.assertEquals("l should resolve.", State.RESOLVED, uses_l.getState());
    Assert.assertEquals("m.conflict1 should resolve.", State.RESOLVED, uses_m_conflict1.getState());
    Assert.assertEquals("m.conflict2 should resolve.", State.RESOLVED, uses_m_conflict2.getState());
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) ModuleContainer(org.eclipse.osgi.container.ModuleContainer) Module(org.eclipse.osgi.container.Module)

Example 38 with Module

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

the class TestModuleContainer method testDynamicImport07.

@Test
public void testDynamicImport07() 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 dynamic3 = installDummyModule("dynamic2_v1.MF", "dynamic2_v1", container);
    Assert.assertNull("Expected no resolution exception.", container.resolve(Arrays.asList(systemBundle, dynamic3), true).getResolutionException());
    installDummyModule("c6_v1.MF", "c6_v1", container);
    ModuleWire dynamicWire = container.resolveDynamic("c6", dynamic3.getCurrentRevision());
    Assert.assertNull("Dynamic wire found.", dynamicWire);
}
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 39 with Module

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

the class TestModuleContainer method testUses3.

/*
	 * Test that split packages are handled ok with uses constraints
	 */
@Test
public void testUses3() 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_e = installDummyModule("uses.e.MF", "e", container);
    Module uses_f = installDummyModule("uses.f.MF", "f", container);
    Module uses_g = installDummyModule("uses.g.MF", "g", 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("e should resolve.", State.RESOLVED, uses_e.getState());
    Assert.assertEquals("f should resolve.", State.RESOLVED, uses_f.getState());
    Assert.assertEquals("g should not resolve.", State.INSTALLED, uses_g.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 40 with Module

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

the class TestModuleContainer method testMultipleSystemBundleFragmentsWithSameName.

@Test
public void testMultipleSystemBundleFragmentsWithSameName() throws BundleException, IOException {
    // install the system.bundle
    Module systemBundle = createContainerWithSystemBundle(true);
    ModuleContainer container = systemBundle.getContainer();
    // install multiple versions of the same fragment
    Map<String, String> systemFragManifest1 = new HashMap<String, String>();
    systemFragManifest1.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    systemFragManifest1.put(Constants.BUNDLE_SYMBOLICNAME, "systemFrag");
    systemFragManifest1.put(Constants.BUNDLE_VERSION, "1.0");
    systemFragManifest1.put(Constants.FRAGMENT_HOST, Constants.SYSTEM_BUNDLE_SYMBOLICNAME);
    Module systemFrag1 = installDummyModule(systemFragManifest1, "systemFrag1", container);
    // first attempt to resolve the lowest version before installing the others
    ResolutionReport report = container.resolve(Arrays.asList(systemFrag1), true);
    Assert.assertNull("Unexpected failure message", report.getResolutionException());
    List<ModuleWire> hostWires = systemBundle.getCurrentRevision().getWiring().getProvidedModuleWires(HostNamespace.HOST_NAMESPACE);
    assertEquals("Wrong number of fragments.", 1, hostWires.size());
    List<ModuleWire> systemFrag1HostWires = systemFrag1.getCurrentRevision().getWiring().getRequiredModuleWires(HostNamespace.HOST_NAMESPACE);
    assertWires(systemFrag1HostWires, hostWires);
    Map<String, String> systemFragManifest2 = new HashMap<String, String>();
    systemFragManifest2.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    systemFragManifest2.put(Constants.BUNDLE_SYMBOLICNAME, "systemFrag");
    systemFragManifest2.put(Constants.BUNDLE_VERSION, "2.0");
    systemFragManifest2.put(Constants.FRAGMENT_HOST, Constants.SYSTEM_BUNDLE_SYMBOLICNAME);
    Module systemFrag2 = installDummyModule(systemFragManifest2, "systemFrag2", container);
    Map<String, String> systemFragManifest3 = new HashMap<String, String>();
    systemFragManifest3.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    systemFragManifest3.put(Constants.BUNDLE_SYMBOLICNAME, "systemFrag");
    systemFragManifest3.put(Constants.BUNDLE_VERSION, "3.0");
    systemFragManifest3.put(Constants.FRAGMENT_HOST, Constants.SYSTEM_BUNDLE_SYMBOLICNAME);
    Module systemFrag3 = installDummyModule(systemFragManifest3, "systemFrag3", container);
    report = container.resolve(Arrays.asList(systemFrag2), true);
    Assert.assertNotNull("Expected failure message", report.getResolutionException());
    report = container.resolve(Arrays.asList(systemFrag3), true);
    Assert.assertNotNull("Expected failure message", report.getResolutionException());
    hostWires = systemBundle.getCurrentRevision().getWiring().getProvidedModuleWires(HostNamespace.HOST_NAMESPACE);
    assertEquals("Wrong number of fragments.", 1, hostWires.size());
    systemFrag1HostWires = systemFrag1.getCurrentRevision().getWiring().getRequiredModuleWires(HostNamespace.HOST_NAMESPACE);
    assertWires(systemFrag1HostWires, hostWires);
    // uninstall the fragments so we can start over
    container.uninstall(systemFrag1);
    container.uninstall(systemFrag2);
    container.uninstall(systemFrag3);
    // refresh the system bundle to get only it resolved
    report = container.refresh(Collections.singleton(systemBundle));
    Assert.assertNull("Unexpected failure message", report.getResolutionException());
    hostWires = systemBundle.getCurrentRevision().getWiring().getProvidedModuleWires(HostNamespace.HOST_NAMESPACE);
    assertEquals("Wrong number of fragments.", 0, hostWires.size());
    // install the fragments again
    systemFrag1 = installDummyModule(systemFragManifest1, "systemFrag1", container);
    systemFrag2 = installDummyModule(systemFragManifest2, "systemFrag2", container);
    systemFrag3 = installDummyModule(systemFragManifest3, "systemFrag3", container);
    report = container.resolve(Arrays.asList(systemFrag1), true);
    Assert.assertNotNull("Expected failure message", report.getResolutionException());
    report = container.resolve(Arrays.asList(systemFrag2), true);
    Assert.assertNotNull("Expected failure message", report.getResolutionException());
    report = container.resolve(Arrays.asList(systemFrag3), true);
    Assert.assertNull("Unexpected failure message", report.getResolutionException());
    hostWires = systemBundle.getCurrentRevision().getWiring().getProvidedModuleWires(HostNamespace.HOST_NAMESPACE);
    List<ModuleWire> systemFrag3HostWires = systemFrag3.getCurrentRevision().getWiring().getRequiredModuleWires(HostNamespace.HOST_NAMESPACE);
    assertWires(systemFrag3HostWires, hostWires);
}
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)

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