Search in sources :

Example 1 with State

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

the class DevModeTest method testDevModeFragment01.

public void testDevModeFragment01() throws BundleException {
    State state = buildDevModeState();
    int bundleID = 0;
    Hashtable manifest = new Hashtable();
    manifest.clear();
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "A");
    manifest.put(Constants.BUNDLE_VERSION, "1.0");
    manifest.put(Constants.EXPORT_PACKAGE, "a");
    manifest.put(Constants.IMPORT_PACKAGE, "c");
    BundleDescription a = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
    manifest.clear();
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "AFrag");
    manifest.put(Constants.BUNDLE_VERSION, "1.0");
    manifest.put(Constants.FRAGMENT_HOST, "A");
    manifest.put(Constants.EXPORT_PACKAGE, "a.frag");
    BundleDescription aFrag = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
    manifest.clear();
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "B");
    manifest.put(Constants.BUNDLE_VERSION, "1.0");
    manifest.put(Constants.IMPORT_PACKAGE, "a, a.frag");
    BundleDescription b = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
    manifest.clear();
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "C");
    manifest.put(Constants.BUNDLE_VERSION, "1.0");
    manifest.put(Constants.EXPORT_PACKAGE, "c");
    BundleDescription c = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
    state.addBundle(a);
    state.addBundle(aFrag);
    state.addBundle(b);
    state.resolve();
    // only A should not be resolved, do not want the domino effect.
    assertFalse("0.1", a.isResolved());
    assertTrue("0.2", aFrag.isResolved());
    assertTrue("0.3", b.isResolved());
    ExportPackageDescription[] aExports = a.getSelectedExports();
    ExportPackageDescription[] bImports = b.getResolvedImports();
    assertTrue("1.1", aExports.length == 2);
    assertTrue("1.2", bImports.length == 2);
    assertTrue("1.3", aExports[0] == bImports[0]);
    assertTrue("1.4", aExports[1] == bImports[1]);
    assertTrue("1.5", aFrag.getHost().getSupplier() == a);
    state.addBundle(c);
    state.resolve();
    assertTrue("2.1", a.isResolved());
    assertTrue("2.2", aFrag.isResolved());
    assertTrue("2.3", b.isResolved());
    assertTrue("2.4", c.isResolved());
    aExports = a.getSelectedExports();
    bImports = b.getResolvedImports();
    assertTrue("3.1", aExports.length == 2);
    assertTrue("3.2", bImports.length == 2);
    assertTrue("3.3", aExports[0] == bImports[0]);
    assertTrue("3.4", aExports[1] == bImports[1]);
    assertTrue("3.5", aFrag.getHost().getSupplier() == a);
}
Also used : State(org.eclipse.osgi.service.resolver.State) Hashtable(java.util.Hashtable) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription) ExportPackageDescription(org.eclipse.osgi.service.resolver.ExportPackageDescription)

Example 2 with State

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

the class DevModeTest method testDevModeDomino01.

public void testDevModeDomino01() throws BundleException {
    State state = buildDevModeState();
    int bundleID = 0;
    Hashtable manifest = new Hashtable();
    manifest.clear();
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "A");
    manifest.put(Constants.BUNDLE_VERSION, "1.0");
    manifest.put(Constants.EXPORT_PACKAGE, "a");
    manifest.put(Constants.IMPORT_PACKAGE, "x");
    manifest.put(Constants.REQUIRE_BUNDLE, "X");
    BundleDescription a = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
    manifest.clear();
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "B");
    manifest.put(Constants.BUNDLE_VERSION, "1.0");
    manifest.put(Constants.REQUIRE_BUNDLE, "A");
    BundleDescription b = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
    manifest.clear();
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "C");
    manifest.put(Constants.BUNDLE_VERSION, "1.0");
    manifest.put(Constants.REQUIRE_BUNDLE, "A");
    BundleDescription c = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
    state.addBundle(a);
    state.addBundle(b);
    state.addBundle(c);
    state.resolve();
    // bundle a has an unsatisfied constraint
    // b and c should still be resolved to bundle a though
    assertFalse("0.1", a.isResolved());
    assertTrue("0.3", b.isResolved());
    assertTrue("0.4", c.isResolved());
    BundleDescription[] bRequired = b.getResolvedRequires();
    assertTrue("1.1", bRequired.length == 1);
    assertTrue("1.2", bRequired[0] == a);
    BundleDescription[] cRequired = c.getResolvedRequires();
    assertTrue("2.1", cRequired.length == 1);
    assertTrue("2.2", cRequired[0] == a);
}
Also used : State(org.eclipse.osgi.service.resolver.State) Hashtable(java.util.Hashtable) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription)

Example 3 with State

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

the class DevModeTest method testDevModeSingleton02.

public void testDevModeSingleton02() throws BundleException {
    State state = buildDevModeState();
    int bundleID = 0;
    Hashtable manifest = new Hashtable();
    manifest.clear();
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "A; singleton:=true");
    manifest.put(Constants.BUNDLE_VERSION, "1.0");
    manifest.put(Constants.EXPORT_PACKAGE, "a");
    manifest.put(Constants.IMPORT_PACKAGE, "x");
    BundleDescription a1 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
    manifest.clear();
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "A; singleton:=true");
    manifest.put(Constants.BUNDLE_VERSION, "2.0");
    manifest.put(Constants.EXPORT_PACKAGE, "a");
    BundleDescription a2 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
    manifest.clear();
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "B");
    manifest.put(Constants.BUNDLE_VERSION, "1.0");
    manifest.put(Constants.REQUIRE_BUNDLE, "A; bundle-version=2.0");
    BundleDescription b = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
    manifest.clear();
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "C");
    manifest.put(Constants.BUNDLE_VERSION, "1.0");
    manifest.put(Constants.REQUIRE_BUNDLE, "A; bundle-version=\"[1.0,2.0)\"");
    BundleDescription c = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
    state.addBundle(a1);
    state.addBundle(a2);
    state.addBundle(b);
    state.addBundle(c);
    state.resolve();
    // only a2 is resolved because a1 has an unsatisfied constraint
    // c should still be resolved to a1 though
    assertFalse("0.1", a1.isResolved());
    assertTrue("0.2", a2.isResolved());
    assertTrue("0.3", b.isResolved());
    assertTrue("0.4", c.isResolved());
    BundleDescription[] bRequired = b.getResolvedRequires();
    assertTrue("1.1", bRequired.length == 1);
    assertTrue("1.2", bRequired[0] == a2);
    BundleDescription[] cRequired = c.getResolvedRequires();
    assertTrue("2.1", cRequired.length == 1);
    assertTrue("2.2", cRequired[0] == a1);
}
Also used : State(org.eclipse.osgi.service.resolver.State) Hashtable(java.util.Hashtable) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription)

Example 4 with State

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

the class DevModeTest method testDevModeSingleton01.

public void testDevModeSingleton01() throws BundleException {
    State state = buildDevModeState();
    int bundleID = 0;
    Hashtable manifest = new Hashtable();
    manifest.clear();
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "A; singleton:=true");
    manifest.put(Constants.BUNDLE_VERSION, "1.0");
    manifest.put(Constants.EXPORT_PACKAGE, "a");
    BundleDescription a1 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
    manifest.clear();
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "A; singleton:=true");
    manifest.put(Constants.BUNDLE_VERSION, "2.0");
    manifest.put(Constants.EXPORT_PACKAGE, "a");
    BundleDescription a2 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
    manifest.clear();
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "B");
    manifest.put(Constants.BUNDLE_VERSION, "1.0");
    manifest.put(Constants.REQUIRE_BUNDLE, "A; bundle-version=2.0");
    BundleDescription b = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
    manifest.clear();
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "C");
    manifest.put(Constants.BUNDLE_VERSION, "1.0");
    manifest.put(Constants.REQUIRE_BUNDLE, "A; bundle-version=\"[1.0,2.0)\"");
    BundleDescription c = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
    state.addBundle(a1);
    state.addBundle(a2);
    state.addBundle(b);
    state.addBundle(c);
    state.resolve();
    // both versions of A should be resolved
    assertTrue("0.1", a1.isResolved());
    assertTrue("0.2", a2.isResolved());
    assertTrue("0.3", b.isResolved());
    assertTrue("0.4", c.isResolved());
    BundleDescription[] bRequired = b.getResolvedRequires();
    assertTrue("1.1", bRequired.length == 1);
    assertTrue("1.2", bRequired[0] == a2);
    BundleDescription[] cRequired = c.getResolvedRequires();
    assertTrue("2.1", cRequired.length == 1);
    assertTrue("2.2", cRequired[0] == a1);
}
Also used : State(org.eclipse.osgi.service.resolver.State) Hashtable(java.util.Hashtable) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription)

Example 5 with State

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

the class DevModeTest method testDevModeDomino02.

public void testDevModeDomino02() throws BundleException {
    State state = buildDevModeState();
    int bundleID = 0;
    Hashtable manifest = new Hashtable();
    manifest.clear();
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "A");
    manifest.put(Constants.BUNDLE_VERSION, "1.0");
    manifest.put(Constants.EXPORT_PACKAGE, "a");
    manifest.put(Constants.IMPORT_PACKAGE, "x, d");
    manifest.put(Constants.REQUIRE_BUNDLE, "X, E");
    BundleDescription a = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
    manifest.clear();
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "B");
    manifest.put(Constants.BUNDLE_VERSION, "1.0");
    manifest.put(Constants.REQUIRE_BUNDLE, "A");
    BundleDescription b = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
    manifest.clear();
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "C");
    manifest.put(Constants.BUNDLE_VERSION, "1.0");
    manifest.put(Constants.REQUIRE_BUNDLE, "A");
    BundleDescription c = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
    manifest.clear();
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "D");
    manifest.put(Constants.BUNDLE_VERSION, "1.0");
    manifest.put(Constants.EXPORT_PACKAGE, "d");
    BundleDescription d = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
    manifest.clear();
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "E");
    manifest.put(Constants.BUNDLE_VERSION, "1.0");
    manifest.put(Constants.EXPORT_PACKAGE, "e");
    BundleDescription e = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
    state.addBundle(a);
    state.addBundle(b);
    state.addBundle(c);
    state.addBundle(d);
    state.addBundle(e);
    state.resolve();
    // bundle a has an unsatisfied constraint
    // b, c, d, e should still be resolved though
    assertFalse("0.1", a.isResolved());
    assertTrue("0.3", b.isResolved());
    assertTrue("0.4", c.isResolved());
    assertTrue("0.5", d.isResolved());
    assertTrue("0.5", e.isResolved());
    BundleDescription[] aRequired = a.getResolvedRequires();
    assertTrue("1.1", aRequired.length == 1);
    assertTrue("1.2", aRequired[0] == e);
    ExportPackageDescription[] aImported = a.getResolvedImports();
    assertTrue("1.3", aImported.length == 1);
    assertTrue("1.4", aImported[0].getExporter() == d);
    BundleDescription[] bRequired = b.getResolvedRequires();
    assertTrue("2.1", bRequired.length == 1);
    assertTrue("2.2", bRequired[0] == a);
    BundleDescription[] cRequired = c.getResolvedRequires();
    assertTrue("3.1", cRequired.length == 1);
    assertTrue("3.2", cRequired[0] == a);
}
Also used : State(org.eclipse.osgi.service.resolver.State) Hashtable(java.util.Hashtable) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription) ExportPackageDescription(org.eclipse.osgi.service.resolver.ExportPackageDescription)

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