[jboss-cvs] apache/commons-logging/src/test/org/apache/commons/logging/simple ...
Scott Stark
scott.stark at jboss.com
Fri Feb 9 01:57:19 EST 2007
User: starksm
Date: 07/02/09 01:57:19
Modified: commons-logging/src/test/org/apache/commons/logging/simple
DateTimeCustomConfigTestCase.java
DefaultConfigTestCase.java DecoratedSimpleLog.java
CustomConfigTestCase.java LogRecord.java
Log:
Update to the http://apache.ziply.com/jakarta/commons/logging/source/commons-logging-1.1-src.zip release
Revision Changes Path
1.2 +103 -69 apache/commons-logging/src/test/org/apache/commons/logging/simple/DateTimeCustomConfigTestCase.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: DateTimeCustomConfigTestCase.java
===================================================================
RCS file: /cvsroot/jboss/apache/commons-logging/src/test/org/apache/commons/logging/simple/DateTimeCustomConfigTestCase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- DateTimeCustomConfigTestCase.java 17 Apr 2006 21:00:06 -0000 1.1
+++ DateTimeCustomConfigTestCase.java 9 Feb 2007 06:57:19 -0000 1.2
@@ -16,12 +16,14 @@
package org.apache.commons.logging.simple;
-import java.util.Date;
-import java.text.SimpleDateFormat;
import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
import junit.framework.Test;
-import junit.framework.TestSuite;
+
+import org.apache.commons.logging.PathableClassLoader;
+import org.apache.commons.logging.PathableTestSuite;
/**
@@ -33,21 +35,53 @@
/**
* Return the tests included in this test suite.
+ * <p>
+ * We need to use a PathableClassLoader here because the SimpleLog class
+ * is a pile of junk and chock-full of static variables. Any other test
+ * (like simple.CustomConfigTestCase) that has used the SimpleLog class
+ * will already have caused it to do once-only initialisation that we
+ * can't reset, even by calling LogFactory.releaseAll, because of those
+ * ugly statics. The only clean solution is to load a clean copy of
+ * commons-logging including SimpleLog via a nice clean classloader.
+ * Or we could fix SimpleLog to be sane...
*/
- public static Test suite() {
- return (new TestSuite(DateTimeCustomConfigTestCase.class));
+ public static Test suite() throws Exception {
+ Class thisClass = DateTimeCustomConfigTestCase.class;
+
+ PathableClassLoader loader = new PathableClassLoader(null);
+ loader.useSystemLoader("junit.");
+ loader.addLogicalLib("testclasses");
+ loader.addLogicalLib("commons-logging");
+
+ Class testClass = loader.loadClass(thisClass.getName());
+ return new PathableTestSuite(testClass, loader);
}
/**
- * <p>Construct a new instance of this test case.</p>
- *
- * @param name Name of the test case
+ * Set up system properties required by this unit test. Here, we
+ * set up the props defined in the parent class setProperties method,
+ * and add a few to configure the SimpleLog class date/time output.
*/
- public DateTimeCustomConfigTestCase(String name) {
- super(name);
+ public void setProperties() {
+ super.setProperties();
+
+ System.setProperty(
+ "org.apache.commons.logging.simplelog.dateTimeFormat",
+ "dd.mm.yyyy");
+ System.setProperty(
+ "org.apache.commons.logging.simplelog.showdatetime",
+ "true");
}
+ /**
+ * Set up instance variables required by this test case.
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+
// ----------------------------------------------------------- Methods
/** Checks that the date time format has been successfully set */
1.2 +248 -231 apache/commons-logging/src/test/org/apache/commons/logging/simple/DefaultConfigTestCase.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: DefaultConfigTestCase.java
===================================================================
RCS file: /cvsroot/jboss/apache/commons-logging/src/test/org/apache/commons/logging/simple/DefaultConfigTestCase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- DefaultConfigTestCase.java 17 Apr 2006 21:00:06 -0000 1.1
+++ DefaultConfigTestCase.java 9 Feb 2007 06:57:19 -0000 1.2
@@ -24,10 +24,11 @@
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.PathableClassLoader;
+import org.apache.commons.logging.PathableTestSuite;
import org.apache.commons.logging.impl.SimpleLog;
@@ -36,25 +37,12 @@
* other than selecting the SimpleLog implementation.</p>
*
* @author Craig R. McClanahan
- * @version $Revision: 1.1 $ $Date: 2006/04/17 21:00:06 $
+ * @version $Revision: 1.2 $ $Date: 2007/02/09 06:57:19 $
*/
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
@@ -74,19 +62,48 @@
/**
- * 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.
+ * <p>
+ * We need to use a PathableClassLoader here because the SimpleLog class
+ * is a pile of junk and chock-full of static variables. Any other test
+ * (like simple.CustomConfigTestCase) that has used the SimpleLog class
+ * will already have caused it to do once-only initialisation that we
+ * can't reset, even by calling LogFactory.releaseAll, because of those
+ * ugly statics. The only clean solution is to load a clean copy of
+ * commons-logging including SimpleLog via a nice clean classloader.
+ * Or we could fix SimpleLog to be sane...
+ */
+ public static Test suite() throws Exception {
+ Class thisClass = DefaultConfigTestCase.class;
+
+ PathableClassLoader loader = new PathableClassLoader(null);
+ loader.useSystemLoader("junit.");
+ loader.addLogicalLib("testclasses");
+ loader.addLogicalLib("commons-logging");
+
+ Class testClass = loader.loadClass(thisClass.getName());
+ return new PathableTestSuite(testClass, loader);
}
+ /**
+ * Set system properties that will control the LogFactory/Log objects
+ * when they are created. Subclasses can override this method to
+ * define properties that suit them.
+ */
+ public void setProperties() {
+ System.setProperty(
+ "org.apache.commons.logging.Log",
+ "org.apache.commons.logging.impl.SimpleLog");
+ }
/**
- * Return the tests included in this test suite.
+ * Set up instance variables required by this test case.
*/
- public static Test suite() {
- return (new TestSuite(DefaultConfigTestCase.class));
+ public void setUp() throws Exception {
+ LogFactory.releaseAll();
+ setProperties();
+ setUpFactory();
+ setUpLog("TestLogger");
}
/**
1.2 +100 -100 apache/commons-logging/src/test/org/apache/commons/logging/simple/DecoratedSimpleLog.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: DecoratedSimpleLog.java
===================================================================
RCS file: /cvsroot/jboss/apache/commons-logging/src/test/org/apache/commons/logging/simple/DecoratedSimpleLog.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
1.2 +275 -254 apache/commons-logging/src/test/org/apache/commons/logging/simple/CustomConfigTestCase.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CustomConfigTestCase.java
===================================================================
RCS file: /cvsroot/jboss/apache/commons-logging/src/test/org/apache/commons/logging/simple/CustomConfigTestCase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- CustomConfigTestCase.java 17 Apr 2006 21:00:06 -0000 1.1
+++ CustomConfigTestCase.java 9 Feb 2007 06:57:19 -0000 1.2
@@ -22,8 +22,10 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.PathableClassLoader;
+import org.apache.commons.logging.PathableTestSuite;
import org.apache.commons.logging.impl.SimpleLog;
@@ -32,24 +34,11 @@
* properties.</p>
*
* @author Craig R. McClanahan
- * @version $Revision: 1.1 $ $Date: 2006/04/17 21:00:06 $
+ * @version $Revision: 1.2 $ $Date: 2007/02/09 06:57:19 $
*/
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
@@ -77,11 +66,26 @@
// ------------------------------------------- JUnit Infrastructure Methods
+ /**
+ * Set system properties that will control the LogFactory/Log objects
+ * when they are created. Subclasses can override this method to
+ * define properties that suit them.
+ */
+ public void setProperties() {
+ System.setProperty(
+ "org.apache.commons.logging.Log",
+ "org.apache.commons.logging.simple.DecoratedSimpleLog");
+ System.setProperty(
+ "org.apache.commons.logging.simplelog.defaultlog",
+ "debug");
+ }
/**
* Set up instance variables required by this test case.
*/
public void setUp() throws Exception {
+ LogFactory.releaseAll();
+ setProperties();
expected = new ArrayList();
setUpFactory();
setUpLog("DecoratedLogger");
@@ -90,9 +94,26 @@
/**
* Return the tests included in this test suite.
+ * <p>
+ * We need to use a PathableClassLoader here because the SimpleLog class
+ * is a pile of junk and chock-full of static variables. Any other test
+ * (like simple.CustomConfigTestCase) that has used the SimpleLog class
+ * will already have caused it to do once-only initialisation that we
+ * can't reset, even by calling LogFactory.releaseAll, because of those
+ * ugly statics. The only clean solution is to load a clean copy of
+ * commons-logging including SimpleLog via a nice clean classloader.
+ * Or we could fix SimpleLog to be sane...
*/
- public static Test suite() {
- return (new TestSuite(CustomConfigTestCase.class));
+ public static Test suite() throws Exception {
+ Class thisClass = CustomConfigTestCase.class;
+
+ PathableClassLoader loader = new PathableClassLoader(null);
+ loader.useSystemLoader("junit.");
+ loader.addLogicalLib("testclasses");
+ loader.addLogicalLib("commons-logging");
+
+ Class testClass = loader.loadClass(thisClass.getName());
+ return new PathableTestSuite(testClass, loader);
}
/**
1.2 +37 -37 apache/commons-logging/src/test/org/apache/commons/logging/simple/LogRecord.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: LogRecord.java
===================================================================
RCS file: /cvsroot/jboss/apache/commons-logging/src/test/org/apache/commons/logging/simple/LogRecord.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
More information about the jboss-cvs-commits
mailing list