Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.equinox.p2.director/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/NewDependencyExpander.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/resolution/ResolutionHelper.java (renamed from bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/resolution/ResolutionHelper.java)12
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/resolution/StateMetadataMap.java (renamed from bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/resolution/StateMetadataMap.java)2
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/resolution/Transformer.java (renamed from bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/resolution/Transformer.java)14
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/resolution/UnsatisfiedCapability.java (renamed from bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/resolution/UnsatisfiedCapability.java)2
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/META-INF/MANIFEST.MF3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AllTests.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/ResolutionHelperTest.java269
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/AllTests.java1
11 files changed, 290 insertions, 26 deletions
diff --git a/bundles/org.eclipse.equinox.p2.director/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.director/META-INF/MANIFEST.MF
index d86adb28d..5396f686b 100644
--- a/bundles/org.eclipse.equinox.p2.director/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.director/META-INF/MANIFEST.MF
@@ -15,11 +15,11 @@ Import-Package: org.eclipse.equinox.internal.p2.core.helpers,
org.eclipse.equinox.p2.metadata,
org.eclipse.equinox.p2.metadata.repository,
org.eclipse.equinox.p2.query,
- org.eclipse.equinox.p2.resolution,
org.eclipse.osgi.service.resolver;version="1.1.0",
org.eclipse.osgi.util;version="1.0.0",
org.osgi.framework;version="1.3.0"
Export-Package: org.eclipse.equinox.internal.p2.director;x-friends:="org.eclipse.equinox.p2.exemplarysetup",
+ org.eclipse.equinox.internal.p2.resolution;x-internal:=true,
org.eclipse.equinox.internal.p2.rollback;x-internal:=true,
org.eclipse.equinox.p2.director
Bundle-Activator: org.eclipse.equinox.internal.p2.director.DirectorActivator
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/NewDependencyExpander.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/NewDependencyExpander.java
index 2259f1833..69e720374 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/NewDependencyExpander.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/NewDependencyExpander.java
@@ -10,11 +10,11 @@ package org.eclipse.equinox.internal.p2.director;
import java.util.*;
import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.internal.p2.resolution.ResolutionHelper;
+import org.eclipse.equinox.internal.p2.resolution.UnsatisfiedCapability;
import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.query.CompoundIterator;
-import org.eclipse.equinox.p2.resolution.ResolutionHelper;
-import org.eclipse.equinox.p2.resolution.UnsatisfiedCapability;
import org.eclipse.osgi.service.resolver.VersionRange;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.InvalidSyntaxException;
@@ -162,10 +162,6 @@ public class NewDependencyExpander {
return wrapped.toString();
}
- public void accept(IMetadataVisitor visitor) {
- wrapped.accept(visitor);
- }
-
public String getApplicabilityFilter() {
return wrapped.getApplicabilityFilter();
}
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
index 0c0fe9514..5c65671c3 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
@@ -11,6 +11,7 @@ package org.eclipse.equinox.internal.p2.director;
import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
+import org.eclipse.equinox.internal.p2.resolution.ResolutionHelper;
import org.eclipse.equinox.p2.director.IPlanner;
import org.eclipse.equinox.p2.director.ProvisioningPlan;
import org.eclipse.equinox.p2.engine.Operand;
@@ -18,7 +19,6 @@ import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.repository.IMetadataRepository;
import org.eclipse.equinox.p2.metadata.repository.IMetadataRepositoryManager;
-import org.eclipse.equinox.p2.resolution.ResolutionHelper;
import org.eclipse.osgi.service.resolver.VersionRange;
import org.eclipse.osgi.util.NLS;
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/resolution/ResolutionHelper.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/resolution/ResolutionHelper.java
index f6a84efc6..8dbf77afd 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/resolution/ResolutionHelper.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/resolution/ResolutionHelper.java
@@ -8,10 +8,11 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.equinox.p2.resolution;
+package org.eclipse.equinox.internal.p2.resolution;
import java.util.*;
-import org.eclipse.equinox.internal.p2.metadata.MetadataActivator;
+import org.eclipse.equinox.internal.p2.director.DirectorActivator;
+import org.eclipse.equinox.internal.p2.director.RecommendationDescriptor;
import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.osgi.service.resolver.*;
import org.osgi.framework.ServiceReference;
@@ -37,8 +38,8 @@ public class ResolutionHelper {
}
private void initialize() {
- ServiceReference sr = MetadataActivator.context.getServiceReference(PlatformAdmin.class.getName());
- PlatformAdmin pa = (PlatformAdmin) MetadataActivator.context.getService(sr);
+ ServiceReference sr = DirectorActivator.context.getServiceReference(PlatformAdmin.class.getName());
+ PlatformAdmin pa = (PlatformAdmin) DirectorActivator.context.getService(sr);
transformer = new Transformer(pa.getFactory(), selectionContext, recommendations);
state = pa.getFactory().createState(true);
fragmentBindings = new HashMap();
@@ -51,8 +52,7 @@ public class ResolutionHelper {
}
private BundleDescription addInResolution(IInstallableUnit toAdd) {
- toAdd.accept(transformer);
- // transformer.visitInstallableUnit(toAdd);
+ transformer.visitInstallableUnit(toAdd);
BundleDescription descriptionToAdd = transformer.getResult();
// bundleDescriptionToIU.put(descriptionToAdd, toAdd);
addToState(descriptionToAdd);
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/resolution/StateMetadataMap.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/resolution/StateMetadataMap.java
index 9d29bc5d5..d2216dbfa 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/resolution/StateMetadataMap.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/resolution/StateMetadataMap.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.equinox.p2.resolution;
+package org.eclipse.equinox.internal.p2.resolution;
import java.util.Map;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/resolution/Transformer.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/resolution/Transformer.java
index 2afb99c84..39d83702a 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/resolution/Transformer.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/resolution/Transformer.java
@@ -6,18 +6,18 @@
*
* Contributors: IBM Corporation - initial API and implementation
******************************************************************************/
-package org.eclipse.equinox.p2.resolution;
+package org.eclipse.equinox.internal.p2.resolution;
import java.util.*;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
-import org.eclipse.equinox.internal.p2.metadata.MetadataActivator;
+import org.eclipse.equinox.internal.p2.director.*;
import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.osgi.service.resolver.*;
import org.osgi.framework.InvalidSyntaxException;
-public class Transformer implements IMetadataVisitor {
+public class Transformer {
private static final byte IU_KIND = 0;
private static final String IU_NAMESPACE = "iu.namespace";
static long iuInternalId = 0;
@@ -63,7 +63,7 @@ public class Transformer implements IMetadataVisitor {
if (filter == null)
return true;
try {
- return MetadataActivator.getContext().createFilter(filter).match(context);
+ return DirectorActivator.context.createFilter(filter).match(context);
} catch (InvalidSyntaxException e) {
// If we fail to parse the filter treat it as invalid and be optimistic
return true;
@@ -96,14 +96,14 @@ public class Transformer implements IMetadataVisitor {
RequiredCapability[] requires = toTransform.getRequiredCapabilities();
iuDependencies = new HashMap(requires.length);
for (int i = 0; i < requires.length; i++) {
- requires[i].accept(this);
+ visitRequiredCapability(requires[i]);
}
//Do the capabilities
ProvidedCapability[] capabilities = toTransform.getProvidedCapabilities();
iuCapabilities = new ArrayList(requires.length + 1);
for (int i = 0; i < capabilities.length; i++) {
- capabilities[i].accept(this);
+ visitCapability(capabilities[i]);
}
//Add a capability representing the IU itself
@@ -128,7 +128,7 @@ public class Transformer implements IMetadataVisitor {
iuDependencies.put(factory.createGenericSpecification(capability.getName(), capability.getNamespace(), toFilter(capability.getRange()), capability.isOptional(), capability.isMultiple()), capability);
}
} catch (InvalidSyntaxException e) {
- LogHelper.log(new Status(IStatus.ERROR, MetadataActivator.PI_METADATA, "Invalid filter: " + e.getFilter(), e)); //$NON-NLS-1$
+ LogHelper.log(new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, "Invalid filter: " + e.getFilter(), e)); //$NON-NLS-1$
}
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/resolution/UnsatisfiedCapability.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/resolution/UnsatisfiedCapability.java
index 024b776b2..462a27bea 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/resolution/UnsatisfiedCapability.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/resolution/UnsatisfiedCapability.java
@@ -6,7 +6,7 @@
*
* Contributors: IBM Corporation - initial API and implementation
******************************************************************************/
-package org.eclipse.equinox.p2.resolution;
+package org.eclipse.equinox.internal.p2.resolution;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.RequiredCapability;
diff --git a/bundles/org.eclipse.equinox.p2.metadata/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.metadata/META-INF/MANIFEST.MF
index 8675af3f1..533613ca2 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.metadata/META-INF/MANIFEST.MF
@@ -7,8 +7,7 @@ Bundle-Localization: plugin
Bundle-Version: 0.1.0.qualifier
Export-Package: org.eclipse.equinox.internal.p2.metadata;x-friends:="org.eclipse.equinox.p2.metadata.generator,org.eclipse.equinox.p2.metadata.repository,org.eclipse.equinox.p2.engine,org.eclipse.equinox.p2.artifact.repository,org.eclipse.equinox.p2.artifact.optimizers,org.eclipse.equinox.p2.artifact.processors",
org.eclipse.equinox.p2.metadata,
- org.eclipse.equinox.p2.query,
- org.eclipse.equinox.p2.resolution
+ org.eclipse.equinox.p2.query
Import-Package: org.eclipse.osgi.service.resolver;version="1.1.0",
org.eclipse.osgi.util;version="1.1.0",
org.osgi.framework;version="1.3.0"
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AllTests.java
index 92e5a385a..706ab5aab 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AllTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AllTests.java
@@ -25,6 +25,7 @@ public class AllTests extends TestCase {
suite.addTestSuite(OracleTest.class);
suite.addTestSuite(OracleTest2.class);
suite.addTestSuite(PickerTest.class);
+ suite.addTestSuite(ResolutionHelperTest.class);
suite.addTestSuite(RollbackTest.class);
suite.addTestSuite(SingletonTest.class);
suite.addTestSuite(UninstallTest.class);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/ResolutionHelperTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/ResolutionHelperTest.java
new file mode 100644
index 000000000..d44d96682
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/ResolutionHelperTest.java
@@ -0,0 +1,269 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.p2.tests.director;
+
+import java.util.*;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.eclipse.equinox.internal.p2.resolution.ResolutionHelper;
+import org.eclipse.equinox.internal.p2.resolution.UnsatisfiedCapability;
+import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
+import org.eclipse.osgi.service.resolver.VersionRange;
+import org.osgi.framework.Version;
+
+/**
+ * Tests for {@link ResolutionHelper}.
+ */
+public class ResolutionHelperTest extends AbstractProvisioningTest {
+ private static final String FILTER_KEY = "osgi.os";
+
+ public static Test suite() {
+ return new TestSuite(ResolutionHelperTest.class);
+ }
+
+ public ResolutionHelperTest() {
+ super("");
+ }
+
+ public ResolutionHelperTest(String name) {
+ super(name);
+ }
+
+ /**
+ * Tests resolving an IU that requires a capability, and the available
+ * provided capability is above the required capability's version range.
+ */
+ public void testDependencyAboveVersionRange() {
+ Version version = new Version(5, 0, 0);
+
+ //The IU that exports the capability
+ ProvidedCapability[] provides = new ProvidedCapability[] {new ProvidedCapability("test.capability", "test", version)};
+ IInstallableUnit required = createIU("required", version, provides);
+
+ //an IU whose required capability falls outside available range
+ RequiredCapability[] requires = createRequiredCapabilities("test.capability", "test", new VersionRange("[2.0,5.0)"), null);
+ IInstallableUnit toInstall = createIU("match", version, requires);
+
+ ResolutionHelper rh = new ResolutionHelper(null, null);
+ HashSet installSet = new HashSet();
+ installSet.add(toInstall);
+ HashSet available = new HashSet();
+ available.add(required);
+ UnsatisfiedCapability[] unsatisfied = rh.install(installSet, available);
+
+ assertEquals("1.0", 1, unsatisfied.length);
+ assertEquals("1.1", "match", unsatisfied[0].getUnsatisfiedUnit().getId());
+ RequiredCapability capability = unsatisfied[0].getRequiredCapability();
+ assertEquals("1.4", "test.capability", capability.getNamespace());
+ assertEquals("1.5", "test", capability.getName());
+ }
+
+ /**
+ * Tests resolving an IU that requires a capability, and the available
+ * provided capability is below the required capability's version range.
+ */
+ public void testDependencyBelowVersionRange() {
+ Version version = new Version(2, 0, 0);
+
+ //The IU that exports the capability
+ ProvidedCapability[] provides = new ProvidedCapability[] {new ProvidedCapability("test.capability", "test", version)};
+ IInstallableUnit required = createIU("required", version, provides);
+
+ //an IU whose required capability falls outside available range
+ RequiredCapability[] requires = createRequiredCapabilities("test.capability", "test", new VersionRange("(2.0,3.0)"), null);
+ IInstallableUnit toInstall = createIU("match", version, requires);
+
+ ResolutionHelper rh = new ResolutionHelper(null, null);
+ HashSet installSet = new HashSet();
+ installSet.add(toInstall);
+ HashSet available = new HashSet();
+ available.add(required);
+ UnsatisfiedCapability[] unsatisfied = rh.install(installSet, available);
+
+ assertEquals("1.0", 1, unsatisfied.length);
+ assertEquals("1.1", "match", unsatisfied[0].getUnsatisfiedUnit().getId());
+ RequiredCapability capability = unsatisfied[0].getRequiredCapability();
+ assertEquals("1.4", "test.capability", capability.getNamespace());
+ assertEquals("1.5", "test", capability.getName());
+ }
+
+ public void testDependencyWithPlatformFilter() {
+ Version version = new Version(1, 0, 0);
+
+ //The IU that exports the capability
+ ProvidedCapability[] provides = new ProvidedCapability[] {new ProvidedCapability("test.capability", "test", version)};
+ IInstallableUnit required = createIU("required", version, createFilter(FILTER_KEY, "win32"), provides);
+
+ RequiredCapability[] requires = createRequiredCapabilities("test.capability", "test", ANY_VERSION, null);
+ IInstallableUnit toInstall = createIU("toInstall", version, requires);
+
+ //setup context so that platform filter will satisfy dependency
+ Hashtable context = new Hashtable();
+ context.put(FILTER_KEY, "win32");
+ ResolutionHelper rh = new ResolutionHelper(context, null);
+ HashSet installSet = new HashSet();
+ installSet.add(toInstall);
+ HashSet available = new HashSet();
+ available.add(required);
+ UnsatisfiedCapability[] unsatisfied = rh.install(installSet, available);
+ assertEquals("1.0", 0, unsatisfied.length);
+
+ //now try with a null evaluation context
+ rh = new ResolutionHelper(null, null);
+ unsatisfied = rh.install(installSet, available);
+ assertEquals("1.1", 1, unsatisfied.length);
+ assertEquals("1.2", "toInstall", unsatisfied[0].getUnsatisfiedUnit().getId());
+ RequiredCapability capability = unsatisfied[0].getRequiredCapability();
+ assertEquals("1.3", "test.capability", capability.getNamespace());
+ assertEquals("1.4", "test", capability.getName());
+
+ //now use a context where platform filter will not be satisfied
+ context.put(FILTER_KEY, "nomatch");
+ rh = new ResolutionHelper(context, null);
+ unsatisfied = rh.install(installSet, available);
+ assertEquals("2.1", 1, unsatisfied.length);
+ assertEquals("2.2", "toInstall", unsatisfied[0].getUnsatisfiedUnit().getId());
+ capability = unsatisfied[0].getRequiredCapability();
+ assertEquals("2.3", "test.capability", capability.getNamespace());
+ assertEquals("2.4", "test", capability.getName());
+
+ }
+
+ /**
+ * Tests resolving an IU that has a filter on its required capability.
+ */
+ public void testSatisfiedDependencyWithMatchingFilter() {
+ //use the same version everywhere because it's not interesting for this test
+ Version version = new Version(1, 0, 0);
+
+ //The IU that exports the capability
+ ProvidedCapability[] provides = new ProvidedCapability[] {new ProvidedCapability("test.capability", "test", version)};
+ IInstallableUnit required = createIU("required", version, provides);
+
+ //an IU whose filter will match the environment
+ RequiredCapability[] requires = createRequiredCapabilities("test.capability", "test", createFilter(FILTER_KEY, "matchValue"));
+ IInstallableUnit toInstall = createIU("match", version, requires);
+
+ Dictionary environment = new Hashtable();
+ environment.put(FILTER_KEY, "matchValue");
+ ResolutionHelper rh = new ResolutionHelper(environment, null);
+ HashSet installSet = new HashSet();
+ installSet.add(toInstall);
+ HashSet available = new HashSet();
+ available.add(required);
+ UnsatisfiedCapability[] unsatisfied = rh.install(installSet, available);
+
+ assertEquals("1.0", 0, unsatisfied.length);
+ }
+
+ /**
+ * In this test we try to resolve an IU that has a required capability that is
+ * available, but there is a filter on the required capability so it should not be considered.
+ */
+ public void testSatisfiedDependencyWithUnmatchingFilter() {
+ //use the same version everywhere because it's not interesting for this test
+ Version version = new Version(1, 0, 0);
+
+ //The IU that exports the capability
+ ProvidedCapability[] provides = new ProvidedCapability[] {new ProvidedCapability("test.capability", "test", version)};
+ IInstallableUnit required = createIU("required", version, provides);
+
+ //an IU whose filter will not match the environment
+ RequiredCapability[] requires = createRequiredCapabilities("test.capability", "test", createFilter(FILTER_KEY, "noMatchValue"));
+ IInstallableUnit toInstall = createIU("noMatch", version, requires);
+
+ Dictionary environment = new Hashtable();
+ environment.put(FILTER_KEY, "matchValue");
+ ResolutionHelper rh = new ResolutionHelper(environment, null);
+ HashSet installSet = new HashSet();
+ installSet.add(toInstall);
+ HashSet available = new HashSet();
+ available.add(required);
+ UnsatisfiedCapability[] unsatisfied = rh.install(installSet, available);
+
+ assertEquals("1.0", 0, unsatisfied.length);
+ }
+
+ public void testSimpleDependency() {
+ RequiredCapability[] requires = new RequiredCapability[] {new RequiredCapability("java.runtime", "JRE", null, null, false, false)};
+ IInstallableUnit osgi = createIU("org.eclipse.osgi", new Version(3, 2, 0, null), requires, NO_PROPERTIES, false);
+
+ ProvidedCapability[] provides = new ProvidedCapability[] {new ProvidedCapability("java.runtime", "JRE", new Version(1, 4, 2, "sr2"))};
+ IInstallableUnit jre = createIU("com.ibm.jre", new Version(1, 4, 2, "sr2"), provides);
+
+ ResolutionHelper rh = new ResolutionHelper(null, null);
+ HashSet osgiSet = new HashSet(1);
+ osgiSet.add(osgi);
+ HashSet jreSet = new HashSet(1);
+ jreSet.add(jre);
+ assertEquals("1.0", 0, rh.install(osgiSet, jreSet).length);
+ }
+
+ /**
+ * Tests resolving an IU that has a filter on its required capability, and
+ * the required capability is not available.
+ */
+ public void testUnsatisfiedDependencyWithMatchingFilter() {
+ //use the same version everywhere because it's not interesting for this test
+ Version version = new Version(1, 0, 0);
+
+ //The IU that exports the capability
+ ProvidedCapability[] provides = new ProvidedCapability[] {new ProvidedCapability("test.capability", "test", version)};
+ IInstallableUnit required = createIU("required", version, provides);
+
+ //an IU whose filter will match the environment
+ RequiredCapability[] requires = createRequiredCapabilities("test.capability", "does.not.exist", createFilter(FILTER_KEY, "matchValue"));
+ IInstallableUnit toInstall = createIU("match", version, requires);
+
+ Dictionary environment = new Hashtable();
+ environment.put(FILTER_KEY, "matchValue");
+ ResolutionHelper rh = new ResolutionHelper(environment, null);
+ HashSet installSet = new HashSet();
+ installSet.add(toInstall);
+ HashSet available = new HashSet();
+ available.add(required);
+ UnsatisfiedCapability[] unsatisfied = rh.install(installSet, available);
+
+ assertEquals("1.0", 1, unsatisfied.length);
+ assertEquals("1.1", "match", unsatisfied[0].getUnsatisfiedUnit().getId());
+ RequiredCapability capability = unsatisfied[0].getRequiredCapability();
+ assertEquals("1.4", "test.capability", capability.getNamespace());
+ assertEquals("1.5", "does.not.exist", capability.getName());
+ }
+
+ /**
+ * In this test we try to resolve an IU that has an unsatisfied dependency.
+ * However, there is a filter on the unresolved dependency that does not
+ * match the environment, so it should not prevent the IU being resolved.
+ */
+ public void testUnsatisfiedDependencyWithUnmatchingFilter() {
+ //use the same version everywhere because it's not interesting for this test
+ Version version = new Version(1, 0, 0);
+
+ //The IU that exports the capability
+ ProvidedCapability[] provides = new ProvidedCapability[] {new ProvidedCapability("test.capability", "test", version)};
+ IInstallableUnit required = createIU("required", version, provides);
+
+ //an IU whose filter will not match the environment
+ RequiredCapability[] requires = createRequiredCapabilities("test.capability", "does.not.exist", createFilter(FILTER_KEY, "noMatchValue"));
+ IInstallableUnit toInstall = createIU("noMatch", version, requires);
+
+ Dictionary environment = new Hashtable();
+ environment.put(FILTER_KEY, "matchValue");
+ ResolutionHelper rh = new ResolutionHelper(environment, null);
+ HashSet installSet = new HashSet();
+ installSet.add(toInstall);
+ HashSet available = new HashSet();
+ available.add(required);
+ UnsatisfiedCapability[] unsatisfied = rh.install(installSet, available);
+
+ assertEquals("1.0", 0, unsatisfied.length);
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/AllTests.java
index e90afea72..6c2942a95 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/AllTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/AllTests.java
@@ -24,7 +24,6 @@ public class AllTests extends TestCase {
suite.addTestSuite(FragmentTest.class);
suite.addTestSuite(MultipleIUAndFragmentTest.class);
suite.addTestSuite(RecommendationTest.class);
- suite.addTestSuite(ResolutionHelperTest.class);
return suite;
}

Back to the top