Make the remaining non-deprecated Log implementations also implement
Serializable, and enhance the unit tests for JDK 1.4 an Log4J logging to validate the ability to deserialize and use such instances. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@138991 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.5 2003/07/18 14:11:45 rsitze Exp $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2003/07/18 14:11:45 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/test/org/apache/commons/logging/jdk14/CustomConfigTestCase.java,v 1.6 2003/08/16 21:58:59 craigmcc Exp $
|
||||
* $Revision: 1.6 $
|
||||
* $Date: 2003/08/16 21:58:59 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
@@ -80,7 +80,7 @@ import junit.framework.TestSuite;
|
||||
* logger configured per the configuration properties.</p>
|
||||
*
|
||||
* @author Craig R. McClanahan
|
||||
* @version $Revision: 1.5 $ $Date: 2003/07/18 14:11:45 $
|
||||
* @version $Revision: 1.6 $ $Date: 2003/08/16 21:58:59 $
|
||||
*/
|
||||
|
||||
public class CustomConfigTestCase extends DefaultConfigTestCase {
|
||||
@@ -206,22 +206,6 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
|
||||
}
|
||||
|
||||
|
||||
// Test pristine Log instance
|
||||
public void testPristineLog() {
|
||||
|
||||
super.testPristineLog();
|
||||
|
||||
// Assert which logging levels have been enabled
|
||||
assertTrue(log.isFatalEnabled());
|
||||
assertTrue(log.isErrorEnabled());
|
||||
assertTrue(log.isWarnEnabled());
|
||||
assertTrue(log.isInfoEnabled());
|
||||
assertTrue(log.isDebugEnabled());
|
||||
assertTrue(!log.isTraceEnabled());
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Test pristine Logger instance
|
||||
public void testPristineLogger() {
|
||||
|
||||
@@ -240,9 +224,37 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
|
||||
}
|
||||
|
||||
|
||||
// Test Serializability of Log instance
|
||||
public void testSerializable() throws Exception {
|
||||
|
||||
super.testSerializable();
|
||||
testExceptionMessages();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------- Support Methods
|
||||
|
||||
|
||||
// Check the log instance
|
||||
protected void checkLog() {
|
||||
|
||||
assertNotNull("Log exists", log);
|
||||
assertEquals("Log class",
|
||||
"org.apache.commons.logging.impl.Jdk14Logger",
|
||||
log.getClass().getName());
|
||||
|
||||
// Assert which logging levels have been enabled
|
||||
assertTrue(log.isFatalEnabled());
|
||||
assertTrue(log.isErrorEnabled());
|
||||
assertTrue(log.isWarnEnabled());
|
||||
assertTrue(log.isInfoEnabled());
|
||||
assertTrue(log.isDebugEnabled());
|
||||
assertTrue(!log.isTraceEnabled());
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Check the recorded messages
|
||||
protected void checkLogRecords(boolean thrown) {
|
||||
Iterator records = handler.records();
|
||||
|
||||
@@ -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.4 2003/07/18 14:11:45 rsitze Exp $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2003/07/18 14:11:45 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/test/org/apache/commons/logging/jdk14/DefaultConfigTestCase.java,v 1.5 2003/08/16 21:58:59 craigmcc Exp $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2003/08/16 21:58:59 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
@@ -62,6 +62,11 @@
|
||||
package org.apache.commons.logging.jdk14;
|
||||
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
@@ -76,7 +81,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
* should be automatically configured.</p>
|
||||
*
|
||||
* @author Craig R. McClanahan
|
||||
* @version $Revision: 1.4 $ $Date: 2003/07/18 14:11:45 $
|
||||
* @version $Revision: 1.5 $ $Date: 2003/08/16 21:58:59 $
|
||||
*/
|
||||
|
||||
public class DefaultConfigTestCase extends TestCase {
|
||||
@@ -145,18 +150,7 @@ public class DefaultConfigTestCase extends TestCase {
|
||||
// Test pristine Log instance
|
||||
public void testPristineLog() {
|
||||
|
||||
assertNotNull("Log exists", log);
|
||||
assertEquals("Log class",
|
||||
"org.apache.commons.logging.impl.Jdk14Logger",
|
||||
log.getClass().getName());
|
||||
|
||||
// Can we call level checkers with no exceptions?
|
||||
log.isDebugEnabled();
|
||||
log.isErrorEnabled();
|
||||
log.isFatalEnabled();
|
||||
log.isInfoEnabled();
|
||||
log.isTraceEnabled();
|
||||
log.isWarnEnabled();
|
||||
checkLog();
|
||||
|
||||
}
|
||||
|
||||
@@ -176,10 +170,49 @@ public class DefaultConfigTestCase extends TestCase {
|
||||
}
|
||||
|
||||
|
||||
// Test Serializability of Log instance
|
||||
public void testSerializable() throws Exception {
|
||||
|
||||
// Serialize and deserialize the instance
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oos = new ObjectOutputStream(baos);
|
||||
oos.writeObject(log);
|
||||
oos.close();
|
||||
ByteArrayInputStream bais =
|
||||
new ByteArrayInputStream(baos.toByteArray());
|
||||
ObjectInputStream ois = new ObjectInputStream(bais);
|
||||
log = (Log) ois.readObject();
|
||||
ois.close();
|
||||
|
||||
// Check the characteristics of the resulting object
|
||||
checkLog();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------- Support Methods
|
||||
|
||||
|
||||
|
||||
// Check the log instance
|
||||
protected void checkLog() {
|
||||
|
||||
assertNotNull("Log exists", log);
|
||||
assertEquals("Log class",
|
||||
"org.apache.commons.logging.impl.Jdk14Logger",
|
||||
log.getClass().getName());
|
||||
|
||||
// Can we call level checkers with no exceptions?
|
||||
log.isDebugEnabled();
|
||||
log.isErrorEnabled();
|
||||
log.isFatalEnabled();
|
||||
log.isInfoEnabled();
|
||||
log.isTraceEnabled();
|
||||
log.isWarnEnabled();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Set up factory instance
|
||||
protected void setUpFactory() throws Exception {
|
||||
factory = LogFactory.getFactory();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/test/org/apache/commons/logging/log4j/CustomConfigTestCase.java,v 1.4 2003/07/18 14:11:45 rsitze Exp $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2003/07/18 14:11:45 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/test/org/apache/commons/logging/log4j/CustomConfigTestCase.java,v 1.5 2003/08/16 21:58:59 craigmcc Exp $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2003/08/16 21:58:59 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
@@ -82,7 +82,7 @@ import org.apache.log4j.spi.LoggingEvent;
|
||||
* logger configured per the configuration properties.</p>
|
||||
*
|
||||
* @author Craig R. McClanahan
|
||||
* @version $Revision: 1.4 $ $Date: 2003/07/18 14:11:45 $
|
||||
* @version $Revision: 1.5 $ $Date: 2003/08/16 21:58:59 $
|
||||
*/
|
||||
|
||||
public class CustomConfigTestCase extends DefaultConfigTestCase {
|
||||
@@ -197,13 +197,6 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
|
||||
|
||||
super.testPristineLog();
|
||||
|
||||
// Assert which logging levels have been enabled
|
||||
assertTrue(log.isErrorEnabled());
|
||||
assertTrue(log.isWarnEnabled());
|
||||
assertTrue(log.isInfoEnabled());
|
||||
assertTrue(!log.isDebugEnabled());
|
||||
assertTrue(!log.isTraceEnabled());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -217,9 +210,36 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
|
||||
}
|
||||
|
||||
|
||||
// Test Serializability of Log instance
|
||||
public void testSerializable() throws Exception {
|
||||
|
||||
super.testSerializable();
|
||||
testExceptionMessages();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------- Support Methods
|
||||
|
||||
|
||||
// Check the log instance
|
||||
protected void checkLog() {
|
||||
|
||||
assertNotNull("Log exists", log);
|
||||
assertEquals("Log class",
|
||||
"org.apache.commons.logging.impl.Log4JLogger",
|
||||
log.getClass().getName());
|
||||
|
||||
// Assert which logging levels have been enabled
|
||||
assertTrue(log.isErrorEnabled());
|
||||
assertTrue(log.isWarnEnabled());
|
||||
assertTrue(log.isInfoEnabled());
|
||||
assertTrue(!log.isDebugEnabled());
|
||||
assertTrue(!log.isTraceEnabled());
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Check the recorded messages
|
||||
protected void checkLoggingEvents(boolean thrown) {
|
||||
Iterator events = appender.events();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/test/org/apache/commons/logging/log4j/DefaultConfigTestCase.java,v 1.3 2003/07/18 14:11:45 rsitze Exp $
|
||||
* $Revision: 1.3 $
|
||||
* $Date: 2003/07/18 14:11:45 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/test/org/apache/commons/logging/log4j/DefaultConfigTestCase.java,v 1.4 2003/08/16 21:58:59 craigmcc Exp $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2003/08/16 21:58:59 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
@@ -62,6 +62,11 @@
|
||||
package org.apache.commons.logging.log4j;
|
||||
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
@@ -76,7 +81,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
* should be automatically configured).</p>
|
||||
*
|
||||
* @author Craig R. McClanahan
|
||||
* @version $Revision: 1.3 $ $Date: 2003/07/18 14:11:45 $
|
||||
* @version $Revision: 1.4 $ $Date: 2003/08/16 21:58:59 $
|
||||
*/
|
||||
|
||||
public class DefaultConfigTestCase extends TestCase {
|
||||
@@ -145,18 +150,7 @@ public class DefaultConfigTestCase extends TestCase {
|
||||
// Test pristine Log instance
|
||||
public void testPristineLog() {
|
||||
|
||||
assertNotNull("Log exists", log);
|
||||
assertEquals("Log class",
|
||||
"org.apache.commons.logging.impl.Log4JLogger",
|
||||
log.getClass().getName());
|
||||
|
||||
// Can we call level checkers with no exceptions?
|
||||
log.isDebugEnabled();
|
||||
log.isErrorEnabled();
|
||||
log.isFatalEnabled();
|
||||
log.isInfoEnabled();
|
||||
log.isTraceEnabled();
|
||||
log.isWarnEnabled();
|
||||
checkLog();
|
||||
|
||||
}
|
||||
|
||||
@@ -176,10 +170,49 @@ public class DefaultConfigTestCase extends TestCase {
|
||||
}
|
||||
|
||||
|
||||
// Test Serializability of Log instance
|
||||
public void testSerializable() throws Exception {
|
||||
|
||||
// Serialize and deserialize the instance
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oos = new ObjectOutputStream(baos);
|
||||
oos.writeObject(log);
|
||||
oos.close();
|
||||
ByteArrayInputStream bais =
|
||||
new ByteArrayInputStream(baos.toByteArray());
|
||||
ObjectInputStream ois = new ObjectInputStream(bais);
|
||||
log = (Log) ois.readObject();
|
||||
ois.close();
|
||||
|
||||
// Check the characteristics of the resulting object
|
||||
checkLog();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------- Support Methods
|
||||
|
||||
|
||||
|
||||
// Check the log instance
|
||||
protected void checkLog() {
|
||||
|
||||
assertNotNull("Log exists", log);
|
||||
assertEquals("Log class",
|
||||
"org.apache.commons.logging.impl.Log4JLogger",
|
||||
log.getClass().getName());
|
||||
|
||||
// Can we call level checkers with no exceptions?
|
||||
log.isDebugEnabled();
|
||||
log.isErrorEnabled();
|
||||
log.isFatalEnabled();
|
||||
log.isInfoEnabled();
|
||||
log.isTraceEnabled();
|
||||
log.isWarnEnabled();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Set up factory instance
|
||||
protected void setUpFactory() throws Exception {
|
||||
factory = LogFactory.getFactory();
|
||||
|
||||
Reference in New Issue
Block a user