use of org.eclipse.osgi.container.ModuleWire 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);
}
use of org.eclipse.osgi.container.ModuleWire 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);
}
use of org.eclipse.osgi.container.ModuleWire 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.ModuleWire 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.ModuleWire 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());
}
Aggregations