commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: jakarta-commons/jexl/src/test/org/apache/commons/jexl JexlTest.java
Date Sun, 15 Aug 2004 15:32:52 GMT
dion        2004/08/15 08:32:52

  Modified:    jexl/src/java/org/apache/commons/jexl/parser
                        ASTSizeFunction.java
               jexl/src/test/org/apache/commons/jexl JexlTest.java
  Log:
  Fix for Issue 30562: cannot issue ${set.size()} on java.util.Set
  
  Revision  Changes    Path
  1.5       +6 -1      jakarta-commons/jexl/src/java/org/apache/commons/jexl/parser/ASTSizeFunction.java
  
  Index: ASTSizeFunction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jexl/src/java/org/apache/commons/jexl/parser/ASTSizeFunction.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ASTSizeFunction.java	28 Feb 2004 13:45:20 -0000	1.4
  +++ ASTSizeFunction.java	15 Aug 2004 15:32:52 -0000	1.5
  @@ -19,6 +19,7 @@
   
   import java.util.List;
   import java.util.Map;
  +import java.util.Set;
   import java.lang.reflect.Array;
   
   /**
  @@ -81,6 +82,10 @@
           else if (val instanceof String)
           {
               return ((String)val).length();
  +        }
  +        else if (val instanceof Set)
  +        {
  +            return ((Set)val).size();
           }
   
           throw new Exception("size() : unknown type : " + val.getClass());
  
  
  
  1.37      +11 -2     jakarta-commons/jexl/src/test/org/apache/commons/jexl/JexlTest.java
  
  Index: JexlTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jexl/src/test/org/apache/commons/jexl/JexlTest.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- JexlTest.java	19 May 2004 15:22:45 -0000	1.36
  +++ JexlTest.java	15 Aug 2004 15:32:52 -0000	1.37
  @@ -17,9 +17,11 @@
   
   import java.util.ArrayList;
   import java.util.HashMap;
  +import java.util.HashSet;
   import java.util.List;
   import java.util.Map;
   import java.util.Collections;
  +import java.util.Set;
   
   import junit.framework.Test;
   import junit.framework.TestCase;
  @@ -395,14 +397,21 @@
           list.add("5");
   
           jc.getVars().put("list", list);
  +        
  +        Set set = new HashSet();
  +        set.addAll(list);
  +        set.add("1");
  +        
  +        jc.getVars().put("set", set);
   
           assertExpression(jc, "size(s)", new Integer(5));
           assertExpression(jc, "size(array)", new Integer(5));
           assertExpression(jc, "size(list)", new Integer(5));
           assertExpression(jc, "size(map)", new Integer(5));
  -        assertExpression(jc, "size(list)", new Integer(5));
  +        assertExpression(jc, "size(set)", new Integer(5));
           assertExpression(jc, "list.size()", new Integer(5));
           assertExpression(jc, "map.size()", new Integer(5));
  +        assertExpression(jc, "set.size()", new Integer(5));
   
           assertExpression(jc, "list.get(size(list) - 1)", "5");
           assertExpression(jc, "list[size(list) - 1]", "5");
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message