use of org.eclipse.osgi.service.resolver.BundleDescription in project rt.equinox.framework by eclipse.
the class StateResolverTest method testFragmentTransitiveUses.
public void testFragmentTransitiveUses() throws BundleException {
State state = buildEmptyState();
Hashtable manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "A1");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "a; uses:=d");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "d");
// $NON-NLS-1$
BundleDescription a1_100 = state.getFactory().createBundleDescription(state, manifest, "a1_100", 0);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "A1.Frag");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "A1");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "a.frag; uses:=a");
// $NON-NLS-1$
BundleDescription a1frag_100 = state.getFactory().createBundleDescription(state, manifest, "a1frag_100", 1);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "A2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "a; uses:=d, a.frag; uses:=a");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "d");
// $NON-NLS-1$
BundleDescription a2_100 = state.getFactory().createBundleDescription(state, manifest, "a2_100", 2);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "B1");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "b; uses:=a");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "a;bundle-symbolic-name=A2, a.frag");
// $NON-NLS-1$
BundleDescription b1_100 = state.getFactory().createBundleDescription(state, manifest, "b1_100", 3);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "C1");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "c; uses:=b");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "b");
// $NON-NLS-1$
BundleDescription c1_100 = state.getFactory().createBundleDescription(state, manifest, "c1_100", 4);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "D1");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "d; uses:=c");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "a.frag, c");
// $NON-NLS-1$
BundleDescription d1_100 = state.getFactory().createBundleDescription(state, manifest, "d1_100", 5);
state.addBundle(a1_100);
state.addBundle(a1frag_100);
state.addBundle(a2_100);
state.addBundle(b1_100);
state.addBundle(c1_100);
state.addBundle(d1_100);
state.resolve();
// $NON-NLS-1$
assertFalse("0.1", a1_100.isResolved());
// $NON-NLS-1$
assertTrue("0.2", a2_100.isResolved());
// $NON-NLS-1$
assertTrue("0.3", b1_100.isResolved());
// $NON-NLS-1$
assertTrue("0.4", c1_100.isResolved());
// $NON-NLS-1$
assertTrue("0.5", d1_100.isResolved());
ExportPackageDescription[] b1ResolvedImports = b1_100.getResolvedImports();
ExportPackageDescription[] d1ResolvedImports = d1_100.getResolvedImports();
ExportPackageDescription[] isConsistent = isConsistent(b1ResolvedImports, d1ResolvedImports);
// $NON-NLS-1$
assertNull("1.1 Packages are not consistent: " + isConsistent, isConsistent);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "B1");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "b; uses:=a");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "a;bundle-symbolic-name=A1");
// $NON-NLS-1$
b1_100 = state.getFactory().createBundleDescription(state, manifest, "b1_100", 2);
state.updateBundle(b1_100);
state.resolve();
// $NON-NLS-1$
assertTrue("2.1", a1_100.isResolved());
// $NON-NLS-1$
assertFalse("2.2", a2_100.isResolved());
// $NON-NLS-1$
assertTrue("2.3", b1_100.isResolved());
// $NON-NLS-1$
assertTrue("2.4", c1_100.isResolved());
// $NON-NLS-1$
assertTrue("2.5", d1_100.isResolved());
b1ResolvedImports = b1_100.getResolvedImports();
d1ResolvedImports = d1_100.getResolvedImports();
isConsistent = isConsistent(b1ResolvedImports, d1ResolvedImports);
// $NON-NLS-1$
assertNull("3.1 Packages are not consistent: " + isConsistent, isConsistent);
}
use of org.eclipse.osgi.service.resolver.BundleDescription in project rt.equinox.framework by eclipse.
the class StateResolverTest method testSingletonsSelection5.
public void testSingletonsSelection5() throws BundleException {
State state = buildEmptyState();
// test the selection algorithm of the resolver to pick the bundles with the largest version
long id = 0;
Hashtable manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$ //$NON-NLS-2$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "base; " + Constants.SINGLETON_DIRECTIVE + ":=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
BundleDescription base10 = state.getFactory().createBundleDescription(state, manifest, "base10", id++);
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$ //$NON-NLS-2$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "base; " + Constants.SINGLETON_DIRECTIVE + ":=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.1");
// $NON-NLS-1$
BundleDescription base11 = state.getFactory().createBundleDescription(state, manifest, "base11", id++);
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$ //$NON-NLS-2$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "requires; " + Constants.SINGLETON_DIRECTIVE + ":=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.REQUIRE_BUNDLE, "base; bundle-version=\"[1.0,1.1)\"");
// $NON-NLS-1$
BundleDescription requires10 = state.getFactory().createBundleDescription(state, manifest, "requires10", id++);
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$ //$NON-NLS-2$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "requires; " + Constants.SINGLETON_DIRECTIVE + ":=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.1");
// $NON-NLS-1$
manifest.put(Constants.REQUIRE_BUNDLE, "base; bundle-version=\"[1.1,1.2)\"");
// $NON-NLS-1$
BundleDescription requires11 = state.getFactory().createBundleDescription(state, manifest, "requires11", id++);
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$ //$NON-NLS-2$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "frag; " + Constants.SINGLETON_DIRECTIVE + ":=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "requires; bundle-version=\"[1.0,1.1)\"");
// $NON-NLS-1$
BundleDescription frag10 = state.getFactory().createBundleDescription(state, manifest, "frag10", id++);
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$ //$NON-NLS-2$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "frag; " + Constants.SINGLETON_DIRECTIVE + ":=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.1");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "requires; bundle-version=\"[1.1,1.2)\"");
// $NON-NLS-1$
BundleDescription frag11 = state.getFactory().createBundleDescription(state, manifest, "frag11", id++);
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$ //$NON-NLS-2$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "fragb; " + Constants.SINGLETON_DIRECTIVE + ":=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "requires; bundle-version=\"[1.0,1.1)\"");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "fragb; version=1.0");
// $NON-NLS-1$
BundleDescription fragb10 = state.getFactory().createBundleDescription(state, manifest, "frag10", id++);
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$ //$NON-NLS-2$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "fragb; " + Constants.SINGLETON_DIRECTIVE + ":=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.1");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "requires; bundle-version=\"[1.1,1.2)\"");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "fragb; version=1.1");
// $NON-NLS-1$
BundleDescription fragb11 = state.getFactory().createBundleDescription(state, manifest, "frag11", id++);
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "import");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "fragb; version=\"[1.0,1.0]\"");
// $NON-NLS-1$
BundleDescription import10 = state.getFactory().createBundleDescription(state, manifest, "import10", id++);
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "import");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.1");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "fragb; version=\"[1.1,1.1]\"");
// $NON-NLS-1$
BundleDescription import11 = state.getFactory().createBundleDescription(state, manifest, "import11", id++);
state.addBundle(base10);
state.addBundle(base11);
state.addBundle(requires10);
state.addBundle(requires11);
state.addBundle(frag10);
state.addBundle(frag11);
state.addBundle(fragb10);
state.addBundle(fragb11);
state.addBundle(import10);
state.addBundle(import11);
state.resolve();
// $NON-NLS-1$
assertTrue("1.0", base11.isResolved());
// $NON-NLS-1$
assertTrue("1.1", requires11.isResolved());
// $NON-NLS-1$
assertTrue("1.2", frag11.isResolved());
// $NON-NLS-1$
assertTrue("1.3", fragb11.isResolved());
// $NON-NLS-1$
assertTrue("1.4", import11.isResolved());
// $NON-NLS-1$
assertFalse("1.5", base10.isResolved());
// $NON-NLS-1$
assertFalse("1.6", requires10.isResolved());
// $NON-NLS-1$
assertFalse("1.7", frag10.isResolved());
// $NON-NLS-1$
assertFalse("1.8", fragb10.isResolved());
// $NON-NLS-1$
assertFalse("1.9", import10.isResolved());
}
use of org.eclipse.osgi.service.resolver.BundleDescription in project rt.equinox.framework by eclipse.
the class StateResolverTest method testBug320124.
public void testBug320124() throws BundleException {
State state = buildEmptyState();
int bundleID = 0;
Hashtable manifest = new Hashtable();
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.0");
BundleDescription a = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), bundleID++);
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.0");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "a");
// $NON-NLS-1$
manifest.put(Constants.REQUIRE_BUNDLE, "d");
BundleDescription b = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), bundleID++);
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "c");
// $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.REQUIRE_BUNDLE, "e");
BundleDescription c = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), bundleID++);
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "d");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "d");
BundleDescription d = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), bundleID++);
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "e");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "e");
BundleDescription e = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), bundleID++);
state.addBundle(a);
state.addBundle(b);
state.addBundle(c);
state.addBundle(d);
state.addBundle(e);
state.resolve();
// $NON-NLS-1$
assertTrue("A is not resolved", a.isResolved());
// $NON-NLS-1$
assertTrue("B is not resolved", b.isResolved());
// $NON-NLS-1$
assertTrue("C is not resolved", c.isResolved());
// $NON-NLS-1$
assertTrue("D is not resolved", d.isResolved());
ExportPackageDescription[] visible = state.getStateHelper().getVisiblePackages(a, StateHelper.VISIBLE_INCLUDE_EE_PACKAGES | StateHelper.VISIBLE_INCLUDE_ALL_HOST_WIRES);
assertEquals("Wrong number of visible", 2, visible.length);
}
use of org.eclipse.osgi.service.resolver.BundleDescription in project rt.equinox.framework by eclipse.
the class StateResolverTest method testPlatformProperties01.
public void testPlatformProperties01() throws BundleException {
State state = buildEmptyState();
int bundleID = 0;
// test the selection algorithm of the resolver to pick the bundles which
// resolve the largest set of bundles; with fragments using Import-Package
Hashtable manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "org.eclipse.osgi");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
BundleDescription systemBundle = state.getFactory().createBundleDescription(state, manifest, "org.eclipse.osgi", bundleID++);
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, "pkg.b, pkg.system.b");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "J2SE-1.4");
// $NON-NLS-1$
BundleDescription a = state.getFactory().createBundleDescription(state, manifest, "A", bundleID++);
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.EXPORT_PACKAGE, "pkg.b");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "pkg.system.b");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "J2SE-1.2");
// $NON-NLS-1$
BundleDescription b = state.getFactory().createBundleDescription(state, manifest, "B", bundleID++);
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "C");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "pkg.d, pkg.system.b");
// $NON-NLS-1$
manifest.put(Constants.REQUIRE_CAPABILITY, "osgi.ee; filter:=\"(&(osgi.ee=JavaSE)(version>=1.4))\"");
// $NON-NLS-1$
BundleDescription c = state.getFactory().createBundleDescription(state, manifest, "C", bundleID++);
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "D");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "pkg.d");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "pkg.system.b");
// $NON-NLS-1$
manifest.put(Constants.REQUIRE_CAPABILITY, "osgi.ee; filter:=\"(&(osgi.ee=JavaSE)(version>=1.2))\"");
// $NON-NLS-1$
BundleDescription d = state.getFactory().createBundleDescription(state, manifest, "D", bundleID++);
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "system.b");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "pkg.system.b");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "J2SE-1.2");
// $NON-NLS-1$
BundleDescription systemB = state.getFactory().createBundleDescription(state, manifest, "system.b", bundleID++);
Dictionary[] props = new Dictionary[] { new Hashtable(), new Hashtable() };
// $NON-NLS-1$ //$NON-NLS-2$
props[0].put("org.osgi.framework.system.packages", "pkg.system.a, pkg.system.c");
// $NON-NLS-1$ //$NON-NLS-2$
props[0].put("org.osgi.framework.executionenvironment", "J2SE-1.2");
props[0].put("org.osgi.framework.system.capabilities", "osgi.ee; osgi.ee=\"JavaSE\"; version:Version=\"1.2\"");
// $NON-NLS-1$ //$NON-NLS-2$
props[1].put("org.osgi.framework.system.packages", "pkg.system.a, pkg.system.b, pkg.system.c");
// $NON-NLS-1$ //$NON-NLS-2$
props[1].put("org.osgi.framework.executionenvironment", "J2SE-1.4");
props[1].put("org.osgi.framework.system.capabilities", "osgi.ee; osgi.ee=\"JavaSE\"; version:List<Version>=\"1.2, 1.3, 1.4\"");
state.setPlatformProperties(props);
state.addBundle(systemBundle);
state.addBundle(a);
state.addBundle(b);
state.addBundle(c);
state.addBundle(d);
state.addBundle(systemB);
state.resolve();
Collection ids = systemBundle.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE);
assertNotNull("Null osgi.identity", ids);
assertEquals("Wrong number of identities", 1, ids.size());
// $NON-NLS-1$
assertTrue("1.0", systemBundle.isResolved());
// $NON-NLS-1$
assertTrue("1.1", a.isResolved());
// $NON-NLS-1$
assertTrue("1.2", b.isResolved());
// $NON-NLS-1$
assertTrue("1.3", c.isResolved());
// $NON-NLS-1$
assertTrue("1.4", d.isResolved());
// $NON-NLS-1$
assertTrue("1.5", systemB.isResolved());
// $NON-NLS-1$
assertTrue("2.0", a.getResolvedImports()[1].getExporter() == systemBundle);
// $NON-NLS-1$
assertTrue("2.1", b.getResolvedImports()[0].getExporter() == systemB);
// $NON-NLS-1$
assertTrue("2.2", c.getResolvedImports()[1].getExporter() == systemBundle);
// $NON-NLS-1$
assertTrue("2.3", d.getResolvedImports()[0].getExporter() == systemB);
// now test the uses clause for pkg.b such that bundle 'A' will be forced to used
// pkg.system.b from bundle 'system.b'
// $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.EXPORT_PACKAGE, "pkg.b; uses:=\"pkg.system.b\"");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "pkg.system.b");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "J2SE-1.2");
// $NON-NLS-1$
BundleDescription b_updated = state.getFactory().createBundleDescription(state, manifest, "B", b.getBundleId());
state.updateBundle(b_updated);
// now test the uses clause for pkg.d such that bundle 'C' will be forced to used
// pkg.system.b from bundle 'system.b'
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "D");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "pkg.d; uses:=\"pkg.system.b\"");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "pkg.system.b");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "J2SE-1.2");
// $NON-NLS-1$
BundleDescription d_updated = state.getFactory().createBundleDescription(state, manifest, "D", d.getBundleId());
state.updateBundle(d_updated);
state.resolve(new BundleDescription[] { b_updated, d_updated });
// $NON-NLS-1$
assertTrue("3.0", systemBundle.isResolved());
// $NON-NLS-1$
assertTrue("3.1", a.isResolved());
// $NON-NLS-1$
assertTrue("3.2", b_updated.isResolved());
// $NON-NLS-1$
assertTrue("3.3", systemB.isResolved());
// $NON-NLS-1$
assertTrue("2.0", a.getResolvedImports()[1].getExporter() == systemB);
// $NON-NLS-1$
assertTrue("2.1", b_updated.getResolvedImports()[0].getExporter() == systemB);
// $NON-NLS-1$
assertTrue("2.2", c.getResolvedImports()[1].getExporter() == systemB);
}
use of org.eclipse.osgi.service.resolver.BundleDescription in project rt.equinox.framework by eclipse.
the class StateResolverTest method testSelectionPolicy.
public void testSelectionPolicy() throws BundleException {
State state = buildEmptyState();
Resolver resolver = state.getResolver();
resolver.setSelectionPolicy(new Comparator() {
public int compare(Object o1, Object o2) {
if (!(o1 instanceof BaseDescription) || !(o2 instanceof BaseDescription))
throw new IllegalArgumentException();
Version v1 = null;
Version v2 = null;
v1 = ((BaseDescription) o1).getVersion();
v2 = ((BaseDescription) o2).getVersion();
// only take version in to account and use lower versions over higher ones
return v1.compareTo(v2);
}
});
Hashtable manifest = new Hashtable();
long bundleID = 0;
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "test.host; singleton:=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
BundleDescription testHost100 = state.getFactory().createBundleDescription(state, manifest, "test.host100", bundleID++);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "test.host; singleton:=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.1");
// $NON-NLS-1$
BundleDescription testHost101 = state.getFactory().createBundleDescription(state, manifest, "test.host101", bundleID++);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "test.frag; singleton:=true");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "test.host; bundle-version=\"[1.0.0,2.0.0)\"");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
BundleDescription testFrag100 = state.getFactory().createBundleDescription(state, manifest, "test.frag100", bundleID++);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "test.frag; singleton:=true");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "test.host; bundle-version=\"[1.0.0,2.0.0)\"");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.1");
// $NON-NLS-1$
BundleDescription testFrag101 = state.getFactory().createBundleDescription(state, manifest, "test.frag101", bundleID++);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "test.dependent; singleton:=true");
// $NON-NLS-1$
manifest.put(Constants.REQUIRE_BUNDLE, "test.host; bundle-version=\"[1.0.0,2.0.0)\"");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
BundleDescription testDependent = state.getFactory().createBundleDescription(state, manifest, "test.frag101", bundleID++);
state.addBundle(testHost100);
state.addBundle(testFrag100);
state.addBundle(testHost101);
state.addBundle(testFrag101);
state.addBundle(testDependent);
state.resolve();
// $NON-NLS-1$
assertTrue("1.0", testHost100.isResolved());
// $NON-NLS-1$
assertFalse("1.1", testHost101.isResolved());
// $NON-NLS-1$
assertTrue("1.2", testFrag100.isResolved());
// $NON-NLS-1$
assertFalse("1.3", testFrag101.isResolved());
// $NON-NLS-1$
assertTrue("1.4", testDependent.isResolved());
}
Aggregations