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