Search in sources :

Example 1 with ModuleRequirement

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

the class TestModuleContainer method testUTF8LineContinuation.

@Test
public void testUTF8LineContinuation() throws BundleException, IOException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    String utfString = "a.with.�.multibyte";
    while (utfString.getBytes("UTF8").length < 500) {
        Map<String, String> manifest = getUTFManifest(utfString);
        Module testModule = installDummyModule(manifest, manifest.get(Constants.BUNDLE_SYMBOLICNAME), container);
        Assert.assertEquals("Wrong bns for the bundle.", utfString, testModule.getCurrentRevision().getSymbolicName());
        ModuleCapability exportPackage = testModule.getCurrentRevision().getModuleCapabilities(PackageNamespace.PACKAGE_NAMESPACE).get(0);
        ModuleRequirement importPackage = testModule.getCurrentRevision().getModuleRequirements(PackageNamespace.PACKAGE_NAMESPACE).get(0);
        String actualPackageName = (String) exportPackage.getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE);
        Assert.assertEquals("Wrong exported package name.", utfString, actualPackageName);
        Assert.assertTrue("import does not match export: " + importPackage, importPackage.matches(exportPackage));
        utfString = "a" + utfString;
    }
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) ModuleContainer(org.eclipse.osgi.container.ModuleContainer) ModuleCapability(org.eclipse.osgi.container.ModuleCapability) Module(org.eclipse.osgi.container.Module) ModuleRequirement(org.eclipse.osgi.container.ModuleRequirement) Test(org.junit.Test)

Example 2 with ModuleRequirement

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

the class TestModuleContainer method testExecutionEnvironment.

@Test
public void testExecutionEnvironment() throws BundleException, IOException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    String extraCapabilities = "osgi.ee; osgi.ee=JavaSE; version:List<Version>=\"1.3, 1.4, 1.5, 1.6, 1.7\"";
    installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, null, null, extraCapabilities, container);
    container.resolve(null, false);
    Module ee1 = installDummyModule("ee1_v1.MF", "ee1", container);
    Module ee2 = installDummyModule("ee2_v1.MF", "ee2", container);
    Module ee3 = installDummyModule("ee3_v1.MF", "ee3", container);
    container.resolve(Arrays.asList(ee1, ee2), true);
    container.resolve(Arrays.asList(ee3), false);
    ModuleWiring ee1Wiring = ee1.getCurrentRevision().getWiring();
    ModuleWiring ee2Wiring = ee2.getCurrentRevision().getWiring();
    ModuleWiring ee3Wiring = ee3.getCurrentRevision().getWiring();
    Assert.assertNotNull("ee1 is not resolved", ee1Wiring);
    Assert.assertNotNull("ee2 is not resolved", ee2Wiring);
    Assert.assertNull("ee3 is resolved", ee3Wiring);
    // make sure the fragment ee requirement did not get merged into the host
    List<ModuleRequirement> ee1Requirements = ee1Wiring.getModuleRequirements(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE);
    Assert.assertEquals("Wrong number of requirements", 1, ee1Requirements.size());
    List<ModuleWire> ee1Wires = ee1Wiring.getRequiredModuleWires(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE);
    Assert.assertEquals("Wrong number of wires", 1, ee1Wires.size());
    List<ModuleRequirement> ee2Requirements = ee2Wiring.getModuleRequirements(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE);
    Assert.assertEquals("Wrong number of requirements", 1, ee2Requirements.size());
    List<ModuleWire> ee2Wires = ee2Wiring.getRequiredModuleWires(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE);
    Assert.assertEquals("Wrong number of wires", 1, ee2Wires.size());
}
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) ModuleRequirement(org.eclipse.osgi.container.ModuleRequirement) Test(org.junit.Test)

Aggregations

Module (org.eclipse.osgi.container.Module)2 ModuleContainer (org.eclipse.osgi.container.ModuleContainer)2 ModuleRequirement (org.eclipse.osgi.container.ModuleRequirement)2 DummyContainerAdaptor (org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor)2 Test (org.junit.Test)2 ModuleCapability (org.eclipse.osgi.container.ModuleCapability)1 ModuleWire (org.eclipse.osgi.container.ModuleWire)1 ModuleWiring (org.eclipse.osgi.container.ModuleWiring)1