Search in sources :

Example 61 with State

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

the class TestVersion_001 method testTest_001.

public void testTest_001() {
    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();
}
Also used : State(org.eclipse.osgi.service.resolver.State) StateObjectFactory(org.eclipse.osgi.service.resolver.StateObjectFactory)

Example 62 with State

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

the class TestVersion_003 method testTest_003.

public void testTest_003() {
    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();
}
Also used : State(org.eclipse.osgi.service.resolver.State) StateObjectFactory(org.eclipse.osgi.service.resolver.StateObjectFactory)

Example 63 with State

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

the class DevModeTest method buildDevModeState.

private State buildDevModeState() {
    State state = buildEmptyState();
    Dictionary[] props = new Dictionary[] { new Hashtable() };
    props[0].put("osgi.resolverMode", "development");
    state.setPlatformProperties(props);
    return state;
}
Also used : Dictionary(java.util.Dictionary) State(org.eclipse.osgi.service.resolver.State) Hashtable(java.util.Hashtable)

Example 64 with State

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

the class DevModeTest method testDevModeGenericCapability.

public void testDevModeGenericCapability() 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.REQUIRE_CAPABILITY, "osgi.service; filter:=\"(objectClass=foo.Bar)\";\n" + "  effective:=\"active\"");
    BundleDescription a = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
    state.addBundle(a);
    state.resolve();
    // a can't be resolved since its required capability is not provided
    assertFalse("0.1", a.isResolved());
    manifest.clear();
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "B; singleton:=true");
    manifest.put(Constants.BUNDLE_VERSION, "1.0");
    manifest.put(Constants.PROVIDE_CAPABILITY, "osgi.service; objectClass:List<String>=\"foo.Bar\"");
    BundleDescription b = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
    state.addBundle(b);
    state.resolve();
    // with bundle B, A is resolvable now
    assertTrue("0.2", a.isResolved());
}
Also used : State(org.eclipse.osgi.service.resolver.State) Hashtable(java.util.Hashtable) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription)

Example 65 with State

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

the class StateResolverTest method testMultipleExportsUses01.

public void testMultipleExportsUses01() throws BundleException {
    State state = buildEmptyState();
    Hashtable manifest = new Hashtable();
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "A1");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
    // $NON-NLS-1$
    manifest.put(Constants.EXPORT_PACKAGE, "a; version=2.0; uses:=d, d; version=2.0");
    // $NON-NLS-1$
    BundleDescription a1_100 = state.getFactory().createBundleDescription(state, manifest, "a1_100", 0);
    manifest = new Hashtable();
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "A2");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
    // $NON-NLS-1$
    manifest.put(Constants.EXPORT_PACKAGE, "a; version=1.0; uses:=d, d; version=1.0");
    // $NON-NLS-1$
    BundleDescription a2_100 = state.getFactory().createBundleDescription(state, manifest, "a2_100", 1);
    manifest = new Hashtable();
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "B1");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
    // $NON-NLS-1$
    manifest.put(Constants.EXPORT_PACKAGE, "b, b; mandatory:=\"test\"; test=value; uses:=d");
    // $NON-NLS-1$
    manifest.put(Constants.IMPORT_PACKAGE, "a;bundle-symbolic-name=A2, d");
    // $NON-NLS-1$
    BundleDescription b1_100 = state.getFactory().createBundleDescription(state, manifest, "b1_100", 2);
    manifest = new Hashtable();
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "C1");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
    // $NON-NLS-1$
    manifest.put(Constants.EXPORT_PACKAGE, "c; uses:=b");
    // $NON-NLS-1$
    manifest.put(Constants.IMPORT_PACKAGE, "b; test=value, d");
    // $NON-NLS-1$
    BundleDescription c1_100 = state.getFactory().createBundleDescription(state, manifest, "c1_100", 3);
    manifest = new Hashtable();
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "D1");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
    // $NON-NLS-1$
    manifest.put(Constants.IMPORT_PACKAGE, "a, c, d");
    // $NON-NLS-1$
    BundleDescription d1_100 = state.getFactory().createBundleDescription(state, manifest, "d1_100", 4);
    state.addBundle(a1_100);
    state.addBundle(a2_100);
    state.addBundle(b1_100);
    state.addBundle(c1_100);
    state.addBundle(d1_100);
    state.resolve();
    ExportPackageDescription[] b1ResolvedImports = b1_100.getResolvedImports();
    ExportPackageDescription[] d1ResolvedImports = d1_100.getResolvedImports();
    ExportPackageDescription[] isConsistent = isConsistent(b1ResolvedImports, d1ResolvedImports);
    // $NON-NLS-1$
    assertNull("1.1 Packages are not consistent: " + isConsistent, isConsistent);
    manifest = new Hashtable();
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "B1");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
    // $NON-NLS-1$
    manifest.put(Constants.EXPORT_PACKAGE, "b; uses:=a");
    // $NON-NLS-1$
    manifest.put(Constants.IMPORT_PACKAGE, "a;bundle-symbolic-name=A1");
    // $NON-NLS-1$
    b1_100 = state.getFactory().createBundleDescription(state, manifest, "b1_100", 2);
    state.updateBundle(b1_100);
    state.resolve();
    b1ResolvedImports = b1_100.getResolvedImports();
    d1ResolvedImports = d1_100.getResolvedImports();
    isConsistent = isConsistent(b1ResolvedImports, d1ResolvedImports);
    // $NON-NLS-1$
    assertNull("1.2 Packages are not consistent: " + isConsistent, isConsistent);
}
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