com.nexwerk.log4junit.log4j
Class DefaultJUnitAppender

java.lang.Object
  extended by org.apache.log4j.AppenderSkeleton
      extended by org.apache.log4j.varia.NullAppender
          extended by com.nexwerk.log4junit.log4j.DefaultJUnitAppender
All Implemented Interfaces:
JUnitAppender, org.apache.log4j.Appender, org.apache.log4j.spi.OptionHandler

public class DefaultJUnitAppender
extends org.apache.log4j.varia.NullAppender
implements JUnitAppender

The JUnitAppender will record the messages sent to a standard Log4J LoggingEvent, so that these can be recorded and asserted at a later stage.

Author:
Enrique Comba Riepenhausen Date: Nov 1, 2007 Time: 9:59:41 PM

Field Summary
 
Fields inherited from class org.apache.log4j.AppenderSkeleton
closed, errorHandler, headFilter, layout, name, tailFilter, threshold
 
Constructor Summary
DefaultJUnitAppender()
          Null constructor...
 
Method Summary
 void doAppend(org.apache.log4j.spi.LoggingEvent event)
          Whenever there is a call to the log4j logging methods (debug, info, warn, error or fatal) this method will be called internally if the log level is reached.
 java.lang.String getLogMessages()
          Returns the log messages collected so far.
 boolean logLevelReached()
          Checks if the threshold has been reached.
 void setLogLevelThreshold(org.apache.log4j.Level level)
          Sets the threshold level to check against to see if an error has occured.
 void startRecording()
          Start the log recording process.
 void stopRecording()
          Stop the recording process to be able to start asserting the log without the log being cluttered with more logging information.
 
Methods inherited from class org.apache.log4j.varia.NullAppender
activateOptions, append, close, getInstance, requiresLayout
 
Methods inherited from class org.apache.log4j.AppenderSkeleton
addFilter, clearFilters, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setErrorHandler, setLayout, setName, setThreshold
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.log4j.Appender
addFilter, clearFilters, close, getErrorHandler, getFilter, getLayout, getName, requiresLayout, setErrorHandler, setLayout, setName
 

Constructor Detail

DefaultJUnitAppender

public DefaultJUnitAppender()
Null constructor...

Method Detail

startRecording

public void startRecording()
Start the log recording process.

Specified by:
startRecording in interface JUnitAppender

getLogMessages

public java.lang.String getLogMessages()
Returns the log messages collected so far.

Specified by:
getLogMessages in interface JUnitAppender
Returns:
The log messages.

setLogLevelThreshold

public void setLogLevelThreshold(org.apache.log4j.Level level)
Sets the threshold level to check against to see if an error has occured.

Specified by:
setLogLevelThreshold in interface JUnitAppender
Parameters:
level - The level threshold

logLevelReached

public boolean logLevelReached()
Checks if the threshold has been reached.

Specified by:
logLevelReached in interface JUnitAppender
Returns:
True if the threshold has been reached.

stopRecording

public void stopRecording()
Stop the recording process to be able to start asserting the log without the log being cluttered with more logging information.

Specified by:
stopRecording in interface JUnitAppender

doAppend

public void doAppend(org.apache.log4j.spi.LoggingEvent event)
Whenever there is a call to the log4j logging methods (debug, info, warn, error or fatal) this method will be called internally if the log level is reached.

Specified by:
doAppend in interface org.apache.log4j.Appender
Overrides:
doAppend in class org.apache.log4j.varia.NullAppender
Parameters:
event - The logging even containing the information (i.e. message exceptions, etc).


Copyright © 2007 NexWerk. All Rights Reserved.