Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2008-07-17 15:38:25 -0400
committerThomas Watson2008-07-17 15:38:25 -0400
commit89b122cfb3c78b5f44f6db52fc4a53af6d4ac494 (patch)
tree45abdc5ba018094111e6ea4587ba464fb838a0b2 /bundles
parent61573c4652fa0414aa987de1282db42b1938c271 (diff)
downloadrt.equinox.framework-89b122cfb3c78b5f44f6db52fc4a53af6d4ac494.tar.gz
rt.equinox.framework-89b122cfb3c78b5f44f6db52fc4a53af6d4ac494.tar.xz
rt.equinox.framework-89b122cfb3c78b5f44f6db52fc4a53af6d4ac494.zip
Bug 241128 StateHelper.getUnsatisfiedLeaves() behaviour changed from 3.2v20080722-0430
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/PlatformAdminTest.java216
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java3
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java12
3 files changed, 230 insertions, 1 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/PlatformAdminTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/PlatformAdminTest.java
index 7bfbf5356..c8265d65b 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/PlatformAdminTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/PlatformAdminTest.java
@@ -11,6 +11,7 @@
package org.eclipse.osgi.tests.services.resolver;
import java.io.*;
+import java.util.Dictionary;
import java.util.Hashtable;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -20,6 +21,9 @@ import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
public class PlatformAdminTest extends AbstractStateTest {
+ private static final String GENERIC_REQUIRE = "Eclipse-GenericRequire"; //$NON-NLS-1$
+ private static final String GENERIC_CAPABILITY = "Eclipse-GenericCapability"; //$NON-NLS-1$
+
public static Test suite() {
return new TestSuite(PlatformAdminTest.class);
}
@@ -152,6 +156,218 @@ public class PlatformAdminTest extends AbstractStateTest {
assertNotNull("exports is null", exports);
assertEquals("Wrong number of exports", 2, exports.length);
}
+
+ public void testBug241128_01() throws BundleException {
+ State state = buildEmptyState();
+ Hashtable manifest = new Hashtable();
+ int id = 0;
+
+ manifest.clear();
+ manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ manifest.put(Constants.BUNDLE_SYMBOLICNAME, "a");
+ manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
+ BundleDescription a1 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
+
+ manifest.clear();
+ manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ manifest.put(Constants.BUNDLE_SYMBOLICNAME, "b");
+ manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
+ manifest.put(Constants.REQUIRE_BUNDLE, "a; bundle-version=\"[1.0.0, 2.0.0)\"");
+ BundleDescription b = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
+
+ state.addBundle(a1);
+ state.addBundle(b);
+ state.resolve(true);
+
+ assertTrue("Bundle a1 is not resolved", a1.isResolved());
+ assertTrue("Bundle b is not resolved", b.isResolved());
+
+ manifest.clear();
+ manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ manifest.put(Constants.BUNDLE_SYMBOLICNAME, "a");
+ manifest.put(Constants.BUNDLE_VERSION, "2.0.0");
+ BundleDescription a2 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), a1.getBundleId());
+ state.updateBundle(a2);
+
+ state.resolve(true);
+ assertTrue("Bundle a2 is not resolved", a2.isResolved());
+ assertFalse("Bundle b is resolved", b.isResolved());
+
+ VersionConstraint[] unsatisified = state.getStateHelper().getUnsatisfiedLeaves(state.getBundles());
+ assertEquals("Wrong number of unsatisified leaves", 1, unsatisified.length);
+ assertEquals("Wrong unsatisfied constraint", b.getRequiredBundles()[0], unsatisified[0]);
+ }
+
+ public void testBug241128_02() throws BundleException {
+ State state = buildEmptyState();
+ Hashtable manifest = new Hashtable();
+ int id = 0;
+
+ manifest.clear();
+ manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ manifest.put(Constants.BUNDLE_SYMBOLICNAME, "a");
+ manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
+ BundleDescription a1 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
+
+ manifest.clear();
+ manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ manifest.put(Constants.BUNDLE_SYMBOLICNAME, "b");
+ manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
+ manifest.put(Constants.FRAGMENT_HOST, "a; bundle-version=\"[1.0.0, 2.0.0)\"");
+ BundleDescription b = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
+
+ state.addBundle(a1);
+ state.addBundle(b);
+ state.resolve(true);
+
+ assertTrue("Bundle a1 is not resolved", a1.isResolved());
+ assertTrue("Bundle b is not resolved", b.isResolved());
+
+ manifest.clear();
+ manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ manifest.put(Constants.BUNDLE_SYMBOLICNAME, "a");
+ manifest.put(Constants.BUNDLE_VERSION, "2.0.0");
+ BundleDescription a2 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), a1.getBundleId());
+ state.updateBundle(a2);
+
+ state.resolve(true);
+ assertTrue("Bundle a2 is not resolved", a2.isResolved());
+ assertFalse("Bundle b is resolved", b.isResolved());
+
+ VersionConstraint[] unsatisified = state.getStateHelper().getUnsatisfiedLeaves(state.getBundles());
+ assertEquals("Wrong number of unsatisified leaves", 1, unsatisified.length);
+ assertEquals("Wrong unsatisfied constraint", b.getHost(), unsatisified[0]);
+ }
+
+ public void testBug241128_03() throws BundleException {
+ State state = buildEmptyState();
+ Hashtable manifest = new Hashtable();
+ int id = 0;
+
+ manifest.clear();
+ manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ manifest.put(Constants.BUNDLE_SYMBOLICNAME, "a");
+ manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
+ manifest.put(Constants.EXPORT_PACKAGE, "a; version=1.0");
+ BundleDescription a1 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
+
+ manifest.clear();
+ manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ manifest.put(Constants.BUNDLE_SYMBOLICNAME, "b");
+ manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
+ manifest.put(Constants.IMPORT_PACKAGE, "a; version=\"[1.0.0, 2.0.0)\"");
+ BundleDescription b = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
+
+ state.addBundle(a1);
+ state.addBundle(b);
+ state.resolve(true);
+
+ assertTrue("Bundle a1 is not resolved", a1.isResolved());
+ assertTrue("Bundle b is not resolved", b.isResolved());
+
+ manifest.clear();
+ manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ manifest.put(Constants.BUNDLE_SYMBOLICNAME, "a");
+ manifest.put(Constants.BUNDLE_VERSION, "2.0.0");
+ manifest.put(Constants.EXPORT_PACKAGE, "a; version=2.0");
+ BundleDescription a2 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), a1.getBundleId());
+ state.updateBundle(a2);
+
+ state.resolve(true);
+ assertTrue("Bundle a2 is not resolved", a2.isResolved());
+ assertFalse("Bundle b is resolved", b.isResolved());
+
+ VersionConstraint[] unsatisified = state.getStateHelper().getUnsatisfiedLeaves(state.getBundles());
+ assertEquals("Wrong number of unsatisified leaves", 1, unsatisified.length);
+ assertEquals("Wrong unsatisfied constraint", b.getImportPackages()[0], unsatisified[0]);
+ }
+
+ public void testBug241128_04() throws BundleException {
+ State state = buildEmptyState();
+ Dictionary[] props = new Dictionary[] {new Hashtable()};
+ props[0].put("osgi.os", "win32");
+ props[0].put("osgi.arch", "x86");
+ state.setPlatformProperties(props);
+
+ Hashtable manifest = new Hashtable();
+ int id = 0;
+
+ manifest.clear();
+ manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ manifest.put(Constants.BUNDLE_SYMBOLICNAME, "a");
+ manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
+ manifest.put(Constants.BUNDLE_NATIVECODE, "Bundle-NativeCode: nativefile1.txt;processor=x86;osname=win32");
+ BundleDescription a1 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), id++);
+
+ state.addBundle(a1);
+ state.resolve(true);
+
+ assertTrue("Bundle a1 is not resolved", a1.isResolved());
+
+ manifest.clear();
+ manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ manifest.put(Constants.BUNDLE_SYMBOLICNAME, "a");
+ manifest.put(Constants.BUNDLE_VERSION, "2.0.0");
+ manifest.put(Constants.BUNDLE_NATIVECODE, "Bundle-NativeCode: nativefile1.txt;processor=linux;osname=gtk");
+ BundleDescription a2 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + manifest.get(Constants.BUNDLE_VERSION), a1.getBundleId());
+ state.updateBundle(a2);
+
+ state.resolve(true);
+ assertFalse("Bundle a2 is resolved", a2.isResolved());
+
+ VersionConstraint[] unsatisified = state.getStateHelper().getUnsatisfiedConstraints(a2);
+ assertEquals("Wrong number of unsatisified leaves", 1, unsatisified.length);
+ assertEquals("Wrong unsatisfied constraint", a2.getNativeCodeSpecification(), unsatisified[0]);
+
+ unsatisified = state.getStateHelper().getUnsatisfiedLeaves(state.getBundles());
+ assertEquals("Wrong number of unsatisified leaves", 1, unsatisified.length);
+ assertEquals("Wrong unsatisfied constraint", a2.getNativeCodeSpecification(), unsatisified[0]);
+ }
+
+ public void testGenericsBasics() throws BundleException {
+ State state = buildEmptyState();
+ Hashtable manifest = new Hashtable();
+ long bundleID = 0;
+
+ manifest.clear();
+ manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ manifest.put(Constants.BUNDLE_SYMBOLICNAME, "genericCapablity");
+ manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
+ manifest.put(GENERIC_CAPABILITY, "foo; version=\"1.3.1\"; attr1=\"value1\"; attr2=\"value2\"");
+ BundleDescription genCap1 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME), bundleID++);
+
+ manifest.clear();
+ manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ manifest.put(Constants.BUNDLE_SYMBOLICNAME, "genericRequire");
+ manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
+ manifest.put(GENERIC_REQUIRE, "foo; selection-filter=\"(version>=1.3.0)\"");
+ BundleDescription genReq = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME), bundleID++);
+
+ state.addBundle(genCap1);
+ state.addBundle(genReq);
+
+ state.resolve();
+
+ assertTrue("Bundle genCap1 is not resolved", genCap1.isResolved());
+ assertTrue("Bundle genReq is not resolved", genReq.isResolved());
+
+ manifest.clear();
+ manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ manifest.put(Constants.BUNDLE_SYMBOLICNAME, "genericCapablity");
+ manifest.put(Constants.BUNDLE_VERSION, "2.0.0");
+ manifest.put(GENERIC_CAPABILITY, "foo; version=\"1.0\"; attr1=\"value1\"; attr2=\"value2\"");
+ BundleDescription genCap2 = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME), genCap1.getBundleId());
+
+ state.updateBundle(genCap2);
+
+ state.resolve(true);
+ assertTrue("Bundle genCap2 is not resolved", genCap2.isResolved());
+ assertFalse("Bundle genReq is resolved", genReq.isResolved());
+
+ VersionConstraint[] unsatisified = state.getStateHelper().getUnsatisfiedLeaves(state.getBundles());
+ assertEquals("Wrong number of unsatisified leaves", 1, unsatisified.length);
+ assertEquals("Wrong unsatisfied constraint", genReq.getGenericRequires()[0], unsatisified[0]);
+ }
}
//TODO tests to enable
//testFragmentUpdateNoVersionChanged()
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java
index d6d453ee4..d584f7f12 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java
@@ -178,6 +178,9 @@ public class StateHelperImpl implements StateHelper {
for (int i = 0; i < generics.length; i++)
if (!generics[i].isResolved() && !isResolvable(generics[i]))
unsatisfied.add(generics[i]);
+ NativeCodeSpecification nativeCode = bundle.getNativeCodeSpecification();
+ if (nativeCode != null && !nativeCode.isResolved())
+ unsatisfied.add(nativeCode);
return (VersionConstraint[]) unsatisfied.toArray(new VersionConstraint[unsatisfied.size()]);
}
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java
index 9838191e9..3d6db2cb7 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java
@@ -373,11 +373,21 @@ public abstract class StateImpl implements State {
bundle.setResolvedRequires(null);
bundle.setSubstitutedExports(null);
- // remove suppliers for generics
+ // remove the constraint suppliers
+ NativeCodeSpecificationImpl nativeCode = (NativeCodeSpecificationImpl) bundle.getNativeCodeSpecification();
+ if (nativeCode != null)
+ nativeCode.setSupplier(null);
+ ImportPackageSpecification[] imports = bundle.getImportPackages();
+ for (int i = 0; i < imports.length; i++)
+ ((ImportPackageSpecificationImpl) imports[i]).setSupplier(null);
+ BundleSpecification[] requires = bundle.getRequiredBundles();
+ for (int i = 0; i < requires.length; i++)
+ ((BundleSpecificationImpl) requires[i]).setSupplier(null);
GenericSpecification[] genericRequires = bundle.getGenericRequires();
if (genericRequires.length > 0)
for (int i = 0; i < genericRequires.length; i++)
((GenericSpecificationImpl) genericRequires[i]).setSupplers(null);
+
bundle.removeDependencies();
}

Back to the top