Add test scenarios where two levels of class loader hierarchies are created -
one exactly like the default configuration of Tomcat 4.1 (with c-l placed inside the webapp) and one where you put c-l in the parent class loader (in place of commons-logging-api.jar) so webapps do not have to. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@138959 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/test/org/apache/commons/logging/jdk14/CustomConfigTestCase.java,v 1.1 2003/03/29 22:04:54 craigmcc Exp $
|
||||
* $Revision: 1.1 $
|
||||
* $Date: 2003/03/29 22:04:54 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/test/org/apache/commons/logging/jdk14/CustomConfigTestCase.java,v 1.2 2003/03/30 02:30:37 craigmcc Exp $
|
||||
* $Revision: 1.2 $
|
||||
* $Date: 2003/03/30 02:30:37 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
@@ -84,7 +84,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
* logger configured per the configuration properties.</p>
|
||||
*
|
||||
* @author Craig R. McClanahan
|
||||
* @version $Revision: 1.1 $ $Date: 2003/03/29 22:04:54 $
|
||||
* @version $Revision: 1.2 $ $Date: 2003/03/30 02:30:37 $
|
||||
*/
|
||||
|
||||
public class CustomConfigTestCase extends DefaultConfigTestCase {
|
||||
@@ -93,6 +93,14 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
|
||||
// ----------------------------------------------------------- Constructors
|
||||
|
||||
|
||||
/**
|
||||
* <p>Construct a new instance of this test case.</p>
|
||||
*/
|
||||
public CustomConfigTestCase() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>Construct a new instance of this test case.</p>
|
||||
*
|
||||
@@ -181,27 +189,20 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
|
||||
// ----------------------------------------------------------- Test Methods
|
||||
|
||||
|
||||
// Test logging message strings with exceptions
|
||||
public void testExceptionMessages() throws Exception {
|
||||
|
||||
logExceptionMessages();
|
||||
checkLogRecords(true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Test logging plain message strings
|
||||
public void testPlainMessages() throws Exception {
|
||||
|
||||
logPlainMessages();
|
||||
Iterator records = handler.records();
|
||||
for (int i = 0; i < testMessages.length; i++) {
|
||||
assertTrue(records.hasNext());
|
||||
LogRecord record = (LogRecord) records.next();
|
||||
assertEquals("LogRecord level",
|
||||
testLevels[i], record.getLevel());
|
||||
assertEquals("LogRecord message",
|
||||
testMessages[i], record.getMessage());
|
||||
assertEquals("LogRecord class",
|
||||
this.getClass().getName(),
|
||||
record.getSourceClassName());
|
||||
assertEquals("LogRecord method",
|
||||
"logPlainMessages",
|
||||
record.getSourceMethodName());
|
||||
}
|
||||
assertTrue(!records.hasNext());
|
||||
handler.flush();
|
||||
checkLogRecords(false);
|
||||
|
||||
}
|
||||
|
||||
@@ -253,6 +254,53 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
|
||||
// -------------------------------------------------------- Support Methods
|
||||
|
||||
|
||||
// Check the recorded messages
|
||||
protected void checkLogRecords(boolean thrown) {
|
||||
Iterator records = handler.records();
|
||||
for (int i = 0; i < testMessages.length; i++) {
|
||||
assertTrue(records.hasNext());
|
||||
LogRecord record = (LogRecord) records.next();
|
||||
assertEquals("LogRecord level",
|
||||
testLevels[i], record.getLevel());
|
||||
assertEquals("LogRecord message",
|
||||
testMessages[i], record.getMessage());
|
||||
assertEquals("LogRecord class",
|
||||
this.getClass().getName(),
|
||||
record.getSourceClassName());
|
||||
if (thrown) {
|
||||
assertEquals("LogRecord method",
|
||||
"logExceptionMessages",
|
||||
record.getSourceMethodName());
|
||||
} else {
|
||||
assertEquals("LogRecord method",
|
||||
"logPlainMessages",
|
||||
record.getSourceMethodName());
|
||||
}
|
||||
if (thrown) {
|
||||
assertNotNull("LogRecord thrown", record.getThrown());
|
||||
assertTrue("LogRecord thrown type",
|
||||
record.getThrown() instanceof IndexOutOfBoundsException);
|
||||
} else {
|
||||
assertNull("LogRecord thrown",
|
||||
record.getThrown());
|
||||
}
|
||||
}
|
||||
assertTrue(!records.hasNext());
|
||||
handler.flush();
|
||||
}
|
||||
|
||||
|
||||
// Log the messages with exceptions
|
||||
protected void logExceptionMessages() {
|
||||
Throwable t = new IndexOutOfBoundsException();
|
||||
log.trace("trace", t); // Should not actually get logged
|
||||
log.debug("debug", t);
|
||||
log.info("info", t);
|
||||
log.warn("warn", t);
|
||||
log.error("error", t);
|
||||
}
|
||||
|
||||
|
||||
// Log the plain messages
|
||||
protected void logPlainMessages() {
|
||||
log.trace("trace"); // Should not actually get logged
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/test/org/apache/commons/logging/jdk14/DefaultConfigTestCase.java,v 1.1 2003/03/29 22:04:54 craigmcc Exp $
|
||||
* $Revision: 1.1 $
|
||||
* $Date: 2003/03/29 22:04:54 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/test/org/apache/commons/logging/jdk14/DefaultConfigTestCase.java,v 1.2 2003/03/30 02:30:37 craigmcc Exp $
|
||||
* $Revision: 1.2 $
|
||||
* $Date: 2003/03/30 02:30:37 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
@@ -76,7 +76,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
* should be automatically configured.</p>
|
||||
*
|
||||
* @author Craig R. McClanahan
|
||||
* @version $Revision: 1.1 $ $Date: 2003/03/29 22:04:54 $
|
||||
* @version $Revision: 1.2 $ $Date: 2003/03/30 02:30:37 $
|
||||
*/
|
||||
|
||||
public class DefaultConfigTestCase extends TestCase {
|
||||
@@ -85,6 +85,14 @@ public class DefaultConfigTestCase extends TestCase {
|
||||
// ----------------------------------------------------------- Constructors
|
||||
|
||||
|
||||
/**
|
||||
* <p>Construct a new instance of this test case.</p>
|
||||
*/
|
||||
public DefaultConfigTestCase() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>Construct a new instance of this test case.</p>
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user