Search in sources :

Example 11 with ModuleWiring

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

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

the class TestModuleContainer method testDynamicImport06.

@Test
public void testDynamicImport06() 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);
    container.resolve(Arrays.asList(systemBundle, dynamic3), true);
    Module f1 = installDummyModule("f1_v1.MF", "f1_v1", container);
    ModuleWire dynamicWire;
    dynamicWire = container.resolveDynamic("h1.a", dynamic3.getCurrentRevision());
    Assert.assertNull("Dynamic wire found.", dynamicWire);
    dynamicWire = container.resolveDynamic("f1.a", dynamic3.getCurrentRevision());
    Assert.assertNull("Dynamic wire found.", dynamicWire);
    Module h1 = installDummyModule("h1_v1.MF", "h1_v1", container);
    dynamicWire = container.resolveDynamic("h1.a", dynamic3.getCurrentRevision());
    Assert.assertNotNull("Dynamic wire not found.", dynamicWire);
    Assert.assertEquals("Wrong package found.", "h1.a", dynamicWire.getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
    Assert.assertEquals("Wrong host revision found.", h1.getCurrentRevision(), dynamicWire.getProvider());
    dynamicWire = container.resolveDynamic("f1.a", dynamic3.getCurrentRevision());
    Assert.assertNotNull("Dynamic wire not found.", dynamicWire);
    Assert.assertEquals("Wrong package found.", "f1.a", dynamicWire.getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
    Assert.assertEquals("Wrong host revision found.", h1.getCurrentRevision(), dynamicWire.getProvider());
    ModuleWiring h1Wiring = h1.getCurrentRevision().getWiring();
    Assert.assertNotNull("h1 wiring is null.", h1Wiring);
    ModuleWiring f1Wiring = f1.getCurrentRevision().getWiring();
    Assert.assertNotNull("f1 wiring is null.", f1Wiring);
}
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 13 with ModuleWiring

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

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

the class TestModuleContainer method testDynamicImport04.

@Test
public void testDynamicImport04() 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 dynamic3 = installDummyModule("dynamic2_v1.MF", "dynamic2_v1", container);
    container.resolve(Arrays.asList(systemBundle, dynamic3), true);
    ModuleWire dynamicWire = container.resolveDynamic("h1.a", dynamic3.getCurrentRevision());
    Assert.assertNull("Dynamic wire found.", dynamicWire);
    Module h1 = installDummyModule("h1_v1.MF", "h1_v1", container);
    Module f1 = installDummyModule("f1_v1.MF", "f1_v1", container);
    database.getModuleEvents();
    dynamicWire = container.resolveDynamic("h1.a", dynamic3.getCurrentRevision());
    Assert.assertNotNull("Dynamic wire not found.", dynamicWire);
    Assert.assertEquals("Wrong package found.", "h1.a", dynamicWire.getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
    Assert.assertEquals("Wrong provider for the wire found.", h1.getCurrentRevision(), dynamicWire.getProvider());
    dynamicWire = container.resolveDynamic("f1.a", dynamic3.getCurrentRevision());
    Assert.assertNotNull("Dynamic wire not found.", dynamicWire);
    Assert.assertEquals("Wrong package found.", "f1.a", dynamicWire.getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
    Assert.assertEquals("Wrong provider for the wire found.", h1.getCurrentRevision(), dynamicWire.getProvider());
    ModuleWiring h1Wiring = h1.getCurrentRevision().getWiring();
    Assert.assertNotNull("h1 wiring is null.", h1Wiring);
    ModuleWiring f1Wiring = f1.getCurrentRevision().getWiring();
    Assert.assertNotNull("f1 wiring is null.", f1Wiring);
}
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) DummyModuleDatabase(org.eclipse.osgi.tests.container.dummys.DummyModuleDatabase) Test(org.junit.Test)

Example 15 with ModuleWiring

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

the class TestModuleContainer method testDynamicImport08.

@Test
public void testDynamicImport08() 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 dynamic2 = installDummyModule("dynamic2_v1.MF", "dynamic2_v1", container);
    container.resolve(Arrays.asList(systemBundle, dynamic2), true);
    Module h1 = installDummyModule("h1_v1.MF", "h1_v1", container);
    Module f1 = installDummyModule("f1_v1.MF", "f1_v1", container);
    database.getModuleEvents();
    // make sure h1 is not resolved
    ModuleWiring h1Wiring = h1.getCurrentRevision().getWiring();
    Assert.assertNull("h1 got resolved somehow.", h1Wiring);
    // do not resolve the host first; make sure it gets pulled in while attempting to resolve
    // to a fragment capability.
    ModuleWire dynamicWire = container.resolveDynamic("f1.a", dynamic2.getCurrentRevision());
    Assert.assertNotNull("Dynamic wire not found.", dynamicWire);
    Assert.assertEquals("Wrong package found.", "f1.a", dynamicWire.getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
    Assert.assertEquals("Wrong provider for the wire found.", h1.getCurrentRevision(), dynamicWire.getProvider());
    h1Wiring = h1.getCurrentRevision().getWiring();
    Assert.assertNotNull("h1 wiring is null.", h1Wiring);
    ModuleWiring f1Wiring = f1.getCurrentRevision().getWiring();
    Assert.assertNotNull("f1 wiring is null.", f1Wiring);
}
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) DummyModuleDatabase(org.eclipse.osgi.tests.container.dummys.DummyModuleDatabase) Test(org.junit.Test)

Aggregations

ModuleWiring (org.eclipse.osgi.container.ModuleWiring)39 Module (org.eclipse.osgi.container.Module)22 ModuleWire (org.eclipse.osgi.container.ModuleWire)21 ModuleContainer (org.eclipse.osgi.container.ModuleContainer)20 DummyContainerAdaptor (org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor)20 Test (org.junit.Test)20 ModuleRevision (org.eclipse.osgi.container.ModuleRevision)12 BundleLoader (org.eclipse.osgi.internal.loader.BundleLoader)8 ArrayList (java.util.ArrayList)7 ResolutionReport (org.eclipse.osgi.report.resolution.ResolutionReport)6 URL (java.net.URL)5 BundleCapability (org.osgi.framework.wiring.BundleCapability)4 HashMap (java.util.HashMap)3 ModuleCapability (org.eclipse.osgi.container.ModuleCapability)3 DummyModuleDatabase (org.eclipse.osgi.tests.container.dummys.DummyModuleDatabase)3 Bundle (org.osgi.framework.Bundle)3 BundleException (org.osgi.framework.BundleException)3 IOException (java.io.IOException)2 ModuleClassLoader (org.eclipse.osgi.internal.loader.ModuleClassLoader)2 BundleRequirement (org.osgi.framework.wiring.BundleRequirement)2