use of org.eclipse.osgi.container.ModuleWiring 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());
}
use of org.eclipse.osgi.container.ModuleWiring in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testR3.
@Test
public void testR3() 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);
ResolutionReport report = container.resolve(Arrays.asList(systemBundle), true);
Assert.assertNull("Failed to resolve system.bundle.", report.getResolutionException());
// R3 bundle
Map<String, String> exporterManifest = new HashMap<String, String>();
exporterManifest = new HashMap<String, String>();
exporterManifest.put(Constants.BUNDLE_SYMBOLICNAME, "exporter");
exporterManifest.put(Constants.EXPORT_PACKAGE, "exporter; version=\"1.1\"");
Module moduleExport = installDummyModule(exporterManifest, "exporter", container);
report = container.resolve(Arrays.asList(moduleExport, moduleExport), true);
Assert.assertNull("Failed to resolve", report.getResolutionException());
List<BundleRequirement> reqs = moduleExport.getCurrentRevision().getWiring().getRequirements(PackageNamespace.PACKAGE_NAMESPACE);
assertEquals("Wrong number of imports.", 0, reqs.size());
// R3 bundle
exporterManifest.clear();
exporterManifest.put(Constants.BUNDLE_SYMBOLICNAME, "dynamicExporter");
exporterManifest.put(Constants.EXPORT_PACKAGE, "exporter; version=\"1.0\"");
exporterManifest.put(Constants.DYNAMICIMPORT_PACKAGE, "exporter");
Module moduleWithDynExport = installDummyModule(exporterManifest, "dynamicExporter", container);
report = container.resolve(Arrays.asList(moduleWithDynExport), true);
Assert.assertNull("Failed to resolve", report.getResolutionException());
reqs = moduleWithDynExport.getCurrentRevision().getWiring().getRequirements(PackageNamespace.PACKAGE_NAMESPACE);
assertEquals("Wrong number of imports.", 2, reqs.size());
report = container.resolve(Arrays.asList(moduleWithDynExport), true);
Assert.assertNull("Failed to resolve", report.getResolutionException());
reqs = moduleWithDynExport.getCurrentRevision().getWiring().getRequirements(PackageNamespace.PACKAGE_NAMESPACE);
assertEquals("Wrong number of imports.", 2, reqs.size());
ModuleWiring wiring = moduleWithDynExport.getCurrentRevision().getWiring();
List<ModuleWire> packageWires = wiring.getRequiredModuleWires(PackageNamespace.PACKAGE_NAMESPACE);
Assert.assertEquals("Unexpected number of wires", 1, packageWires.size());
Assert.assertEquals("Wrong exporter", packageWires.get(0).getProviderWiring().getRevision(), moduleExport.getCurrentRevision());
}
use of org.eclipse.osgi.container.ModuleWiring in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testBug483849.
@Test
public void testBug483849() throws BundleException, IOException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
// install and resolve host bundle
Module host = installDummyModule("bug483849.host.MF", "host", container);
ResolutionReport report = container.resolve(Arrays.asList(host), true);
Assert.assertNull("Failed to resolve host.", report.getResolutionException());
// install and dynamically attach a fragment that exports a package and resolve an importer
Module frag = installDummyModule("bug483849.frag.MF", "frag", container);
Module importer = installDummyModule("bug483849.importer.MF", "importer", container);
report = container.resolve(Arrays.asList(frag, importer), true);
Assert.assertNull("Failed to resolve test fragment and importer.", report.getResolutionException());
// get the count of package exports
ModuleWiring wiring = host.getCurrentRevision().getWiring();
int originalPackageCnt = wiring.getCapabilities(PackageNamespace.PACKAGE_NAMESPACE).size();
// update the host to generate a new revision
Map<String, String> updateManifest = getManifest("bug483849.host.MF");
ModuleRevisionBuilder updateBuilder = OSGiManifestBuilderFactory.createBuilder(updateManifest);
container.update(host, updateBuilder, null);
// refresh host which should force the importer to re-resolve to the new revision
report = container.refresh(Collections.singleton(host));
ModuleWiring importerWiring = importer.getCurrentRevision().getWiring();
Assert.assertNotNull("No wiring for importer.", importerWiring);
List<ModuleWire> importerPackageWires = importerWiring.getRequiredModuleWires(PackageNamespace.PACKAGE_NAMESPACE);
Assert.assertEquals("Wrong number of importer package Wires.", 1, importerPackageWires.size());
Assert.assertEquals("Wrong provider wiring.", host.getCurrentRevision().getWiring(), importerPackageWires.iterator().next().getProviderWiring());
Assert.assertEquals("Wrong provider revision.", host.getCurrentRevision(), importerPackageWires.iterator().next().getProviderWiring().getRevision());
wiring = host.getCurrentRevision().getWiring();
List<BundleCapability> packages = wiring.getCapabilities(PackageNamespace.PACKAGE_NAMESPACE);
Assert.assertEquals("Wrong number of host packages.", originalPackageCnt, packages.size());
}
use of org.eclipse.osgi.container.ModuleWiring in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testPlatformFilter01.
@Test
public void testPlatformFilter01() throws BundleException, IOException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
String extraCapabilities = EclipsePlatformNamespace.ECLIPSE_PLATFORM_NAMESPACE + "; osgi.os=foo; osgi.arch=bar";
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), true);
ModuleWiring platformFilter1Wiring = platformFilter1.getCurrentRevision().getWiring();
Assert.assertNotNull("platformFilter1 is not resolved", platformFilter1Wiring);
}
use of org.eclipse.osgi.container.ModuleWiring in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testFragments01.
@Test
public void testFragments01() throws BundleException, IOException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
Module systemModule = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, container);
Module c1 = installDummyModule("c1_v1.MF", "c1_v1", container);
Module h2 = installDummyModule("h2_v1.MF", "h2_v1", container);
Module f2 = installDummyModule("f2_v1.MF", "f2_v1", container);
container.resolve(Arrays.asList(systemModule, c1, h2, f2), true);
ModuleWiring wiring = h2.getCurrentRevision().getWiring();
List<ModuleWire> requiredWires = wiring.getRequiredModuleWires(null);
Assert.assertEquals("Wrong number of required wires.", 3, requiredWires.size());
for (ModuleWire wire : requiredWires) {
ModuleCapability capability = wire.getCapability();
Assert.assertEquals("Wrong namespace.", PackageNamespace.PACKAGE_NAMESPACE, capability.getNamespace());
Assert.assertEquals("Wrong requirer.", h2.getCurrentRevision(), wire.getRequirer());
String pkgName = (String) capability.getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE);
Assert.assertNotNull("No package name.", pkgName);
ModuleRevision expectedReqRevision;
if (pkgName.equals("org.osgi.framework")) {
expectedReqRevision = h2.getCurrentRevision();
} else {
expectedReqRevision = f2.getCurrentRevision();
}
Assert.assertEquals("Wrong requirement revision.", expectedReqRevision, wire.getRequirement().getRevision());
}
}
Aggregations