commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r799798 - /commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/scripting/JexlScriptEngineTest.java
Date Sat, 01 Aug 2009 04:02:55 GMT
Author: sebb
Date: Sat Aug  1 04:02:55 2009
New Revision: 799798

URL: http://svn.apache.org/viewvc?rev=799798&view=rev
Log:
Add some scope tests

Modified:
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/scripting/JexlScriptEngineTest.java

Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/scripting/JexlScriptEngineTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/scripting/JexlScriptEngineTest.java?rev=799798&r1=799797&r2=799798&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/scripting/JexlScriptEngineTest.java
(original)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/scripting/JexlScriptEngineTest.java
Sat Aug  1 04:02:55 2009
@@ -49,4 +49,38 @@
         assertEquals(newValue,engine.get("value"));
     }
 
+    public void testEngineNames() throws Exception {
+        ScriptEngine engine;
+        ScriptEngineManager manager = new ScriptEngineManager();
+        assertNotNull("Manager should not be null", manager);
+        engine = manager.getEngineByName("JEXL");
+        assertNotNull("Engine should not be null (JEXL)", engine);        
+        engine = manager.getEngineByName("Jexl");
+        assertNotNull("Engine should not be null (Jexl)", engine);        
+        engine = manager.getEngineByName("jexl");
+        assertNotNull("Engine should not be null (jexl)", engine);        
+    }
+
+    public void testScopes() throws Exception {
+        ScriptEngine engine;
+        ScriptEngineManager manager = new ScriptEngineManager();
+        assertNotNull("Manager should not be null", manager);
+        engine = manager.getEngineByName("JEXL");
+        assertNotNull("Engine should not be null (JEXL)", engine);
+        manager.put("global",Integer.valueOf(1));
+        engine.put("local", Integer.valueOf(10));
+        manager.put("both",Integer.valueOf(7));
+        engine.put("both", Integer.valueOf(7));
+        engine.eval("local=local+1");
+        engine.eval("global=global+1");
+        engine.eval("both=both+1"); // should update engine value only
+        engine.eval("newvar=42;");
+        assertEquals(Long.valueOf(2),manager.get("global"));
+        assertEquals(Long.valueOf(11),engine.get("local"));
+        assertEquals(Integer.valueOf(7),manager.get("both"));
+        assertEquals(Long.valueOf(8),engine.get("both"));
+        assertEquals(Integer.valueOf(42),engine.get("newvar"));
+        assertNull(manager.get("newvar"));
+        // TODO how to delete variables in Jexl?
+    }
 }



Mime
View raw message