Author: sebb Date: Thu Mar 26 00:35:12 2009 New Revision: 758484 URL: http://svn.apache.org/viewvc?rev=758484&view=rev Log: Add eval and compile test
Modified: jakarta/bsf/trunk/bsf3/bsf-api/src/test/java/org/apache/bsf/ScriptEngineManagerTest.java Modified: jakarta/bsf/trunk/bsf3/bsf-api/src/test/java/org/apache/bsf/ScriptEngineManagerTest.java URL: http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/bsf-api/src/test/java/org/apache/bsf/ScriptEngineManagerTest.java?rev=758484&r1=758483&r2=758484&view=diff ============================================================================== --- jakarta/bsf/trunk/bsf3/bsf-api/src/test/java/org/apache/bsf/ScriptEngineManagerTest.java (original) +++ jakarta/bsf/trunk/bsf3/bsf-api/src/test/java/org/apache/bsf/ScriptEngineManagerTest.java Thu Mar 26 00:35:12 2009 @@ -20,15 +20,18 @@ import java.util.List; +import javax.script.Compilable; +import javax.script.CompiledScript; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; +import javax.script.ScriptException; import javax.script.SimpleBindings; +import junit.framework.TestCase; + import org.apache.bsf.utils.TestScriptEngine; import org.apache.bsf.utils.TestScriptEngineFactory; -import junit.framework.TestCase; - public class ScriptEngineManagerTest extends TestCase { private ScriptEngineManager mgr = null; @@ -188,13 +191,32 @@ } public void testSetBindings() { - mgr.getBindings(); + assertNotNull(mgr.getBindings()); try { mgr.setBindings(null); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException e) { } - mgr.setBindings(new SimpleBindings()); + final SimpleBindings bindings = new SimpleBindings(); + assertNotSame(bindings, mgr.getBindings()); + mgr.setBindings(bindings); + assertSame(bindings, mgr.getBindings()); + } + + public void testEvalAndCompile() throws ScriptException{ + ScriptEngine se = mgr.getEngineByName("JUnit"); + assertNotNull(se); + se.put("key", "value"); + assertEquals("value",se.eval("key")); + if (se instanceof Compilable){ + Compilable co = (Compilable) se; + CompiledScript cs = co.compile("key"); + assertNotNull(cs); + assertEquals("value",cs.eval()); + assertEquals("value",cs.eval()); + } else { + fail("Expected engine to implement Compilable"); + } } - + } --------------------------------------------------------------------- To unsubscribe, e-mail: bsf-dev-unsubscr...@jakarta.apache.org For additional commands, e-mail: bsf-dev-h...@jakarta.apache.org