use of org.eclipse.osgi.service.resolver.ExportPackageDescription in project rt.equinox.framework by eclipse.
the class TestDynamic_002 method checkWiringState_1.
// end of method
public void checkWiringState_1() {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
for (int i = 0; i < exports.length; i++) {
ExportPackageDescription exp = exports[i];
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("p")) {
assertNotNull("Package [p] is not wired when it should be ", exp.getExporter());
assertEquals("Package [p] is wired incorrectly ", exp.getExporter(), bundle_2);
} else if (exportPackageName.equals("q")) {
assertNotNull("Package [q] is not wired when it should be ", exp.getExporter());
assertEquals("Package [q] is wired incorrectly ", exp.getExporter(), bundle_2);
}
}
// end for
}
use of org.eclipse.osgi.service.resolver.ExportPackageDescription in project rt.equinox.framework by eclipse.
the class StateResolverTest method testBug324618.
public void testBug324618() throws BundleException {
State state = buildEmptyState();
long bundleID = 0;
Dictionary manifest;
manifest = loadManifest("p1.MF");
BundleDescription p1 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME), bundleID++);
manifest = loadManifest("p2.MF");
BundleDescription p2 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME), bundleID++);
manifest = loadManifest("c1.MF");
BundleDescription c1 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME), bundleID++);
state.addBundle(p1);
state.addBundle(p2);
state.addBundle(c1);
state.resolve();
ExportPackageDescription x = state.linkDynamicImport(c1, "x");
assertNotNull("x dynamic import is null", x);
ExportPackageDescription xSub = state.linkDynamicImport(c1, "x.sub");
assertNotNull("x.sub dynamic import is null", xSub);
assertEquals("The exporter is not the same for x and x.sub", x.getExporter(), xSub.getExporter());
ExportPackageDescription xExtra = state.linkDynamicImport(c1, "x.extra");
assertNotNull("x.extra dynamic import is null", xExtra);
}
use of org.eclipse.osgi.service.resolver.ExportPackageDescription in project rt.equinox.framework by eclipse.
the class StateResolverTest method testFragmentConstraints02.
public void testFragmentConstraints02() throws BundleException {
int id = 0;
State state = buildEmptyState();
Hashtable manifest = new Hashtable();
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "a");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "a");
// $NON-NLS-1$
BundleDescription a = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "aFrag1");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "a");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "b, c, d");
// $NON-NLS-1$
BundleDescription aFrag1 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "aFrag2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "a");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "b, c, e");
// $NON-NLS-1$
BundleDescription aFrag2 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "aFrag3");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "a");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "b, c");
// $NON-NLS-1$
BundleDescription aFrag3 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
// Bug 353103 need to create a bundle that has the same unresolved imports as other bundles
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "aFrag4");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "a");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "b, c, d, e");
// $NON-NLS-1$
BundleDescription aFrag4 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "b");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "a, b, c");
// $NON-NLS-1$
BundleDescription b = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
state.addBundle(a);
state.addBundle(aFrag1);
state.addBundle(aFrag2);
state.addBundle(aFrag3);
state.addBundle(aFrag4);
state.addBundle(b);
state.resolve();
// $NON-NLS-1$
assertTrue("0.1", a.isResolved());
// $NON-NLS-1$
assertFalse("0.2", aFrag1.isResolved());
// $NON-NLS-1$
assertFalse("0.3", aFrag2.isResolved());
// $NON-NLS-1$
assertTrue("0.4", aFrag3.isResolved());
// $NON-NLS-1$
assertFalse("0.5", aFrag4.isResolved());
// $NON-NLS-1$
assertTrue("0.6", b.isResolved());
ExportPackageDescription[] aResolvedImports = a.getResolvedImports();
ExportPackageDescription[] bSelectedExports = b.getSelectedExports();
// $NON-NLS-1$
assertEquals("1.0", 3, aResolvedImports.length);
// $NON-NLS-1$
assertEquals("1.1", 3, bSelectedExports.length);
for (int i = 0; i < aResolvedImports.length; i++) {
assertEquals(bSelectedExports[i], aResolvedImports[i]);
}
}
use of org.eclipse.osgi.service.resolver.ExportPackageDescription in project rt.equinox.framework by eclipse.
the class StateResolverTest method testFragmentConstraints03.
public void testFragmentConstraints03() throws BundleException {
// same as testFragmentConstraints02 but with a cycle
int id = 0;
State state = buildEmptyState();
Hashtable manifest = new Hashtable();
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "a");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "x");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "a");
// $NON-NLS-1$
BundleDescription a = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "aFrag1");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "a");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "b, c, d");
// $NON-NLS-1$
BundleDescription aFrag1 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "aFrag2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "a");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "b, c, e");
// $NON-NLS-1$
BundleDescription aFrag2 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "aFrag3");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "a");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "b, c");
// $NON-NLS-1$
BundleDescription aFrag3 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
// Bug 353103 need to create a bundle that has the same unresolved imports as other bundles
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "aFrag4");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "a");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "b, c, d, e");
// $NON-NLS-1$
BundleDescription aFrag4 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "b");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "a, b, c");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "x");
// $NON-NLS-1$
BundleDescription b = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
state.addBundle(a);
state.addBundle(aFrag1);
state.addBundle(aFrag2);
state.addBundle(aFrag3);
state.addBundle(aFrag4);
state.addBundle(b);
state.resolve();
// $NON-NLS-1$
assertTrue("0.1", a.isResolved());
// $NON-NLS-1$
assertFalse("0.2", aFrag1.isResolved());
// $NON-NLS-1$
assertFalse("0.3", aFrag2.isResolved());
// $NON-NLS-1$
assertTrue("0.4", aFrag3.isResolved());
// $NON-NLS-1$
assertFalse("0.5", aFrag4.isResolved());
// $NON-NLS-1$
assertTrue("0.6", b.isResolved());
ExportPackageDescription[] aResolvedImports = a.getResolvedImports();
ExportPackageDescription[] aSelectedExports = a.getSelectedExports();
ExportPackageDescription[] bResolvedImports = b.getResolvedImports();
ExportPackageDescription[] bSelectedExports = b.getSelectedExports();
// $NON-NLS-1$
assertEquals("1.0", 3, aResolvedImports.length);
// $NON-NLS-1$
assertEquals("1.1", 3, bSelectedExports.length);
for (int i = 0; i < aResolvedImports.length; i++) // $NON-NLS-1$
assertEquals("1.2", bSelectedExports[i], aResolvedImports[i]);
// $NON-NLS-1$
assertEquals("2.0", 1, aSelectedExports.length);
// $NON-NLS-1$
assertEquals("2.1", 1, bResolvedImports.length);
// $NON-NLS-1$
assertEquals("2.2", aSelectedExports[0], bResolvedImports[0]);
}
use of org.eclipse.osgi.service.resolver.ExportPackageDescription in project rt.equinox.framework by eclipse.
the class StateResolverTest method testSingletonsSelection7.
public void testSingletonsSelection7() throws BundleException {
State state = buildEmptyState();
long id = 0;
// test the selection algorithm of the resolver to pick the bundles with the largest version
Hashtable manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$ //$NON-NLS-2$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "singleton; " + Constants.SINGLETON_DIRECTIVE + ":=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "singleton");
// $NON-NLS-1$
BundleDescription singleton1 = state.getFactory().createBundleDescription(state, manifest, "singleton1", id++);
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "a");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "singleton");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "a;version=1.0.0");
// $NON-NLS-1$
BundleDescription a1 = state.getFactory().createBundleDescription(state, manifest, "a1", id++);
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "b");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "a");
// $NON-NLS-1$
BundleDescription b = state.getFactory().createBundleDescription(state, manifest, "b", id++);
state.addBundle(singleton1);
state.addBundle(a1);
state.addBundle(b);
state.resolve();
// $NON-NLS-1$
assertTrue("1.0", singleton1.isResolved());
// $NON-NLS-1$
assertTrue("1.1", a1.isResolved());
// $NON-NLS-1$
assertTrue("1.2", b.isResolved());
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$ //$NON-NLS-2$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "singleton; " + Constants.SINGLETON_DIRECTIVE + ":=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.1");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "singleton");
// $NON-NLS-1$
BundleDescription singleton2 = state.getFactory().createBundleDescription(state, manifest, "singleton2", id++);
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "a");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.1");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "singleton");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "a;version=1.0.1");
// $NON-NLS-1$
BundleDescription a2 = state.getFactory().createBundleDescription(state, manifest, "a2", id++);
state.addBundle(singleton2);
state.addBundle(a2);
state.resolve(new BundleDescription[] { singleton1, singleton2, a1, a2 });
// $NON-NLS-1$
assertFalse("2.0", singleton1.isResolved());
// $NON-NLS-1$
assertTrue("2.1", singleton2.isResolved());
// $NON-NLS-1$
assertTrue("2.2", a1.isResolved());
// $NON-NLS-1$
assertTrue("2.3", a2.isResolved());
// $NON-NLS-1$
assertTrue("2.4", b.isResolved());
ExportPackageDescription[] imports = b.getResolvedImports();
// $NON-NLS-1$
assertEquals("Unexpected number of imports", 1, imports.length);
// $NON-NLS-1$
assertEquals("Unexpected exporter", a2, imports[0].getExporter());
}
Aggregations