summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault (Ericsson)2013-05-23 11:57:03 (EDT)
committerPascal Rapicault2013-05-23 11:57:03 (EDT)
commit7998ef5c4036704351f25dbbd19ddc1fc7e1438c (patch)
tree100a149b3d1b2315ffedc5b39596693e434dc0ff
parentf2872fd9df7cd4273ec7715b0dced4ab3393e7b2 (diff)
downloadrt.equinox.p2-7998ef5c4036704351f25dbbd19ddc1fc7e1438c.zip
rt.equinox.p2-7998ef5c4036704351f25dbbd19ddc1fc7e1438c.tar.gz
rt.equinox.p2-7998ef5c4036704351f25dbbd19ddc1fc7e1438c.tar.bz2
Bug 408691 - Regression in toString of IRequirementI20130523-1400
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequiredCapability.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/AllTests.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/RequirementToString.java37
3 files changed, 39 insertions, 1 deletions
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequiredCapability.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequiredCapability.java
index 6408e7b..bda16bc 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequiredCapability.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequiredCapability.java
@@ -181,7 +181,7 @@ public class RequiredCapability implements IRequiredCapability, IMemberProvider
if (matchExpression.getParameters().length == 0)
return matchExpression.toString();
- if (matchExpression.getParameters().length < 3 || matchExpression.getParameters().length > 3) {
+ if (!isSimpleRequirement(matchExpression)) {
result.append(matchExpression.toString()).append(' ');
for (int i = 0; i < matchExpression.getParameters().length; i++) {
result.append(matchExpression.getParameters()[i]).append(' ');
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 2eb0a58..0a4facf 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
@@ -31,6 +31,7 @@ public class AllTests extends TestCase {
suite.addTestSuite(PersistNegation.class);
suite.addTestSuite(PersistFragment.class);
suite.addTestSuite(ProvidedCapabilityTest.class);
+ suite.addTestSuite(RequirementToString.class);
return suite;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/RequirementToString.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/RequirementToString.java
new file mode 100644
index 0000000..f0a36b1
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/RequirementToString.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Ericsson AB 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:
+ * Ericsson AB - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.p2.tests.metadata;
+
+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.tests.AbstractProvisioningTest;
+
+//These tests are not here to force the toString of a requirement.
+//They are here to ensure that the toString of a requirement does not become unreadable because this ends up being presented in the p2 UI and in the tycho build.
+//As such if there are better ways present all this information, by all mean change the test.
+public class RequirementToString extends AbstractProvisioningTest {
+ public void testRequirementWithEmptyRange() {
+ IRequirement req = MetadataFactory.createRequirement("expectedNameSpace", "expectedName", VersionRange.emptyRange, null, false, false);
+ assertEquals("expectedNameSpace expectedName 0.0.0", req.toString());
+ }
+
+ public void testStandardRequirement() {
+ IRequirement req = MetadataFactory.createRequirement("expectedNameSpace", "expectedName", new VersionRange("[1.0.0, 2.0.0)"), null, false, false);
+ assertEquals("expectedNameSpace expectedName [1.0.0,2.0.0)", req.toString());
+ }
+
+ public void testFancyRequirement() {
+ Object[] expressionParameters = new Object[] {"expectedId1, expectedVersion1", "expectedId2, expectedVersion2"};
+ IMatchExpression<IInstallableUnit> iuMatcher = ExpressionUtil.getFactory().<IInstallableUnit> matchExpression(ExpressionUtil.parse("(id == $0 && version == $1) || (id == $2 && version == $3)"), expressionParameters);
+ IRequirement req = MetadataFactory.createRequirement(iuMatcher, null, 1, 1, true);
+ assertEquals("id == $0 && version == $1 || id == $2 && version == $3 expectedId1, expectedVersion1 expectedId2, expectedVersion2", req.toString().trim());
+ }
+}