Search in sources :

Example 6 with DummyContainerAdaptor

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

the class TestModuleContainer method testDynamicImport05.

@Test
public void testDynamicImport05() 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 dynamic3 = installDummyModule("dynamic3_v1.MF", "dynamic3_v1", container);
    Module dynamic3Frag = installDummyModule("dynamic3.frag_v1.MF", "dynamic3.frag_v1", container);
    container.resolve(Arrays.asList(c1, c4, dynamic3, dynamic3Frag), true);
    ModuleWire dynamicWire = container.resolveDynamic("c4.a", dynamic3.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", dynamic3.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 7 with DummyContainerAdaptor

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

the class TestModuleContainer method testSubstitutionWithMoreThan2Providers.

@Test
public void testSubstitutionWithMoreThan2Providers() throws BundleException, IOException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    Module systemBundle = installDummyModule(// 
    "system.bundle.MF", // 
    Constants.SYSTEM_BUNDLE_LOCATION, // 
    Constants.SYSTEM_BUNDLE_SYMBOLICNAME, // 
    "javax.crypto, javax.crypto.spec, javax.net, javax.net.ssl, javax.security.auth.x500, org.ietf.jgss", // 
    "osgi.ee; osgi.ee=JavaSE; version:List<Version>=\"1.3, 1.4, 1.5, 1.6, 1.7\"", container);
    ResolutionReport report = container.resolve(Arrays.asList(systemBundle), true);
    Assert.assertNull("Failed to resolve test.", report.getResolutionException());
    List<Module> modules = new ArrayList<Module>();
    for (String manifest : HTTPCOMPS_AND_EATHER) {
        modules.add(installDummyModule(manifest, manifest, container));
    }
    report = container.resolve(modules, 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) ArrayList(java.util.ArrayList) Module(org.eclipse.osgi.container.Module) ResolutionReport(org.eclipse.osgi.report.resolution.ResolutionReport) Test(org.junit.Test)

Example 8 with DummyContainerAdaptor

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

the class TestModuleContainer method testResolveInstallBundles.

// Disabled @Test
public void testResolveInstallBundles() throws BundleException, IOException {
    setupModuleDatabase();
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    resolvedModuleDatabase.store(new DataOutputStream(bytes), false);
    bytes.close();
    adaptor.getDatabase().load(new DataInputStream(new ByteArrayInputStream(bytes.toByteArray())));
    adaptor.getContainer().resolve(new ArrayList<Module>(), false);
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) ByteArrayInputStream(java.io.ByteArrayInputStream) DataOutputStream(java.io.DataOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DataInputStream(java.io.DataInputStream) Module(org.eclipse.osgi.container.Module)

Example 9 with DummyContainerAdaptor

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

the class TestModuleContainer method testSubstitutableExports02.

@Test
public void testSubstitutableExports02() throws BundleException, IOException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    Module a = installDummyModule("sub.a.MF", "a", container);
    Module b = installDummyModule("sub.b.MF", "b", container);
    Module c = installDummyModule("sub.c.MF", "c", container);
    container.resolve(Arrays.asList(a, b, c), true);
    ModuleWiring wiringA = a.getCurrentRevision().getWiring();
    ModuleWiring wiringB = b.getCurrentRevision().getWiring();
    ModuleWiring wiringC = c.getCurrentRevision().getWiring();
    List<ModuleWire> providedWiresA = wiringA.getProvidedModuleWires(PackageNamespace.PACKAGE_NAMESPACE);
    Assert.assertEquals("Wrong number of provided wires.", 2, providedWiresA.size());
    Collection<ModuleRevision> requirers = new ArrayList<ModuleRevision>();
    for (ModuleWire wire : providedWiresA) {
        requirers.add(wire.getRequirer());
    }
    Assert.assertTrue("b does not require.", requirers.contains(b.getCurrentRevision()));
    Assert.assertTrue("c does not require.", requirers.contains(c.getCurrentRevision()));
    List<ModuleWire> requiredWiresB = wiringB.getRequiredModuleWires(PackageNamespace.PACKAGE_NAMESPACE);
    Assert.assertEquals("Wrong number of required wires.", 1, requiredWiresB.size());
    Assert.assertEquals("Unexpected package name.", "javax.servlet", requiredWiresB.iterator().next().getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
    Assert.assertEquals("Wrong provider.", a.getCurrentRevision(), requiredWiresB.iterator().next().getProvider());
    List<ModuleWire> requiredWiresC = wiringC.getRequiredModuleWires(PackageNamespace.PACKAGE_NAMESPACE);
    Assert.assertEquals("Wrong number of required wires.", 1, requiredWiresC.size());
    Assert.assertEquals("Wrong number of required wires.", 1, requiredWiresC.size());
    Assert.assertEquals("Unexpected package name.", "javax.servlet", requiredWiresC.iterator().next().getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
    Assert.assertEquals("Wrong provider.", a.getCurrentRevision(), requiredWiresC.iterator().next().getProvider());
    Module d = installDummyModule("sub.d.MF", "d", container);
    container.resolve(Arrays.asList(d), true);
    ModuleWiring wiringD = d.getCurrentRevision().getWiring();
    List<ModuleWire> requiredWiresD = wiringD.getRequiredModuleWires(PackageNamespace.PACKAGE_NAMESPACE);
    Assert.assertEquals("Wrong number of required wires.", 2, requiredWiresD.size());
    Assert.assertEquals("Unexpected package name.", "org.ops4j.pax.web.service", requiredWiresD.get(0).getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
    Assert.assertEquals("Wrong provider.", c.getCurrentRevision(), requiredWiresD.get(0).getProvider());
    Assert.assertEquals("Unexpected package name.", "javax.servlet", requiredWiresD.get(1).getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
    Assert.assertEquals("Wrong provider.", a.getCurrentRevision(), requiredWiresD.get(1).getProvider());
}
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) ArrayList(java.util.ArrayList) Module(org.eclipse.osgi.container.Module) ModuleRevision(org.eclipse.osgi.container.ModuleRevision) Test(org.junit.Test)

Example 10 with DummyContainerAdaptor

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

the class TestModuleContainer method testRequireBundleUses.

@Test
public void testRequireBundleUses() 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 b1 = installDummyModule("require.b1.MF", "b1", container);
    installDummyModule("require.b2.MF", "b2", container);
    installDummyModule("require.b3.MF", "b3", container);
    installDummyModule("require.b4.MF", "b4", container);
    container.resolve(null, false);
    Assert.assertEquals("b1 should not resolve.", State.INSTALLED, b1.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)

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