junit.log4j
Class LoggedTestCase

java.lang.Object
  |
  +--junit.framework.Assert
        |
        +--junit.framework.TestCase
              |
              +--junit.log4j.LoggedTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
BusinessTestCase, DemoTestCase

public class LoggedTestCase
extends junit.framework.TestCase

Extension of TestCase integrating Log4J.

Created: Fri Nov 02 14:21:45 2001

Version:
$Revision: 1.4 $
Author:
Wolfgang Reissenberger

Field Summary
protected  org.apache.log4j.Category category
           
protected  boolean isLog4jInClasspath
           
 
Constructor Summary
LoggedTestCase()
          Calls LoggedTestCase(null).
LoggedTestCase(java.lang.String name)
          Calls LoggedTestCase(name, log4j.properties).
LoggedTestCase(java.lang.String name, java.lang.String propertyFile)
          Creates a new LoggedTestCase instance.
 
Method Summary
 void debug(java.lang.Object message)
          Redirection to debug() in the testcase category.
 void debug(java.lang.Object message, java.lang.Throwable t)
          Redirection to debug() in the testcase category.
 void error(java.lang.Object message)
          Redirection to error() in the testcase category.
 void error(java.lang.Object message, java.lang.Throwable t)
          Redirection to error() in the testcase category.
 void fatal(java.lang.Object message)
          Redirection to fatal() in the testcase category.
 void fatal(java.lang.Object message, java.lang.Throwable t)
          Redirection to fatal() in the testcase category.
 java.util.Properties getProperties()
          Get the value of properties.
 void info(java.lang.Object message)
          Redirection to info() in the testcase category.
 void info(java.lang.Object message, java.lang.Throwable t)
          Redirection to info() in the testcase category.
 void setProperties(java.util.Properties v)
          Set the value of properties.
protected  void setUp()
          Setup of the test case.
protected  void tearDown()
          Tear down of the test case.
 void warn(java.lang.Object message)
          Redirection to warn() in the testcase category.
 void warn(java.lang.Object message, java.lang.Throwable t)
          Redirection to warn() in the testcase category.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, 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
 

Field Detail

category

protected org.apache.log4j.Category category

isLog4jInClasspath

protected boolean isLog4jInClasspath
Constructor Detail

LoggedTestCase

public LoggedTestCase(java.lang.String name,
                      java.lang.String propertyFile)

Creates a new LoggedTestCase instance. The Log4J properties are read from the file propertyFile from the classpath. If the file does not exist, the default Log4J properties are used.

If Log4J is not in the classpath, all log messages will be written to stdout. This is to make it easy on user who do not want to have to download log4j and put it in their classpath !
Parameters:
name - name of the testcase
propertyFile - file name of the property file for the configuration

LoggedTestCase

public LoggedTestCase(java.lang.String name)
Calls LoggedTestCase(name, log4j.properties).
Parameters:
name - test case name

LoggedTestCase

public LoggedTestCase()
Calls LoggedTestCase(null).
Method Detail

setUp

protected void setUp()
              throws java.lang.Exception
Setup of the test case. Simply writes "Set up started." to the logger with priority INFO.
Overrides:
setUp in class junit.framework.TestCase
Throws:
java.lang.Exception - if an error occurs

tearDown

protected void tearDown()
                 throws java.lang.Exception
Tear down of the test case. Simply writes "Tear down finished." to the logger with priority INFO.
Overrides:
tearDown in class junit.framework.TestCase
Throws:
java.lang.Exception - if an error occurs

debug

public void debug(java.lang.Object message)
Redirection to debug() in the testcase category.
Parameters:
message - the message object to log

debug

public void debug(java.lang.Object message,
                  java.lang.Throwable t)
Redirection to debug() in the testcase category.
Parameters:
message - the message object to log
t - the exception to log, including its stack trace

error

public void error(java.lang.Object message)
Redirection to error() in the testcase category.
Parameters:
message - the message object to log

error

public void error(java.lang.Object message,
                  java.lang.Throwable t)
Redirection to error() in the testcase category.
Parameters:
message - the message object to log
t - the exception to log, including its stack trace

fatal

public void fatal(java.lang.Object message)
Redirection to fatal() in the testcase category.
Parameters:
message - the message object to log

fatal

public void fatal(java.lang.Object message,
                  java.lang.Throwable t)
Redirection to fatal() in the testcase category.
Parameters:
message - the message object to log
t - the exception to log, including its stack trace

info

public void info(java.lang.Object message)
Redirection to info() in the testcase category.
Parameters:
message - the message object to log

info

public void info(java.lang.Object message,
                 java.lang.Throwable t)
Redirection to info() in the testcase category.
Parameters:
message - the message object to log
t - the exception to log, including its stack trace

warn

public void warn(java.lang.Object message)
Redirection to warn() in the testcase category.
Parameters:
message - the message object to log

warn

public void warn(java.lang.Object message,
                 java.lang.Throwable t)
Redirection to warn() in the testcase category.
Parameters:
message - the message object to log
t - the exception to log, including its stack trace

getProperties

public java.util.Properties getProperties()
Get the value of properties.
Returns:
value of properties.

setProperties

public void setProperties(java.util.Properties v)
Set the value of properties.
Parameters:
v - Value to assign to properties.


Copyright © 2000 -- 2003 openfuture.de. All Rights Reserved.