01: package org.apache.commons.jexl.parser;
02:
03: import junit.framework.TestCase;
04: import junit.framework.TestSuite;
05: import junit.framework.Test;
06:
07: import java.io.StringReader;
08:
09: import org.apache.commons.jexl.JexlContext;
10: import org.apache.commons.jexl.JexlHelper;
11:
12: /**
13: * @since 1.0
14: *
15: */
16: public class ParserTest extends TestCase {
17: public static Test suite() {
18: return new TestSuite(ParserTest.class);
19: }
20:
21: public ParserTest(String testName) {
22: super (testName);
23: }
24:
25: /**
26: * parse test : see if we can parse a little script
27: */
28: public void testParse1() throws Exception {
29: Parser parser = new Parser(new StringReader(";"));
30:
31: SimpleNode sn = parser.parse(new StringReader("foo = 1;"));
32:
33: JexlContext jc = JexlHelper.createContext();
34:
35: sn.interpret(jc);
36: }
37:
38: public void testParse2() throws Exception {
39: Parser parser = new Parser(new StringReader(";"));
40:
41: JexlContext jc = JexlHelper.createContext();
42:
43: SimpleNode sn = parser
44: .parse(new StringReader("foo = \"bar\";"));
45: sn.interpret(jc);
46: sn = parser.parse(new StringReader("foo = 'bar';"));
47: sn.interpret(jc);
48: }
49:
50: public static void main(String[] args) throws Exception {
51: ParserTest pt = new ParserTest("foo");
52:
53: pt.testParse1();
54: }
55:
56: }
|