use of org.eclipse.osgi.service.resolver.State in project rt.equinox.framework by eclipse.
the class StateResolverTest method testPlatformPropertiesBug207500b.
public void testPlatformPropertiesBug207500b() 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, "a");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_NATIVECODE, "libwrapper-linux-x86-32.so; wrapper-linux-x86-32; osname=linux; processor=x86");
// $NON-NLS-1$
BundleDescription a = state.getFactory().createBundleDescription(state, manifest, "A", bundleID++);
Dictionary props = new Hashtable();
// $NON-NLS-1$ //$NON-NLS-2$
props.put("osgi.os", new CatchAllValue("*"));
// $NON-NLS-1$ //$NON-NLS-2$
props.put("osgi.arch", new CatchAllValue("*"));
// $NON-NLS-1$ //$NON-NLS-2$
props.put("osgi.lang", new CatchAllValue("*"));
// $NON-NLS-1$ //$NON-NLS-2$
props.put("osgi.ws", new CatchAllValue("*"));
state.setPlatformProperties(props);
state.addBundle(a);
state.resolve();
// should resolve
// $NON-NLS-1$
assertTrue("1.1", a.isResolved());
}
use of org.eclipse.osgi.service.resolver.State in project rt.equinox.framework by eclipse.
the class StateResolverTest method testSingletonsSelection4.
public void testSingletonsSelection4() throws BundleException {
State state = buildEmptyState();
int bundleID = 0;
// test the selection algorithm of the resolver to pick the bundles with the largest version; with fragments using Import-Package
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.EXPORT_PACKAGE, "sdk; version=1.0");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "platform; version=\"[1.0,2.0]\"");
// $NON-NLS-1$
BundleDescription sdk10 = state.getFactory().createBundleDescription(state, manifest, "sdk10", bundleID++);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$ //$NON-NLS-2$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "sdk.frag; " + Constants.SINGLETON_DIRECTIVE + ":=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "sdk");
// $NON-NLS-1$
BundleDescription sdk_frag10 = state.getFactory().createBundleDescription(state, manifest, "sdk.frag10", bundleID++);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$ //$NON-NLS-2$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "sdk.frag2; " + Constants.SINGLETON_DIRECTIVE + ":=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "sdk; bundle-version=2.0");
// $NON-NLS-1$
BundleDescription sdk_frag210 = state.getFactory().createBundleDescription(state, manifest, "sdk.frag210", bundleID++);
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.EXPORT_PACKAGE, "platform; version=1.0");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "rcp; version=\"[1.0,2.0]\"");
// $NON-NLS-1$
BundleDescription platform10 = state.getFactory().createBundleDescription(state, manifest, "platform10", bundleID++);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$ //$NON-NLS-2$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "platform.frag; " + Constants.SINGLETON_DIRECTIVE + ":=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "platform");
// $NON-NLS-1$
BundleDescription platform_frag10 = state.getFactory().createBundleDescription(state, manifest, "platform.frag10", bundleID++);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$ //$NON-NLS-2$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "platform.frag2; " + Constants.SINGLETON_DIRECTIVE + ":=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "platform; bundle-version=2.0");
// $NON-NLS-1$
BundleDescription platform_frag210 = state.getFactory().createBundleDescription(state, manifest, "platform.frag210", bundleID++);
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$
manifest.put(Constants.EXPORT_PACKAGE, "rcp; version=1.0");
// $NON-NLS-1$
BundleDescription rcp10 = state.getFactory().createBundleDescription(state, manifest, "rcp10", bundleID++);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$ //$NON-NLS-2$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "rcp.frag; " + Constants.SINGLETON_DIRECTIVE + ":=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "rcp");
// $NON-NLS-1$
BundleDescription rcp_frag10 = state.getFactory().createBundleDescription(state, manifest, "rcp.frag10", bundleID++);
manifest = new Hashtable();
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
// $NON-NLS-1$ //$NON-NLS-2$
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "rcp.frag2; " + Constants.SINGLETON_DIRECTIVE + ":=true");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "1.0");
// $NON-NLS-1$
manifest.put(Constants.FRAGMENT_HOST, "rcp; bundle-version=2.0");
// $NON-NLS-1$
BundleDescription rcp_frag210 = state.getFactory().createBundleDescription(state, manifest, "rcp.frag210", bundleID++);
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.IMPORT_PACKAGE, "rcp; version=\"[1.0,1.0]\"");
// $NON-NLS-1$
BundleDescription gef10 = state.getFactory().createBundleDescription(state, manifest, "gef10", bundleID++);
state.addBundle(sdk10);
state.addBundle(sdk_frag10);
state.addBundle(sdk_frag210);
state.addBundle(platform10);
state.addBundle(platform_frag10);
state.addBundle(platform_frag210);
state.addBundle(rcp10);
state.addBundle(rcp_frag10);
state.addBundle(rcp_frag210);
state.addBundle(gef10);
state.resolve();
// $NON-NLS-1$
assertTrue("1.0", sdk10.isResolved());
// $NON-NLS-1$
assertTrue("1.0.1", sdk_frag10.isResolved());
// $NON-NLS-1$
assertFalse("1.0.2", sdk_frag210.isResolved());
// $NON-NLS-1$
assertTrue("1.1", platform10.isResolved());
// $NON-NLS-1$
assertTrue("1.1.1", platform_frag10.isResolved());
// $NON-NLS-1$
assertFalse("1.1.2", platform_frag210.isResolved());
// $NON-NLS-1$
assertTrue("1.2", rcp10.isResolved());
// $NON-NLS-1$
assertTrue("1.2.1", rcp_frag10.isResolved());
// $NON-NLS-1$
assertFalse("1.2.2", rcp_frag210.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.EXPORT_PACKAGE, "sdk; version=2.0");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "platform; version=\"[1.0,2.0]\"");
// $NON-NLS-1$
BundleDescription sdk20 = state.getFactory().createBundleDescription(state, manifest, "sdk20", bundleID++);
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.EXPORT_PACKAGE, "platform; version=2.0");
// $NON-NLS-1$
manifest.put(Constants.IMPORT_PACKAGE, "rcp; version=\"[1.0,2.0]\"");
// $NON-NLS-1$
BundleDescription platform20 = state.getFactory().createBundleDescription(state, manifest, "platform20", bundleID++);
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.EXPORT_PACKAGE, "rcp; version=2.0");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_VERSION, "2.0");
// $NON-NLS-1$
BundleDescription rcp20 = state.getFactory().createBundleDescription(state, manifest, "rcp20", bundleID++);
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.0.1", sdk_frag10.isResolved());
// $NON-NLS-1$
assertTrue("2.0.2", sdk_frag210.isResolved());
// $NON-NLS-1$
assertTrue("2.1", platform20.isResolved());
// $NON-NLS-1$
assertTrue("2.1.1", platform_frag10.isResolved());
// $NON-NLS-1$
assertTrue("2.1.2", platform_frag210.isResolved());
// $NON-NLS-1$
assertTrue("2.2", rcp20.isResolved());
// $NON-NLS-1$
assertTrue("2.2.1", rcp_frag10.isResolved());
// $NON-NLS-1$
assertTrue("2.2.2", rcp_frag210.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 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);
}
use of org.eclipse.osgi.service.resolver.State in project rt.equinox.framework by eclipse.
the class StateResolverTest method testCapabilities.
public void testCapabilities() throws InvalidSyntaxException, BundleException, IOException {
State state = buildEmptyState();
long bundleID = 0;
Dictionary manifest;
manifest = loadManifest("r1.MF");
BundleDescription hostDescription = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME), bundleID++);
state.addBundle(hostDescription);
doTestCapabilities(hostDescription);
// $NON-NLS-1$
File stateCache = OSGiTestsActivator.getContext().getDataFile("statecache");
stateCache.mkdirs();
StateObjectFactory.defaultFactory.writeState(state, stateCache);
state = StateObjectFactory.defaultFactory.readState(stateCache);
hostDescription = state.getBundle(0);
}
use of org.eclipse.osgi.service.resolver.State in project rt.equinox.framework by eclipse.
the class StateResolverTest method testEEBug377510.
public void testEEBug377510() 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");
manifest.put(Constants.IMPORT_PACKAGE, "test");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "JavaSE-1.6");
// $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, "A.FRAG");
manifest.put(Constants.FRAGMENT_HOST, "A");
manifest.put(Constants.IMPORT_PACKAGE, "test");
// $NON-NLS-1$
manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "J2SE-1.5");
// $NON-NLS-1$
BundleDescription aFrag = state.getFactory().createBundleDescription(state, manifest, "A.FRAG", bundleID++);
bundles.add(aFrag);
state.addBundle(aFrag);
Dictionary[] props = new Dictionary[] { new Hashtable(), new Hashtable(), new Hashtable(), new Hashtable(), new Hashtable(), new Hashtable(), new Hashtable(), new Hashtable() };
props[0].put("org.osgi.framework.executionenvironment", "J2SE-1.5");
props[0].put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, "test");
props[1].put("org.osgi.framework.executionenvironment", "J2SE-1.5, JavaSE-1.6");
props[1].put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, "test");
state.setPlatformProperties(props);
state.resolve();
assertTrue("host not resolved", a.isResolved());
assertTrue("fragment not resolved", aFrag.isResolved());
}
Aggregations