Search in sources :

Example 1 with BundleDescription

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

the class TestVersion_001 method create_bundle_1.

// end method
public BundleDescription create_bundle_1(StateObjectFactory sof) {
    java.util.Dictionary dictionary_1 = new java.util.Properties();
    BundleDescription bundle = null;
    dictionary_1.put("Bundle-ManifestVersion", "2");
    dictionary_1.put("Bundle-SymbolicName", "A");
    dictionary_1.put("Export-Package", "p; version=1.0");
    dictionary_1.put("Import-Package", "p; version=1.0");
    try {
        bundle = sof.createBundleDescription(dictionary_1, "bundle_1", 1);
    } catch (BundleException be) {
        fail(be.getMessage());
    }
    return bundle;
}
Also used : BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription) BundleException(org.osgi.framework.BundleException)

Example 2 with BundleDescription

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

the class TestVersion_001 method create_bundle_3.

// end of method
public BundleDescription create_bundle_3(StateObjectFactory sof) {
    java.util.Dictionary dictionary_3 = new java.util.Properties();
    BundleDescription bundle = null;
    dictionary_3.put("Bundle-ManifestVersion", "2");
    dictionary_3.put("Bundle-SymbolicName", "C");
    dictionary_3.put("Export-Package", "p; version=2.0");
    dictionary_3.put("Import-Package", "p; version=2.0");
    try {
        bundle = sof.createBundleDescription(dictionary_3, "bundle_3", 3);
    } catch (BundleException be) {
        fail(be.getMessage());
    }
    return bundle;
}
Also used : BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription) BundleException(org.osgi.framework.BundleException)

Example 3 with BundleDescription

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

the class TestVersion_003 method create_bundle_1.

// end method
public BundleDescription create_bundle_1(StateObjectFactory sof) {
    java.util.Dictionary dictionary_1 = new java.util.Properties();
    BundleDescription bundle = null;
    dictionary_1.put("Bundle-ManifestVersion", "2");
    dictionary_1.put("Bundle-SymbolicName", "A");
    dictionary_1.put("Import-Package", "p");
    try {
        bundle = sof.createBundleDescription(dictionary_1, "bundle_1", 1);
    } catch (BundleException be) {
        fail(be.getMessage());
    }
    return bundle;
}
Also used : BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription) BundleException(org.osgi.framework.BundleException)

Example 4 with BundleDescription

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

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

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