use of org.eclipse.osgi.service.resolver.State in project rt.equinox.framework by eclipse.
the class StateResolverTest method testEECapabilityRequirement.
public void testEECapabilityRequirement() throws BundleException {
State state = buildEmptyState();
int bundleID = 0;
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$
BundleDescription systemBundle = state.getFactory().createBundleDescription(state, manifest, "org.eclipse.osgi", bundleID++);
state.addBundle(systemBundle);
List bundles = new ArrayList();
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_REQUIREDEXECUTIONENVIRONMENT, "OSGi/Minimum-1.1");
// $NON-NLS-1$
BundleDescription a = state.getFactory().createBundleDescription(state, manifest, "A", bundleID++);
bundles.add(a);
state.addBundle(a);
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_REQUIREDEXECUTIONENVIRONMENT, "CDC-1.1/Foundation-1.1");
// $NON-NLS-1$
BundleDescription b = state.getFactory().createBundleDescription(state, manifest, "B", bundleID++);
bundles.add(b);
state.addBundle(b);
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_REQUIREDEXECUTIONENVIRONMENT, "J2SE-1.4");
// $NON-NLS-1$
BundleDescription c = state.getFactory().createBundleDescription(state, manifest, "C", bundleID++);
bundles.add(c);
state.addBundle(c);
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_REQUIREDEXECUTIONENVIRONMENT, "AA/BB");
// $NON-NLS-1$
BundleDescription d = state.getFactory().createBundleDescription(state, manifest, "D", bundleID++);
bundles.add(d);
state.addBundle(d);
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_REQUIREDEXECUTIONENVIRONMENT, "CC-XX/DD-YY");
// $NON-NLS-1$
BundleDescription e = state.getFactory().createBundleDescription(state, manifest, "E", bundleID++);
bundles.add(e);
state.addBundle(e);
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "F");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "EE-2.0/FF-YY");
// $NON-NLS-1$
BundleDescription f = state.getFactory().createBundleDescription(state, manifest, "F", bundleID++);
bundles.add(f);
state.addBundle(f);
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "G");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "GG-XX/HH-1.0");
// $NON-NLS-1$
BundleDescription g = state.getFactory().createBundleDescription(state, manifest, "G", bundleID++);
bundles.add(g);
state.addBundle(g);
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "H");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "II-1.0/JJ-2.0");
// $NON-NLS-1$
BundleDescription h = state.getFactory().createBundleDescription(state, manifest, "H", bundleID++);
bundles.add(h);
state.addBundle(h);
Dictionary[] props = new Dictionary[] { new Hashtable(), new Hashtable(), new Hashtable(), new Hashtable(), new Hashtable(), new Hashtable(), new Hashtable(), new Hashtable() };
// $NON-NLS-1$ //$NON-NLS-2$
props[0].put("org.osgi.framework.executionenvironment", "OSGi/Minimum-1.0, OSGi/Minimum-1.1, OSGi/Minimum-1.2");
// $NON-NLS-1$ //$NON-NLS-2$
props[1].put("org.osgi.framework.executionenvironment", "CDC-1.0/Foundation-1.0, CDC-1.1/Foundation-1.1");
// $NON-NLS-1$ //$NON-NLS-2$
props[2].put("org.osgi.framework.executionenvironment", "J2SE-1.2, J2SE-1.3, J2SE-1.4, J2SE-1.5, JavaSE-1.6");
props[3].put("org.osgi.framework.executionenvironment", "AA/BB");
props[4].put("org.osgi.framework.executionenvironment", "CC-XX/DD-YY");
props[5].put("org.osgi.framework.executionenvironment", "EE-1.0/FF-YY, EE-2.0/FF-YY");
props[6].put("org.osgi.framework.executionenvironment", "GG-XX/HH-1.0, GG-XX/HH-2.0");
props[7].put("org.osgi.framework.executionenvironment", "II-1.0/JJ-2.0");
state.setPlatformProperties(props);
state.resolve();
checkEECapabilities(systemBundle.getWiring().getCapabilities("osgi.ee"), bundles);
state.setPlatformProperties(new Hashtable());
state.resolve(false);
// $NON-NLS-1$
assertTrue("2.0", systemBundle.isResolved());
// $NON-NLS-1$
assertFalse("2.1", a.isResolved());
// $NON-NLS-1$
assertFalse("2.2", b.isResolved());
// $NON-NLS-1$
assertFalse("2.3", c.isResolved());
// $NON-NLS-1$
assertFalse("2.4", d.isResolved());
// $NON-NLS-1$
assertFalse("2.5", e.isResolved());
// $NON-NLS-1$
assertFalse("2.7", f.isResolved());
// $NON-NLS-1$
assertFalse("2.8", g.isResolved());
// $NON-NLS-1$
assertFalse("2.9", h.isResolved());
// $NON-NLS-1$ //$NON-NLS-2$
props[0].put("org.osgi.framework.executionenvironment", "OSGi/Minimum-1.1");
// $NON-NLS-1$ //$NON-NLS-2$
props[1].put("org.osgi.framework.executionenvironment", "CDC-1.1/Foundation-1.1");
// $NON-NLS-1$ //$NON-NLS-2$
props[2].put("org.osgi.framework.executionenvironment", "J2SE-1.4");
props[3].put("org.osgi.framework.executionenvironment", "AA/BB");
props[4].put("org.osgi.framework.executionenvironment", "CC-XX/DD-YY");
props[5].put("org.osgi.framework.executionenvironment", "EE-2.0/FF-YY");
props[6].put("org.osgi.framework.executionenvironment", "GG-XX/HH-1.0");
props[7].put("org.osgi.framework.executionenvironment", "II-1.0/JJ-2.0");
// $NON-NLS-1$ //$NON-NLS-2$
props[0].put("org.osgi.framework.system.capabilities", "osgi.ee; osgi.ee=\"OSGi/Minimum\"; version:List<Version>=\"1.0, 1.1, 1.2\"");
// $NON-NLS-1$ //$NON-NLS-2$
props[1].put("org.osgi.framework.system.capabilities", "osgi.ee; osgi.ee=\"CDC/Foundation\"; version:List<Version>=\"1.0, 1.1\"");
// $NON-NLS-1$ //$NON-NLS-2$
props[2].put("org.osgi.framework.system.capabilities", "osgi.ee; osgi.ee=\"JavaSE\"; version:List<Version>=\"1.2, 1.3, 1.4, 1.5, 1.6\"");
// $NON-NLS-1$ //$NON-NLS-2$
props[3].put("org.osgi.framework.system.capabilities", "osgi.ee; osgi.ee=\"AA/BB\"");
// $NON-NLS-1$ //$NON-NLS-2$
props[4].put("org.osgi.framework.system.capabilities", "osgi.ee; osgi.ee=\"CC-XX/DD-YY\"");
// $NON-NLS-1$ //$NON-NLS-2$
props[5].put("org.osgi.framework.system.capabilities", "osgi.ee; osgi.ee=\"EE/FF-YY\"; version:List<Version>=\"1.0, 2.0\"");
// $NON-NLS-1$ //$NON-NLS-2$
props[6].put("org.osgi.framework.system.capabilities", "osgi.ee; osgi.ee=\"GG-XX/HH\"; version:List<Version>=\"1.0, 2.0\"");
// $NON-NLS-1$ //$NON-NLS-2$
props[7].put("org.osgi.framework.system.capabilities", "osgi.ee; osgi.ee=\"II-1.0/JJ-2.0\"");
state.setPlatformProperties(props);
state.resolve(false);
checkEECapabilities(systemBundle.getWiring().getCapabilities("osgi.ee"), bundles);
}
use of org.eclipse.osgi.service.resolver.State in project rt.equinox.framework by eclipse.
the class StateResolverTest method testSingletonsSelection1.
public void testSingletonsSelection1() throws BundleException {
State state = buildEmptyState();
// test the selection algorithm of the resolver to pick the bundles with the largest version
Hashtable manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$ //$NON-NLS-2$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "sdk; " + Constants.SINGLETON_DIRECTIVE + ":=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.REQUIRE_BUNDLE, "platform; bundle-version=\"[1.0,2.0]\"");
// $NON-NLS-1$
BundleDescription sdk10 = state.getFactory().createBundleDescription(state, manifest, "sdk10", 0);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$ //$NON-NLS-2$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "platform; " + Constants.SINGLETON_DIRECTIVE + ":=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.REQUIRE_BUNDLE, "rcp; bundle-version=\"[1.0,2.0]\"");
// $NON-NLS-1$
BundleDescription platform10 = state.getFactory().createBundleDescription(state, manifest, "platform10", 1);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$ //$NON-NLS-2$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "rcp; " + Constants.SINGLETON_DIRECTIVE + ":=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
BundleDescription rcp10 = state.getFactory().createBundleDescription(state, manifest, "rcp10", 2);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$ //$NON-NLS-2$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "gef; " + Constants.SINGLETON_DIRECTIVE + ":=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.REQUIRE_BUNDLE, "rcp; bundle-version=\"[1.0,1.0]\"");
// $NON-NLS-1$
BundleDescription gef10 = state.getFactory().createBundleDescription(state, manifest, "gef10", 3);
state.addBundle(sdk10);
state.addBundle(platform10);
state.addBundle(rcp10);
state.addBundle(gef10);
state.resolve();
// $NON-NLS-1$
assertTrue("1.0", sdk10.isResolved());
// $NON-NLS-1$
assertTrue("1.1", platform10.isResolved());
// $NON-NLS-1$
assertTrue("1.2", rcp10.isResolved());
// $NON-NLS-1$
assertTrue("1.3", gef10.isResolved());
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$ //$NON-NLS-2$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "sdk; " + Constants.SINGLETON_DIRECTIVE + ":=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "2.0");
// $NON-NLS-1$
manifest.put(Constants.REQUIRE_BUNDLE, "platform; bundle-version=\"[1.0,2.0]\"");
// $NON-NLS-1$
BundleDescription sdk20 = state.getFactory().createBundleDescription(state, manifest, "sdk20", 4);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$ //$NON-NLS-2$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "platform; " + Constants.SINGLETON_DIRECTIVE + ":=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "2.0");
// $NON-NLS-1$
manifest.put(Constants.REQUIRE_BUNDLE, "rcp; bundle-version=\"[1.0,2.0]\"");
// $NON-NLS-1$
BundleDescription platform20 = state.getFactory().createBundleDescription(state, manifest, "platform20", 5);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$ //$NON-NLS-2$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "rcp; " + Constants.SINGLETON_DIRECTIVE + ":=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "2.0");
// $NON-NLS-1$
BundleDescription rcp20 = state.getFactory().createBundleDescription(state, manifest, "rcp20", 6);
state.addBundle(sdk20);
state.addBundle(platform20);
state.addBundle(rcp20);
state.resolve(false);
// $NON-NLS-1$
assertTrue("2.0", sdk20.isResolved());
// $NON-NLS-1$
assertTrue("2.1", platform20.isResolved());
// $NON-NLS-1$
assertTrue("2.2", rcp20.isResolved());
// $NON-NLS-1$
assertFalse("2.3", gef10.isResolved());
// $NON-NLS-1$
assertFalse("2.4", sdk10.isResolved());
// $NON-NLS-1$
assertFalse("2.5", platform10.isResolved());
// $NON-NLS-1$
assertFalse("2.6", rcp10.isResolved());
}
use of org.eclipse.osgi.service.resolver.State in project rt.equinox.framework by eclipse.
the class StateResolverTest method testDependentBundles.
public void testDependentBundles() throws BundleException {
State state = buildComplexState();
state.resolve();
BundleDescription[] dependent;
dependent = state.getStateHelper().getDependentBundles(new BundleDescription[] { state.getBundle(2) });
// $NON-NLS-1$
assertEquals("1.0", 1, dependent.length);
// $NON-NLS-1$
assertEquals("1.1", state.getBundle(2), dependent[0]);
dependent = state.getStateHelper().getDependentBundles(new BundleDescription[] { state.getBundle(1) });
// $NON-NLS-1$
assertEquals("2.0", 4, dependent.length);
// $NON-NLS-1$
assertContains("2.1", dependent, state.getBundle(1));
// $NON-NLS-1$
assertContains("2.2", dependent, state.getBundle(2));
// $NON-NLS-1$
assertContains("2.3", dependent, state.getBundle(4));
// $NON-NLS-1$
assertContains("2.4", dependent, state.getBundle(6));
}
use of org.eclipse.osgi.service.resolver.State in project rt.equinox.framework by eclipse.
the class StateResolverTest method testFragmentUses02.
public void testFragmentUses02() throws BundleException {
long id = 0;
State state = buildEmptyState();
Dictionary[] props = new Dictionary[] { new Hashtable() };
// $NON-NLS-1$ //$NON-NLS-2$
props[0].put("osgi.resolverMode", "development");
state.setPlatformProperties(props);
Hashtable manifest = new Hashtable();
manifest.clear();
// $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$
manifest.put(Constants.REQUIRE_BUNDLE, "C2");
// $NON-NLS-1$
BundleDescription a1 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), id++);
manifest.clear();
// $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.IMPORT_PACKAGE, "b; good=true");
// $NON-NLS-1$
BundleDescription a1frag = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), id++);
manifest.clear();
// $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; good=true; uses:=c");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "c; good=true");
// $NON-NLS-1$
BundleDescription b1 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), id++);
manifest.clear();
// $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; good=true");
// $NON-NLS-1$
BundleDescription c1 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), id++);
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "C2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.EXPORT_PACKAGE, "c; bad=true");
// $NON-NLS-1$
BundleDescription c2 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), id++);
state.addBundle(a1);
state.addBundle(a1frag);
state.addBundle(b1);
state.addBundle(c1);
state.addBundle(c2);
state.resolve();
// $NON-NLS-1$
assertTrue("0.1", a1.isResolved());
// uses constraints are ignored when in dev mode (see 261849)
// $NON-NLS-1$
assertTrue("0.2", a1frag.isResolved());
// $NON-NLS-1$
assertTrue("0.3", b1.isResolved());
// $NON-NLS-1$
assertTrue("0.4", c1.isResolved());
// $NON-NLS-1$
assertTrue("0.5", c2.isResolved());
}
use of org.eclipse.osgi.service.resolver.State in project rt.equinox.framework by eclipse.
the class StateResolverTest method testReresolveBundle.
/**
* 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. Then re-resolving the same bundle. The result
* should be only the one bundle being resolved.
*/
public void testReresolveBundle() 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());
delta = state.resolve(new BundleDescription[] { state.getBundle(1) });
deltas = delta.getChanges();
// $NON-NLS-1$
assertEquals("3.0", 3, deltas.length);
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("3.1", deltasMap.get(new Long(1)));
// $NON-NLS-1$
assertNotNull("3.2", deltasMap.get(new Long(2)));
// $NON-NLS-1$
assertNotNull("3.3", deltasMap.get(new Long(3)));
// $NON-NLS-1$
assertEquals("3.4", BundleDelta.RESOLVED, ((BundleDelta) deltasMap.get(new Long(1))).getType());
// $NON-NLS-1$
assertEquals("3.5", BundleDelta.RESOLVED, ((BundleDelta) deltasMap.get(new Long(2))).getType());
// $NON-NLS-1$
assertEquals("3.6", BundleDelta.RESOLVED, ((BundleDelta) deltasMap.get(new Long(3))).getType());
}
Aggregations