Search in sources :

Example 11 with BundleDescription

use of org.eclipse.osgi.service.resolver.BundleDescription in project rt.equinox.framework by eclipse.

the class StateResolverTest method testNativeCodeResolution01.

public void testNativeCodeResolution01() throws BundleException {
    State state = buildEmptyState();
    Dictionary[] props = new Dictionary[] { new Hashtable() };
    // $NON-NLS-1$ //$NON-NLS-2$
    props[0].put("osgi.ws", "win32");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[0].put("osgi.os", "win32");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[0].put("osgi.arch", "x86");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[0].put("osgi.nl", "en_US");
    state.setPlatformProperties(props);
    Hashtable manifest = new Hashtable();
    long bundleID = 0;
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "NativeBundle");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_NATIVECODE, "Bundle-NativeCode: nativefile1.txt;processor=x86;osname=Windows2000;osname=\"Windows 2003\";osname=Windows95;osname=Windows98;osname=WindowsNT;osname=WindowsXP;osname=\"Windows NT (unknown)\";osname=\"Windows Vista\"; language=en");
    // $NON-NLS-1$
    BundleDescription testNativeBundle = state.getFactory().createBundleDescription(state, manifest, "NativeBundle", bundleID++);
    state.addBundle(testNativeBundle);
    state.resolve();
    // $NON-NLS-1$
    assertTrue("1.0", testNativeBundle.isResolved());
}
Also used : Dictionary(java.util.Dictionary) State(org.eclipse.osgi.service.resolver.State) Hashtable(java.util.Hashtable) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription)

Example 12 with BundleDescription

use of org.eclipse.osgi.service.resolver.BundleDescription in project rt.equinox.framework by eclipse.

the class StateResolverTest method testSingletonsSelection2.

public void testSingletonsSelection2() throws BundleException {
    State state = buildEmptyState();
    // test the selection algorithm of the resolver to pick the bundles with the largest version; test with cycle added
    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]\", cycle");
    // $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]\", sdk");
    // $NON-NLS-1$
    BundleDescription gef10 = state.getFactory().createBundleDescription(state, manifest, "gef10", 3);
    manifest = new Hashtable();
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    // $NON-NLS-1$ //$NON-NLS-2$
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "cycle; " + Constants.SINGLETON_DIRECTIVE + ":=true");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_VERSION, "1.0");
    // $NON-NLS-1$
    manifest.put(Constants.REQUIRE_BUNDLE, "gef");
    // $NON-NLS-1$
    BundleDescription cycle10 = state.getFactory().createBundleDescription(state, manifest, "cycle10", 4);
    state.addBundle(sdk10);
    state.addBundle(platform10);
    state.addBundle(rcp10);
    state.addBundle(gef10);
    state.addBundle(cycle10);
    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());
    // $NON-NLS-1$
    assertTrue("1.4", cycle10.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", 5);
    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", 6);
    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", 7);
    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", cycle10.isResolved());
    // $NON-NLS-1$
    assertFalse("2.5", sdk10.isResolved());
    // $NON-NLS-1$
    assertFalse("2.6", platform10.isResolved());
    // $NON-NLS-1$
    assertFalse("2.7", rcp10.isResolved());
}
Also used : State(org.eclipse.osgi.service.resolver.State) Hashtable(java.util.Hashtable) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription)

Example 13 with BundleDescription

use of org.eclipse.osgi.service.resolver.BundleDescription in project rt.equinox.framework by eclipse.

the class StateResolverTest method testNativeCodeResolution05.

public void testNativeCodeResolution05() throws BundleException {
    State state = buildEmptyState();
    Dictionary[] props = new Dictionary[] { new Hashtable(), new Hashtable(), new Hashtable() };
    // $NON-NLS-1$ //$NON-NLS-2$
    props[0].put("osgi.ws", "win32");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[0].put("osgi.os", "win32");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[0].put("osgi.arch", "x86");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[0].put("osgi.nl", "en_US");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[1].put("osgi.ws", "win32");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[1].put("osgi.os", "win32");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[1].put("osgi.arch", "x86_64");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[1].put("osgi.nl", "en_US");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[2].put("osgi.ws", "win32");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[2].put("osgi.os", "win32");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[2].put("osgi.arch", "x86");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[2].put("osgi.nl", "fr_FR");
    state.setPlatformProperties(props);
    Hashtable manifest = new Hashtable();
    long bundleID = 0;
    manifest.clear();
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "NativeBundle1");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_NATIVECODE, "Bundle-NativeCode: nativefile1.txt;processor=x86;osname=win32; language=en");
    // $NON-NLS-1$
    BundleDescription testNativeBundle1 = state.getFactory().createBundleDescription(state, manifest, "NativeBundle", bundleID++);
    manifest.clear();
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "NativeBundle2");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_NATIVECODE, "Bundle-NativeCode: nativefile1.txt;processor=x86_64;osname=win32; language=en");
    // $NON-NLS-1$
    BundleDescription testNativeBundle2 = state.getFactory().createBundleDescription(state, manifest, "NativeBundle", bundleID++);
    manifest.clear();
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "NativeBundle3");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_NATIVECODE, "Bundle-NativeCode: nativefile1.txt;processor=x86;osname=win32; language=fr");
    // $NON-NLS-1$
    BundleDescription testNativeBundle3 = state.getFactory().createBundleDescription(state, manifest, "NativeBundle", bundleID++);
    state.addBundle(testNativeBundle1);
    state.addBundle(testNativeBundle2);
    state.addBundle(testNativeBundle3);
    state.resolve();
    // $NON-NLS-1$
    assertTrue("1.0", testNativeBundle1.isResolved());
    // $NON-NLS-1$
    assertTrue("2.0", testNativeBundle2.isResolved());
    // $NON-NLS-1$
    assertTrue("3.0", testNativeBundle3.isResolved());
}
Also used : Dictionary(java.util.Dictionary) State(org.eclipse.osgi.service.resolver.State) Hashtable(java.util.Hashtable) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription)

Example 14 with BundleDescription

use of org.eclipse.osgi.service.resolver.BundleDescription in project rt.equinox.framework by eclipse.

the class StateResolverTest method testSingletonsSameVersion.

public void testSingletonsSameVersion() throws BundleException {
    // this is a testcase to handle how PDE build is using the state
    // with multiple singleton bundles installed with the same BSN and version
    State state = buildEmptyState();
    Hashtable manifest = new Hashtable();
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "test.host; singleton:=true");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
    // $NON-NLS-1$
    BundleDescription testHost100 = state.getFactory().createBundleDescription(state, manifest, "test.host100", 0);
    manifest = new Hashtable();
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "test.host; singleton:=true");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
    // $NON-NLS-1$
    BundleDescription testHost101 = state.getFactory().createBundleDescription(state, manifest, "test.host101", 1);
    manifest = new Hashtable();
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "test.frag; singleton:=true");
    // $NON-NLS-1$
    manifest.put(Constants.FRAGMENT_HOST, "test.host; bundle-version=\"[1.0.0,2.0.0)\"");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
    // $NON-NLS-1$
    BundleDescription testFrag100 = state.getFactory().createBundleDescription(state, manifest, "test.frag100", 2);
    manifest = new Hashtable();
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "test.frag; singleton:=true");
    // $NON-NLS-1$
    manifest.put(Constants.FRAGMENT_HOST, "test.host; bundle-version=\"[1.0.0,2.0.0)\"");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
    // $NON-NLS-1$
    BundleDescription testFrag101 = state.getFactory().createBundleDescription(state, manifest, "test.frag101", 3);
    state.addBundle(testHost100);
    state.addBundle(testFrag100);
    state.resolve();
    state.addBundle(testHost101);
    state.addBundle(testFrag101);
    state.resolve();
    // $NON-NLS-1$
    assertTrue("1.0", testHost100.isResolved());
    // $NON-NLS-1$
    assertFalse("1.1", testHost101.isResolved());
    // $NON-NLS-1$
    assertTrue("1.2", testFrag100.isResolved());
    // $NON-NLS-1$
    assertFalse("1.3", testFrag101.isResolved());
}
Also used : State(org.eclipse.osgi.service.resolver.State) Hashtable(java.util.Hashtable) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription)

Example 15 with BundleDescription

use of org.eclipse.osgi.service.resolver.BundleDescription in project rt.equinox.framework by eclipse.

the class StateResolverTest method testMultiStateAdd02.

public void testMultiStateAdd02() throws BundleException {
    State state1 = buildEmptyState();
    // test the selection algorithm of the resolver to pick the bundles which
    // resolve the largest set of bundles
    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 = state1.getFactory().createBundleDescription(state1, 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 = state1.getFactory().createBundleDescription(state1, 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 = state1.getFactory().createBundleDescription(state1, 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 = state1.getFactory().createBundleDescription(state1, manifest, "gef10", 3);
    state1.addBundle(sdk10);
    state1.addBundle(platform10);
    state1.addBundle(rcp10);
    state1.addBundle(gef10);
    state1.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());
    // remove the rcp10 bundle.  The bundle will be removal pending
    // this should still throw an exception until the removal is no longer pending
    state1.removeBundle(rcp10);
    State state2 = buildEmptyState();
    try {
        state2.addBundle(rcp10);
        // $NON-NLS-1$
        fail("Expected IllegalStateException on adding to multiple states");
    } catch (IllegalStateException e) {
    // expected
    }
}
Also used : State(org.eclipse.osgi.service.resolver.State) Hashtable(java.util.Hashtable) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription)

Aggregations

BundleDescription (org.eclipse.osgi.service.resolver.BundleDescription)202 BundleException (org.osgi.framework.BundleException)106 State (org.eclipse.osgi.service.resolver.State)87 Hashtable (java.util.Hashtable)70 Dictionary (java.util.Dictionary)28 ExportPackageDescription (org.eclipse.osgi.service.resolver.ExportPackageDescription)18 ArrayList (java.util.ArrayList)11 StateDelta (org.eclipse.osgi.service.resolver.StateDelta)11 BundleDelta (org.eclipse.osgi.service.resolver.BundleDelta)10 List (java.util.List)9 HashMap (java.util.HashMap)8 File (java.io.File)6 Map (java.util.Map)6 CaseInsensitiveDictionaryMap (org.eclipse.osgi.framework.util.CaseInsensitiveDictionaryMap)6 VersionConstraint (org.eclipse.osgi.service.resolver.VersionConstraint)6 Version (org.osgi.framework.Version)6 BundleWiring (org.osgi.framework.wiring.BundleWiring)5 BundleContext (org.osgi.framework.BundleContext)2 ResolverHook (org.osgi.framework.hooks.resolver.ResolverHook)2 Collection (java.util.Collection)1