org.apache.velocity.test
Class EventHandlingTestCase

java.lang.Object
  |
  +--junit.framework.Assert
        |
        +--junit.framework.TestCase
              |
              +--org.apache.velocity.test.EventHandlingTestCase
All Implemented Interfaces:
EventHandler, LogSystem, MethodExceptionEventHandler, NullSetEventHandler, ReferenceInsertionEventHandler, junit.framework.Test

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

Tests event handling

Version:
$Id: EventHandlingTestCase.java,v 1.5 2001/08/07 22:20:28 geirm Exp $
Author:
Geir Magnusson Jr.

Field Summary
private  boolean exceptionSwitch
           
private  java.lang.String logString
           
private static java.lang.String NO_REFERENCE_VALUE
           
private static java.lang.String REFERENCE_VALUE
           
 
Fields inherited from class junit.framework.TestCase
fName
 
Fields inherited from interface org.apache.velocity.runtime.log.LogSystem
DEBUG_ID, DEBUG_ON, ERROR_ID, INFO_ID, WARN_ID
 
Constructor Summary
EventHandlingTestCase()
          Default constructor.
 
Method Summary
 void init(RuntimeServices rs)
          init()
 void logVelocityMessage(int level, java.lang.String message)
          handler for LogSystem interface
 java.lang.Object methodException(java.lang.Class claz, java.lang.String method, java.lang.Exception e)
          Handles exceptions thrown during in-template method access
 java.lang.Object referenceInsert(java.lang.String reference, java.lang.Object value)
          Event handler for when a reference is inserted into the output stream.
 void runTest()
          Runs the test.
 boolean shouldLogOnNullSet(java.lang.String lhs, java.lang.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, name, run, run, runBare, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assert, assert, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertNotNull, assertNotNull, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

logString

private java.lang.String logString

exceptionSwitch

private boolean exceptionSwitch

NO_REFERENCE_VALUE

private static java.lang.String NO_REFERENCE_VALUE

REFERENCE_VALUE

private static java.lang.String REFERENCE_VALUE
Constructor Detail

EventHandlingTestCase

public EventHandlingTestCase()
Default constructor.
Method Detail

init

public void init(RuntimeServices rs)
Description copied from interface: LogSystem
init()
Specified by:
init in interface LogSystem

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 java.lang.Exception
silly method to throw an exception to test the method invocation exception event handling

referenceInsert

public java.lang.Object referenceInsert(java.lang.String reference,
                                        java.lang.Object value)
Event handler for when a reference is inserted into the output stream.
Specified by:
referenceInsert in interface ReferenceInsertionEventHandler
Following copied from interface: org.apache.velocity.app.event.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(java.lang.String lhs,
                                  java.lang.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
Following copied from interface: org.apache.velocity.app.event.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 java.lang.Object methodException(java.lang.Class claz,
                                        java.lang.String method,
                                        java.lang.Exception e)
                                 throws java.lang.Exception
Handles exceptions thrown during in-template method access
Specified by:
methodException in interface MethodExceptionEventHandler

logVelocityMessage

public void logVelocityMessage(int level,
                               java.lang.String message)
handler for LogSystem interface
Specified by:
logVelocityMessage in interface LogSystem


Copyright © 2003 Apache Software Foundation. All Rights Reserved.