use of org.eclipse.osgi.service.resolver.BundleDescription in project rt.equinox.framework by eclipse.
the class StateResolverTest method testNativeCodeResolution06.
public void testNativeCodeResolution06() throws BundleException {
State state = buildEmptyState();
Dictionary[] props = new Dictionary[] { new Hashtable(), new Hashtable(), new Hashtable() };
// empty props[0]
// $NON-NLS-1$ //$NON-NLS-2$
props[1].put("osgi.ws", "win32");
// $NON-NLS-1$ //$NON-NLS-2$
props[1].put("osgi.os", "win32");
// $NON-NLS-1$ //$NON-NLS-2$
props[1].put("osgi.arch", "x86_64");
// $NON-NLS-1$ //$NON-NLS-2$
props[2].put("osgi.ws", "win32");
// $NON-NLS-1$ //$NON-NLS-2$
props[2].put("osgi.os", "win32");
// $NON-NLS-1$ //$NON-NLS-2$
props[2].put("osgi.arch", "x86");
state.setPlatformProperties(props);
Hashtable manifest = new Hashtable();
long bundleID = 0;
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "NativeBundle1");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_NATIVECODE, "Bundle-NativeCode: nativefile1.txt;processor=x86;osname=win32");
// $NON-NLS-1$
BundleDescription testNativeBundle1 = state.getFactory().createBundleDescription(state, manifest, "NativeBundle", bundleID++);
state.addBundle(testNativeBundle1);
state.resolve();
// $NON-NLS-1$
assertTrue("1.0", testNativeBundle1.isResolved());
}
use of org.eclipse.osgi.service.resolver.BundleDescription in project rt.equinox.framework by eclipse.
the class StateResolverTest method testRemovalPending.
public void testRemovalPending() throws BundleException {
State state = buildEmptyState();
Hashtable wManifest = new Hashtable();
// $NON-NLS-1$
wManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
wManifest.put(Constants.BUNDLE_SYMBOLICNAME, "W");
// $NON-NLS-1$
wManifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
wManifest.put(Constants.EXPORT_PACKAGE, "a; b; version=1.0");
// $NON-NLS-1$
wManifest.put(Constants.IMPORT_PACKAGE, "a, b");
// $NON-NLS-1$
BundleDescription w1_100 = state.getFactory().createBundleDescription(state, wManifest, "w1_100", 0);
Hashtable manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "X");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "a");
// $NON-NLS-1$
BundleDescription x1_100 = state.getFactory().createBundleDescription(state, manifest, "x1_100", 1);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "Y");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "a");
// $NON-NLS-1$
BundleDescription y1_100 = state.getFactory().createBundleDescription(state, manifest, "y1_100", 2);
state.addBundle(w1_100);
state.addBundle(x1_100);
state.addBundle(y1_100);
state.resolve();
// $NON-NLS-1$
assertTrue("0.1", w1_100.isResolved());
// $NON-NLS-1$
assertTrue("0.2", x1_100.isResolved());
// $NON-NLS-1$
assertTrue("0.3", y1_100.isResolved());
// $NON-NLS-1$
BundleDescription w1_100_prime = state.getFactory().createBundleDescription(state, wManifest, "w1_100", 0);
state.updateBundle(w1_100_prime);
state.resolve(new BundleDescription[0]);
// $NON-NLS-1$
assertTrue("1.1", w1_100_prime.isResolved());
// $NON-NLS-1$
assertTrue("1.2", x1_100.isResolved());
// $NON-NLS-1$
assertTrue("1.3", y1_100.isResolved());
ExportPackageDescription[] exports_w1_100 = w1_100.getSelectedExports();
ExportPackageDescription[] imports_w1_100_prime = w1_100_prime.getResolvedImports();
ExportPackageDescription[] isConsistent = isConsistent(exports_w1_100, imports_w1_100_prime);
// $NON-NLS-1$
assertNull("2.1 Packages are not consistent: " + isConsistent, isConsistent);
state.resolve(new BundleDescription[] { w1_100 });
// $NON-NLS-1$
assertTrue("3.1", w1_100_prime.isResolved());
// $NON-NLS-1$
assertTrue("3.2", x1_100.isResolved());
// $NON-NLS-1$
assertTrue("3.3", y1_100.isResolved());
ExportPackageDescription[] exports_w1_100_prime = w1_100_prime.getSelectedExports();
imports_w1_100_prime = w1_100_prime.getResolvedImports();
isConsistent = isConsistent(exports_w1_100_prime, imports_w1_100_prime);
// $NON-NLS-1$
assertNull("4.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 testTransitiveUses.
public void testTransitiveUses() 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");
// $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, "A2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "a");
// $NON-NLS-1$
BundleDescription a2_100 = state.getFactory().createBundleDescription(state, manifest, "a2_100", 1);
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");
// $NON-NLS-1$
BundleDescription b1_100 = state.getFactory().createBundleDescription(state, manifest, "b1_100", 2);
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", 3);
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.IMPORT_PACKAGE, "a, c");
// $NON-NLS-1$
BundleDescription d1_100 = state.getFactory().createBundleDescription(state, manifest, "d1_100", 4);
state.addBundle(a1_100);
state.addBundle(a2_100);
state.addBundle(b1_100);
state.addBundle(c1_100);
state.addBundle(d1_100);
state.resolve();
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();
b1ResolvedImports = b1_100.getResolvedImports();
d1ResolvedImports = d1_100.getResolvedImports();
isConsistent = isConsistent(b1ResolvedImports, d1ResolvedImports);
// $NON-NLS-1$
assertNull("1.2 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 testResolveFragmentEE01.
public void testResolveFragmentEE01() throws BundleException {
State state = buildEmptyState();
Dictionary[] props = new Dictionary[] { new Hashtable() };
// $NON-NLS-1$ //$NON-NLS-2$
props[0].put("org.osgi.framework.executionenvironment", "test");
state.setPlatformProperties(props);
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, "org.eclipse.osgi");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "test");
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, "org.eclipse.osgi; bundle-version=\"[1.0, 1.1)\"");
manifest.put(Constants.REQUIRE_CAPABILITY, "osgi.ee; filter:=\"(osgi.ee=test)\"");
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.REQUIRE_CAPABILITY, "osgi.identity; filter:=\"(osgi.identity=b)\"");
BundleDescription c = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), bundleID++);
state.addBundle(b);
state.addBundle(a);
state.addBundle(c);
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());
BundleWiring aWiring = a.getWiring();
List aRequirements = a.getRequirements("osgi.ee");
List aRequiredWires = aWiring.getRequiredWires("osgi.ee");
assertEquals("Wrong number of osgi.ee requirements from system bundle", 1, aRequirements.size());
assertEquals("Wrong number of wires from system bundle", 1, aRequiredWires.size());
BundleWiring bWiring = b.getWiring();
List bRequirements = b.getRequirements("osgi.ee");
List bRequiredWires = bWiring.getRequiredWires("osgi.ee");
assertEquals("Wrong number of osgi.ee requirements from fragment", 1, bRequirements.size());
assertEquals("Wrong number of wires from fragment", 1, bRequiredWires.size());
BundleWiring cWiring = c.getWiring();
List cRequirements = c.getRequirements("osgi.identity");
List cRequiredWires = cWiring.getRequiredWires("osgi.identity");
assertEquals("Wrong number of osgi.identity requirements from c", 1, cRequirements.size());
assertEquals("Wrong number of wires from c", 1, cRequiredWires.size());
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, "org.eclipse.osgi; bundle-version=\"[1.0, 1.1)\"");
manifest.put(Constants.REQUIRE_CAPABILITY, "osgi.ee; filter:=\"(osgi.ee=fail)\"");
b = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), b.getBundleId());
state.updateBundle(b);
state.resolve(false);
// $NON-NLS-1$
assertTrue("A is not resolved", a.isResolved());
// $NON-NLS-1$
assertFalse("B is not resolved", b.isResolved());
// $NON-NLS-1$
assertFalse("C is not resolved", c.isResolved());
}
use of org.eclipse.osgi.service.resolver.BundleDescription in project rt.equinox.framework by eclipse.
the class StateResolverTest method testImportJavaPackages.
public void testImportJavaPackages() throws Exception {
State state = buildEmptyState();
int bundleID = 0;
Hashtable manifest = new Hashtable();
Dictionary[] props = new Dictionary[] { new Hashtable() };
props[0].put("org.osgi.framework.executionenvironment", "J2SE-1.5, JavaSE-1.6");
props[0].put(Constants.FRAMEWORK_SYSTEMPACKAGES, "java.lang,java.util");
state.setPlatformProperties(props);
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "org.eclipse.osgi");
BundleDescription systemBundle = state.getFactory().createBundleDescription(state, manifest, "org.eclipse.osgi", bundleID++);
state.addBundle(systemBundle);
List bundles = new ArrayList();
manifest.clear();
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "A");
manifest.put(Constants.IMPORT_PACKAGE, "java.lang");
manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "JavaSE-1.6");
BundleDescription a = state.getFactory().createBundleDescription(state, manifest, "A", bundleID++);
bundles.add(a);
state.addBundle(a);
manifest.clear();
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "A.FRAG");
manifest.put(Constants.FRAGMENT_HOST, "A");
manifest.put(Constants.IMPORT_PACKAGE, "java.lang,java.util");
manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "J2SE-1.5");
BundleDescription aFrag = state.getFactory().createBundleDescription(state, manifest, "A.FRAG", bundleID++);
bundles.add(aFrag);
state.addBundle(aFrag);
manifest.clear();
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "B");
manifest.put(Constants.IMPORT_PACKAGE, "java.xyz");
manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "JavaSE-1.6");
BundleDescription b = state.getFactory().createBundleDescription(state, manifest, "B", bundleID++);
bundles.add(b);
state.addBundle(b);
state.resolve();
assertTrue("host A not resolved", a.isResolved());
assertTrue("fragment A.FRAG not resolved", aFrag.isResolved());
assertFalse("host B is wrongly resolved", b.isResolved());
}
Aggregations