use of org.eclipse.osgi.service.resolver.ExportPackageDescription in project rt.equinox.framework by eclipse.
the class DevModeTest method testDevModeDomino02.
public void testDevModeDomino02() throws BundleException {
State state = buildDevModeState();
int bundleID = 0;
Hashtable manifest = new Hashtable();
manifest.clear();
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "A");
manifest.put(Constants.BUNDLE_VERSION, "1.0");
manifest.put(Constants.EXPORT_PACKAGE, "a");
manifest.put(Constants.IMPORT_PACKAGE, "x, d");
manifest.put(Constants.REQUIRE_BUNDLE, "X, E");
BundleDescription a = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
manifest.clear();
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "B");
manifest.put(Constants.BUNDLE_VERSION, "1.0");
manifest.put(Constants.REQUIRE_BUNDLE, "A");
BundleDescription b = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
manifest.clear();
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "C");
manifest.put(Constants.BUNDLE_VERSION, "1.0");
manifest.put(Constants.REQUIRE_BUNDLE, "A");
BundleDescription c = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
manifest.clear();
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "D");
manifest.put(Constants.BUNDLE_VERSION, "1.0");
manifest.put(Constants.EXPORT_PACKAGE, "d");
BundleDescription d = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
manifest.clear();
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "E");
manifest.put(Constants.BUNDLE_VERSION, "1.0");
manifest.put(Constants.EXPORT_PACKAGE, "e");
BundleDescription e = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
state.addBundle(a);
state.addBundle(b);
state.addBundle(c);
state.addBundle(d);
state.addBundle(e);
state.resolve();
// bundle a has an unsatisfied constraint
// b, c, d, e should still be resolved though
assertFalse("0.1", a.isResolved());
assertTrue("0.3", b.isResolved());
assertTrue("0.4", c.isResolved());
assertTrue("0.5", d.isResolved());
assertTrue("0.5", e.isResolved());
BundleDescription[] aRequired = a.getResolvedRequires();
assertTrue("1.1", aRequired.length == 1);
assertTrue("1.2", aRequired[0] == e);
ExportPackageDescription[] aImported = a.getResolvedImports();
assertTrue("1.3", aImported.length == 1);
assertTrue("1.4", aImported[0].getExporter() == d);
BundleDescription[] bRequired = b.getResolvedRequires();
assertTrue("2.1", bRequired.length == 1);
assertTrue("2.2", bRequired[0] == a);
BundleDescription[] cRequired = c.getResolvedRequires();
assertTrue("3.1", cRequired.length == 1);
assertTrue("3.2", cRequired[0] == a);
}
use of org.eclipse.osgi.service.resolver.ExportPackageDescription 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.ExportPackageDescription 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.ExportPackageDescription in project rt.equinox.framework by eclipse.
the class StateResolverTest method testCyclicTransitiveUses.
public void testCyclicTransitiveUses() 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, "A2");
// $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 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.EXPORT_PACKAGE, "d; uses:=c");
// $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();
// $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.ExportPackageDescription in project rt.equinox.framework by eclipse.
the class StateResolverTest method testRequireBundleUses.
public void testRequireBundleUses() throws BundleException {
State state = buildEmptyState();
int id = 0;
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, "a");
// $NON-NLS-1$
BundleDescription a_100 = state.getFactory().createBundleDescription(state, manifest, "a_100", id++);
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, "2.0.0");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "a");
// $NON-NLS-1$
BundleDescription a_200 = state.getFactory().createBundleDescription(state, manifest, "a_200", 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, "b; uses:=a");
// $NON-NLS-1$
manifest.put(Constants.REQUIRE_BUNDLE, "A; visibility:=reexport");
// $NON-NLS-1$
BundleDescription b_100 = state.getFactory().createBundleDescription(state, manifest, "b_100", id++);
manifest = new Hashtable();
// $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.EXPORT_PACKAGE, "c; uses:=b");
// $NON-NLS-1$
manifest.put(Constants.REQUIRE_BUNDLE, "A, B");
// $NON-NLS-1$
BundleDescription c_100 = state.getFactory().createBundleDescription(state, manifest, "c_100", id++);
state.addBundle(a_100);
state.addBundle(b_100);
// first resolve just A and B
state.resolve();
// $NON-NLS-1$
assertTrue("0.1", a_100.isResolved());
// $NON-NLS-1$
assertTrue("0.2", b_100.isResolved());
// now add A v2 and resolve it
state.addBundle(a_200);
state.resolve();
// $NON-NLS-1$
assertTrue("1.1", a_200.isResolved());
// now add C and make sure it does not get packages from A v2
state.addBundle(c_100);
state.resolve();
// $NON-NLS-1$
assertTrue("1.2", c_100.isResolved());
ExportPackageDescription[] c1ResolvedImports = state.getStateHelper().getVisiblePackages(c_100);
// $NON-NLS-1$
assertTrue("2.1", c1ResolvedImports.length == 2);
// $NON-NLS-1$ //$NON-NLS-2$
int index = c1ResolvedImports[0].getName().equals("a") ? 0 : c1ResolvedImports[1].getName().equals("a") ? 1 : -1;
// $NON-NLS-1$
assertTrue("2.2", index >= 0);
// $NON-NLS-1$
assertEquals("2.2", c1ResolvedImports[index].getExporter(), a_100);
}
Aggregations