use of org.eclipse.osgi.service.resolver.State in project rt.equinox.framework by eclipse.
the class StateResolverTest method testUpdate.
public void testUpdate() throws BundleException {
State state = buildEmptyState();
// $NON-NLS-1$
String B1_LOCATION = "org.eclipse.b";
// $NON-NLS-1$ //$NON-NLS-2$
final String B1_RESOLVED = "Bundle-SymbolicName: org.eclipse.b1\n" + "Bundle-Version: 1.0\n";
// $NON-NLS-1$ //$NON-NLS-2$
final String B1_UNRESOLVED = "Bundle-SymbolicName: org.eclipse.b1\n" + "Bundle-Version: 2.0\nRequire-Bundle: non.existant.bundle\n";
BundleDescription b1 = state.getFactory().createBundleDescription(parseManifest(B1_RESOLVED), B1_LOCATION, 1);
// $NON-NLS-1$
assertTrue("0.9", state.addBundle(b1));
StateDelta delta = state.resolve();
b1 = state.getBundleByLocation(b1.getLocation());
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);
// $NON-NLS-1$
assertTrue("1.8", contains(state.getResolvedBundles(), b1));
BundleDescription b11 = state.getFactory().createBundleDescription(parseManifest(B1_UNRESOLVED), B1_LOCATION, 1);
// $NON-NLS-1$
assertTrue("1.8b", state.updateBundle(b11));
b11 = state.getBundle(b11.getBundleId());
// $NON-NLS-1$
assertTrue("1.9", !contains(state.getResolvedBundles(), b11));
delta = state.resolve();
changes = delta.getChanges();
// $NON-NLS-1$
assertEquals("2.0", 2, changes.length);
HashMap deltasMap = new HashMap();
for (int i = 0; i < changes.length; i++) deltasMap.put(changes[i].getBundle(), changes[i]);
// $NON-NLS-1$
assertNotNull("2.1", deltasMap.get(b1));
// $NON-NLS-1$
assertNotNull("2.2", deltasMap.get(b11));
// $NON-NLS-1$
assertEquals("2.3", BundleDelta.UNRESOLVED, ((BundleDelta) deltasMap.get(b1)).getType());
// $NON-NLS-1$
assertEquals("2.4", BundleDelta.UPDATED, ((BundleDelta) deltasMap.get(b11)).getType());
BundleDescription b111 = state.getFactory().createBundleDescription(parseManifest(B1_RESOLVED), B1_LOCATION, 1);
// $NON-NLS-1$
assertTrue("3.0", state.updateBundle(b111));
b111 = state.getBundle(b111.getBundleId());
// $NON-NLS-1$
assertTrue("3.1", !contains(state.getResolvedBundles(), b111));
delta = state.resolve();
changes = delta.getChanges();
// $NON-NLS-1$
assertEquals("3.2", 1, changes.length);
// $NON-NLS-1$
assertEquals("3.1", b111, changes[0].getBundle());
// $NON-NLS-1$
assertEquals("3.2", BundleDelta.UPDATED | BundleDelta.RESOLVED, changes[0].getType());
// $NON-NLS-1$
assertFullyResolved("3.3", b111);
}
use of org.eclipse.osgi.service.resolver.State in project rt.equinox.framework by eclipse.
the class StateResolverTest method testPlatformPropertiesBug246640a.
public void testPlatformPropertiesBug246640a() throws BundleException {
State state = buildEmptyState();
int bundleID = 0;
// $NON-NLS-1$
String configuredSystemBundle = "org.eclipse.osgi; singleton:=true";
// test the selection algorithm of the resolver to pick the bundles which
// resolve the largest set of bundles; with fragments using Import-Package
Hashtable manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
manifest.put(Constants.BUNDLE_SYMBOLICNAME, configuredSystemBundle);
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
BundleDescription systemBundle1 = state.getFactory().createBundleDescription(state, manifest, configuredSystemBundle + manifest.get(Constants.BUNDLE_VERSION), bundleID++);
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
manifest.put(Constants.BUNDLE_SYMBOLICNAME, configuredSystemBundle);
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "2.0");
BundleDescription systemBundle2 = state.getFactory().createBundleDescription(state, manifest, configuredSystemBundle + 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, "A");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "pkg.system.b");
// $NON-NLS-1$
BundleDescription a = state.getFactory().createBundleDescription(state, manifest, "A", bundleID++);
manifest.clear();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "require.system.b");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.REQUIRE_BUNDLE, "org.eclipse.osgi; bundle-version=2.0");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "J2SE-1.2");
BundleDescription requireSystemBundle = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME), bundleID++);
Dictionary[] props = new Dictionary[] { new Hashtable(), new Hashtable() };
// $NON-NLS-1$ //$NON-NLS-2$
props[0].put("org.osgi.framework.system.packages", "pkg.system.a, pkg.system.c");
// $NON-NLS-1$ //$NON-NLS-2$
props[0].put("org.osgi.framework.executionenvironment", "J2SE-1.2");
// $NON-NLS-1$ //$NON-NLS-2$
props[1].put("org.osgi.framework.system.packages", "pkg.system.a, pkg.system.b, pkg.system.c");
// $NON-NLS-1$ //$NON-NLS-2$
props[1].put("org.osgi.framework.executionenvironment", "J2SE-1.4");
state.setPlatformProperties(props);
state.addBundle(systemBundle1);
state.addBundle(systemBundle2);
state.addBundle(a);
state.addBundle(requireSystemBundle);
state.resolve();
// $NON-NLS-1$
assertFalse("1.0", systemBundle1.isResolved());
// $NON-NLS-1$
assertTrue("1.0.1", systemBundle2.isResolved());
// $NON-NLS-1$
assertTrue("1.1", a.isResolved());
// $NON-NLS-1$
assertTrue("1.4", requireSystemBundle.isResolved());
// $NON-NLS-1$
assertTrue("2.0", a.getResolvedImports()[0].getExporter() == systemBundle2);
}
use of org.eclipse.osgi.service.resolver.State in project rt.equinox.framework by eclipse.
the class TestDynamic_006 method testTest_005.
public void testTest_005() {
State state = buildEmptyState();
StateObjectFactory sof = StateObjectFactory.defaultFactory;
bundle_1 = create_bundle_1(sof);
bundle_2 = create_bundle_2(sof);
bundle_3 = create_bundle_3(sof);
// ***************************************************
// stage a
// expect to pass =true
// ***************************************************
addBundlesToState_a(state);
// ***************************************************
try {
state.resolve();
} catch (Throwable t) {
fail("unexpected exception class=" + t.getClass().getName() + " message=" + t.getMessage());
return;
}
checkBundlesResolved_a();
checkWiring_a();
// Dynamics
ExportPackageDescription exp = state.linkDynamicImport(bundle_1, "p.b");
assertNotNull("Package [p.b] is not wired when it should be ", exp);
assertEquals("Package [p.b] is wired incorrectly ", exp.getExporter(), bundle_3);
}
use of org.eclipse.osgi.service.resolver.State in project rt.equinox.framework by eclipse.
the class TestGrouping_001 method testTest_001.
public void testTest_001() {
State state = buildEmptyState();
StateObjectFactory sof = StateObjectFactory.defaultFactory;
bundle_1 = create_bundle_1(sof);
bundle_2 = create_bundle_2(sof);
bundle_3 = create_bundle_3(sof);
// ***************************************************
// stage a
// expect to pass =true
// ***************************************************
addBundlesToState_a(state);
// ***************************************************
try {
state.resolve();
} catch (Throwable t) {
fail("unexpected exception class=" + t.getClass().getName() + " message=" + t.getMessage());
return;
}
checkBundlesResolved_a();
checkWiring_a();
}
use of org.eclipse.osgi.service.resolver.State in project rt.equinox.framework by eclipse.
the class TestRFC79_001 method testTest_001.
public void testTest_001() {
State state = buildEmptyState();
StateObjectFactory sof = StateObjectFactory.defaultFactory;
bundle_1 = create_bundle_1(sof);
bundle_2 = create_bundle_2(sof);
bundle_3 = create_bundle_3(sof);
// ***************************************************
// stage a
// expect to pass =true
// ***************************************************
addBundlesToState_a(state);
// ***************************************************
try {
state.resolve();
} catch (Throwable t) {
fail("unexpected exception class=" + t.getClass().getName() + " message=" + t.getMessage());
return;
}
checkBundlesResolved_a();
checkWiring_a();
}
Aggregations