use of org.eclipse.osgi.container.ModuleWiring in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testSubstitutableExports04.
@Test
public void testSubstitutableExports04() throws BundleException, IOException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
// install order does not really matter
installDummyModule("sub.h.MF", "h", container);
Module i = installDummyModule("sub.i.MF", "i", container);
installDummyModule("sub.j.MF", "j", container);
Module k = installDummyModule("sub.k.MF", "k", container);
// resolve order does matter so that transitive dependencies are pulled in
// and cause substitution to happen in a certain way
container.resolve(Arrays.asList(k), true);
ModuleWiring wiringI = i.getCurrentRevision().getWiring();
ModuleWiring wiringK = k.getCurrentRevision().getWiring();
List<ModuleWire> requiredWiresK = wiringK.getRequiredModuleWires(PackageNamespace.PACKAGE_NAMESPACE);
// I should be the provider for all of K
Assert.assertEquals("Wrong number of required wires: " + requiredWiresK, 2, requiredWiresK.size());
for (ModuleWire moduleWire : requiredWiresK) {
Assert.assertEquals("Wrong provider: " + moduleWire.getProviderWiring(), wiringI, moduleWire.getProviderWiring());
}
}
use of org.eclipse.osgi.container.ModuleWiring in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testDynamicImport03.
@Test
public void testDynamicImport03() 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("c1.a", dynamic3.getCurrentRevision());
Assert.assertNull("Dynamic wire found.", dynamicWire);
Module c1v1 = installDummyModule("c1_v1.MF", "c1_v1", container);
database.getModuleEvents();
dynamicWire = container.resolveDynamic("c1.a", dynamic3.getCurrentRevision());
Assert.assertNotNull("Dynamic wire not found.", dynamicWire);
Assert.assertEquals("Wrong package found.", "c1.a", dynamicWire.getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
Assert.assertEquals("Wrong provider for the wire found.", c1v1.getCurrentRevision(), dynamicWire.getProvider());
ModuleWiring c1v1Wiring = c1v1.getCurrentRevision().getWiring();
Assert.assertNotNull("c1 wiring is null.", c1v1Wiring);
Module c1v2 = installDummyModule("c1_v2.MF", "c1_v2", container);
container.resolve(Arrays.asList(c1v2), true);
database.getModuleEvents();
dynamicWire = container.resolveDynamic("c1.b", dynamic3.getCurrentRevision());
Assert.assertNotNull("Dynamic wire not found.", dynamicWire);
Assert.assertEquals("Wrong package found.", "c1.b", dynamicWire.getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
Assert.assertEquals("Wrong provider.", c1v1.getCurrentRevision(), dynamicWire.getProvider());
}
use of org.eclipse.osgi.container.ModuleWiring in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testSubstitutableExports01.
@Test
public void testSubstitutableExports01() 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 sub1 = installDummyModule("sub1_v1.MF", "sub1", container);
Module sub2 = installDummyModule("sub2_v1.MF", "sub2", container);
ModuleRevision sub1Revision0 = sub1.getCurrentRevision();
container.resolve(Arrays.asList(sub2), true);
container.update(sub1, OSGiManifestBuilderFactory.createBuilder(getManifest("sub1_v2.MF")), null);
container.resolve(Arrays.asList(sub1), true);
ModuleWiring sub1Wiring = sub1.getCurrentRevision().getWiring();
List<BundleCapability> exportedPackages = sub1Wiring.getCapabilities(PackageNamespace.PACKAGE_NAMESPACE);
Assert.assertEquals("Wrong number of exported packages: " + exportedPackages, 0, exportedPackages.size());
List<BundleWire> requiredWires = sub1Wiring.getRequiredWires(PackageNamespace.PACKAGE_NAMESPACE);
Assert.assertEquals("Wrong number of imported packages: ", 2, requiredWires.size());
Assert.assertEquals("Wrong provider for package: " + requiredWires.get(1).getProvider(), sub1Revision0, requiredWires.get(1).getProvider());
container.refresh(Arrays.asList(sub1));
sub1Wiring = sub1.getCurrentRevision().getWiring();
exportedPackages = sub1Wiring.getCapabilities(PackageNamespace.PACKAGE_NAMESPACE);
Assert.assertEquals("Wrong number of exported packages: " + exportedPackages, 1, exportedPackages.size());
requiredWires = sub1Wiring.getRequiredWires(PackageNamespace.PACKAGE_NAMESPACE);
Assert.assertEquals("Wrong number of imported packages: ", 1, requiredWires.size());
}
use of org.eclipse.osgi.container.ModuleWiring in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testFragments02.
@Test
public void testFragments02() 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);
container.resolve(Arrays.asList(systemModule, c1, h2), true);
ModuleWiring h2wiring = h2.getCurrentRevision().getWiring();
Assert.assertNotNull("Wiring is null.", h2wiring);
Module f2 = installDummyModule("f2_v1.MF", "f2_v1", container);
Assert.assertEquals("Wrong state.", State.INSTALLED, f2.getState());
container.resolve(Arrays.asList(f2), false);
Assert.assertNull("Expected to not be able to resolve f2.", f2.getCurrentRevision().getWiring());
}
use of org.eclipse.osgi.container.ModuleWiring in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testMissingHost.
@Test
public void testMissingHost() throws BundleException, IOException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, container);
Module f1v1 = installDummyModule("f1_v1.MF", "f1_v1", container);
Module b3 = installDummyModule("b3_v1.MF", "b3_v1", container);
ResolutionReport report = container.resolve(Arrays.asList(f1v1, b3), true);
Assert.assertNotNull("Expected a resolution exception.", report.getResolutionException());
Module h1v1 = installDummyModule("h1_v1.MF", "h1_v1", container);
report = container.resolve(Arrays.asList(b3), true);
Assert.assertNull("Expected no resolution exception.", report.getResolutionException());
ModuleWiring wiring = b3.getCurrentRevision().getWiring();
List<ModuleWire> packageWires = wiring.getRequiredModuleWires(PackageNamespace.PACKAGE_NAMESPACE);
Assert.assertEquals("Expected 1 import.", 1, packageWires.size());
ModuleWire pkgWire = packageWires.get(0);
Assert.assertEquals("Wrong host exporter.", pkgWire.getProviderWiring().getRevision(), h1v1.getCurrentRevision());
}
Aggregations