01: package org.mvel.tests.bsf;
02:
03: import junit.framework.TestCase;
04: import org.mvel.jsr223.MVELScriptEngineFactory;
05:
06: import javax.script.*;
07: import java.io.StringReader;
08: import java.util.List;
09:
10: /**
11: * @author Richard L. Burton III
12: * @version 1.0
13: */
14: public class CompiledScriptTestCase extends TestCase {
15:
16: ScriptEngineFactory factory;
17:
18: ScriptEngine scriptEngine;
19:
20: protected void setUp() throws Exception {
21: factory = new MVELScriptEngineFactory();
22: scriptEngine = factory.getScriptEngine();
23: }
24:
25: public void testCompileString() throws ScriptException {
26: Compilable compilable = (Compilable) scriptEngine;
27:
28: CompiledScript compiledScript = compilable.compile("[1,2,3]");
29: Object result = compiledScript.eval();
30: assertTrue(result instanceof List);
31: }
32:
33: public void testCompileReader() throws ScriptException {
34: Compilable compilable = (Compilable) scriptEngine;
35:
36: StringReader reader = new StringReader("[1,2,3]");
37: CompiledScript compiledScript = compilable.compile(reader);
38:
39: Object result = compiledScript.eval();
40: assertTrue(result instanceof List);
41: }
42:
43: }
|