commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hen...@apache.org
Subject svn commit: r832466 - in /commons/proper/jexl/trunk/src: main/java/org/apache/commons/jexl/scripting/JexlScriptEngineFactory.java test/java/org/apache/commons/jexl/scripting/JexlScriptEngineTest.java
Date Tue, 03 Nov 2009 16:12:51 GMT
Author: henrib
Date: Tue Nov  3 16:12:50 2009
New Revision: 832466

URL: http://svn.apache.org/viewvc?rev=832466&view=rev
Log:
Added a test on JexlScriptEngineFactory; fixed small issue on getParameter()

Modified:
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/scripting/JexlScriptEngineFactory.java
    commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl/scripting/JexlScriptEngineTest.java

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/scripting/JexlScriptEngineFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/scripting/JexlScriptEngineFactory.java?rev=832466&r1=832465&r2=832466&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/scripting/JexlScriptEngineFactory.java
(original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/scripting/JexlScriptEngineFactory.java
Tue Nov  3 16:12:50 2009
@@ -108,7 +108,7 @@
             return getNames();
         } else if (key.equals(ScriptEngine.LANGUAGE)) {
             return getLanguageName();
-        } else if(key.equals(ScriptEngine.ENGINE_VERSION)) {
+        } else if(key.equals(ScriptEngine.LANGUAGE_VERSION)) {
             return getLanguageVersion();
         } else if (key.equals("THREADING")) {
             return null;//"MULTITHREADED"; // TODO what is the correct value here?

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl/scripting/JexlScriptEngineTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl/scripting/JexlScriptEngineTest.java?rev=832466&r1=832465&r2=832466&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl/scripting/JexlScriptEngineTest.java
(original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl/scripting/JexlScriptEngineTest.java
Tue Nov  3 16:12:50 2009
@@ -19,6 +19,7 @@
 package org.apache.commons.jexl.scripting;
 
 import java.io.Reader;
+import java.util.Arrays;
 import java.util.Map;
 
 import javax.script.ScriptEngine;
@@ -26,7 +27,27 @@
 import junit.framework.TestCase;
 
 public class JexlScriptEngineTest extends TestCase {
-    
+
+    public void testScriptEngineFactory() throws Exception {
+        JexlScriptEngineFactory factory = new JexlScriptEngineFactory();
+        assertEquals("JEXL Engine", factory.getParameter(ScriptEngine.ENGINE));
+        assertEquals("1.0", factory.getParameter(ScriptEngine.ENGINE_VERSION));
+        assertEquals("JEXL", factory.getParameter(ScriptEngine.LANGUAGE));
+        assertEquals("2.0", factory.getParameter(ScriptEngine.LANGUAGE_VERSION));
+        assertEquals(Arrays.asList("JEXL", "Jexl", "jexl"), factory.getParameter(ScriptEngine.NAME));
+        assertNull(factory.getParameter("THREADING"));
+
+        assertEquals(Arrays.asList("jexl"), factory.getExtensions());
+        assertEquals(Arrays.asList("application/x-jexl"), factory.getMimeTypes());
+
+        assertEquals("42;", factory.getProgram(new String[]{"42"}));
+        assertEquals("str.substring(3,4)", factory.getMethodCallSyntax("str", "substring",
new String[]{"3", "4"}));
+        try {
+            factory.getOutputStatement("foo");
+            fail("getOutputStatement() should have thrown");
+        } catch(Exception xignore) {}
+    }
+
     public void testScripting() throws Exception {
         ScriptEngineManager manager = new ScriptEngineManager();
         assertNotNull("Manager should not be null", manager);



Mime
View raw message