commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r159228 [4/6] - in jakarta/commons/proper/logging/branches/DON_QUIXOTE: ./ classic/ classic/src/ classic/src/conf/ classic/src/java/ classic/src/java/org/ classic/src/java/org/apache/ classic/src/java/org/apache/commons/ classic/src/java/org/apache/commons/logging/ classic/src/java/org/apache/commons/logging/impl/ classic/src/media/ classic/src/test/ classic/src/test/org/ classic/src/test/org/apache/ classic/src/test/org/apache/commons/ classic/src/test/org/apache/commons/logging/ classic/src/test/org/apache/commons/logging/avalon/ classic/src/test/org/apache/commons/logging/jdk14/ classic/src/test/org/apache/commons/logging/log4j/ classic/src/test/org/apache/commons/logging/simple/ classic/xdocs/ classic/xdocs/images/ kernel/ kernel/src/ kernel/src/conf/ kernel/src/java/ kernel/src/java/org/ kernel/src/java/org/apache/ kernel/src/java/org/apache/commons/ kernel/src/java/org/apache/commons/logging/ kernel/src/java/org/apache/commons/logging/impl/ kernel/src/media/ kernel/src/test/ kernel/src/test/org/ kernel/src/test/org/apache/ kernel/src/test/org/apache/commons/ kernel/src/test/org/apache/commons/logging/
Date Mon, 28 Mar 2005 10:37:03 GMT
Added: jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/LogTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/LogTest.java?view=auto&rev=159228
==============================================================================
--- jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/LogTest.java (added)
+++ jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/LogTest.java Mon Mar 28 02:36:50 2005
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+ 
+package org.apache.commons.logging;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * 
+ *
+ * 
+ * 
+ * 
+ * 
+ */
+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;
+    }
+    
+}

Added: jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/NoOpLogTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/NoOpLogTest.java?view=auto&rev=159228
==============================================================================
--- jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/NoOpLogTest.java (added)
+++ jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/NoOpLogTest.java Mon Mar 28 02:36:50 2005
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+ 
+package org.apache.commons.logging;
+
+import org.apache.commons.logging.impl.NoOpLog;
+import junit.framework.*;
+
+/**
+ * 
+ *
+ * 
+ * 
+ * 
+ * 
+ */
+public class NoOpLogTest extends AbstractLogTest
+{
+
+	/**
+	 * 
+	 * 
+	 * @param testName
+	 * 
+	 */
+	public NoOpLogTest(String testName)
+	{
+		super(testName);
+	}
+
+	/**
+	 * 
+	 * 
+	 * 
+	 */
+	public Log getLogObject()
+	{
+		return (Log) new NoOpLog(this.getClass().getName());
+	}
+
+	public static void main(String[] args)
+	{
+        String[] testCaseName = { NoOpLogTest.class.getName() };
+        junit.textui.TestRunner.main(testCaseName);	
+	}
+	
+    public static Test suite() {
+        TestSuite suite = new TestSuite();
+        
+        suite.addTestSuite(NoOpLogTest.class);
+        
+        return suite;
+    }
+	
+}

Added: jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/SimpleLogTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/SimpleLogTest.java?view=auto&rev=159228
==============================================================================
--- jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/SimpleLogTest.java (added)
+++ jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/SimpleLogTest.java Mon Mar 28 02:36:50 2005
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+ 
+ package org.apache.commons.logging;
+
+import org.apache.commons.logging.impl.SimpleLog;
+import junit.framework.*;
+
+/**
+ * 
+ *
+ * 
+ * 
+ * 
+ * 
+ */
+public class SimpleLogTest extends AbstractLogTest
+{
+
+	/**
+	 * 
+	 * 
+	 * @param testName
+	 * 
+	 */
+	public SimpleLogTest(String testName)
+	{
+		super(testName);
+	}
+
+	/**
+	 * 
+	 * 
+	 * 
+	 */
+	public Log getLogObject()
+	{
+		return (Log) new SimpleLog(this.getClass().getName());
+	}
+
+	public static void main(String[] args)
+	{
+        String[] testCaseName = { SimpleLogTest.class.getName() };
+        junit.textui.TestRunner.main(testCaseName);	
+    }
+	
+    public static Test suite() {
+        TestSuite suite = new TestSuite();
+        
+        suite.addTestSuite(SimpleLogTest.class);
+        
+        return suite;
+    }
+	
+}

Added: jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/TestAll.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/TestAll.java?view=auto&rev=159228
==============================================================================
--- jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/TestAll.java (added)
+++ jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/TestAll.java Mon Mar 28 02:36:50 2005
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+ 
+ 
+package org.apache.commons.logging;
+
+import junit.framework.*;
+
+
+/**
+  * <p> The build script calls just one <code>TestSuite</code> - this one!
+  * All tests should be written into separate <code>TestSuite</code>'s
+  * and added to this. Don't clutter this class with implementations. </p>
+  *
+  * <p> This class is based on <code>org.apache.commons.betwixt.TestAll</code> 
+  * coded by James Strachan. </p>
+  *
+  * @author Robert Burrell Donkin
+  * @version $Revision: 1.7 $
+ */
+public class TestAll extends TestCase {
+
+    public TestAll(String testName) {
+        super(testName);
+    }
+
+    
+    public static Test suite() {
+        TestSuite suite = new TestSuite();
+        
+        suite.addTest(SimpleLogTest.suite());
+        suite.addTest(NoOpLogTest.suite());
+        suite.addTest(LogTest.suite());
+        
+        return suite;
+    }
+
+    /**
+     * This allows the tests to run as a standalone application.
+     */
+    public static void main(String args[]) {
+        String[] testCaseName = { TestAll.class.getName() };
+        junit.textui.TestRunner.main(testCaseName);
+    }
+}

Added: jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/UserClass.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/UserClass.java?view=auto&rev=159228
==============================================================================
--- jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/UserClass.java (added)
+++ jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/UserClass.java Mon Mar 28 02:36:50 2005
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+ 
+package org.apache.commons.logging;
+
+public class UserClass {
+    
+   
+ 
+    public UserClass() {
+        Log log = LogFactory.getLog(LoadTest.class);
+      }
+    
+}

Added: jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/Wrapper.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/Wrapper.java?view=auto&rev=159228
==============================================================================
--- jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/Wrapper.java (added)
+++ jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/Wrapper.java Mon Mar 28 02:36:50 2005
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+
+package org.apache.commons.logging;
+
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * <p>Wrapper around test cases that need to have a custom class loader
+ * hierarchy assembled.  The wrapper is configured by the following
+ * system properties:</p>
+ * <ul>
+ * <li><strong>wrapper.hierarchy</strong> - Descriptive code describing how
+ *     the class loader hierarchy should be assembled:
+ *     <ul>
+ *     <li><strong>API</strong> - Parent class loader contains
+ *         <code>commons-logging-api.jar</code> and child class loader
+ *         contains <code>commons-logging.jar</code>.  This is like the
+ *         default configuration for Tomcat 4.1.</li>
+ *     <li><strong>FULL</strong> - Parent class loader contains
+ *         <code>commons-logging.jar</code>.  This is what would happen
+ *         if you replaced <code>commons-logging-api.jar</code> with
+ *         <code>commons-logging.jar</code> so that you did not need to
+ *         include the latter with your application.</li>
+ *     </ul>
+ *     The child class loader also unconditionally includes
+ *     <code>commons-logging-tests.jar</code>.</li>
+ * <li><strong>wrapper.junit</strong> - Fully qualified pathname of the
+ *     JUnit JAR file.</li>
+ * <li><strong>wrapper.log4j</strong> - Fully qualified pathname of the
+ *     Log4J JAR file, which will be placed in whichever class loader
+ *     <code>commons-logging.jar</code> is placed in, if specified.</li>
+ * <li><strong>wrapper.target</strong> - Fully qualified pathname of the
+ *     "target" directory created by the build process.  This directory
+ *     must contain the <code>commons-logging.jar</code>,
+ *     <code>commons-logging-api.jar</code>, and
+ *     <code>commons-logging-tests.jar</code> files resulting from the
+ *     execution of the <code>compile.tests</code> target.</li>
+ * <li><strong>wrapper.testcase</strong> - Fully qualified Java class name
+ *     of a TestCase that will ultimately be executed.  This class must
+ *     exist in the <code>commons-logging-tests.jar</code> file.</li>
+ * </ul>
+ *
+ * <p>When executed, the system classpath for the wrapper should include
+ * only the wrapper class itself.</p>
+ *
+ * @author Craig R. McClanahan
+ * @version $Revision: 1.5 $ $Date: 2004-02-28 21:46:46 +0000 (Sat, 28 Feb 2004) $
+ */
+
+public class Wrapper {
+
+
+    public static void main(String args[]) {
+
+        try {
+
+            // Create variables we will need
+            List parentList = new ArrayList();
+            List childList = new ArrayList();
+            URL urls[] = null;
+
+            // Construct URLs for the various JAR files
+            File target = new File(System.getProperty("wrapper.target"));
+            URL commonsLogging =
+                (new File(target, "commons-logging.jar")).toURL();
+            URL commonsLoggingApi =
+                (new File(target, "commons-logging-api.jar")).toURL();
+            URL commonsLoggingKernel =
+                (new File(target, "commons-logging-kernel.jar")).toURL();
+            URL commonsLoggingTests =
+                (new File(target, "commons-logging-tests.jar")).toURL();
+            URL junit =
+                (new File(System.getProperty("wrapper.junit"))).toURL();
+            URL appender = null;
+            URL log4j = null;
+            if (System.getProperty("wrapper.log4j") != null) {
+                log4j =
+                    (new File(System.getProperty("wrapper.log4j"))).toURL();
+                appender =
+                    (new File(target, "commons-logging-appender.jar")).toURL();
+            }
+
+            // Construct class loader repository lists for supported scenarios
+            if ("API".equals(System.getProperty("wrapper.hierarchy"))) {
+                parentList.add(commonsLoggingApi);
+                parentList.add(commonsLoggingKernel);
+                childList.add(commonsLogging);
+                if (log4j != null) {
+                    childList.add(log4j);
+                    childList.add(appender);
+                }
+            } else { // Assumes "FULL"
+                parentList.add(commonsLogging);
+                parentList.add(commonsLoggingKernel);
+                if (log4j != null) {
+                    parentList.add(log4j);
+                    childList.add(appender);
+                }
+            }
+            childList.add(commonsLoggingTests);
+            childList.add(junit);
+
+            // Construt the parent and child class loaders
+            urls = (URL[]) parentList.toArray(new URL[parentList.size()]);
+            ClassLoader parent =
+                new URLClassLoader(urls,
+                                   ClassLoader.getSystemClassLoader());
+            urls = (URL[]) childList.toArray(new URL[childList.size()]);
+            ClassLoader child = new URLClassLoader(urls, parent);
+
+            // Execute the test runner for this TestCase
+            ClassLoader old = Thread.currentThread().getContextClassLoader();
+            Thread.currentThread().setContextClassLoader(child);
+            Class clazz = child.loadClass("junit.textui.TestRunner");
+            String params[] = new String[1];
+            params[0] = System.getProperty("wrapper.testcase");
+            Method method = clazz.getMethod("main",
+                                            new Class[] { params.getClass() });
+            method.invoke(null, new Object[] { params });
+            Thread.currentThread().setContextClassLoader(old);
+
+        } catch (Exception e) {
+
+            System.out.println("Wrapper Exception Occurred:  " + e);
+            e.printStackTrace(System.out);
+            System.exit(1);
+
+        }
+
+    }
+
+
+
+}

Added: jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/avalon/AvalonLoggerTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/avalon/AvalonLoggerTest.java?view=auto&rev=159228
==============================================================================
--- jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/avalon/AvalonLoggerTest.java (added)
+++ jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/avalon/AvalonLoggerTest.java Mon Mar 28 02:36:50 2005
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+package org.apache.commons.logging.avalon;
+
+import org.apache.avalon.framework.logger.ConsoleLogger;
+import org.apache.commons.logging.impl.AvalonLogger;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.AbstractLogTest;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author <a href="mailto:neeme@apache.org">Neeme Praks</a>
+ * @version $Revision: 1.4 $ $Date: 2004-02-28 21:46:46 +0000 (Sat, 28 Feb 2004) $
+ */
+public class AvalonLoggerTest extends AbstractLogTest {
+
+    public static void main(String[] args) {
+        String[] testCaseName = { AvalonLoggerTest.class.getName() };
+        junit.textui.TestRunner.main(testCaseName);	
+    }
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite();
+        suite.addTestSuite(AvalonLoggerTest.class);
+        return suite;
+    }
+
+    public AvalonLoggerTest(String testName) {
+		super(testName);
+	}
+
+    public Log getLogObject() {
+        Log log = new AvalonLogger(new ConsoleLogger());
+		return log;
+	}
+}
\ No newline at end of file

Added: jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/jdk14/CustomConfig.properties
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/jdk14/CustomConfig.properties?view=auto&rev=159228
==============================================================================
--- jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/jdk14/CustomConfig.properties (added)
+++ jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/jdk14/CustomConfig.properties Mon Mar 28 02:36:50 2005
@@ -0,0 +1,24 @@
+# Copyright 2001-2004 The Apache Software Foundation.
+# 
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+# 
+#      http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+# This is the custom configuration properties for the JDK 1.4 logger tests
+# in CustomConfigTestCase.
+
+# Configure the Handler so we can examine the logged messages
+handlers = org.apache.commons.logging.jdk14.TestHandler
+
+# Configre the default logging level to be FINE so we should get
+# everything except trace messages
+.level = FINE

Added: jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/jdk14/CustomConfigTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/jdk14/CustomConfigTestCase.java?view=auto&rev=159228
==============================================================================
--- jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/jdk14/CustomConfigTestCase.java (added)
+++ jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/jdk14/CustomConfigTestCase.java Mon Mar 28 02:36:50 2005
@@ -0,0 +1,302 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+
+package org.apache.commons.logging.jdk14;
+
+
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogManager;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+
+/**
+ * <p>TestCase for JDK 1.4 logging when running on a JDK 1.4 system with
+ * custom configuration, so that JDK 1.4 should be selected and an appropriate
+ * logger configured per the configuration properties.</p>
+ *
+ * @author Craig R. McClanahan
+ * @version $Revision: 1.9 $ $Date: 2004-02-28 21:46:46 +0000 (Sat, 28 Feb 2004) $
+ */
+
+public class CustomConfigTestCase extends DefaultConfigTestCase {
+
+
+    // ----------------------------------------------------------- Constructors
+
+
+    /**
+     * <p>Construct a new instance of this test case.</p>
+     *
+     * @param name Name of the test case
+     */
+    public CustomConfigTestCase(String name) {
+        super(name);
+    }
+
+
+    // ----------------------------------------------------- Instance Variables
+
+
+    /**
+     * <p>The customized <code>Handler</code> we will be using.</p>
+     */
+    protected TestHandler handler = null;
+
+
+    /**
+     * <p>The underlying <code>Handler</code>s we will be using.</p>
+     */
+    protected Handler handlers[] = null;
+
+
+    /**
+     * <p>The underlying <code>Logger</code> we will be using.</p>
+     */
+    protected Logger logger = null;
+
+
+    /**
+     * <p>The underlying <code>LogManager</code> we will be using.</p>
+     */
+    protected LogManager manager = null;
+
+
+    /**
+     * <p>The message levels that should have been logged.</p>
+     */
+    protected Level testLevels[] =
+    { Level.FINE, Level.INFO, Level.WARNING, Level.SEVERE, Level.SEVERE };
+
+
+    /**
+     * <p>The message strings that should have been logged.</p>
+     */
+    protected String testMessages[] =
+    { "debug", "info", "warn", "error", "fatal" };
+
+
+    // ------------------------------------------- JUnit Infrastructure Methods
+
+
+    /**
+     * Set up instance variables required by this test case.
+     */
+    public void setUp() throws Exception {
+        setUpManager
+            ("org/apache/commons/logging/jdk14/CustomConfig.properties");
+        setUpLogger("TestLogger");
+        setUpHandlers();
+        setUpFactory();
+        setUpLog("TestLogger");
+    }
+
+
+    /**
+     * Return the tests included in this test suite.
+     */
+    public static Test suite() {
+        return (new TestSuite(CustomConfigTestCase.class));
+    }
+
+    /**
+     * Tear down instance variables required by this test case.
+     */
+    public void tearDown() {
+        super.tearDown();
+        handlers = null;
+        logger = null;
+        manager = null;
+    }
+
+
+    // ----------------------------------------------------------- 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();
+        checkLogRecords(false);
+
+    }
+
+
+    // Test pristine Handlers instances
+    public void testPristineHandlers() {
+
+        assertNotNull(handlers);
+        assertEquals(1, handlers.length);
+        assertTrue(handlers[0] instanceof TestHandler);
+        assertNotNull(handler);
+
+    }
+
+
+    // Test pristine Logger instance
+    public void testPristineLogger() {
+
+        assertNotNull("Logger exists", logger);
+        assertEquals("Logger name", "TestLogger", logger.getName());
+
+        // Assert which logging levels have been enabled
+        assertTrue(logger.isLoggable(Level.SEVERE));
+        assertTrue(logger.isLoggable(Level.WARNING));
+        assertTrue(logger.isLoggable(Level.INFO));
+        assertTrue(logger.isLoggable(Level.CONFIG));
+        assertTrue(logger.isLoggable(Level.FINE));
+        assertTrue(!logger.isLoggable(Level.FINER));
+        assertTrue(!logger.isLoggable(Level.FINEST));
+
+    }
+
+
+    // 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();
+        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.fatal("fatal", t);
+    }
+
+
+    // Log the plain messages
+    protected void logPlainMessages() {
+        log.trace("trace"); // Should not actually get logged
+        log.debug("debug");
+        log.info("info");
+        log.warn("warn");
+        log.error("error");
+        log.fatal("fatal");
+    }
+
+
+    // Set up handlers instance
+    protected void setUpHandlers() throws Exception {
+        Logger parent = logger;
+        while (parent.getParent() != null) {
+            parent = parent.getParent();
+        }
+        handlers = parent.getHandlers();
+        if ((handlers != null) && (handlers.length == 1) &&
+            (handlers[0] instanceof TestHandler)) {
+            handler = (TestHandler) handlers[0];
+        }
+    }
+
+
+    // Set up logger instance
+    protected void setUpLogger(String name) throws Exception {
+        logger = Logger.getLogger(name);
+    }
+
+
+    // Set up LogManager instance
+    protected void setUpManager(String config) throws Exception {
+        manager = LogManager.getLogManager();
+        InputStream is =
+            this.getClass().getClassLoader().getResourceAsStream(config);
+        manager.readConfiguration(is);
+        is.close();
+    }
+
+
+}

Added: jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/jdk14/DefaultConfigTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/jdk14/DefaultConfigTestCase.java?view=auto&rev=159228
==============================================================================
--- jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/jdk14/DefaultConfigTestCase.java (added)
+++ jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/jdk14/DefaultConfigTestCase.java Mon Mar 28 02:36:50 2005
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+
+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;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+/**
+ * <p>TestCase for JDK 1.4 logging when running on a JDK 1.4 system with
+ * zero configuration, and with Log4J not present (so JDK 1.4 logging
+ * should be automatically configured.</p>
+ *
+ * @author Craig R. McClanahan
+ * @version $Revision: 1.8 $ $Date: 2004-02-28 21:46:46 +0000 (Sat, 28 Feb 2004) $
+ */
+
+public class DefaultConfigTestCase extends TestCase {
+
+
+    // ----------------------------------------------------------- Constructors
+
+
+    /**
+     * <p>Construct a new instance of this test case.</p>
+     *
+     * @param name Name of the test case
+     */
+    public DefaultConfigTestCase(String name) {
+        super(name);
+    }
+
+
+    // ----------------------------------------------------- Instance Variables
+
+
+    /**
+     * <p>The {@link LogFactory} implementation we have selected.</p>
+     */
+    protected LogFactory factory = null;
+
+
+    /**
+     * <p>The {@link Log} implementation we have selected.</p>
+     */
+    protected Log log = null;
+
+
+    // ------------------------------------------- JUnit Infrastructure Methods
+
+
+    /**
+     * Set up instance variables required by this test case.
+     */
+    public void setUp() throws Exception {
+        setUpFactory();
+        setUpLog("TestLogger");
+    }
+
+
+    /**
+     * Return the tests included in this test suite.
+     */
+    public static Test suite() {
+        return (new TestSuite(DefaultConfigTestCase.class));
+    }
+
+    /**
+     * Tear down instance variables required by this test case.
+     */
+    public void tearDown() {
+        log = null;
+        factory = null;
+        LogFactory.releaseAll();
+    }
+
+
+    // ----------------------------------------------------------- Test Methods
+
+
+    // Test pristine Log instance
+    public void testPristineLog() {
+
+        checkLog();
+
+    }
+
+
+    // Test pristine LogFactory instance
+    public void testPristineFactory() {
+
+        assertNotNull("LogFactory exists", factory);
+        assertEquals("LogFactory class",
+                     "org.apache.commons.logging.impl.LogFactoryImpl",
+                     factory.getClass().getName());
+
+        String names[] = factory.getAttributeNames();
+        assertNotNull("Names exists", names);
+        assertEquals("Names empty", 0, names.length);
+
+    }
+
+
+    // 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();
+    }
+
+
+    // Set up log instance
+    protected void setUpLog(String name) throws Exception {
+        log = LogFactory.getLog(name);
+    }
+
+
+}

Added: jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/jdk14/TestHandler.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/jdk14/TestHandler.java?view=auto&rev=159228
==============================================================================
--- jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/jdk14/TestHandler.java (added)
+++ jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/jdk14/TestHandler.java Mon Mar 28 02:36:50 2005
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+package org.apache.commons.logging.jdk14;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Handler;
+import java.util.logging.LogRecord;
+
+
+/**
+ * <p>Test implementation of <code>java.util.logging.Handler</code>.</p>
+ *
+ * @author Craig R. McClanahan
+ * @version $Revision: 1.4 $ $Date: 2004-02-28 21:46:46 +0000 (Sat, 28 Feb 2004) $
+ */
+
+public class TestHandler extends Handler {
+
+
+
+    // ----------------------------------------------------- Instance Variables
+
+
+    // The set of logged records for this handler
+    private List records = new ArrayList();
+
+
+    // --------------------------------------------------------- Public Methods
+
+
+    public Iterator records() {
+        return (records.iterator());
+    }
+
+
+    // -------------------------------------------------------- Handler Methods
+
+
+    public void close() {
+    }
+
+
+    public void flush() {
+        records.clear();
+    }
+
+
+    public void publish(LogRecord record) {
+        records.add(record);
+    }
+
+
+}

Added: jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/log4j/CustomConfig.properties
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/log4j/CustomConfig.properties?view=auto&rev=159228
==============================================================================
--- jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/log4j/CustomConfig.properties (added)
+++ jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/log4j/CustomConfig.properties Mon Mar 28 02:36:50 2005
@@ -0,0 +1,23 @@
+# Copyright 2001-2004 The Apache Software Foundation.
+# 
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+# 
+#      http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+# This is the custom configuration properties for the Log4J logger tests
+# in CustomConfigTestCase.
+
+# Configure the root logger's level and appender
+log4j.rootLogger = INFO, A1
+
+# Configure the default appender
+log4j.appender.A1 = org.apache.commons.logging.log4j.TestAppender

Added: jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/log4j/CustomConfigTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/log4j/CustomConfigTestCase.java?view=auto&rev=159228
==============================================================================
--- jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/log4j/CustomConfigTestCase.java (added)
+++ jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/log4j/CustomConfigTestCase.java Mon Mar 28 02:36:50 2005
@@ -0,0 +1,283 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+
+package org.apache.commons.logging.log4j;
+
+
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Properties;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PropertyConfigurator;
+import org.apache.log4j.spi.LoggingEvent;
+
+
+/**
+ * <p>TestCase for Log4J logging when running on a system with Log4J present,
+ * so that Log4J should be selected and an appropriate
+ * logger configured per the configuration properties.</p>
+ *
+ * @author Craig R. McClanahan
+ * @version $Revision: 1.9 $ $Date: 2004-05-19 21:59:56 +0100 (Wed, 19 May 2004) $
+ */
+
+public class CustomConfigTestCase extends DefaultConfigTestCase {
+
+
+    // ----------------------------------------------------------- Constructors
+
+
+    /**
+     * <p>Construct a new instance of this test case.</p>
+     *
+     * @param name Name of the test case
+     */
+    public CustomConfigTestCase(String name) {
+        super(name);
+    }
+
+
+    // ----------------------------------------------------- Instance Variables
+
+
+    /**
+     * <p>The <code>Appender</code> we are utilizing.</p>
+     */
+    protected TestAppender appender = null;
+
+
+    /**
+     * <p>The <code>Logger</code> we are utilizing.</p>
+     */
+    protected Logger logger = null;
+
+
+    /**
+     * <p>The message levels that should have been logged.</p>
+     */
+    protected Level testLevels[] =
+    { Level.INFO, Level.WARN, Level.ERROR, Level.FATAL };
+
+
+    /**
+     * <p>The message strings that should have been logged.</p>
+     */
+    protected String testMessages[] =
+    { "info", "warn", "error", "fatal" };
+
+
+    // ------------------------------------------- JUnit Infrastructure Methods
+
+
+    /**
+     * Set up instance variables required by this test case.
+     */
+    public void setUp() throws Exception {
+        setUpAppender
+            ("org/apache/commons/logging/log4j/CustomConfig.properties");
+        setUpLogger("TestLogger");
+        setUpFactory();
+        setUpLog("TestLogger");
+    }
+
+
+    /**
+     * Return the tests included in this test suite.
+     */
+    public static Test suite() {
+        return (new TestSuite(CustomConfigTestCase.class));
+    }
+
+    /**
+     * Tear down instance variables required by this test case.
+     */
+    public void tearDown() {
+        super.tearDown();
+        Logger.getRootLogger().removeAppender(appender);
+        appender = null;
+        logger = null;
+    }
+
+
+    // ----------------------------------------------------------- Test Methods
+
+
+    // Test logging message strings with exceptions
+    public void testExceptionMessages() throws Exception {
+
+        logExceptionMessages();
+        checkLoggingEvents(true);
+
+    }
+
+
+    // Test logging plain message strings
+    public void testPlainMessages() throws Exception {
+
+        logPlainMessages();
+        checkLoggingEvents(false);
+
+    }
+
+
+    // Test pristine Appender instance
+    public void testPristineAppender() {
+
+        assertNotNull("Appender exists", appender);
+
+    }
+
+
+    // Test pristine Log instance
+    public void testPristineLog() {
+
+        super.testPristineLog();
+
+    }
+
+
+    // Test pristine Logger instance
+    public void testPristineLogger() {
+
+        assertNotNull("Logger exists", logger);
+        assertEquals("Logger level", Level.INFO, logger.getEffectiveLevel());
+        assertEquals("Logger name", "TestLogger", logger.getName());
+
+    }
+
+
+    // 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();
+        for (int i = 0; i < testMessages.length; i++) {
+            assertTrue("Logged event " + i + " exists",events.hasNext());
+            LoggingEvent event = (LoggingEvent) events.next();
+            assertEquals("LoggingEvent level",
+                         testLevels[i], event.getLevel());
+            assertEquals("LoggingEvent message",
+                         testMessages[i], event.getMessage());
+            /* Does not appear to be logged correctly?
+            assertEquals("LoggingEvent class",
+                         this.getClass().getName(),
+                         event.getLocationInformation().getClassName());
+            */
+            /* Does not appear to be logged correctly?
+            if (thrown) {
+                assertEquals("LoggingEvent method",
+                             "logExceptionMessages",
+                             event.getLocationInformation().getMethodName());
+            } else {
+                assertEquals("LoggingEvent method",
+                             "logPlainMessages",
+                             event.getLocationInformation().getMethodName());
+            }
+            */
+            if (thrown) {
+                assertNotNull("LoggingEvent thrown",
+                              event.getThrowableInformation().getThrowableStrRep());
+                assertTrue("LoggingEvent thrown type",
+                           event.getThrowableInformation()
+                                .getThrowableStrRep()[0]
+                                    .indexOf("IndexOutOfBoundsException")>0);
+            } else {
+                assertNull("LoggingEvent thrown",
+                           event.getThrowableInformation());
+            }
+        }
+        assertTrue(!events.hasNext());
+        appender.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); // Should not actually get logged
+        log.info("info", t);
+        log.warn("warn", t);
+        log.error("error", t);
+        log.fatal("fatal", t);
+    }
+
+
+    // Log the plain messages
+    protected void logPlainMessages() {
+        log.trace("trace"); // Should not actually get logged
+        log.debug("debug"); // Should not actually get logged
+        log.info("info");
+        log.warn("warn");
+        log.error("error");
+        log.fatal("fatal");
+    }
+
+
+    // Set up our custom Appender
+    protected void setUpAppender(String config) throws Exception {
+        Properties props = new Properties();
+        InputStream is =
+            this.getClass().getClassLoader().getResourceAsStream(config);
+        props.load(is);
+        is.close();
+        PropertyConfigurator.configure(props);
+        Enumeration appenders = Logger.getRootLogger().getAllAppenders();
+        appender = (TestAppender) appenders.nextElement();
+    }
+
+
+    // Set up our custom Logger
+    protected void setUpLogger(String name) throws Exception {
+        logger = Logger.getLogger(name);
+    }
+
+
+}

Added: jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/log4j/DefaultConfigTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/log4j/DefaultConfigTestCase.java?view=auto&rev=159228
==============================================================================
--- jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/log4j/DefaultConfigTestCase.java (added)
+++ jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/log4j/DefaultConfigTestCase.java Mon Mar 28 02:36:50 2005
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+
+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;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+/**
+ * <p>TestCase for Log4J logging when running on a system with
+ * zero configuration, and with Log4J present (so Log4J logging
+ * should be automatically configured).</p>
+ *
+ * @author Craig R. McClanahan
+ * @version $Revision: 1.7 $ $Date: 2004-02-28 21:46:46 +0000 (Sat, 28 Feb 2004) $
+ */
+
+public class DefaultConfigTestCase extends TestCase {
+
+
+    // ----------------------------------------------------------- Constructors
+
+
+    /**
+     * <p>Construct a new instance of this test case.</p>
+     *
+     * @param name Name of the test case
+     */
+    public DefaultConfigTestCase(String name) {
+        super(name);
+    }
+
+
+    // ----------------------------------------------------- Instance Variables
+
+
+    /**
+     * <p>The {@link LogFactory} implementation we have selected.</p>
+     */
+    protected LogFactory factory = null;
+
+
+    /**
+     * <p>The {@link Log} implementation we have selected.</p>
+     */
+    protected Log log = null;
+
+
+    // ------------------------------------------- JUnit Infrastructure Methods
+
+
+    /**
+     * Set up instance variables required by this test case.
+     */
+    public void setUp() throws Exception {
+        setUpFactory();
+        setUpLog("TestLogger");
+    }
+
+
+    /**
+     * Return the tests included in this test suite.
+     */
+    public static Test suite() {
+        return (new TestSuite(DefaultConfigTestCase.class));
+    }
+
+    /**
+     * Tear down instance variables required by this test case.
+     */
+    public void tearDown() {
+        log = null;
+        factory = null;
+        LogFactory.releaseAll();
+    }
+
+
+    // ----------------------------------------------------------- Test Methods
+
+
+    // Test pristine Log instance
+    public void testPristineLog() {
+
+        checkLog();
+
+    }
+
+
+    // Test pristine LogFactory instance
+    public void testPristineFactory() {
+
+        assertNotNull("LogFactory exists", factory);
+        assertEquals("LogFactory class",
+                     "org.apache.commons.logging.impl.LogFactoryImpl",
+                     factory.getClass().getName());
+
+        String names[] = factory.getAttributeNames();
+        assertNotNull("Names exists", names);
+        assertEquals("Names empty", 0, names.length);
+
+    }
+
+
+    // 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();
+    }
+
+
+    // Set up log instance
+    protected void setUpLog(String name) throws Exception {
+        log = LogFactory.getLog(name);
+    }
+
+
+}

Added: jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/log4j/TestAppender.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/log4j/TestAppender.java?view=auto&rev=159228
==============================================================================
--- jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/log4j/TestAppender.java (added)
+++ jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/log4j/TestAppender.java Mon Mar 28 02:36:50 2005
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+
+package org.apache.commons.logging.log4j;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.log4j.AppenderSkeleton;
+import org.apache.log4j.spi.LoggingEvent;
+
+
+/**
+ * <p>Test implementation of <code>org.apache.log4j.Appender</code>.</p>
+ *
+ * @author Craig R. McClanahan
+ * @version $Revision: 1.4 $ $Date: 2004-02-28 21:46:46 +0000 (Sat, 28 Feb 2004) $
+ */
+
+public class TestAppender extends AppenderSkeleton {
+
+
+
+    // ----------------------------------------------------- Instance Variables
+
+
+    // The set of logged events for this appender
+    private List events = new ArrayList();
+
+
+    // --------------------------------------------------------- Public Methods
+
+
+    public Iterator events() {
+        return (events.iterator());
+    }
+
+
+    public void flush() {
+        events.clear();
+    }
+
+
+    // ------------------------------------------------------- Appender Methods
+
+
+    protected void append(LoggingEvent event) {
+        events.add(event);
+    }
+
+
+    public void close() {
+    }
+
+
+    public boolean requiresLayout() {
+        return (false);
+    }
+
+
+}

Added: jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/simple/CustomConfigTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/simple/CustomConfigTestCase.java?view=auto&rev=159228
==============================================================================
--- jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/simple/CustomConfigTestCase.java (added)
+++ jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/simple/CustomConfigTestCase.java Mon Mar 28 02:36:50 2005
@@ -0,0 +1,254 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+
+package org.apache.commons.logging.simple;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.commons.logging.impl.SimpleLog;
+
+
+/**
+ * <p>TestCase for simple logging when running with custom configuration
+ * properties.</p>
+ *
+ * @author Craig R. McClanahan
+ * @version $Revision: 1.6 $ $Date: 2004-05-30 11:32:25 +0100 (Sun, 30 May 2004) $
+ */
+public class CustomConfigTestCase extends DefaultConfigTestCase {
+
+
+    // ----------------------------------------------------------- Constructors
+
+
+    /**
+     * <p>Construct a new instance of this test case.</p>
+     *
+     * @param name Name of the test case
+     */
+    public CustomConfigTestCase(String name) {
+        super(name);
+    }
+
+
+    // ----------------------------------------------------- Instance Variables
+
+
+    /**
+     * <p>The expected log records.</p>
+     */
+    protected List expected;
+
+
+    /**
+     * <p>The message levels that should have been logged.</p>
+     */
+    /*
+    protected Level testLevels[] =
+    { Level.FINE, Level.INFO, Level.WARNING, Level.SEVERE, Level.SEVERE };
+    */
+
+
+    /**
+     * <p>The message strings that should have been logged.</p>
+     */
+    protected String testMessages[] =
+    { "debug", "info", "warn", "error", "fatal" };
+
+
+    // ------------------------------------------- JUnit Infrastructure Methods
+
+
+    /**
+     * Set up instance variables required by this test case.
+     */
+    public void setUp() throws Exception {
+        expected = new ArrayList();
+        setUpFactory();
+        setUpLog("DecoratedLogger");
+    }
+
+
+    /**
+     * Return the tests included in this test suite.
+     */
+    public static Test suite() {
+        return (new TestSuite(CustomConfigTestCase.class));
+    }
+
+    /**
+     * Tear down instance variables required by this test case.
+     */
+    public void tearDown() {
+        super.tearDown();
+        expected = null;
+    }
+
+
+    // ----------------------------------------------------------- Test Methods
+
+
+    // Test logging message strings with exceptions
+    public void testExceptionMessages() throws Exception {
+
+        ((DecoratedSimpleLog) log).clearCache();
+        logExceptionMessages();
+        checkExpected();
+
+    }
+
+
+    // Test logging plain message strings
+    public void testPlainMessages() throws Exception {
+
+        ((DecoratedSimpleLog) log).clearCache();
+        logPlainMessages();
+        checkExpected();
+
+    }
+
+
+    // Test Serializability of standard instance
+    public void testSerializable() throws Exception {
+
+        ((DecoratedSimpleLog) log).clearCache();
+        logPlainMessages();
+        super.testSerializable();
+        logExceptionMessages();
+        checkExpected();
+
+    }
+
+
+    // -------------------------------------------------------- Support Methods
+
+
+    // Check the decorated log instance
+    protected void checkDecorated() {
+
+        assertNotNull("Log exists", log);
+        assertEquals("Log class",
+                     "org.apache.commons.logging.simple.DecoratedSimpleLog",
+                     log.getClass().getName());
+
+        // Can we call level checkers with no exceptions?
+        assertTrue(log.isDebugEnabled());
+        assertTrue(log.isErrorEnabled());
+        assertTrue(log.isFatalEnabled());
+        assertTrue(log.isInfoEnabled());
+        assertTrue(!log.isTraceEnabled());
+        assertTrue(log.isWarnEnabled());
+
+        // Can we retrieve the current log level?
+        assertEquals(SimpleLog.LOG_LEVEL_DEBUG, ((SimpleLog) log).getLevel());
+
+        // Can we validate the extra exposed properties?
+        checkDecoratedDateTime();
+        assertEquals("DecoratedLogger",
+                     ((DecoratedSimpleLog) log).getLogName());
+        checkShowDateTime();
+        assertTrue(((DecoratedSimpleLog) log).getShowShortName());
+
+    }
+    
+    /** Hook for subclassses */
+    protected void checkShowDateTime() {
+        assertTrue(!((DecoratedSimpleLog) log).getShowDateTime());
+    }
+    
+    /** Hook for subclasses */
+    protected void checkDecoratedDateTime() {
+            assertEquals("yyyy/MM/dd HH:mm:ss:SSS zzz",
+                     ((DecoratedSimpleLog) log).getDateTimeFormat());
+    }
+    
+
+
+    // Check the actual log records against the expected ones
+    protected void checkExpected() {
+
+        List acts = ((DecoratedSimpleLog) log).getCache();
+        Iterator exps = expected.iterator();
+        int n = 0;
+        while (exps.hasNext()) {
+            LogRecord exp = (LogRecord) exps.next();
+            LogRecord act = (LogRecord) acts.get(n++);
+            assertEquals("Row " + n + " type", exp.type, act.type);
+            assertEquals("Row " + n + " message", exp.message, act.message);
+            assertEquals("Row " + n + " throwable", exp.t, act.t);
+        }
+
+    }
+
+
+    // Check the standard log instance
+    protected void checkStandard() {
+
+        checkDecorated();
+
+    }
+
+
+    // Log the messages with exceptions
+    protected void logExceptionMessages() {
+
+        // Generate log records
+        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.fatal("fatal", t);
+
+        // Record the log records we expect
+        expected.add(new LogRecord(SimpleLog.LOG_LEVEL_DEBUG, "debug", t));
+        expected.add(new LogRecord(SimpleLog.LOG_LEVEL_INFO, "info", t));
+        expected.add(new LogRecord(SimpleLog.LOG_LEVEL_WARN, "warn", t));
+        expected.add(new LogRecord(SimpleLog.LOG_LEVEL_ERROR, "error", t));
+        expected.add(new LogRecord(SimpleLog.LOG_LEVEL_FATAL, "fatal", t));
+
+    }
+
+
+    // Log the plain messages
+    protected void logPlainMessages() {
+
+        // Generate log records
+        log.trace("trace"); // Should not actually get logged
+        log.debug("debug");
+        log.info("info");
+        log.warn("warn");
+        log.error("error");
+        log.fatal("fatal");
+
+        // Record the log records we expect
+        expected.add(new LogRecord(SimpleLog.LOG_LEVEL_DEBUG, "debug", null));
+        expected.add(new LogRecord(SimpleLog.LOG_LEVEL_INFO, "info", null));
+        expected.add(new LogRecord(SimpleLog.LOG_LEVEL_WARN, "warn", null));
+        expected.add(new LogRecord(SimpleLog.LOG_LEVEL_ERROR, "error", null));
+        expected.add(new LogRecord(SimpleLog.LOG_LEVEL_FATAL, "fatal", null));
+
+    }
+
+
+}

Added: jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/simple/DateTimeCustomConfigTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/simple/DateTimeCustomConfigTestCase.java?view=auto&rev=159228
==============================================================================
--- jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/simple/DateTimeCustomConfigTestCase.java (added)
+++ jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/simple/DateTimeCustomConfigTestCase.java Mon Mar 28 02:36:50 2005
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+
+package org.apache.commons.logging.simple;
+
+import java.util.Date;
+import java.text.SimpleDateFormat;
+import java.text.DateFormat;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+
+/**
+ * Tests custom date time format configuration
+ */
+public class DateTimeCustomConfigTestCase extends CustomConfigTestCase {
+    
+    // ----------------------------------------------------------- Constructors
+
+    /**
+     * Return the tests included in this test suite.
+     */
+    public static Test suite() {
+        return (new TestSuite(DateTimeCustomConfigTestCase.class));
+    }
+
+
+    /**
+     * <p>Construct a new instance of this test case.</p>
+     *
+     * @param name Name of the test case
+     */
+    public DateTimeCustomConfigTestCase(String name) {
+        super(name);
+    }
+    
+    // ----------------------------------------------------------- Methods
+
+    /** Checks that the date time format has been successfully set */
+    protected void checkDecoratedDateTime() {
+        assertEquals("Expected date format to be set", "dd.mm.yyyy",
+                     ((DecoratedSimpleLog) log).getDateTimeFormat());
+        
+        // try the formatter
+        Date now = new Date();
+        DateFormat formatter = ((DecoratedSimpleLog) log).getDateTimeFormatter(); 
+        SimpleDateFormat sampleFormatter = new SimpleDateFormat("dd.mm.yyyy");
+        assertEquals("Date should be formatters to pattern dd.mm.yyyy", sampleFormatter.format(now), formatter.format(now));
+    }
+    
+        /** Hook for subclassses */
+    protected void checkShowDateTime() {
+        assertTrue(((DecoratedSimpleLog) log).getShowDateTime());
+    }
+    
+}
\ No newline at end of file

Added: jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/simple/DecoratedSimpleLog.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/simple/DecoratedSimpleLog.java?view=auto&rev=159228
==============================================================================
--- jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/simple/DecoratedSimpleLog.java (added)
+++ jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/simple/DecoratedSimpleLog.java Mon Mar 28 02:36:50 2005
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+
+package org.apache.commons.logging.simple;
+
+
+import java.util.ArrayList;
+import java.util.List;
+import java.text.DateFormat;
+import org.apache.commons.logging.impl.SimpleLog;
+
+
+/**
+ * <p>Decorated instance of SimpleLog to expose internal state and
+ * support buffered output.</p>
+ */
+
+public class DecoratedSimpleLog extends SimpleLog {
+
+
+    // ------------------------------------------------------------ Constructor
+
+
+    public DecoratedSimpleLog(String name) {
+        super(name);
+    }
+
+
+    // ------------------------------------------------------------- Properties
+
+    public DateFormat getDateTimeFormatter() {
+        return (dateFormatter);
+    }
+
+
+    public String getDateTimeFormat() {
+        return (dateTimeFormat);
+    }
+
+
+    public String getLogName() {
+        return (logName);
+    }
+
+
+    public boolean getShowDateTime() {
+        return (showDateTime);
+    }
+
+
+    public boolean getShowShortName() {
+        return (showShortName);
+    }
+
+
+    // ------------------------------------------------------- Protected Methods
+
+
+    // Cache logged messages
+    protected void log(int type, Object message, Throwable t) {
+
+        super.log(type, message, t);
+        cache.add(new LogRecord(type, message, t));
+
+    }
+
+
+    // ---------------------------------------------------------- Public Methods
+
+
+    // Cache of logged records
+    protected ArrayList cache = new ArrayList();
+
+
+    // Clear cache
+    public void clearCache() {
+        cache.clear();
+    }
+
+
+    // Return cache
+    public List getCache() {
+        return (this.cache);
+    }
+
+
+}

Added: jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/simple/DefaultConfigTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/simple/DefaultConfigTestCase.java?view=auto&rev=159228
==============================================================================
--- jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/simple/DefaultConfigTestCase.java (added)
+++ jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/simple/DefaultConfigTestCase.java Mon Mar 28 02:36:50 2005
@@ -0,0 +1,231 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+
+package org.apache.commons.logging.simple;
+
+
+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;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.impl.SimpleLog;
+
+
+/**
+ * <p>TestCase for simple logging when running with zero configuration
+ * other than selecting the SimpleLog implementation.</p>
+ *
+ * @author Craig R. McClanahan
+ * @version $Revision: 1.5 $ $Date: 2004-05-29 11:43:35 +0100 (Sat, 29 May 2004) $
+ */
+
+public class DefaultConfigTestCase extends TestCase {
+
+
+    // ----------------------------------------------------------- Constructors
+
+
+    /**
+     * <p>Construct a new instance of this test case.</p>
+     *
+     * @param name Name of the test case
+     */
+    public DefaultConfigTestCase(String name) {
+        super(name);
+    }
+
+
+    // ----------------------------------------------------- Instance Variables
+
+
+    /**
+     * <p>The {@link LogFactory} implementation we have selected.</p>
+     */
+    protected LogFactory factory = null;
+
+
+    /**
+     * <p>The {@link Log} implementation we have selected.</p>
+     */
+    protected Log log = null;
+
+
+    // ------------------------------------------- JUnit Infrastructure Methods
+
+
+    /**
+     * Set up instance variables required by this test case.
+     */
+    public void setUp() throws Exception {
+        setUpFactory();
+        setUpLog("TestLogger");
+    }
+
+
+    /**
+     * Return the tests included in this test suite.
+     */
+    public static Test suite() {
+        return (new TestSuite(DefaultConfigTestCase.class));
+    }
+
+    /**
+     * Tear down instance variables required by this test case.
+     */
+    public void tearDown() {
+        log = null;
+        factory = null;
+        LogFactory.releaseAll();
+    }
+
+
+    // ----------------------------------------------------------- Test Methods
+
+
+    // Test pristine DecoratedSimpleLog instance
+    public void testPristineDecorated() {
+
+        setUpDecorated("DecoratedLogger");
+        checkDecorated();
+
+    }
+
+
+    // Test pristine Log instance
+    public void testPristineLog() {
+
+        checkStandard();
+
+    }
+
+
+    // Test pristine LogFactory instance
+    public void testPristineFactory() {
+
+        assertNotNull("LogFactory exists", factory);
+        assertEquals("LogFactory class",
+                     "org.apache.commons.logging.impl.LogFactoryImpl",
+                     factory.getClass().getName());
+
+        String names[] = factory.getAttributeNames();
+        assertNotNull("Names exists", names);
+        assertEquals("Names empty", 0, names.length);
+
+    }
+
+
+    // Test Serializability of standard 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
+        checkStandard();
+
+    }
+
+
+    // -------------------------------------------------------- Support Methods
+
+
+
+    // Check the decorated log instance
+    protected void checkDecorated() {
+
+        assertNotNull("Log exists", log);
+        assertEquals("Log class",
+                     "org.apache.commons.logging.simple.DecoratedSimpleLog",
+                     log.getClass().getName());
+
+        // Can we call level checkers with no exceptions?
+        assertTrue(!log.isDebugEnabled());
+        assertTrue(log.isErrorEnabled());
+        assertTrue(log.isFatalEnabled());
+        assertTrue(log.isInfoEnabled());
+        assertTrue(!log.isTraceEnabled());
+        assertTrue(log.isWarnEnabled());
+
+        // Can we retrieve the current log level?
+        assertEquals(SimpleLog.LOG_LEVEL_INFO, ((SimpleLog) log).getLevel());
+
+        // Can we validate the extra exposed properties?
+        assertEquals("yyyy/MM/dd HH:mm:ss:SSS zzz",
+                     ((DecoratedSimpleLog) log).getDateTimeFormat());
+        assertEquals("DecoratedLogger",
+                     ((DecoratedSimpleLog) log).getLogName());
+        assertTrue(!((DecoratedSimpleLog) log).getShowDateTime());
+        assertTrue(((DecoratedSimpleLog) log).getShowShortName());
+
+    }
+
+
+    // Check the standard log instance
+    protected void checkStandard() {
+
+        assertNotNull("Log exists", log);
+        assertEquals("Log class",
+                     "org.apache.commons.logging.impl.SimpleLog",
+                     log.getClass().getName());
+
+        // Can we call level checkers with no exceptions?
+        assertTrue(!log.isDebugEnabled());
+        assertTrue(log.isErrorEnabled());
+        assertTrue(log.isFatalEnabled());
+        assertTrue(log.isInfoEnabled());
+        assertTrue(!log.isTraceEnabled());
+        assertTrue(log.isWarnEnabled());
+
+        // Can we retrieve the current log level?
+        assertEquals(SimpleLog.LOG_LEVEL_INFO, ((SimpleLog) log).getLevel());
+
+    }
+
+
+    // Set up decorated log instance
+    protected void setUpDecorated(String name) {
+        log = new DecoratedSimpleLog(name);
+    }
+
+
+    // Set up factory instance
+    protected void setUpFactory() throws Exception {
+        factory = LogFactory.getFactory();
+    }
+
+
+    // Set up log instance
+    protected void setUpLog(String name) throws Exception {
+        log = LogFactory.getLog(name);
+    }
+
+
+}

Added: jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/simple/LogRecord.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/simple/LogRecord.java?view=auto&rev=159228
==============================================================================
--- jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/simple/LogRecord.java (added)
+++ jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/src/test/org/apache/commons/logging/simple/LogRecord.java Mon Mar 28 02:36:50 2005
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+
+
+package org.apache.commons.logging.simple;
+
+
+import java.io.Serializable;
+
+
+public class LogRecord implements Serializable {
+
+
+    public LogRecord(int type, Object message, Throwable t) {
+        this.type = type;
+        this.message = message;
+        this.t = t;
+    }
+
+    public int type;
+    public Object message;
+    public Throwable t;
+
+}

Added: jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/xdocs/.cvsignore
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/xdocs/.cvsignore?view=auto&rev=159228
==============================================================================
--- jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/xdocs/.cvsignore (added)
+++ jakarta/commons/proper/logging/branches/DON_QUIXOTE/classic/xdocs/.cvsignore Mon Mar 28 02:36:50 2005
@@ -0,0 +1 @@
+stylesheets



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message