Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2012-12-09 02:59:07 +0000
committerPascal Rapicault2012-12-09 02:59:07 +0000
commit3d04353d8947710873181679046fa3ab8fa2fc98 (patch)
tree847d3456d511230b3596bc2da2aea996a6100b8d /bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions
parentbb3337b22a12bedb23b068bd4d5f25c4465170ee (diff)
downloadrt.equinox.p2-3d04353d8947710873181679046fa3ab8fa2fc98.tar.gz
rt.equinox.p2-3d04353d8947710873181679046fa3ab8fa2fc98.tar.xz
rt.equinox.p2-3d04353d8947710873181679046fa3ab8fa2fc98.zip
Bug 396136 - [publisher] Support for expression in update descriptor andv20121209-025907
requirements
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java41
1 files changed, 40 insertions, 1 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java
index 9c752ba85..20a9bc7b2 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java
@@ -15,6 +15,8 @@ import junit.framework.TestCase;
import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
import org.eclipse.equinox.internal.p2.metadata.RequiredCapability;
import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
+import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
import org.eclipse.equinox.p2.publisher.AdviceFileParser;
import org.eclipse.equinox.p2.query.QueryUtil;
@@ -87,7 +89,7 @@ public class AdviceFileParserTest extends TestCase {
public void testUpdateDescriptorWithMatch() {
Map map = new HashMap();
- map.put("update.match", "providedCapabilities.exists(pc | pc.namespace == 'org.eclipse.equinox.p2.iu' && (pc.name == 'B' || pc.name == 'C'))");
+ map.put("update.matchExp", "providedCapabilities.exists(pc | pc.namespace == 'org.eclipse.equinox.p2.iu' && (pc.name == 'B' || pc.name == 'C'))");
map.put("update.severity", "10");
map.put("update.description", "Test Description");
@@ -245,6 +247,43 @@ public class AdviceFileParserTest extends TestCase {
assertEquals(1, reqs[1].getMin());
}
+ public void testRequireWithExpression() {
+ Map map = new HashMap();
+ String matchExp = "properties[abc] == 'def'";
+ map.put("requires.0.matchExp", matchExp);
+ map.put("requires.0.greedy", Boolean.TRUE.toString());
+ map.put("requires.0.min", "1");
+ map.put("requires.0.max", "1");
+
+ AdviceFileParser parser = new AdviceFileParser("id", Version.emptyVersion, map);
+ parser.parse();
+ IRequirement[] reqs = parser.getRequiredCapabilities();
+ reqs = parser.getRequiredCapabilities();
+ assertEquals(1, reqs.length);
+
+ IMatchExpression<IInstallableUnit> matchExpression = ExpressionUtil.getFactory().matchExpression(ExpressionUtil.parse(matchExp));
+ assertEquals(matchExpression, reqs[0].getMatches());
+ }
+
+ public void testRequireWithExpressionAndOptional() {
+ Map map = new HashMap();
+ String matchExp = "properties[abc] == 'def'";
+ map.put("requires.0.matchExp", matchExp);
+ map.put("requires.0.greedy", Boolean.TRUE.toString());
+ map.put("requires.0.optional", Boolean.TRUE.toString());
+
+ AdviceFileParser parser = new AdviceFileParser("id", Version.emptyVersion, map);
+ parser.parse();
+ IRequirement[] reqs = parser.getRequiredCapabilities();
+ reqs = parser.getRequiredCapabilities();
+ assertEquals(1, reqs.length);
+
+ IMatchExpression<IInstallableUnit> matchExpression = ExpressionUtil.getFactory().matchExpression(ExpressionUtil.parse(matchExp));
+ assertEquals(matchExpression, reqs[0].getMatches());
+ assertEquals(0, reqs[0].getMin());
+ assertEquals(1, reqs[0].getMax());
+ }
+
public void testMetaRequiresAdvice() {
Map map = new HashMap();
map.put("metaRequirements.0.namespace", "testNamespace1");

Back to the top