use of org.eclipse.osgi.service.resolver.StateDelta 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.StateDelta 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());
}
use of org.eclipse.osgi.service.resolver.StateDelta in project rt.equinox.framework by eclipse.
the class StateResolverTest method testComplexResolution.
public void testComplexResolution() throws BundleException {
State state = buildComplexState();
StateDelta delta = state.resolve();
// $NON-NLS-1$ //$NON-NLS-2$
BundleDescription b1 = state.getBundle("org.eclipse.b1", Version.parseVersion("1.0"));
// $NON-NLS-1$ //$NON-NLS-2$
BundleDescription b2 = state.getBundle("org.eclipse.b2", Version.parseVersion("2.0"));
// $NON-NLS-1$ //$NON-NLS-2$
BundleDescription b3 = state.getBundle("org.eclipse.b3", Version.parseVersion("2.0"));
// $NON-NLS-1$ //$NON-NLS-2$
BundleDescription b4 = state.getBundle("org.eclipse.b4", Version.parseVersion("2.0"));
// $NON-NLS-1$ //$NON-NLS-2$
BundleDescription b5 = state.getBundle("org.eclipse.b5", Version.parseVersion("1.0"));
// $NON-NLS-1$ //$NON-NLS-2$
BundleDescription b6 = state.getBundle("org.eclipse.b6", Version.parseVersion("1.0"));
// $NON-NLS-1$
assertNotNull("0.1", b1);
// $NON-NLS-1$
assertNotNull("0.2", b2);
// $NON-NLS-1$
assertNotNull("0.3", b3);
// $NON-NLS-1$
assertNotNull("0.4", b4);
// $NON-NLS-1$
assertNotNull("0.5", b5);
// $NON-NLS-1$
assertNotNull("0.6", b6);
BundleDelta[] changes = delta.getChanges();
// $NON-NLS-1$
assertEquals("1.0", 6, changes.length);
BundleDelta[] additions = delta.getChanges(BundleDelta.ADDED, false);
// $NON-NLS-1$
assertEquals("2.0", 6, additions.length);
BundleDelta[] resolutions = delta.getChanges(BundleDelta.RESOLVED, false);
// $NON-NLS-1$
assertEquals("3.0", 6, resolutions.length);
Map deltasMap = new HashMap();
for (int i = 0; i < resolutions.length; i++) deltasMap.put(resolutions[i].getBundle().getSymbolicName(), resolutions[i]);
// $NON-NLS-1$
assertNotNull("3.1", deltasMap.get(b1.getSymbolicName()));
// $NON-NLS-1$
assertNotNull("3.2", deltasMap.get(b2.getSymbolicName()));
// $NON-NLS-1$
assertNotNull("3.3", deltasMap.get(b3.getSymbolicName()));
// $NON-NLS-1$
assertNotNull("3.4", deltasMap.get(b4.getSymbolicName()));
// $NON-NLS-1$
assertNotNull("3.5", deltasMap.get(b5.getSymbolicName()));
// $NON-NLS-1$
assertNotNull("3.6", deltasMap.get(b6.getSymbolicName()));
BundleDelta[] unresolutions = delta.getChanges(BundleDelta.UNRESOLVED, false);
// $NON-NLS-1$
assertEquals("4.0", 0, unresolutions.length);
// $NON-NLS-1$
assertFullyResolved("5.1", b1);
// $NON-NLS-1$
assertFullyResolved("5.2", b2);
// $NON-NLS-1$
assertFullyResolved("5.3", b3);
// $NON-NLS-1$
assertFullyResolved("5.4", b4);
// $NON-NLS-1$
assertFullyResolved("5.5", b5);
// $NON-NLS-1$
assertFullyResolved("5.6", b6);
}
use of org.eclipse.osgi.service.resolver.StateDelta in project rt.equinox.framework by eclipse.
the class StateResolverTest method testAdd3Resolve1.
/**
* Tests adding 3 new bundles to an already resolved state and then
* resolving only one of the bundles. The result should be all 3 added
* bundles being resolved.
*/
public void testAdd3Resolve1() throws BundleException {
State state = buildInitialState();
StateDelta delta = state.resolve();
BundleDelta[] deltas = delta.getChanges();
BundleDescription b0 = state.getBundle(0);
// $NON-NLS-1$
assertNotNull("0.1", b0);
// $NON-NLS-1$
assertFullyResolved("0.2", b0);
Hashtable manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "org.eclipse.b1");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "org.osgi.framework");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "org.eclipse.p1; specification-version=1.0");
BundleDescription b1 = null;
try {
// $NON-NLS-1$
b1 = state.getFactory().createBundleDescription(manifest, "org.eclipse.b1", 1);
state.removeBundle(1);
state.addBundle(b1);
} catch (BundleException e) {
// $NON-NLS-1$
fail("Failed to create BundleDescription: " + e.getMessage());
}
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "org.eclipse.b2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "org.osgi.framework,org.eclipse.p1");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "org.eclipse.p2; specification-version=1.0");
BundleDescription b2 = null;
try {
// $NON-NLS-1$
b2 = state.getFactory().createBundleDescription(manifest, "org.eclipse.b2", 2);
state.removeBundle(2);
state.addBundle(b2);
} catch (BundleException e) {
// $NON-NLS-1$
fail("Failed to create BundleDescription: " + e.getMessage());
}
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "org.eclipse.b3");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "org.osgi.framework,org.eclipse.p2");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "org.eclipse.p3; specification-version=1.0");
BundleDescription b3 = null;
try {
// $NON-NLS-1$
b3 = state.getFactory().createBundleDescription(manifest, "org.eclipse.b3", 3);
state.removeBundle(3);
state.addBundle(b3);
} catch (BundleException e) {
// $NON-NLS-1$
fail("Failed to create BundleDescription: " + e.getMessage());
}
delta = state.resolve(new BundleDescription[] { state.getBundle(1) });
deltas = delta.getChanges();
// $NON-NLS-1$
assertEquals("1.0", 3, deltas.length);
Map deltasMap = new HashMap();
for (int i = 0; i < deltas.length; i++) deltasMap.put(new Long(deltas[i].getBundle().getBundleId()), deltas[i]);
// $NON-NLS-1$
assertNotNull("1.1", deltasMap.get(new Long(1)));
// $NON-NLS-1$
assertNotNull("1.2", deltasMap.get(new Long(2)));
// $NON-NLS-1$
assertNotNull("1.3", deltasMap.get(new Long(3)));
// $NON-NLS-1$
assertEquals("2.1", (BundleDelta.RESOLVED | BundleDelta.ADDED), ((BundleDelta) deltasMap.get(new Long(1))).getType());
// $NON-NLS-1$
assertEquals("2.2", (BundleDelta.RESOLVED | BundleDelta.ADDED), ((BundleDelta) deltasMap.get(new Long(2))).getType());
// $NON-NLS-1$
assertEquals("2.3", (BundleDelta.RESOLVED | BundleDelta.ADDED), ((BundleDelta) deltasMap.get(new Long(3))).getType());
}
use of org.eclipse.osgi.service.resolver.StateDelta in project rt.equinox.framework by eclipse.
the class StateResolverTest method testRemoval.
public void testRemoval() throws BundleException {
// $NON-NLS-1$
String B1_LOCATION = "org.eclipse.b1";
// $NON-NLS-1$ //$NON-NLS-2$
final String B1_MANIFEST = "Bundle-SymbolicName: org.eclipse.b1\n" + "Bundle-Version: 1.0\n";
// $NON-NLS-1$
String B2_LOCATION = "org.eclipse.b2";
// $NON-NLS-1$ //$NON-NLS-2$
final String B2_MANIFEST = "Bundle-SymbolicName: org.eclipse.b2\n" + "Bundle-Version: 1.0\n";
State state = buildEmptyState();
BundleDescription b1 = state.getFactory().createBundleDescription(parseManifest(B1_MANIFEST), B1_LOCATION, 1);
BundleDescription b2 = state.getFactory().createBundleDescription(parseManifest(B2_MANIFEST), B2_LOCATION, 2);
state.addBundle(b1);
state.addBundle(b2);
StateDelta delta = state.resolve();
// $NON-NLS-1$
assertTrue("1.1", contains(state.getResolvedBundles(), b1));
// $NON-NLS-1$
assertTrue("1.2", contains(state.getResolvedBundles(), b2));
BundleDelta[] changes = delta.getChanges();
// $NON-NLS-1$
assertEquals("1.3", 2, changes.length);
// $NON-NLS-1$
assertEquals("1.4 - " + changes[0].getBundle(), (BundleDelta.ADDED | BundleDelta.RESOLVED), changes[0].getType());
// $NON-NLS-1$
assertEquals("1.5 - " + changes[1].getBundle(), (BundleDelta.ADDED | BundleDelta.RESOLVED), changes[1].getType());
// $NON-NLS-1$
assertFullyResolved("1.6", b1);
// $NON-NLS-1$
assertFullyResolved("1.7", b2);
// remove a resolved bundle
state.removeBundle(b1);
// $NON-NLS-1$
assertTrue("2.0", !contains(state.getResolvedBundles(), b1));
// $NON-NLS-1$
assertTrue("2.1", contains(state.getResolvedBundles(), b2));
delta = state.resolve();
changes = delta.getChanges();
// $NON-NLS-1$
assertEquals("2.2", 1, changes.length);
// $NON-NLS-1$
assertEquals("2.3", b1, changes[0].getBundle());
// $NON-NLS-1$
assertEquals("2.4", BundleDelta.REMOVED | BundleDelta.UNRESOLVED, changes[0].getType());
}
Aggregations