ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1231711 - in /ant/ivy/core/trunk: src/java/org/apache/ivy/osgi/obr/filter/RequirementFilterParser.java src/java/org/apache/ivy/osgi/obr/filter/UniOperatorFilter.java test/java/org/apache/ivy/osgi/obr/RequirementFilterTest.java
Date Sun, 15 Jan 2012 17:51:24 GMT
Author: hibou
Date: Sun Jan 15 17:51:24 2012
New Revision: 1231711

URL: http://svn.apache.org/viewvc?rev=1231711&view=rev
Log:
IVY-1329: fix the parse of ! (NOT) in the OSGi requirement filter

Modified:
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/filter/RequirementFilterParser.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/filter/UniOperatorFilter.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/RequirementFilterTest.java

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/filter/RequirementFilterParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/filter/RequirementFilterParser.java?rev=1231711&r1=1231710&r2=1231711&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/filter/RequirementFilterParser.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/filter/RequirementFilterParser.java
Sun Jan 15 17:51:24 2012
@@ -93,27 +93,33 @@ public class RequirementFilterParser {
             if (c != '(') {
                 throw new ParseException("Expecting '(' as the start of the filter", pos);
             }
+            RequirementFilter filter;
             switch (readNext()) {
                 case '&':
-                    return parseAnd();
+                    filter = parseAnd();
+                    break;
                 case '|':
-                    return parseOr();
+                    filter = parseOr();
+                    break;
                 case '!':
-                    return parseNot();
+                    filter = parseNot();
+                    break;
                 default:
                     unread();
-                    return parseCompare();
+                    filter = parseCompare();
+                    break;
+            }
+            readNext();
+            if (c != ')') {
+                throw new ParseException("Expecting ')' as the end of the filter", pos);
             }
+            return filter;
         }
 
         private RequirementFilter parseCompare() throws ParseException {
             String leftValue = parseCompareValue();
             Operator operator = parseCompareOperator();
             String rightValue = parseCompareValue();
-            readNext();
-            if (c != ')') {
-                throw new ParseException("Expecting ')' as the end of the filter", pos);
-            }
             return new CompareFilter(leftValue, operator, rightValue);
         }
 
@@ -177,6 +183,7 @@ public class RequirementFilterParser {
                     unread();
                     filter.add(parseFilter());
                 } else {
+                    unread();
                     break;
                 }
             } while (pos < length);

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/filter/UniOperatorFilter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/filter/UniOperatorFilter.java?rev=1231711&r1=1231710&r2=1231711&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/filter/UniOperatorFilter.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/filter/UniOperatorFilter.java Sun
Jan 15 17:51:24 2012
@@ -54,7 +54,7 @@ public abstract class UniOperatorFilter 
         if (obj == null) {
             return false;
         }
-        if (!(obj instanceof MultiOperatorFilter)) {
+        if (!(obj instanceof UniOperatorFilter)) {
             return false;
         }
         UniOperatorFilter other = (UniOperatorFilter) obj;

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/RequirementFilterTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/RequirementFilterTest.java?rev=1231711&r1=1231710&r2=1231711&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/RequirementFilterTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/RequirementFilterTest.java Sun Jan
15 17:51:24 2012
@@ -25,6 +25,7 @@ import junit.framework.TestCase;
 import org.apache.ivy.osgi.obr.filter.AndFilter;
 import org.apache.ivy.osgi.obr.filter.CompareFilter;
 import org.apache.ivy.osgi.obr.filter.CompareFilter.Operator;
+import org.apache.ivy.osgi.obr.filter.NotFilter;
 import org.apache.ivy.osgi.obr.filter.RequirementFilterParser;
 import org.apache.ivy.osgi.obr.xml.RequirementFilter;
 
@@ -38,16 +39,28 @@ public class RequirementFilterTest exten
         checkParse(cgt2, "(c>2)");
         RequirementFilter twoeqd = new CompareFilter("2", Operator.EQUALS, "d");
         checkParse(twoeqd, "(2=d)");
-        RequirementFilter foodorbarge0dot0 = new CompareFilter("foo.bar",
+        RequirementFilter foodotbarge0dot0 = new CompareFilter("foo.bar",
                 Operator.GREATER_OR_EQUAL, "0.0");
-        checkParse(foodorbarge0dot0, "(foo.bar>=0.0)");
-        RequirementFilter and = new AndFilter(new RequirementFilter[] {foodorbarge0dot0});
+        checkParse(foodotbarge0dot0, "(foo.bar>=0.0)");
+        RequirementFilter and = new AndFilter(new RequirementFilter[] {foodotbarge0dot0});
         checkParse(and, "(&(foo.bar>=0.0))");
         RequirementFilter and2 = new AndFilter(new RequirementFilter[] {cgt2, twoeqd,
-                foodorbarge0dot0});
+                foodotbarge0dot0});
         checkParse(and2, "(&(c>2)(2=d)(foo.bar>=0.0))");
         RequirementFilter spaceAfterAnd = new AndFilter(new RequirementFilter[] {twoeqd});
         checkParse(spaceAfterAnd, "(& (2=d))");
+
+        RequirementFilter version350 = new CompareFilter("version", Operator.GREATER_OR_EQUAL,
+                "3.5.0");
+        RequirementFilter version400 = new CompareFilter("version", Operator.GREATER_OR_EQUAL,
+                "4.0.0");
+        RequirementFilter notVersion400 = new NotFilter(version400);
+        RequirementFilter bundle = new CompareFilter("bundle", Operator.EQUALS,
+                "org.eclipse.core.runtime");
+        RequirementFilter andEverythingWithSpace = new AndFilter(new RequirementFilter[]
{
+                version350, notVersion400, bundle});
+        checkParse(andEverythingWithSpace,
+            "(&     (version>=3.5.0)     (!(version>=4.0.0))     (bundle=org.eclipse.core.runtime)
   )");
     }
 
     private void assertParseFail(String toParse) {



Mime
View raw message