package com.waldura.util; import java.util.Date; /** * The test case for the Logger class. * * @see Logger */ public class LoggerTest extends junit.framework.TestCase { /** * Dummy exception error message. */ public static final String DUMMY_EXCEPTION_MESG = "Dummy exception used for TESTING; this is NOT an error"; /** * The logger object being tested. */ private Logger log; public LoggerTest(String testName) { super(testName); } public void testNewInstanceFromClass() { // get a new logger object log = Logger.newInstance( LoggerTest.class ); } public void testNewInstanceFromString() { // get a new logger object log = Logger.newInstance( "MyLoggingCategory" ); } public void testLogDebug() { // get a new logger object log = Logger.newInstance( LoggerTest.class ); Date now = new Date(); log.debug("this is a TEST debugging message"); log.debug( now ); log.debug("this is a TEST debugging message with an exception", new Exception( DUMMY_EXCEPTION_MESG )); } public void testLogInfo() { // get a new logger object log = Logger.newInstance( LoggerTest.class ); Date now = new Date(); log.info("this is a TEST information message"); log.info( now ); log.info("this is a TEST information with an exception", new Exception( DUMMY_EXCEPTION_MESG )); } public void testLogWarning() { // get a new logger object log = Logger.newInstance( LoggerTest.class ); Date now = new Date(); log.warn("this is a TEST warning message"); log.warn( now ); log.warn("this is a TEST warning with an exception", new Exception( DUMMY_EXCEPTION_MESG )); } public void testLogError() { // get a new logger object log = Logger.newInstance( LoggerTest.class ); // log.error("this is a TEST error message"); log.error("this is a TEST error with an exception", new Exception( DUMMY_EXCEPTION_MESG )); } public void testLogFatal() { // get a new logger object log = Logger.newInstance( LoggerTest.class ); // log.fatal("this is a TEST fatal error message"); log.fatal("this is a TEST fatal error with an exception", new Exception( DUMMY_EXCEPTION_MESG )); } }