use of org.eclipse.osgi.service.resolver.BundleDescription in project rt.equinox.framework by eclipse.
the class DevModeTest method testDevModeSingleton02.
public void testDevModeSingleton02() 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; singleton:=true");
manifest.put(Constants.BUNDLE_VERSION, "1.0");
manifest.put(Constants.EXPORT_PACKAGE, "a");
manifest.put(Constants.IMPORT_PACKAGE, "x");
BundleDescription a1 = 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, "A; singleton:=true");
manifest.put(Constants.BUNDLE_VERSION, "2.0");
manifest.put(Constants.EXPORT_PACKAGE, "a");
BundleDescription a2 = 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; bundle-version=2.0");
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; bundle-version=\"[1.0,2.0)\"");
BundleDescription c = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
state.addBundle(a1);
state.addBundle(a2);
state.addBundle(b);
state.addBundle(c);
state.resolve();
// only a2 is resolved because a1 has an unsatisfied constraint
// c should still be resolved to a1 though
assertFalse("0.1", a1.isResolved());
assertTrue("0.2", a2.isResolved());
assertTrue("0.3", b.isResolved());
assertTrue("0.4", c.isResolved());
BundleDescription[] bRequired = b.getResolvedRequires();
assertTrue("1.1", bRequired.length == 1);
assertTrue("1.2", bRequired[0] == a2);
BundleDescription[] cRequired = c.getResolvedRequires();
assertTrue("2.1", cRequired.length == 1);
assertTrue("2.2", cRequired[0] == a1);
}
use of org.eclipse.osgi.service.resolver.BundleDescription in project rt.equinox.framework by eclipse.
the class DevModeTest method testDevModeSingleton01.
public void testDevModeSingleton01() 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; singleton:=true");
manifest.put(Constants.BUNDLE_VERSION, "1.0");
manifest.put(Constants.EXPORT_PACKAGE, "a");
BundleDescription a1 = 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, "A; singleton:=true");
manifest.put(Constants.BUNDLE_VERSION, "2.0");
manifest.put(Constants.EXPORT_PACKAGE, "a");
BundleDescription a2 = 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; bundle-version=2.0");
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; bundle-version=\"[1.0,2.0)\"");
BundleDescription c = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
state.addBundle(a1);
state.addBundle(a2);
state.addBundle(b);
state.addBundle(c);
state.resolve();
// both versions of A should be resolved
assertTrue("0.1", a1.isResolved());
assertTrue("0.2", a2.isResolved());
assertTrue("0.3", b.isResolved());
assertTrue("0.4", c.isResolved());
BundleDescription[] bRequired = b.getResolvedRequires();
assertTrue("1.1", bRequired.length == 1);
assertTrue("1.2", bRequired[0] == a2);
BundleDescription[] cRequired = c.getResolvedRequires();
assertTrue("2.1", cRequired.length == 1);
assertTrue("2.2", cRequired[0] == a1);
}
use of org.eclipse.osgi.service.resolver.BundleDescription 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.BundleDescription in project rt.equinox.framework by eclipse.
the class StateResolverTest method testReinstall.
// temporarily disabled
public void testReinstall() throws BundleException {
State state = buildComplexState();
StateDelta delta = state.resolve();
// remove bundle 4 - should cause 6 to be unresolved
state.removeBundle(4);
delta = state.resolve();
// $NON-NLS-1$
assertEquals("1.0", 1, delta.getChanges(BundleDelta.REMOVED | BundleDelta.UNRESOLVED | BundleDelta.REMOVAL_COMPLETE, true).length);
// $NON-NLS-1$
assertEquals("1.1", 4, delta.getChanges(BundleDelta.REMOVED | BundleDelta.UNRESOLVED | BundleDelta.REMOVAL_COMPLETE, true)[0].getBundle().getBundleId());
// $NON-NLS-1$
assertEquals("2.0", 1, delta.getChanges(BundleDelta.UNRESOLVED, true).length);
// $NON-NLS-1$
assertEquals("2.1", 6, delta.getChanges(BundleDelta.UNRESOLVED, true)[0].getBundle().getBundleId());
// reinstall bundle 4 - should cause 6 to be resolved again
BundleDescription b4 = delta.getChanges(BundleDelta.REMOVED | BundleDelta.UNRESOLVED | BundleDelta.REMOVAL_COMPLETE, true)[0].getBundle();
state.addBundle(b4);
delta = state.resolve();
// $NON-NLS-1$
assertEquals("3.0", 1, delta.getChanges(BundleDelta.ADDED | BundleDelta.RESOLVED, true).length);
// $NON-NLS-1$
assertEquals("3.1", 4, delta.getChanges(BundleDelta.ADDED | BundleDelta.RESOLVED, true)[0].getBundle().getBundleId());
// $NON-NLS-1$
assertEquals("4.0", 1, delta.getChanges(BundleDelta.RESOLVED, true).length);
// $NON-NLS-1$
assertEquals("4.1", 6, delta.getChanges(BundleDelta.RESOLVED, true)[0].getBundle().getBundleId());
}
use of org.eclipse.osgi.service.resolver.BundleDescription in project rt.equinox.framework by eclipse.
the class StateResolverTest method testRemoveAndAdd.
public void testRemoveAndAdd() throws BundleException {
// $NON-NLS-1$
String B_LOCATION = "org.eclipse.b";
// $NON-NLS-1$ //$NON-NLS-2$
final String B_MANIFEST = "Bundle-SymbolicName: org.eclipse.b\n" + "Bundle-Version: 1.0\n";
State state = buildEmptyState();
BundleDescription b1 = state.getFactory().createBundleDescription(parseManifest(B_MANIFEST), B_LOCATION, 1);
BundleDescription b2 = state.getFactory().createBundleDescription(parseManifest(B_MANIFEST), B_LOCATION, 2);
state.addBundle(b1);
StateDelta delta = state.resolve();
BundleDelta[] changes = delta.getChanges();
// $NON-NLS-1$
assertEquals("1.0", 1, changes.length);
// $NON-NLS-1$
assertEquals("1.1", b1, changes[0].getBundle());
// $NON-NLS-1$
assertEquals("1.2", (BundleDelta.ADDED | BundleDelta.RESOLVED), changes[0].getType());
// $NON-NLS-1$
assertFullyResolved("1.3", b1);
state.removeBundle(b1);
state.addBundle(b2);
delta = state.resolve();
// $NON-NLS-1$
assertEquals("2.0", 2, delta.getChanges().length);
// $NON-NLS-1$
assertEquals("2.1", 1, delta.getChanges(BundleDelta.UNRESOLVED | BundleDelta.REMOVED, true).length);
// $NON-NLS-1$
assertEquals("2.2", b1, delta.getChanges(BundleDelta.UNRESOLVED | BundleDelta.REMOVED, true)[0].getBundle());
// $NON-NLS-1$
assertEquals("2.3", 1, delta.getChanges(BundleDelta.RESOLVED | BundleDelta.ADDED, true).length);
// $NON-NLS-1$
assertEquals("2.3", b2, delta.getChanges(BundleDelta.RESOLVED | BundleDelta.ADDED, true)[0].getBundle());
}
Aggregations