org.apache.commons.jexl2
Class JexlTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.commons.jexl2.JexlTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
ArithmeticTest, ArrayAccessTest, ArrayLiteralTest, AsserterTest, AssignTest, BitwiseOperatorTest, BlockTest, CacheTest, ClassCreatorTest, DiscoveryTest, ForEachTest, IfTest, IssuesTest, JexlTest, MapLiteralTest, MethodTest, ParseFailuresTest, PublicFieldsTest, SandboxTest, ScriptCallableTest, ScriptTest, UnifiedJEXLTest, VarTest, WhileTest

public class JexlTestCase
extends junit.framework.TestCase

Implements runTest methods to dynamically instantiate and invoke a test, wrapping the call with setUp(), tearDown() calls. Eases the implementation of main methods to debug.


Field Summary
protected  JexlEngine JEXL
          A default Jexl engine instance.
 
Constructor Summary
  JexlTestCase()
           
protected JexlTestCase(JexlEngine jexl)
           
  JexlTestCase(String name)
           
protected JexlTestCase(String name, JexlEngine jexl)
           
 
Method Summary
static JexlEngine createEngine(boolean lenient)
           
static JexlEngine createThreadedArithmeticEngine(boolean lenient)
           
static void debuggerCheck(JexlEngine jexl)
          Will force testing the debugger for each derived test class by recreating each expression from the JexlNode in the JexlEngine cache & testing them for equality with the origin.
protected static ArrayList<JexlNode> flatten(JexlNode node)
          Creates a list of all descendants of a script including itself.
protected  String flattenedStr(Script e)
          A helper class to help debug AST problems.
static void main(String[] args)
          Runs a test.
 void runTest(String name)
          Dynamically runs a test method.
static void runTest(String tname, String mname)
          Instantiate and runs a test method; useful for debugging purpose.
protected  void tearDown()
           
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

JEXL

protected final JexlEngine JEXL
A default Jexl engine instance.

Constructor Detail

JexlTestCase

public JexlTestCase(String name)

JexlTestCase

protected JexlTestCase(String name,
                       JexlEngine jexl)

JexlTestCase

public JexlTestCase()

JexlTestCase

protected JexlTestCase(JexlEngine jexl)
Method Detail

tearDown

protected void tearDown()
                 throws Exception
Overrides:
tearDown in class junit.framework.TestCase
Throws:
Exception

createEngine

public static JexlEngine createEngine(boolean lenient)

createThreadedArithmeticEngine

public static JexlEngine createThreadedArithmeticEngine(boolean lenient)

debuggerCheck

public static void debuggerCheck(JexlEngine jexl)
                          throws Exception
Will force testing the debugger for each derived test class by recreating each expression from the JexlNode in the JexlEngine cache & testing them for equality with the origin.

Throws:
Exception

flatten

protected static ArrayList<JexlNode> flatten(JexlNode node)
Creates a list of all descendants of a script including itself.

Parameters:
script - the script to flatten
Returns:
the descendants-and-self list

flattenedStr

protected String flattenedStr(Script e)
A helper class to help debug AST problems.

Parameters:
e - the script
Returns:
an indented version of the AST

runTest

public void runTest(String name)
             throws Exception
Dynamically runs a test method.

Parameters:
name - the test method to run
Throws:
Exception - if anything goes wrong

runTest

public static void runTest(String tname,
                           String mname)
                    throws Exception
Instantiate and runs a test method; useful for debugging purpose. For instance: public static void main(String[] args) throws Exception { runTest("BitwiseOperatorTest","testAndVariableNumberCoercion"); }

Parameters:
tname - the test class name
mname - the test class method
Throws:
Exception

main

public static void main(String[] args)
                 throws Exception
Runs a test.

Parameters:
args - where args[0] is the test class name and args[1] the test class method
Throws:
Exception


Copyright © 2001-2011 The Apache Software Foundation. All Rights Reserved.