From dfcf03ab415d41a43a89cea819a43032c0cd8b1a Mon Sep 17 00:00:00 2001 From: "Richard A. Sitze" Date: Sat, 19 Oct 2002 17:14:26 +0000 Subject: [PATCH] - Added new LogTest that exercises factory - log statements now show implementation class (helpfull for visual verification that expected logger was found). git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@138925 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/logging/AbstractLogTest.java | 31 ++++++----- .../org/apache/commons/logging/LogTest.java | 55 +++++++++++++++++++ .../org/apache/commons/logging/TestAll.java | 9 +-- 3 files changed, 78 insertions(+), 17 deletions(-) create mode 100644 src/test/org/apache/commons/logging/LogTest.java diff --git a/src/test/org/apache/commons/logging/AbstractLogTest.java b/src/test/org/apache/commons/logging/AbstractLogTest.java index ae600c4..a44b183 100644 --- a/src/test/org/apache/commons/logging/AbstractLogTest.java +++ b/src/test/org/apache/commons/logging/AbstractLogTest.java @@ -86,53 +86,58 @@ public abstract class AbstractLogTest extends TestCase { assertNotNull(log); + log.debug(null); log.debug(null, null); - log.debug("debug statement"); + log.debug(log.getClass().getName() + ": debug statement"); - log.debug("debug statement w/ null exception", new RuntimeException()); + log.debug(log.getClass().getName() + ": debug statement w/ null exception", new RuntimeException()); + log.error(null); log.error(null, null); - log.error("error statement"); + log.error(log.getClass().getName() + ": error statement"); - log.error("error statement w/ null exception", new RuntimeException()); + log.error(log.getClass().getName() + ": error statement w/ null exception", new RuntimeException()); + log.fatal(null); log.fatal(null, null); - log.fatal("fatal statement"); + log.fatal(log.getClass().getName() + ": fatal statement"); - log.fatal("fatal statement w/ null exception", new RuntimeException()); + log.fatal(log.getClass().getName() + ": fatal statement w/ null exception", new RuntimeException()); + log.info(null); log.info(null, null); - log.info("info statement"); + log.info(log.getClass().getName() + ": info statement"); - log.info("info statement w/ null exception", new RuntimeException()); + log.info(log.getClass().getName() + ": info statement w/ null exception", new RuntimeException()); + log.trace(null); log.trace(null, null); - log.trace("trace statement"); + log.trace(log.getClass().getName() + ": trace statement"); + + log.trace(log.getClass().getName() + ": trace statement w/ null exception", new RuntimeException()); - log.trace("trace statement w/ null exception", new RuntimeException()); log.warn(null); log.warn(null, null); - log.warn("warn statement"); - - log.warn("warn statement w/ null exception", new RuntimeException()); + log.warn(log.getClass().getName() + ": warn statement"); + log.warn(log.getClass().getName() + ": warn statement w/ null exception", new RuntimeException()); } } diff --git a/src/test/org/apache/commons/logging/LogTest.java b/src/test/org/apache/commons/logging/LogTest.java new file mode 100644 index 0000000..c015b65 --- /dev/null +++ b/src/test/org/apache/commons/logging/LogTest.java @@ -0,0 +1,55 @@ +package org.apache.commons.logging; + +import org.apache.commons.logging.impl.SimpleLog; +import junit.framework.*; + +/** + * + * + * + * + * + * + */ +public class LogTest extends AbstractLogTest +{ + + /** + * + * + * @param testName + * + */ + public LogTest(String testName) + { + super(testName); + } + + /** + * + * + * + */ + public Log getLogObject() + { + /** + * Pickup whatever is found/configured! + */ + return LogFactory.getLog(this.getClass().getName()); + } + + public static void main(String[] args) + { + String[] testCaseName = { LogTest.class.getName() }; + junit.textui.TestRunner.main(testCaseName); + } + + public static Test suite() { + TestSuite suite = new TestSuite(); + + suite.addTestSuite(LogTest.class); + + return suite; + } + +} diff --git a/src/test/org/apache/commons/logging/TestAll.java b/src/test/org/apache/commons/logging/TestAll.java index a31230f..d889be9 100644 --- a/src/test/org/apache/commons/logging/TestAll.java +++ b/src/test/org/apache/commons/logging/TestAll.java @@ -1,7 +1,7 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/test/org/apache/commons/logging/TestAll.java,v 1.3 2002/10/11 04:53:21 sullis Exp $ - * $Revision: 1.3 $ - * $Date: 2002/10/11 04:53:21 $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/test/org/apache/commons/logging/TestAll.java,v 1.4 2002/10/19 17:14:26 rsitze Exp $ + * $Revision: 1.4 $ + * $Date: 2002/10/19 17:14:26 $ * * ==================================================================== * @@ -74,7 +74,7 @@ import junit.framework.*; * coded by James Strachan.

* * @author Robert Burrell Donkin - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ */ public class TestAll extends TestCase { @@ -88,6 +88,7 @@ public class TestAll extends TestCase { suite.addTest(SimpleLogTest.suite()); suite.addTest(NoOpLogTest.suite()); + suite.addTest(LogTest.suite()); return suite; }