1   package org.apache.commons.jexl.parser;
2   
3   import junit.framework.TestCase;
4   import junit.framework.TestSuite;
5   import junit.framework.Test;
6   
7   import java.io.StringReader;
8   
9   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  {
18      public static Test suite()
19      {
20          return new TestSuite(ParserTest.class);
21      }
22  
23      public ParserTest(String testName)
24      {
25          super(testName);
26      }
27  
28      /***
29        *  parse test : see if we can parse a little script
30        */
31       public void testParse1()
32           throws Exception
33       {
34           Parser parser = new Parser(new StringReader(";"));
35  
36           SimpleNode sn = parser.parse(new StringReader("foo = 1;"));
37  
38           JexlContext jc = JexlHelper.createContext();
39  
40           sn.interpret(jc);
41       }
42  
43      public void testParse2()
44          throws Exception
45      {
46          Parser parser = new Parser(new StringReader(";"));
47  
48          JexlContext jc = JexlHelper.createContext();
49  
50          SimpleNode sn = parser.parse(new StringReader("foo = \"bar\";"));
51          sn.interpret(jc);
52          sn = parser.parse(new StringReader("foo = 'bar';"));
53          sn.interpret(jc);
54      }
55  
56      public static void main(String[] args)
57          throws Exception
58      {
59          ParserTest pt = new ParserTest("foo");
60  
61          pt.testParse1();
62      }
63  
64  }