Search in sources :

Example 91 with State

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

the class TestDynamic_002 method testTest_002.

public void testTest_002() {
    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, "r");
    assertNull("Package [r] is wired when it should not be ", exp);
}
Also used : State(org.eclipse.osgi.service.resolver.State) ExportPackageDescription(org.eclipse.osgi.service.resolver.ExportPackageDescription) StateObjectFactory(org.eclipse.osgi.service.resolver.StateObjectFactory)

Example 92 with State

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

the class StateResolverTest method testNativeCodeResolution02.

public void testNativeCodeResolution02() throws BundleException {
    State state = buildEmptyState();
    Dictionary[] props = new Dictionary[] { new Hashtable() };
    // Use different case for osname //$NON-NLS-1$
    props[0].put(Constants.FRAMEWORK_OS_NAME, "WIN32");
    // $NON-NLS-1$
    props[0].put(Constants.FRAMEWORK_PROCESSOR, "x86");
    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\"");
    // $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 93 with State

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

the class StateResolverTest method testMultiStateAdd03.

public void testMultiStateAdd03() 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);
    state1.resolve(new BundleDescription[] { rcp10 });
    State state2 = buildEmptyState();
    try {
        state2.addBundle(rcp10);
    } catch (IllegalStateException e) {
        // $NON-NLS-1$
        fail("Unexpected IllegalStateException on adding to state", e);
    }
}
Also used : State(org.eclipse.osgi.service.resolver.State) Hashtable(java.util.Hashtable) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription)

Example 94 with State

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

the class StateResolverTest method testBug324618.

public void testBug324618() throws BundleException {
    State state = buildEmptyState();
    long bundleID = 0;
    Dictionary manifest;
    manifest = loadManifest("p1.MF");
    BundleDescription p1 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME), bundleID++);
    manifest = loadManifest("p2.MF");
    BundleDescription p2 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME), bundleID++);
    manifest = loadManifest("c1.MF");
    BundleDescription c1 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME), bundleID++);
    state.addBundle(p1);
    state.addBundle(p2);
    state.addBundle(c1);
    state.resolve();
    ExportPackageDescription x = state.linkDynamicImport(c1, "x");
    assertNotNull("x dynamic import is null", x);
    ExportPackageDescription xSub = state.linkDynamicImport(c1, "x.sub");
    assertNotNull("x.sub dynamic import is null", xSub);
    assertEquals("The exporter is not the same for x and x.sub", x.getExporter(), xSub.getExporter());
    ExportPackageDescription xExtra = state.linkDynamicImport(c1, "x.extra");
    assertNotNull("x.extra dynamic import is null", xExtra);
}
Also used : Dictionary(java.util.Dictionary) State(org.eclipse.osgi.service.resolver.State) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription) ExportPackageDescription(org.eclipse.osgi.service.resolver.ExportPackageDescription)

Example 95 with State

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

the class StateResolverTest method testSingletonsSelection3.

public void testSingletonsSelection3() 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
    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", 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.REQUIRE_BUNDLE, "rcp; bundle-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$
    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.REQUIRE_BUNDLE, "rcp; bundle-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.REQUIRE_BUNDLE, "platform; bundle-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.REQUIRE_BUNDLE, "rcp; bundle-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.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_frag210.isResolved());
    // $NON-NLS-1$
    assertTrue("2.2.2", rcp_frag10.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());
}
Also used : 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