craigmcc 2003/08/16 14:58:59
Modified: logging/src/java/org/apache/commons/logging/impl
AvalonLogger.java Jdk14Logger.java Log4JLogger.java
LogKitLogger.java
logging/src/test/org/apache/commons/logging/jdk14
CustomConfigTestCase.java
DefaultConfigTestCase.java
logging/src/test/org/apache/commons/logging/log4j
CustomConfigTestCase.java
DefaultConfigTestCase.java
Log:
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.
Revision Changes Path
1.4 +31 -25
jakarta-commons/logging/src/java/org/apache/commons/logging/impl/AvalonLogger.java
Index: AvalonLogger.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/impl/AvalonLogger.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AvalonLogger.java 16 Aug 2003 18:21:50 -0000 1.3
+++ AvalonLogger.java 16 Aug 2003 21:58:59 -0000 1.4
@@ -61,6 +61,7 @@
package org.apache.commons.logging.impl;
+import java.io.Serializable;
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log;
@@ -71,15 +72,17 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Neeme Praks</a>
* @version $Revision$ $Date$
*/
-public class AvalonLogger implements Log {
+public class AvalonLogger implements Log, Serializable {
private static Logger defaultLogger = null;
- private Logger logger = null;
+ private transient Logger logger = null;
+ private String name = null;
/**
* @param logger the avalon logger implementation to delegate to
*/
public AvalonLogger(Logger logger) {
+ this.name = name;
this.logger = logger;
}
@@ -89,13 +92,16 @@
public AvalonLogger(String name) {
if (defaultLogger == null)
throw new NullPointerException("default logger has to be specified if
this constructor is used!");
- this.logger = defaultLogger.getChildLogger(name);
+ this.logger = getLogger();
}
/**
* @return avalon logger implementation
*/
public Logger getLogger() {
+ if (logger == null) {
+ logger = defaultLogger.getChildLogger(name);
+ }
return logger;
}
@@ -110,126 +116,126 @@
* @see org.apache.commons.logging.Log#debug(java.lang.Object,
java.lang.Throwable)
*/
public void debug(Object o, Throwable t) {
- if (this.logger.isDebugEnabled()) this.logger.debug(String.valueOf(o), t);
+ if (getLogger().isDebugEnabled()) getLogger().debug(String.valueOf(o), t);
}
/**
* @see org.apache.commons.logging.Log#debug(java.lang.Object)
*/
public void debug(Object o) {
- if (this.logger.isDebugEnabled()) this.logger.debug(String.valueOf(o));
+ if (getLogger().isDebugEnabled()) getLogger().debug(String.valueOf(o));
}
/**
* @see org.apache.commons.logging.Log#error(java.lang.Object,
java.lang.Throwable)
*/
public void error(Object o, Throwable t) {
- if (this.logger.isErrorEnabled()) this.logger.error(String.valueOf(o), t);
+ if (getLogger().isErrorEnabled()) getLogger().error(String.valueOf(o), t);
}
/**
* @see org.apache.commons.logging.Log#error(java.lang.Object)
*/
public void error(Object o) {
- if (this.logger.isErrorEnabled()) this.logger.error(String.valueOf(o));
+ if (getLogger().isErrorEnabled()) getLogger().error(String.valueOf(o));
}
/**
* @see org.apache.commons.logging.Log#fatal(java.lang.Object,
java.lang.Throwable)
*/
public void fatal(Object o, Throwable t) {
- if (this.logger.isFatalErrorEnabled())
this.logger.fatalError(String.valueOf(o), t);
+ if (getLogger().isFatalErrorEnabled())
getLogger().fatalError(String.valueOf(o), t);
}
/**
* @see org.apache.commons.logging.Log#fatal(java.lang.Object)
*/
public void fatal(Object o) {
- if (this.logger.isFatalErrorEnabled())
this.logger.fatalError(String.valueOf(o));
+ if (getLogger().isFatalErrorEnabled())
getLogger().fatalError(String.valueOf(o));
}
/**
* @see org.apache.commons.logging.Log#info(java.lang.Object,
java.lang.Throwable)
*/
public void info(Object o, Throwable t) {
- if (this.logger.isInfoEnabled()) this.logger.info(String.valueOf(o), t);
+ if (getLogger().isInfoEnabled()) getLogger().info(String.valueOf(o), t);
}
/**
* @see org.apache.commons.logging.Log#info(java.lang.Object)
*/
public void info(Object o) {
- if (this.logger.isInfoEnabled()) this.logger.info(String.valueOf(o));
+ if (getLogger().isInfoEnabled()) getLogger().info(String.valueOf(o));
}
/**
* @see org.apache.commons.logging.Log#isDebugEnabled()
*/
public boolean isDebugEnabled() {
- return this.logger.isDebugEnabled();
+ return getLogger().isDebugEnabled();
}
/**
* @see org.apache.commons.logging.Log#isErrorEnabled()
*/
public boolean isErrorEnabled() {
- return this.logger.isErrorEnabled();
+ return getLogger().isErrorEnabled();
}
/**
* @see org.apache.commons.logging.Log#isFatalEnabled()
*/
public boolean isFatalEnabled() {
- return this.logger.isFatalErrorEnabled();
+ return getLogger().isFatalErrorEnabled();
}
/**
* @see org.apache.commons.logging.Log#isInfoEnabled()
*/
public boolean isInfoEnabled() {
- return this.logger.isInfoEnabled();
+ return getLogger().isInfoEnabled();
}
/**
* @see org.apache.commons.logging.Log#isTraceEnabled()
*/
public boolean isTraceEnabled() {
- return this.logger.isDebugEnabled();
+ return getLogger().isDebugEnabled();
}
/**
* @see org.apache.commons.logging.Log#isWarnEnabled()
*/
public boolean isWarnEnabled() {
- return this.logger.isWarnEnabled();
+ return getLogger().isWarnEnabled();
}
/**
* @see org.apache.commons.logging.Log#trace(java.lang.Object,
java.lang.Throwable)
*/
public void trace(Object o, Throwable t) {
- if (this.logger.isDebugEnabled()) this.logger.debug(String.valueOf(o), t);
+ if (getLogger().isDebugEnabled()) getLogger().debug(String.valueOf(o), t);
}
/**
* @see org.apache.commons.logging.Log#trace(java.lang.Object)
*/
public void trace(Object o) {
- if (this.logger.isDebugEnabled()) this.logger.debug(String.valueOf(o));
+ if (getLogger().isDebugEnabled()) getLogger().debug(String.valueOf(o));
}
/**
* @see org.apache.commons.logging.Log#warn(java.lang.Object,
java.lang.Throwable)
*/
public void warn(Object o, Throwable t) {
- if (this.logger.isWarnEnabled()) this.logger.warn(String.valueOf(o), t);
+ if (getLogger().isWarnEnabled()) getLogger().warn(String.valueOf(o), t);
}
/**
* @see org.apache.commons.logging.Log#warn(java.lang.Object)
*/
public void warn(Object o) {
- if (this.logger.isWarnEnabled()) this.logger.warn(String.valueOf(o));
+ if (getLogger().isWarnEnabled()) getLogger().warn(String.valueOf(o));
}
}
1.7 +28 -14
jakarta-commons/logging/src/java/org/apache/commons/logging/impl/Jdk14Logger.java
Index: Jdk14Logger.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/impl/Jdk14Logger.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Jdk14Logger.java 31 Mar 2003 00:27:08 -0000 1.6
+++ Jdk14Logger.java 16 Aug 2003 21:58:59 -0000 1.7
@@ -63,6 +63,7 @@
package org.apache.commons.logging.impl;
+import java.io.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -80,7 +81,7 @@
* @version $Revision$ $Date$
*/
-public final class Jdk14Logger implements Log {
+public final class Jdk14Logger implements Log, Serializable {
// ----------------------------------------------------------- Constructors
@@ -93,7 +94,8 @@
*/
public Jdk14Logger(String name) {
- logger = Logger.getLogger(name);
+ this.name = name;
+ logger = getLogger();
}
@@ -104,12 +106,20 @@
/**
* The underlying Logger implementation we are using.
*/
- protected Logger logger = null;
+ protected transient Logger logger = null;
+
+
+ /**
+ * The name of the logger we are wrapping.
+ */
+ protected String name = null;
// --------------------------------------------------------- Public Methods
private void log( Level level, String msg, Throwable ex ) {
+
+ Logger logger = getLogger();
if (logger.isLoggable(level)) {
// Hack (?) to get the stack trace.
Throwable dummyException=new Throwable();
@@ -128,6 +138,7 @@
logger.logp( level, cname, method, msg, ex );
}
}
+
}
/**
@@ -182,7 +193,10 @@
* Return the native Logger instance we are using.
*/
public Logger getLogger() {
- return (this.logger);
+ if (logger == null) {
+ logger = Logger.getLogger(name);
+ }
+ return (logger);
}
@@ -206,7 +220,7 @@
* Is debug logging currently enabled?
*/
public boolean isDebugEnabled() {
- return (logger.isLoggable(Level.FINE));
+ return (getLogger().isLoggable(Level.FINE));
}
@@ -214,7 +228,7 @@
* Is error logging currently enabled?
*/
public boolean isErrorEnabled() {
- return (logger.isLoggable(Level.SEVERE));
+ return (getLogger().isLoggable(Level.SEVERE));
}
@@ -222,7 +236,7 @@
* Is fatal logging currently enabled?
*/
public boolean isFatalEnabled() {
- return (logger.isLoggable(Level.SEVERE));
+ return (getLogger().isLoggable(Level.SEVERE));
}
@@ -230,7 +244,7 @@
* Is info logging currently enabled?
*/
public boolean isInfoEnabled() {
- return (logger.isLoggable(Level.INFO));
+ return (getLogger().isLoggable(Level.INFO));
}
@@ -238,7 +252,7 @@
* Is tace logging currently enabled?
*/
public boolean isTraceEnabled() {
- return (logger.isLoggable(Level.FINEST));
+ return (getLogger().isLoggable(Level.FINEST));
}
@@ -246,7 +260,7 @@
* Is warning logging currently enabled?
*/
public boolean isWarnEnabled() {
- return (logger.isLoggable(Level.WARNING));
+ return (getLogger().isLoggable(Level.WARNING));
}
1.5 +35 -26
jakarta-commons/logging/src/java/org/apache/commons/logging/impl/Log4JLogger.java
Index: Log4JLogger.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/impl/Log4JLogger.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Log4JLogger.java 18 Jul 2003 14:14:16 -0000 1.4
+++ Log4JLogger.java 16 Aug 2003 21:58:59 -0000 1.5
@@ -62,6 +62,7 @@
package org.apache.commons.logging.impl;
+import java.io.Serializable;
import org.apache.commons.logging.Log;
import org.apache.log4j.Logger;
import org.apache.log4j.Priority;
@@ -77,7 +78,7 @@
* @author Robert Burrell Donkin
* @version $Id$
*/
-public final class Log4JLogger implements Log {
+public final class Log4JLogger implements Log, Serializable {
// ------------------------------------------------------------- Attributes
@@ -86,7 +87,10 @@
private static final String FQCN = Log4JLogger.class.getName();
/** Log to this logger */
- private Logger logger = null;
+ private transient Logger logger = null;
+
+ /** Logger name */
+ private String name = null;
// ------------------------------------------------------------ Constructor
@@ -99,17 +103,19 @@
* Base constructor
*/
public Log4JLogger(String name) {
- this.logger=Logger.getLogger(name);
+ this.name = name;
+ this.logger = getLogger();
}
/** For use with a log4j factory
*/
public Log4JLogger(Logger logger ) {
+ this.name = logger.getName();
this.logger=logger;
}
- // ---------------------------------------------------------- Implmentation
+ // --------------------------------------------------------- Implementation
/**
@@ -117,7 +123,7 @@
* Currently logs to <code>DEBUG</code> level in Log4J.
*/
public void trace(Object message) {
- logger.log(FQCN, Priority.DEBUG, message, null);
+ getLogger().log(FQCN, Priority.DEBUG, message, null);
}
@@ -126,7 +132,7 @@
* Currently logs to <code>DEBUG</code> level in Log4J.
*/
public void trace(Object message, Throwable t) {
- logger.log(FQCN, Priority.DEBUG, message, t );
+ getLogger().log(FQCN, Priority.DEBUG, message, t );
}
@@ -134,14 +140,14 @@
* Log a message to the Log4j Logger with <code>DEBUG</code> priority.
*/
public void debug(Object message) {
- logger.log(FQCN, Priority.DEBUG, message, null);
+ getLogger().log(FQCN, Priority.DEBUG, message, null);
}
/**
* Log an error to the Log4j Logger with <code>DEBUG</code> priority.
*/
public void debug(Object message, Throwable t) {
- logger.log(FQCN, Priority.DEBUG, message, t );
+ getLogger().log(FQCN, Priority.DEBUG, message, t );
}
@@ -149,7 +155,7 @@
* Log a message to the Log4j Logger with <code>INFO</code> priority.
*/
public void info(Object message) {
- logger.log(FQCN, Priority.INFO, message, null );
+ getLogger().log(FQCN, Priority.INFO, message, null );
}
@@ -157,7 +163,7 @@
* Log an error to the Log4j Logger with <code>INFO</code> priority.
*/
public void info(Object message, Throwable t) {
- logger.log(FQCN, Priority.INFO, message, t );
+ getLogger().log(FQCN, Priority.INFO, message, t );
}
@@ -165,7 +171,7 @@
* Log a message to the Log4j Logger with <code>WARN</code> priority.
*/
public void warn(Object message) {
- logger.log(FQCN, Priority.WARN, message, null );
+ getLogger().log(FQCN, Priority.WARN, message, null );
}
@@ -173,7 +179,7 @@
* Log an error to the Log4j Logger with <code>WARN</code> priority.
*/
public void warn(Object message, Throwable t) {
- logger.log(FQCN, Priority.WARN, message, t );
+ getLogger().log(FQCN, Priority.WARN, message, t );
}
@@ -181,7 +187,7 @@
* Log a message to the Log4j Logger with <code>ERROR</code> priority.
*/
public void error(Object message) {
- logger.log(FQCN, Priority.ERROR, message, null );
+ getLogger().log(FQCN, Priority.ERROR, message, null );
}
@@ -189,7 +195,7 @@
* Log an error to the Log4j Logger with <code>ERROR</code> priority.
*/
public void error(Object message, Throwable t) {
- logger.log(FQCN, Priority.ERROR, message, t );
+ getLogger().log(FQCN, Priority.ERROR, message, t );
}
@@ -197,7 +203,7 @@
* Log a message to the Log4j Logger with <code>FATAL</code> priority.
*/
public void fatal(Object message) {
- logger.log(FQCN, Priority.FATAL, message, null );
+ getLogger().log(FQCN, Priority.FATAL, message, null );
}
@@ -205,7 +211,7 @@
* Log an error to the Log4j Logger with <code>FATAL</code> priority.
*/
public void fatal(Object message, Throwable t) {
- logger.log(FQCN, Priority.FATAL, message, t );
+ getLogger().log(FQCN, Priority.FATAL, message, t );
}
@@ -213,6 +219,9 @@
* Return the native Logger instance we are using.
*/
public Logger getLogger() {
+ if (logger == null) {
+ logger = Logger.getLogger(name);
+ }
return (this.logger);
}
@@ -221,7 +230,7 @@
* Check whether the Log4j Logger used is enabled for <code>DEBUG</code>
priority.
*/
public boolean isDebugEnabled() {
- return logger.isDebugEnabled();
+ return getLogger().isDebugEnabled();
}
@@ -229,7 +238,7 @@
* Check whether the Log4j Logger used is enabled for <code>ERROR</code>
priority.
*/
public boolean isErrorEnabled() {
- return logger.isEnabledFor(Priority.ERROR);
+ return getLogger().isEnabledFor(Priority.ERROR);
}
@@ -237,7 +246,7 @@
* Check whether the Log4j Logger used is enabled for <code>FATAL</code>
priority.
*/
public boolean isFatalEnabled() {
- return logger.isEnabledFor(Priority.FATAL);
+ return getLogger().isEnabledFor(Priority.FATAL);
}
@@ -245,7 +254,7 @@
* Check whether the Log4j Logger used is enabled for <code>INFO</code>
priority.
*/
public boolean isInfoEnabled() {
- return logger.isInfoEnabled();
+ return getLogger().isInfoEnabled();
}
@@ -254,13 +263,13 @@
* For Log4J, this returns the value of <code>isDebugEnabled()</code>
*/
public boolean isTraceEnabled() {
- return logger.isDebugEnabled();
+ return getLogger().isDebugEnabled();
}
/**
* Check whether the Log4j Logger used is enabled for <code>WARN</code>
priority.
*/
public boolean isWarnEnabled() {
- return logger.isEnabledFor(Priority.WARN);
+ return getLogger().isEnabledFor(Priority.WARN);
}
}
1.4 +44 -23
jakarta-commons/logging/src/java/org/apache/commons/logging/impl/LogKitLogger.java
Index: LogKitLogger.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/impl/LogKitLogger.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LogKitLogger.java 30 Mar 2003 23:42:36 -0000 1.3
+++ LogKitLogger.java 16 Aug 2003 21:58:59 -0000 1.4
@@ -62,6 +62,7 @@
package org.apache.commons.logging.impl;
+import java.io.Serializable;
import org.apache.log.Logger;
import org.apache.log.Hierarchy;
import org.apache.commons.logging.Log;
@@ -81,14 +82,17 @@
* @version $Id$
*/
-public final class LogKitLogger implements Log {
+public final class LogKitLogger implements Log, Serializable {
// ------------------------------------------------------------- Attributes
/** Logging goes to this <code>LogKit</code> logger */
- protected Logger logger = null;
+ protected transient Logger logger = null;
+
+ /** Name of this logger */
+ protected String name = null;
// ------------------------------------------------------------ Constructor
@@ -101,7 +105,24 @@
* @param name log name
*/
public LogKitLogger(String name) {
- logger = Hierarchy.getDefaultHierarchy().getLoggerFor(name);
+ this.name = name;
+ this.logger = getLogger();
+ }
+
+
+ // --------------------------------------------------------- Public Methods
+
+
+ /**
+ * <p>Return the underlying Logger we are using.</p>
+ */
+ public Logger getLogger() {
+
+ if (logger == null) {
+ logger = Hierarchy.getDefaultHierarchy().getLoggerFor(name);
+ }
+ return (logger);
+
}
@@ -129,7 +150,7 @@
*/
public void debug(Object message) {
if (message != null) {
- logger.debug(String.valueOf(message));
+ getLogger().debug(String.valueOf(message));
}
}
@@ -139,7 +160,7 @@
*/
public void debug(Object message, Throwable t) {
if (message != null) {
- logger.debug(String.valueOf(message), t);
+ getLogger().debug(String.valueOf(message), t);
}
}
@@ -149,7 +170,7 @@
*/
public void info(Object message) {
if (message != null) {
- logger.info(String.valueOf(message));
+ getLogger().info(String.valueOf(message));
}
}
@@ -159,7 +180,7 @@
*/
public void info(Object message, Throwable t) {
if (message != null) {
- logger.info(String.valueOf(message), t);
+ getLogger().info(String.valueOf(message), t);
}
}
@@ -169,7 +190,7 @@
*/
public void warn(Object message) {
if (message != null) {
- logger.warn(String.valueOf(message));
+ getLogger().warn(String.valueOf(message));
}
}
@@ -179,7 +200,7 @@
*/
public void warn(Object message, Throwable t) {
if (message != null) {
- logger.warn(String.valueOf(message), t);
+ getLogger().warn(String.valueOf(message), t);
}
}
@@ -189,7 +210,7 @@
*/
public void error(Object message) {
if (message != null) {
- logger.error(String.valueOf(message));
+ getLogger().error(String.valueOf(message));
}
}
@@ -199,7 +220,7 @@
*/
public void error(Object message, Throwable t) {
if (message != null) {
- logger.error(String.valueOf(message), t);
+ getLogger().error(String.valueOf(message), t);
}
}
@@ -209,7 +230,7 @@
*/
public void fatal(Object message) {
if (message != null) {
- logger.fatalError(String.valueOf(message));
+ getLogger().fatalError(String.valueOf(message));
}
}
@@ -219,7 +240,7 @@
*/
public void fatal(Object message, Throwable t) {
if (message != null) {
- logger.fatalError(String.valueOf(message), t);
+ getLogger().fatalError(String.valueOf(message), t);
}
}
@@ -228,7 +249,7 @@
* Check whether the <code>LogKit</code> logger will log messages of priority
<code>DEBUG</code>.
*/
public boolean isDebugEnabled() {
- return logger.isDebugEnabled();
+ return getLogger().isDebugEnabled();
}
@@ -236,7 +257,7 @@
* Check whether the <code>LogKit</code> logger will log messages of priority
<code>ERROR</code>.
*/
public boolean isErrorEnabled() {
- return logger.isErrorEnabled();
+ return getLogger().isErrorEnabled();
}
@@ -244,7 +265,7 @@
* Check whether the <code>LogKit</code> logger will log messages of priority
<code>FATAL_ERROR</code>.
*/
public boolean isFatalEnabled() {
- return logger.isFatalErrorEnabled();
+ return getLogger().isFatalErrorEnabled();
}
@@ -252,7 +273,7 @@
* Check whether the <code>LogKit</code> logger will log messages of priority
<code>INFO</code>.
*/
public boolean isInfoEnabled() {
- return logger.isInfoEnabled();
+ return getLogger().isInfoEnabled();
}
@@ -260,7 +281,7 @@
* Check whether the <code>LogKit</code> logger will log messages of priority
<code>DEBUG</code>.
*/
public boolean isTraceEnabled() {
- return logger.isDebugEnabled();
+ return getLogger().isDebugEnabled();
}
@@ -268,7 +289,7 @@
* Check whether the <code>LogKit</code> logger will log messages of priority
<code>WARN</code>.
*/
public boolean isWarnEnabled() {
- return logger.isWarnEnabled();
+ return getLogger().isWarnEnabled();
}
1.6 +32 -20
jakarta-commons/logging/src/test/org/apache/commons/logging/jdk14/CustomConfigTestCase.java
Index: CustomConfigTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/logging/src/test/org/apache/commons/logging/jdk14/CustomConfigTestCase.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- CustomConfigTestCase.java 18 Jul 2003 14:11:45 -0000 1.5
+++ CustomConfigTestCase.java 16 Aug 2003 21:58:59 -0000 1.6
@@ -206,22 +206,6 @@
}
- // 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,7 +224,35 @@
}
+ // 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
1.5 +49 -16
jakarta-commons/logging/src/test/org/apache/commons/logging/jdk14/DefaultConfigTestCase.java
Index: DefaultConfigTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/logging/src/test/org/apache/commons/logging/jdk14/DefaultConfigTestCase.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultConfigTestCase.java 18 Jul 2003 14:11:45 -0000 1.4
+++ DefaultConfigTestCase.java 16 Aug 2003 21:58:59 -0000 1.5
@@ -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;
@@ -145,18 +150,7 @@
// 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,8 +170,47 @@
}
+ // 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
1.5 +31 -11
jakarta-commons/logging/src/test/org/apache/commons/logging/log4j/CustomConfigTestCase.java
Index: CustomConfigTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/logging/src/test/org/apache/commons/logging/log4j/CustomConfigTestCase.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- CustomConfigTestCase.java 18 Jul 2003 14:11:45 -0000 1.4
+++ CustomConfigTestCase.java 16 Aug 2003 21:58:59 -0000 1.5
@@ -197,13 +197,6 @@
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,7 +210,34 @@
}
+ // 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
1.4 +49 -16
jakarta-commons/logging/src/test/org/apache/commons/logging/log4j/DefaultConfigTestCase.java
Index: DefaultConfigTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/logging/src/test/org/apache/commons/logging/log4j/DefaultConfigTestCase.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultConfigTestCase.java 18 Jul 2003 14:11:45 -0000 1.3
+++ DefaultConfigTestCase.java 16 Aug 2003 21:58:59 -0000 1.4
@@ -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;
@@ -145,18 +150,7 @@
// 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,8 +170,47 @@
}
+ // 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
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]