KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > jexl > parser > ParserTest


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 JavaDoc;
8
9 import org.apache.commons.jexl.JexlContext;
10 import org.apache.commons.jexl.JexlHelper;
11
12 /**
13  *
14  */

15 public class ParserTest extends TestCase
16 {
17     public static Test suite()
18     {
19         return new TestSuite(ParserTest.class);
20     }
21
22     public ParserTest(String JavaDoc testName)
23     {
24         super(testName);
25     }
26
27     /**
28       * parse test : see if we can parse a little script
29       */

30      public void testParse1()
31          throws Exception JavaDoc
32      {
33          Parser parser = new Parser(new StringReader JavaDoc(";"));
34
35          SimpleNode sn = parser.parse(new StringReader JavaDoc("foo = 1;"));
36
37          JexlContext jc = JexlHelper.createContext();
38
39          sn.interpret(jc);
40      }
41
42     public void testParse2()
43         throws Exception JavaDoc
44     {
45         Parser parser = new Parser(new StringReader JavaDoc(";"));
46
47         JexlContext jc = JexlHelper.createContext();
48
49         SimpleNode sn = parser.parse(new StringReader JavaDoc("foo = \"bar\";"));
50         sn.interpret(jc);
51         sn = parser.parse(new StringReader JavaDoc("foo = 'bar';"));
52         sn.interpret(jc);
53     }
54
55     public static void main(String JavaDoc[] args)
56         throws Exception JavaDoc
57     {
58         ParserTest pt = new ParserTest("foo");
59
60         pt.testParse1();
61     }
62
63 }
64
Popular Tags