commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r463704 - /jakarta/commons/proper/jexl/trunk/src/test/org/apache/commons/jexl/ScriptTest.java
Date Fri, 13 Oct 2006 15:18:55 GMT
Author: dion
Date: Fri Oct 13 08:18:54 2006
New Revision: 463704

URL: http://svn.apache.org/viewvc?view=rev&rev=463704
Log:
Add test method for ensuring script and expression return same values.
Adapted from email of Pascal LAVAUX.
See http://www.nabble.com/-JEXL--Execution-difference-between-Expression-and-Script-tf2425540.html

Modified:
    jakarta/commons/proper/jexl/trunk/src/test/org/apache/commons/jexl/ScriptTest.java

Modified: jakarta/commons/proper/jexl/trunk/src/test/org/apache/commons/jexl/ScriptTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jexl/trunk/src/test/org/apache/commons/jexl/ScriptTest.java?view=diff&rev=463704&r1=463703&r2=463704
==============================================================================
--- jakarta/commons/proper/jexl/trunk/src/test/org/apache/commons/jexl/ScriptTest.java (original)
+++ jakarta/commons/proper/jexl/trunk/src/test/org/apache/commons/jexl/ScriptTest.java Fri
Oct 13 08:18:54 2006
@@ -26,6 +26,20 @@
  */
 public class ScriptTest extends TestCase {
 
+    // test class for testScriptUpdatesContext
+    // making this class private static will cause the test to fail.
+    // this is due to unusual code in ClassMap.getAccessibleMethods(Class)
+    // that treats non-public classes in a specific way. Why getAccessibleMethods
+    // does this is not known yet.
+    public static class Tester {
+        private String code;
+        public String getCode () { 
+            return code; 
+        }
+        public void setCode(String c) {
+            code = c;
+        }
+    }
     /**
      * Create a new test case.
      * @param name case name
@@ -66,5 +80,22 @@
         Object result = s.execute(jc);
         assertNotNull("No result", result);
         assertEquals("Wrong result", new Long(7), result);
+    }
+    
+    public void testScriptUpdatesContext() throws Exception {
+        String jexlCode = "resultat.setCode('OK')";
+        Expression e = ExpressionFactory.createExpression(jexlCode);
+        Script s = ScriptFactory.createScript(jexlCode);
+
+        Tester resultatJexl = new Tester();
+        JexlContext jc = JexlHelper.createContext();
+        jc.getVars().put("resultat", resultatJexl);
+
+        resultatJexl.setCode("");
+        e.evaluate(jc);
+        assertEquals("OK", resultatJexl.getCode());
+        resultatJexl.setCode("");
+        s.execute(jc);
+        assertEquals("OK", resultatJexl.getCode());
     }
 }



---------------------------------------------------------------------
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