org.apache.velocity.test
Class EventHandlingTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.velocity.test.EventHandlingTestCase
All Implemented Interfaces:
junit.framework.Test, EventHandler, MethodExceptionEventHandler, NullSetEventHandler, ReferenceInsertionEventHandler

public class EventHandlingTestCase
extends junit.framework.TestCase
implements ReferenceInsertionEventHandler, NullSetEventHandler, MethodExceptionEventHandler

Tests event handling

Version:
$Id: EventHandlingTestCase.java 191743 2005-06-21 23:22:20Z dlr $
Author:
Geir Magnusson Jr.

Constructor Summary
EventHandlingTestCase()
          Default constructor.
 
Method Summary
 void init(RuntimeServices rs)
           
 void logVelocityMessage(int level, String message)
          handler for LogSystem interface
 Object methodException(Class claz, String method, Exception e)
          Handles exceptions thrown during in-template method access
 Object referenceInsert(String reference, Object value)
          Event handler for when a reference is inserted into the output stream.
 void runTest()
          Runs the test.
 boolean shouldLogOnNullSet(String lhs, String rhs)
          Event handler for when the right hand side of a #set() directive is null, which results in a log message.
static junit.framework.Test suite()
           
 void throwException()
          silly method to throw an exception to test the method invocation exception event handling
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, setName, setUp, tearDown, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EventHandlingTestCase

public EventHandlingTestCase()
Default constructor.

Method Detail

init

public void init(RuntimeServices rs)

suite

public static junit.framework.Test suite()

runTest

public void runTest()
Runs the test.

Overrides:
runTest in class junit.framework.TestCase

throwException

public void throwException()
                    throws Exception
silly method to throw an exception to test the method invocation exception event handling

Throws:
Exception

referenceInsert

public Object referenceInsert(String reference,
                              Object value)
Event handler for when a reference is inserted into the output stream.

Specified by:
referenceInsert in interface ReferenceInsertionEventHandler
Parameters:
reference - Reference from template about to be inserted.
value - Value about to be inserted (after its toString() method is called).
Returns:
Object on which toString() should be called for output.

shouldLogOnNullSet

public boolean shouldLogOnNullSet(String lhs,
                                  String rhs)
Event handler for when the right hand side of a #set() directive is null, which results in a log message. This method gives the application a chance to 'vote' on msg generation

Specified by:
shouldLogOnNullSet in interface NullSetEventHandler
Parameters:
lhs - reference literal of left-hand-side of set statement
rhs - reference literal of right-hand-side of set statement
Returns:
true if log message should be written, false otherwise

methodException

public Object methodException(Class claz,
                              String method,
                              Exception e)
                       throws Exception
Handles exceptions thrown during in-template method access

Specified by:
methodException in interface MethodExceptionEventHandler
Throws:
Exception

logVelocityMessage

public void logVelocityMessage(int level,
                               String message)
handler for LogSystem interface



Copyright © 2002 Apache Software Foundation. All Rights Reserved.