commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject svn commit: r799781 - in /commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl: ./ parser/ util/introspection/
Date Sat, 01 Aug 2009 00:46:51 GMT
Author: rahul
Date: Sat Aug  1 00:46:50 2009
New Revision: 799781

URL: http://svn.apache.org/viewvc?rev=799781&view=rev
Log:
JEXL-60
Step 3 of 4

Changes to the test cases:
 - Make all test cases inherit from new JexlTestCase class that allows easy programmatic execution of individual tests
 - Accommodate for changes to parser and MethodKey class
 - Added some much needed cache testing

Thanks to patch by Henri Biestro <hbiestro at gmail dot com>.

Added:
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/CacheTest.java   (with props)
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/JexlTestCase.java   (with props)
Modified:
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ArithmeticTest.java
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ArrayAccessTest.java
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/AssignTest.java
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/BitwiseOperatorTest.java
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/BlockTest.java
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/Foo.java
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ForEachTest.java
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/IfTest.java
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/IssuesTest.java
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/JexlTest.java
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/MapLiteralTest.java
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/MethodTest.java
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ParseFailuresTest.java
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ScriptFactoryTest.java
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ScriptTest.java
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/UnifiedJEXLTest.java
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/WhileTest.java
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/parser/ParserTest.java
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/util/introspection/MethodKeyTest.java

Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ArithmeticTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ArithmeticTest.java?rev=799781&r1=799780&r2=799781&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ArithmeticTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ArithmeticTest.java Sat Aug  1 00:46:50 2009
@@ -22,9 +22,8 @@
 
 import org.apache.commons.jexl.junit.Asserter;
 
-import junit.framework.TestCase;
 
-public class ArithmeticTest extends TestCase {
+public class ArithmeticTest extends JexlTestCase {
     private Asserter asserter;
 
     public void setUp() {
@@ -187,5 +186,4 @@
                         zeval == PERMS);
         }
     }
-
 }
\ No newline at end of file

Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ArrayAccessTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ArrayAccessTest.java?rev=799781&r1=799780&r2=799781&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ArrayAccessTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ArrayAccessTest.java Sat Aug  1 00:46:50 2009
@@ -23,14 +23,13 @@
 
 import org.apache.commons.jexl.junit.Asserter;
 
-import junit.framework.TestCase;
 
 /**
  * Tests for array access operator []
  * 
  * @since 2.0
  */
-public class ArrayAccessTest extends TestCase {
+public class ArrayAccessTest extends JexlTestCase {
 
     private Asserter asserter;
 

Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/AssignTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/AssignTest.java?rev=799781&r1=799780&r2=799781&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/AssignTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/AssignTest.java Sat Aug  1 00:46:50 2009
@@ -16,15 +16,13 @@
  */
 package org.apache.commons.jexl;
 
-import junit.framework.TestCase;
-
 /**
  * Test cases for the if statement.
  * 
  * @author Dion Gillard
  * @since 1.1
  */
-public class AssignTest extends TestCase {
+public class AssignTest extends JexlTestCase {
     static JexlEngine JEXL = new JexlEngine();
     static {
         JEXL.setSilent(false);
@@ -178,9 +176,5 @@
         o = jc.getVars().get("x.y.z");
         assertEquals("Should be bar", "bar", o);
     }
-    
-    public static void main(String[] args) throws Exception {
-        new AssignTest("debug").testUtil();
-        //new AssignTest("debug").testArray();
-    }
+
 }
\ No newline at end of file

Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/BitwiseOperatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/BitwiseOperatorTest.java?rev=799781&r1=799780&r2=799781&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/BitwiseOperatorTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/BitwiseOperatorTest.java Sat Aug  1 00:46:50 2009
@@ -17,14 +17,13 @@
 
 package org.apache.commons.jexl;
 
-import junit.framework.TestCase;
 
 /**
  * Tests for the bitwise operators.
  * @author Dion Gillard
  * @since 1.1
  */
-public class BitwiseOperatorTest extends TestCase {
+public class BitwiseOperatorTest extends JexlTestCase {
 
     /**
      * Create the named test.

Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/BlockTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/BlockTest.java?rev=799781&r1=799780&r2=799781&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/BlockTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/BlockTest.java Sat Aug  1 00:46:50 2009
@@ -16,12 +16,11 @@
  */
 package org.apache.commons.jexl;
 
-import junit.framework.TestCase;
 /**
  * Tests for blocks
  * @since 1.1
  */
-public class BlockTest extends TestCase {
+public class BlockTest extends JexlTestCase {
 
     /**
      * Create the test

Added: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/CacheTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/CacheTest.java?rev=799781&view=auto
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/CacheTest.java (added)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/CacheTest.java Sat Aug  1 00:46:50 2009
@@ -0,0 +1,572 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.jexl;
+
+import java.util.Map;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Verifies cache & tryExecute
+ */
+public class CacheTest extends JexlTestCase {
+    public static Test suite() {
+        return new TestSuite(CacheTest.class);
+    }
+
+    public CacheTest(String testName) {
+        super(testName);
+    }
+    static JexlEngine jexl = new JexlEngine();
+
+    static {
+        jexl.setLenient(false);
+        jexl.setSilent(false);
+    }
+    static int LOOPS = 1024;
+    // A pseudo random mix of accessors
+    static int[] MIX = {
+        0, 0, 3, 3, 4, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 1, 2, 2, 2,
+        3, 3, 3, 4, 4, 4, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 2, 2, 3, 3, 0
+    };
+
+    public static class Cached {
+        public String compute(String arg) {
+            if (arg == null) {
+                arg = "na";
+            }
+            return getClass().getSimpleName() + "@s#" + arg;
+        }
+
+        public String compute(String arg0, String arg1) {
+            if (arg0 == null) {
+                arg0 = "na";
+            }
+            if (arg1 == null) {
+                arg1 = "na";
+            }
+            return getClass().getSimpleName() + "@s#" + arg0 + ",s#" + arg1;
+        }
+
+        public String compute(Integer arg) {
+            return getClass().getSimpleName() + "@i#" + arg;
+        }
+
+        public String compute(float arg) {
+            return getClass().getSimpleName() + "@f#" + arg;
+        }
+
+        public String compute(int arg0, int arg1) {
+            return getClass().getSimpleName() + "@i#" + arg0 + ",i#" + arg1;
+        }
+
+        public String ambiguous(Integer arg0, int arg1) {
+            return getClass().getSimpleName() + "!i#" + arg0 + ",i#" + arg1;
+        }
+
+        public String ambiguous(int arg0, Integer arg1) {
+            return getClass().getSimpleName() + "!i#" + arg0 + ",i#" + arg1;
+        }
+
+        public static String COMPUTE(String arg) {
+            if (arg == null) {
+                arg = "na";
+            }
+            return "CACHED@s#" + arg;
+        }
+
+        public static String COMPUTE(String arg0, String arg1) {
+            if (arg0 == null) {
+                arg0 = "na";
+            }
+            if (arg1 == null) {
+                arg1 = "na";
+            }
+            return "CACHED@s#" + arg0 + ",s#" + arg1;
+        }
+
+        public static String COMPUTE(int arg) {
+            return "CACHED@i#" + arg;
+        }
+
+        public static String COMPUTE(int arg0, int arg1) {
+            return "CACHED@i#" + arg0 + ",i#" + arg1;
+        }
+    }
+
+    public static class Cached0 extends Cached {
+        protected String value = "Cached0:new";
+        protected Boolean flag = Boolean.FALSE;
+
+        public Cached0() {
+        }
+
+        public String getValue() {
+            return value;
+        }
+
+        public void setValue(String arg) {
+            if (arg == null) {
+                arg = "na";
+            }
+            value = "Cached0:" + arg;
+        }
+
+        public void setFlag(boolean b) {
+            flag = b;
+        }
+
+        public boolean isFlag() {
+            return flag;
+        }
+    }
+
+    public static class Cached1 extends Cached0 {
+        @Override
+        public void setValue(String arg) {
+            if (arg == null) {
+                arg = "na";
+            }
+            value = "Cached1:" + arg;
+        }
+    }
+
+    public static class Cached2 extends Cached {
+        boolean flag = false;
+        protected String value;
+
+        public Cached2() {
+            value = "Cached2:new";
+        }
+
+        public Object get(String prop) {
+            if ("value".equals(prop)) {
+                return value;
+            } else if ("flag".equals(prop)) {
+                return flag;
+            }
+            throw new RuntimeException("no such property");
+        }
+
+        public void put(String p, Object v) {
+            if (v == null) {
+                v = "na";
+            }
+            if ("value".equals(p)) {
+                value = getClass().getSimpleName() + ":" + v;
+            } else if ("flag".equals(p)) {
+                flag = Boolean.parseBoolean(v.toString());
+            } else {
+                throw new RuntimeException("no such property");
+            }
+        }
+    }
+
+    public static class Cached3 extends java.util.TreeMap<String, Object> {
+        boolean flag = false;
+
+        public Cached3() {
+            put("value", "Cached3:new");
+            put("flag", "false");
+        }
+
+        @Override
+        public Object get(Object key) {
+            return super.get(key.toString());
+        }
+
+        @Override
+        public Object put(String key, Object arg) {
+            if (arg == null) {
+                arg = "na";
+            }
+            arg = "Cached3:" + arg;
+            return super.put(key, arg);
+        }
+
+        public void setflag(boolean b) {
+            flag = b;
+        }
+
+        public boolean isflag() {
+            return flag;
+        }
+    }
+
+    public static class Cached4 extends java.util.ArrayList<String> {
+        public Cached4() {
+            super.add("Cached4:new");
+            super.add("false");
+        }
+
+        public String getValue() {
+            return super.get(0);
+        }
+
+        public void setValue(String arg) {
+            if (arg == null) {
+                arg = "na";
+            }
+            super.set(0, "Cached4:" + arg);
+        }
+
+        public void setflag(Boolean b) {
+            super.set(1, b.toString());
+        }
+
+        public boolean isflag() {
+            return Boolean.parseBoolean(super.get(1));
+        }
+    }
+
+    static class TestCacheArguments {
+        Cached0 c0 = new Cached0();
+        Cached1 c1 = new Cached1();
+        Cached2 c2 = new Cached2();
+        Cached3 c3 = new Cached3();
+        Cached4 c4 = new Cached4();
+        Object[] ca = {
+            c0, c1, c2, c3, c4
+        };
+        Object value = null;
+    }
+
+    void doAssign(TestCacheArguments x, int loops, boolean cache) throws Exception {
+        if (loops == 0) {
+            loops = MIX.length;
+        }
+        if (cache) {
+            jexl.setCache(32);
+        } else {
+            jexl.setCache(0);
+        }
+        JexlContext jc = JexlHelper.createContext();
+        Map<String, Object> vars = jc.getVars();
+        Expression cacheGetValue = jexl.createExpression("cache.value");
+        Expression cacheSetValue = jexl.createExpression("cache.value = value");
+        Object result;
+
+        for (int l = 0; l < loops; ++l) {
+            int mix = MIX[l % MIX.length];
+
+            vars.put("cache", x.ca[mix]);
+            vars.put("value", x.value);
+            result = cacheSetValue.evaluate(jc);
+            if (x.value == null) {
+                assertNull(cacheSetValue.toString(), result);
+            } else {
+                assertEquals(cacheSetValue.toString(), x.value, result);
+            }
+
+            result = cacheGetValue.evaluate(jc);
+            if (x.value == null) {
+                assertEquals(cacheGetValue.toString(), "Cached" + mix + ":na", result);
+            } else {
+                assertEquals(cacheGetValue.toString(), "Cached" + mix + ":" + x.value, result);
+            }
+
+        }
+    }
+
+    public void testNullAssignNoCache() throws Exception {
+        TestCacheArguments args = new TestCacheArguments();
+        doAssign(args, LOOPS, false);
+    }
+
+    public void testNullAssignCache() throws Exception {
+        TestCacheArguments args = new TestCacheArguments();
+        doAssign(args, LOOPS, true);
+    }
+
+    public void testAssignNoCache() throws Exception {
+        TestCacheArguments args = new TestCacheArguments();
+        args.value = "foo";
+        doAssign(args, LOOPS, false);
+    }
+
+    public void testAssignCache() throws Exception {
+        TestCacheArguments args = new TestCacheArguments();
+        args.value = "foo";
+        doAssign(args, LOOPS, true);
+    }
+
+    void doAssignBoolean(TestCacheArguments x, int loops, boolean cache) throws Exception {
+        if (loops == 0) {
+            loops = MIX.length;
+        }
+        if (cache) {
+            jexl.setCache(32);
+        } else {
+            jexl.setCache(0);
+        }
+        JexlContext jc = JexlHelper.createContext();
+        Map<String, Object> vars = jc.getVars();
+        Expression cacheGetValue = jexl.createExpression("cache.flag");
+        Expression cacheSetValue = jexl.createExpression("cache.flag = value");
+        Object result;
+
+        for (int l = 0; l < loops; ++l) {
+            int mix = MIX[l % MIX.length];
+
+            vars.put("cache", x.ca[mix]);
+            vars.put("value", x.value);
+            result = cacheSetValue.evaluate(jc);
+            assertEquals(cacheSetValue.toString(), x.value, result);
+
+            result = cacheGetValue.evaluate(jc);
+            assertEquals(cacheGetValue.toString(), x.value, result);
+
+        }
+    }
+
+    public void testAssignBooleanNoCache() throws Exception {
+        TestCacheArguments args = new TestCacheArguments();
+        args.value = Boolean.TRUE;
+        doAssignBoolean(args, LOOPS, false);
+    }
+
+    public void testAssignBooleanCache() throws Exception {
+        TestCacheArguments args = new TestCacheArguments();
+        args.value = Boolean.TRUE;
+        doAssignBoolean(args, LOOPS, true);
+    }
+
+    void doAssignList(TestCacheArguments x, int loops, boolean cache) throws Exception {
+        if (loops == 0) {
+            loops = MIX.length;
+        }
+        if (cache) {
+            jexl.setCache(32);
+        } else {
+            jexl.setCache(0);
+        }
+        JexlContext jc = JexlHelper.createContext();
+        Map<String, Object> vars = jc.getVars();
+        Expression cacheGetValue = jexl.createExpression("cache.0");
+        Expression cacheSetValue = jexl.createExpression("cache[0] = value");
+        Object result;
+
+        for (int l = 0; l < loops; ++l) {
+            int mix = MIX[l % MIX.length] % x.ca.length;
+
+            vars.put("cache", x.ca[mix]);
+            vars.put("value", x.value);
+            result = cacheSetValue.evaluate(jc);
+            assertEquals(cacheSetValue.toString(), x.value, result);
+
+            result = cacheGetValue.evaluate(jc);
+            assertEquals(cacheGetValue.toString(), x.value, result);
+
+        }
+    }
+
+    public void testAssignListNoCache() throws Exception {
+        TestCacheArguments args = new TestCacheArguments();
+        args.value = "foo";
+        java.util.ArrayList<String> c1 = new java.util.ArrayList<String>(2);
+        c1.add("foo");
+        c1.add("bar");
+        args.ca = new Object[]{
+            new String[]{"one", "two"},
+            c1
+        };
+        doAssignList(args, LOOPS, false);
+    }
+
+    public void testAssignListCache() throws Exception {
+        TestCacheArguments args = new TestCacheArguments();
+        args.value = "foo";
+        java.util.ArrayList<String> c1 = new java.util.ArrayList<String>(2);
+        c1.add("foo");
+        c1.add("bar");
+        args.ca = new Object[]{
+            new String[]{"one", "two"},
+            c1
+        };
+        doAssignList(args, LOOPS, true);
+    }
+
+    void doCompute(TestCacheArguments x, int loops, boolean cache) throws Exception {
+        if (loops == 0) {
+            loops = MIX.length;
+        }
+        if (cache) {
+            jexl.setCache(32);
+        } else {
+            jexl.setCache(0);
+        }
+        JexlContext jc = JexlHelper.createContext();
+        Map<String, Object> vars = jc.getVars();
+        jexl.setDebug(true);
+        Expression compute2 = jexl.createExpression("cache.compute(a0, a1)");
+        Expression compute1 = jexl.createExpression("cache.compute(a0)");
+        Expression compute1null = jexl.createExpression("cache.compute(a0)");
+        Expression ambiguous = jexl.createExpression("cache.ambiguous(a0, a1)");
+        jexl.setDebug(false);
+        Object result = null;
+        String expected = null;
+        for (int l = 0; l < loops; ++l) {
+            int mix = MIX[l % MIX.length] % x.ca.length;
+
+            vars.put("cache", x.ca[mix]);
+            if (x.value instanceof String) {
+                vars.put("a0", "S0");
+                vars.put("a1", "S1");
+                expected = "Cached" + mix + "@s#S0,s#S1";
+            } else if (x.value instanceof Integer) {
+                vars.put("a0", 7);
+                vars.put("a1", 9);
+                expected = "Cached" + mix + "@i#7,i#9";
+            } else {
+                fail("unexpected value type");
+            }
+            result = compute2.evaluate(jc);
+            assertEquals(compute2.toString(), expected, result);
+
+            if (x.value instanceof Integer) {
+                try {
+                    vars.put("a0", (short) 17);
+                    vars.put("a1", (short) 19);
+                    result = ambiguous.evaluate(jc);
+                    fail("should have thrown an exception");
+                } catch (JexlException xany) {
+                    // throws due to ambiguous exception
+                }
+            }
+
+            if (x.value instanceof String) {
+                vars.put("a0", "X0");
+                expected = "Cached" + mix + "@s#X0";
+            } else if (x.value instanceof Integer) {
+                vars.put("a0", 5);
+                expected = "Cached" + mix + "@i#5";
+            } else {
+                fail("unexpected value type");
+            }
+            result = compute1.evaluate(jc);
+            assertEquals(compute1.toString(), expected, result);
+
+            try {
+                vars.put("a0", null);
+                jexl.setDebug(true);
+                result = compute1null.evaluate(jc);
+                fail("should have thrown an exception");
+            } catch (JexlException xany) {
+                // throws due to ambiguous exception
+                String sany = xany.getMessage();
+                String tname = getClass().getName();
+                if (!sany.startsWith(tname)) {
+                    fail("debug mode should carry caller information, "
+                         + sany +", "
+                         + tname);
+                }
+            }
+            finally {
+                jexl.setDebug(false);
+            }
+        }
+    }
+
+    public void testComputeNoCache() throws Exception {
+        TestCacheArguments args = new TestCacheArguments();
+        args.ca = new Object[]{
+                    args.c0, args.c1, args.c2
+                };
+        args.value = new Integer(2);
+        doCompute(args, LOOPS, false);
+    }
+
+    public void testComputeCache() throws Exception {
+        TestCacheArguments args = new TestCacheArguments();
+        args.ca = new Object[]{
+                    args.c0, args.c1, args.c2
+                };
+        args.value = new Integer(2);
+        doCompute(args, LOOPS, true);
+    }
+
+    void doCOMPUTE(TestCacheArguments x, int loops, boolean cache) throws Exception {
+        if (loops == 0) {
+            loops = MIX.length;
+        }
+        if (cache) {
+            jexl.setCache(32);
+        } else {
+            jexl.setCache(0);
+        }
+        JexlContext jc = JexlHelper.createContext();
+        Map<String, Object> vars = jc.getVars();
+        java.util.Map<String, Object> funcs = new java.util.HashMap<String, Object>();
+        jexl.setFunctions(funcs);
+        Expression compute2 = jexl.createExpression("cached:COMPUTE(a0, a1)");
+        Expression compute1 = jexl.createExpression("cached:COMPUTE(a0)");
+        Object result = null;
+        String expected = null;
+        for (int l = 0; l < loops; ++l) {
+            int mix = MIX[l % MIX.length] % x.ca.length;
+
+            funcs.put("cached", x.ca[mix]);
+            if (x.value instanceof String) {
+                vars.put("a0", "S0");
+                vars.put("a1", "S1");
+                expected = "CACHED@s#S0,s#S1";
+            } else if (x.value instanceof Integer) {
+                vars.put("a0", 7);
+                vars.put("a1", 9);
+                expected = "CACHED@i#7,i#9";
+            } else {
+                fail("unexpected value type");
+            }
+            result = compute2.evaluate(jc);
+            assertEquals(compute2.toString(), expected, result);
+
+            if (x.value instanceof String) {
+                vars.put("a0", "X0");
+                expected = "CACHED@s#X0";
+            } else if (x.value instanceof Integer) {
+                vars.put("a0", 5);
+                expected = "CACHED@i#5";
+            } else {
+                fail("unexpected value type");
+            }
+            result = compute1.evaluate(jc);
+            assertEquals(compute1.toString(), expected, result);
+        }
+    }
+
+    public void testCOMPUTENoCache() throws Exception {
+        TestCacheArguments args = new TestCacheArguments();
+        args.ca = new Object[]{
+            Cached.class, Cached1.class, Cached2.class
+        };
+        args.value = new Integer(2);
+        doCOMPUTE(args, LOOPS, false);
+    }
+    
+    public void testCOMPUTECache() throws Exception {
+        TestCacheArguments args = new TestCacheArguments();
+        args.ca = new Object[]{
+            Cached.class, Cached1.class, Cached2.class
+        };
+        args.value = new Integer(2);
+        doCOMPUTE(args, LOOPS, true);
+    }
+
+    public static void main(String[] args) throws Exception {
+        new CacheTest("debug").runTest("testNew");
+    }
+}

Propchange: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/CacheTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/CacheTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/Foo.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/Foo.java?rev=799781&r1=799780&r2=799781&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/Foo.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/Foo.java Sat Aug  1 00:46:50 2009
@@ -30,6 +30,7 @@
     
     private boolean beenModified = false;
     private String property1 = "some value";
+    public Foo() {}
     
     public String bar()
     {

Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ForEachTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ForEachTest.java?rev=799781&r1=799780&r2=799781&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ForEachTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ForEachTest.java Sat Aug  1 00:46:50 2009
@@ -22,14 +22,13 @@
 import java.util.Map;
 import java.util.StringTokenizer;
 
-import junit.framework.TestCase;
 
 /**
  * Tests for the foreach statement
  * @author Dion Gillard
  * @since 1.1
  */
-public class ForEachTest extends TestCase {
+public class ForEachTest extends JexlTestCase {
 
     /** create a named test */
     public ForEachTest(String name) {
@@ -123,7 +122,4 @@
         assertEquals("Result is not last evaluated expression", "brie", o);
     }
 
-    public static void main(String[] args) throws Exception {
-        new ForEachTest("").testForEachWithEmptyStatement();
-    }
 }
\ No newline at end of file

Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/IfTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/IfTest.java?rev=799781&r1=799780&r2=799781&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/IfTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/IfTest.java Sat Aug  1 00:46:50 2009
@@ -17,7 +17,6 @@
 
 package org.apache.commons.jexl;
 
-import junit.framework.TestCase;
 
 /**
  * Test cases for the if statement.
@@ -25,7 +24,7 @@
  * @author Dion Gillard
  * @since 1.1
  */
-public class IfTest extends TestCase {
+public class IfTest extends JexlTestCase {
 
     public IfTest(String testName) {
         super(testName);

Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/IssuesTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/IssuesTest.java?rev=799781&r1=799780&r2=799781&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/IssuesTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/IssuesTest.java Sat Aug  1 00:46:50 2009
@@ -17,12 +17,11 @@
 
 package org.apache.commons.jexl;
 import java.util.Map;
-import junit.framework.TestCase;
 
 /**
  * Test cases for reported issues
  */
-public class IssuesTest  extends TestCase {
+public class IssuesTest  extends JexlTestCase {
 
     @Override
     public void setUp() throws Exception {
@@ -183,8 +182,5 @@
             }
         }
     }
-    public static void main(String[] args) throws Exception {
-        new IssuesTest().test52base();
-    }
 
 }
\ No newline at end of file

Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/JexlTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/JexlTest.java?rev=799781&r1=799780&r2=799781&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/JexlTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/JexlTest.java Sat Aug  1 00:46:50 2009
@@ -31,7 +31,6 @@
 import java.util.Set;
 
 import junit.framework.Test;
-import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
 import org.apache.commons.jexl.parser.ParseException;
@@ -44,7 +43,7 @@
  *  @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
  *  @version $Id$
  */
-public class JexlTest extends TestCase
+public class JexlTest extends JexlTestCase
 {
     protected static final String METHOD_STRING = "Method string";
     protected static final String GET_METHOD_STRING = "GetMethod string";
@@ -262,6 +261,26 @@
     }
 
     /**
+      *  test the new function e.g constructor invocation
+      */
+    public void testNew() throws Exception {
+        JexlContext jc = JexlHelper.createContext();
+        jc.getVars().put("double", Double.class);
+        jc.getVars().put("foo", "org.apache.commons.jexl.Foo");
+        Expression expr;
+        Object value;
+        expr = ExpressionFactory.createExpression("new(double, 1)");
+        value = expr.evaluate(jc);
+        assertEquals(expr.toString(), new Double(1.0), value);
+        expr = ExpressionFactory.createExpression("new('java.lang.Float', 100)");
+        value = expr.evaluate(jc);
+        assertEquals(expr.toString(), new Float(100.0), value);
+        expr = ExpressionFactory.createExpression("new(foo).quux");
+        value = expr.evaluate(jc);
+        assertEquals(expr.toString(), "Repeat : quux", value);
+    }
+
+    /**
       *  test some simple mathematical calculations
       */
     public void testCalculations()
@@ -694,7 +713,7 @@
         Foo foo = new Foo();
         jc.getVars().put("foo", foo);
         Parser parser = new Parser(new StringReader(";"));
-        parser.parse(new StringReader("aString = 'World';"));
+        parser.parse(new StringReader("aString = 'World';"), null);
         
         assertExpression(jc, "hello = 'world'", "world");
         assertEquals("hello variable not changed", "world", jc.getVars().get("hello"));
@@ -726,6 +745,72 @@
         assertExpression(JexlHelper.createContext(), "myvar == 'Użytkownik'", Boolean.FALSE);
     }
 
+    public static final class Duck {
+        int user = 10;
+        public Integer get(String val) {
+            if ("zero".equals(val))
+                return 0;
+            if ("one".equals(val))
+                return 1;
+            if ("user".equals(val))
+                return user;
+            return -1;
+        }
+        public void put(String val, Object value) {
+            if ("user".equals(val)) {
+                if ("zero".equals(value))
+                    user = 0;
+                else if ("one".equals(value))
+                    user = 1;
+                else
+                    user = value instanceof Integer? (Integer) value : -1;
+            }
+        }
+    }
+
+    public void testDuck() throws Exception {
+        JexlEngine jexl = new JexlEngine();
+        JexlContext jc = JexlHelper.createContext();
+        jc.getVars().put("duck", new Duck());
+        Expression expr;
+        Object result;
+        expr = jexl.createExpression("duck.zero");
+        result = expr.evaluate(jc);
+        assertEquals(expr.toString(), 0, result);
+        expr = jexl.createExpression("duck.one");
+        result = expr.evaluate(jc);
+        assertEquals(expr.toString(), 1, result);
+        expr = jexl.createExpression("duck.user = 20");
+        result = expr.evaluate(jc);
+        assertEquals(expr.toString(), 20, result);
+        expr = jexl.createExpression("duck.user");
+        result = expr.evaluate(jc);
+        assertEquals(expr.toString(), 20, result);
+        expr = jexl.createExpression("duck.user = 'zero'");
+        result = expr.evaluate(jc);
+        expr = jexl.createExpression("duck.user");
+        result = expr.evaluate(jc);
+        assertEquals(expr.toString(), 0, result);
+    }
+
+    public void testArray() throws Exception {
+        int[] array = { 100, 101 , 102 };
+        JexlEngine jexl = new JexlEngine();
+        JexlContext jc = JexlHelper.createContext();
+        jc.getVars().put("array", array);
+        Expression expr;
+        Object result;
+        expr = jexl.createExpression("array.1");
+        result = expr.evaluate(jc);
+        assertEquals(expr.toString(), 101, result);
+        expr = jexl.createExpression("array[1] = 1010");
+        result = expr.evaluate(jc);
+        assertEquals(expr.toString(), 1010, result);
+        expr = jexl.createExpression("array.0");
+        result = expr.evaluate(jc);
+        assertEquals(expr.toString(), 100, result);
+    }
+
     /**
      * Asserts that the given expression returns the given value when applied to the
      * given context
@@ -737,16 +822,8 @@
         assertEquals(expression, expected, actual);
     }
 
-
-    /**
-     *  Helps in debugging the testcases when working with it
-     *
-     */
-    public static void main(String[] args)
-        throws Exception
-    {
-        JexlTest jt = new JexlTest("foo");
-        jt.testEmpty();
+    public static void main(String[] args) throws Exception {
+        new JexlTest("debug").runTest("testNew");
     }
 
 }
\ No newline at end of file

Added: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/JexlTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/JexlTestCase.java?rev=799781&view=auto
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/JexlTestCase.java (added)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/JexlTestCase.java Sat Aug  1 00:46:50 2009
@@ -0,0 +1,60 @@
+/*
+ *  Copyright 2009 henri.
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  under the License.
+ */
+
+package org.apache.commons.jexl;
+import java.lang.reflect.Method;
+import junit.framework.TestCase;
+/**
+ * Implements a runTest method to dynamically invoke a test,
+ * wrapping the call with setUp(), tearDown() calls.
+ * Eases the implementation of main methods to debug.
+ */
+public class JexlTestCase extends TestCase {
+    private static final Class<?>[] noParms = {};
+
+    public JexlTestCase(String name) {
+        super(name);
+    }
+    public JexlTestCase() {
+        super();
+    }
+
+    public void runTest(String name) throws Exception {
+        if ("runTest".equals(name)) {
+            return;
+        }
+        Method method = null;
+        try {
+            method = this.getClass().getDeclaredMethod(name, noParms);
+        }
+        catch(Exception xany) {
+            fail("no such test: " + name);
+            return;
+        }
+        try {
+            this.setUp();
+            method.invoke(this);
+        } finally {
+            this.tearDown();
+        }
+    }
+
+    /*public void testRunTest() throws Exception {
+        new JexlTestCase().runTest("runTest");
+    }*/
+
+}

Propchange: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/JexlTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/JexlTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/MapLiteralTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/MapLiteralTest.java?rev=799781&r1=799780&r2=799781&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/MapLiteralTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/MapLiteralTest.java Sat Aug  1 00:46:50 2009
@@ -20,15 +20,13 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import junit.framework.TestCase;
-
 /**
  * Tests for map literals
  *
  * @author Peter Royal
  * @since 1.2
  */
-public class MapLiteralTest extends TestCase {
+public class MapLiteralTest extends JexlTestCase {
 
     public void testLiteralWithStrings() throws Exception {
         Expression e = ExpressionFactory.createExpression( "[ 'foo' => 'bar' ]" );

Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/MethodTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/MethodTest.java?rev=799781&r1=799780&r2=799781&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/MethodTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/MethodTest.java Sat Aug  1 00:46:50 2009
@@ -18,14 +18,12 @@
 
 import org.apache.commons.jexl.junit.Asserter;
 
-import junit.framework.TestCase;
-
 /**
  * Tests for calling methods on objects
  * 
  * @since 2.0
  */
-public class MethodTest extends TestCase {
+public class MethodTest extends JexlTestCase {
 
     private Asserter asserter;
 
@@ -157,7 +155,7 @@
     }
 
     public static void main(String[] args) throws Exception {
-        new MethodTest().testTopLevelCall();
+        new MethodTest().runTest("testNamespaceCall");
     }
 
 }
\ No newline at end of file

Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ParseFailuresTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ParseFailuresTest.java?rev=799781&r1=799780&r2=799781&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ParseFailuresTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ParseFailuresTest.java Sat Aug  1 00:46:50 2009
@@ -16,8 +16,6 @@
  */
 package org.apache.commons.jexl;
 
-import junit.framework.TestCase;
-
 import org.apache.commons.jexl.parser.ParseException;
 
 /**
@@ -27,7 +25,7 @@
  *
  * @since 1.1
  */
-public class ParseFailuresTest extends TestCase {
+public class ParseFailuresTest extends JexlTestCase {
 
     /**
      * Create the test.

Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ScriptFactoryTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ScriptFactoryTest.java?rev=799781&r1=799780&r2=799781&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ScriptFactoryTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ScriptFactoryTest.java Sat Aug  1 00:46:50 2009
@@ -19,13 +19,12 @@
 import java.io.File;
 import java.net.URL;
 
-import junit.framework.TestCase;
 
 /**
  * Tests for ScriptFactory
  * @since 1.1
  */
-public class ScriptFactoryTest extends TestCase {
+public class ScriptFactoryTest extends JexlTestCase {
     static final String TEST1 = "src/test-scripts/test1.jexl";
     /**
      * Creates a new test case.

Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ScriptTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ScriptTest.java?rev=799781&r1=799780&r2=799781&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ScriptTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ScriptTest.java Sat Aug  1 00:46:50 2009
@@ -19,13 +19,11 @@
 import java.io.File;
 import java.net.URL;
 
-import junit.framework.TestCase;
-
 /**
  * Tests for Script
  * @since 1.1
  */
-public class ScriptTest extends TestCase {
+public class ScriptTest extends JexlTestCase {
     static final String TEST1 =  "src/test-scripts/test1.jexl";
 
     // test class for testScriptUpdatesContext

Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/UnifiedJEXLTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/UnifiedJEXLTest.java?rev=799781&r1=799780&r2=799781&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/UnifiedJEXLTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/UnifiedJEXLTest.java Sat Aug  1 00:46:50 2009
@@ -18,11 +18,10 @@
 import java.util.Map;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import junit.framework.TestCase;
 /**
  * Test cases for the UnifiedEL.
  */
-public class UnifiedJEXLTest extends TestCase {
+public class UnifiedJEXLTest extends JexlTestCase {
     static JexlEngine JEXL = new JexlEngine();
     static {
         JEXL.setLenient(false);

Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/WhileTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/WhileTest.java?rev=799781&r1=799780&r2=799781&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/WhileTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/WhileTest.java Sat Aug  1 00:46:50 2009
@@ -17,13 +17,12 @@
 
 package org.apache.commons.jexl;
 
-import junit.framework.TestCase;
 /**
  * Tests for while statement.
  * @author Dion Gillard
  * @since 1.1
  */
-public class WhileTest extends TestCase {
+public class WhileTest extends JexlTestCase {
 
     public WhileTest(String testName) {
         super(testName);

Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/parser/ParserTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/parser/ParserTest.java?rev=799781&r1=799780&r2=799781&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/parser/ParserTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/parser/ParserTest.java Sat Aug  1 00:46:50 2009
@@ -46,7 +46,7 @@
      {
          Parser parser = new Parser(new StringReader(";"));
 
-         SimpleNode sn = parser.parse(new StringReader("foo = 1;"));
+         SimpleNode sn = parser.parse(new StringReader("foo = 1;"), null);
          assertNotNull("parsed node is null", sn);
      }
 
@@ -55,10 +55,10 @@
     {
         Parser parser = new Parser(new StringReader(";"));
 
-        SimpleNode sn = parser.parse(new StringReader("foo = \"bar\";"));
+        SimpleNode sn = parser.parse(new StringReader("foo = \"bar\";"), null);
         assertNotNull("parsed node is null", sn);
 
-        sn = parser.parse(new StringReader("foo = 'bar';"));
+        sn = parser.parse(new StringReader("foo = 'bar';"), null);
         assertNotNull("parsed node is null", sn);
     }
 

Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/util/introspection/MethodKeyTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/util/introspection/MethodKeyTest.java?rev=799781&r1=799780&r2=799781&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/util/introspection/MethodKeyTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/util/introspection/MethodKeyTest.java Sat Aug  1 00:46:50 2009
@@ -75,15 +75,15 @@
     };
     
     /** from key to string */
-    static java.util.Map<ClassMap.MethodKey, String> byKey;
+    static java.util.Map< MethodKey, String> byKey;
     /** form string to key */
-    static java.util.Map<String, ClassMap.MethodKey> byString;
+    static java.util.Map<String,MethodKey> byString;
     /** the list of keys we generated & test against */
-    static ClassMap.MethodKey[] keyList;
+    static MethodKey[] keyList;
     
     /** Creates & inserts a key into the byKey & byString map */
     static void setUpKey(String name, Class[] parms) {
-        ClassMap.MethodKey key = new ClassMap.MethodKey(name, parms);
+        MethodKey key = new MethodKey(name, parms);
         String str = key.toString();
         byKey.put(key, str);
         byString.put(str, key);
@@ -92,8 +92,8 @@
 
     /** Generate a list of method*(prims*), method(prims*, prims*), method*(prims*,prims*,prims*) */
     static {
-        byKey = new java.util.HashMap<ClassMap.MethodKey, String>();
-        byString = new java.util.HashMap<String, ClassMap.MethodKey>();
+        byKey = new java.util.HashMap< MethodKey, String>();
+        byString = new java.util.HashMap<String,MethodKey>();
         for (int m = 0; m < METHODS.length; ++m) {
             String method = METHODS[m];
             for (int p0 = 0; p0 < PRIMS.length; ++p0) {
@@ -109,7 +109,7 @@
                 }
             }
         }
-        keyList = byKey.keySet().toArray(new ClassMap.MethodKey[byKey.size()]);
+        keyList = byKey.keySet().toArray(new MethodKey[byKey.size()]);
     }
 
     /** Builds a string key */
@@ -124,26 +124,26 @@
     /** Checks that a string key does exist */
     void checkStringKey(String method, Class... params) {
         String key = makeStringKey(method, params);
-        ClassMap.MethodKey out = byString.get(key);
+        MethodKey out = byString.get(key);
         assertTrue(out != null);
     }
         
     /** Builds a method key */
-    ClassMap.MethodKey makeKey(String method, Class... params) {
-        return new ClassMap.MethodKey(method, params);
+    MethodKey makeKey(String method, Class... params) {
+        return new MethodKey(method, params);
     }
     
     /** Checks that a method key exists */
     void checkKey(String method, Class... params) {
-        ClassMap.MethodKey key = makeKey(method, params);
+        MethodKey key = makeKey(method, params);
         String out = byKey.get(key);
         assertTrue(out != null);
     }
     
     public void testObjectKey() throws Exception {
         for(int k = 0; k < keyList.length; ++k) {
-            ClassMap.MethodKey ctl = keyList[k];
-            ClassMap.MethodKey key = makeKey(ctl.getMethod(), ctl.getParameters());
+            MethodKey ctl = keyList[k];
+            MethodKey key = makeKey(ctl.getMethod(), ctl.getParameters());
             String out = byKey.get(key);
             assertTrue(out != null);
             assertTrue(ctl.toString() + " != " + out, ctl.toString().equals(out));
@@ -153,9 +153,9 @@
     
     public void testStringKey() throws Exception {
         for(int k = 0; k < keyList.length; ++k) {
-            ClassMap.MethodKey ctl = keyList[k];
+            MethodKey ctl = keyList[k];
             String key = makeStringKey(ctl.getMethod(), ctl.getParameters());
-            ClassMap.MethodKey out = byString.get(key);
+            MethodKey out = byString.get(key);
             assertTrue(out != null);
             assertTrue(ctl.toString() + " != " + key, ctl.equals(out));
         }
@@ -167,8 +167,8 @@
     public void testPerfKey() throws Exception {
         for(int l = 0; l < LOOP; ++l)
         for(int k = 0; k < keyList.length; ++k) {
-            ClassMap.MethodKey ctl = keyList[k];
-            ClassMap.MethodKey key = makeKey(ctl.getMethod(), ctl.getParameters());
+            MethodKey ctl = keyList[k];
+            MethodKey key = makeKey(ctl.getMethod(), ctl.getParameters());
             String out = byKey.get(key);
             assertTrue(out != null);
         }
@@ -177,9 +177,9 @@
     public void testPerfString() throws Exception {
         for(int l = 0; l < LOOP; ++l)
         for(int k = 0; k < keyList.length; ++k) {
-            ClassMap.MethodKey ctl = keyList[k];
+            MethodKey ctl = keyList[k];
             String key = makeStringKey(ctl.getMethod(), ctl.getParameters());
-            ClassMap.MethodKey out = byString.get(key);
+            MethodKey out = byString.get(key);
             assertTrue(out != null);
         }
     }



Mime
View raw message