Search in sources :

Example 6 with State

use of org.eclipse.osgi.service.resolver.State 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());
}
Also used : State(org.eclipse.osgi.service.resolver.State) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription) StateDelta(org.eclipse.osgi.service.resolver.StateDelta)

Example 7 with State

use of org.eclipse.osgi.service.resolver.State 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());
}
Also used : State(org.eclipse.osgi.service.resolver.State) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription) StateDelta(org.eclipse.osgi.service.resolver.StateDelta) BundleDelta(org.eclipse.osgi.service.resolver.BundleDelta)

Example 8 with State

use of org.eclipse.osgi.service.resolver.State 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 9 with State

use of org.eclipse.osgi.service.resolver.State 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 10 with State

use of org.eclipse.osgi.service.resolver.State 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)

Aggregations

State (org.eclipse.osgi.service.resolver.State)119 BundleDescription (org.eclipse.osgi.service.resolver.BundleDescription)87 Hashtable (java.util.Hashtable)70 Dictionary (java.util.Dictionary)28 StateObjectFactory (org.eclipse.osgi.service.resolver.StateObjectFactory)27 ExportPackageDescription (org.eclipse.osgi.service.resolver.ExportPackageDescription)22 StateDelta (org.eclipse.osgi.service.resolver.StateDelta)11 BundleDelta (org.eclipse.osgi.service.resolver.BundleDelta)10 ArrayList (java.util.ArrayList)7 List (java.util.List)7 File (java.io.File)6 HashMap (java.util.HashMap)6 Map (java.util.Map)5 CaseInsensitiveDictionaryMap (org.eclipse.osgi.framework.util.CaseInsensitiveDictionaryMap)5 Version (org.osgi.framework.Version)5 BundleWiring (org.osgi.framework.wiring.BundleWiring)4 PerformanceTestRunner (org.eclipse.core.tests.harness.PerformanceTestRunner)3 BundleException (org.osgi.framework.BundleException)3 BundleContext (org.osgi.framework.BundleContext)2 Collection (java.util.Collection)1