[jboss-cvs] apache/commons-logging/src/test/org/apache/commons/logging/jdk14 ...
Scott Stark
scott.stark at jboss.com
Fri Feb 9 01:57:16 EST 2007
User: starksm
Date: 07/02/09 01:57:16
Modified: commons-logging/src/test/org/apache/commons/logging/jdk14
TestHandler.java CustomConfig.properties
CustomConfigTestCase.java
DefaultConfigTestCase.java
Added: commons-logging/src/test/org/apache/commons/logging/jdk14
CustomConfigFullTestCase.java
CustomConfigAPITestCase.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 +69 -69 apache/commons-logging/src/test/org/apache/commons/logging/jdk14/TestHandler.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TestHandler.java
===================================================================
RCS file: /cvsroot/jboss/apache/commons-logging/src/test/org/apache/commons/logging/jdk14/TestHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- TestHandler.java 17 Apr 2006 21:00:06 -0000 1.1
+++ TestHandler.java 9 Feb 2007 06:57:16 -0000 1.2
@@ -27,7 +27,7 @@
* <p>Test implementation of <code>java.util.logging.Handler</code>.</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:16 $
*/
public class TestHandler extends Handler {
1.2 +24 -24 apache/commons-logging/src/test/org/apache/commons/logging/jdk14/CustomConfig.properties
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CustomConfig.properties
===================================================================
RCS file: /cvsroot/jboss/apache/commons-logging/src/test/org/apache/commons/logging/jdk14/CustomConfig.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
1.2 +327 -302 apache/commons-logging/src/test/org/apache/commons/logging/jdk14/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/jdk14/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:16 -0000 1.2
@@ -35,7 +35,7 @@
* logger configured per the configuration 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:16 $
*/
public class CustomConfigTestCase extends DefaultConfigTestCase {
@@ -114,8 +114,19 @@
/**
* Return the tests included in this test suite.
*/
- public static Test suite() {
- return (new TestSuite(CustomConfigTestCase.class));
+ public static Test suite() throws Exception {
+ /*
+ PathableClassLoader loader = new PathableClassLoader(null);
+ loader.useSystemLoader("junit.");
+
+ PathableClassLoader child = new PathableClassLoader(parent);
+ child.addLogicalLib("testclasses");
+ child.addLogicalLib("commons-logging");
+
+ Class testClass = child.loadClass(CustomConfigTestCase.class.getName());
+ return new PathableTestSuite(testClass, child);
+ */
+ return new TestSuite(CustomConfigTestCase.class);
}
/**
@@ -220,9 +231,9 @@
testLevels[i], record.getLevel());
assertEquals("LogRecord message",
testMessages[i], record.getMessage());
- assertEquals("LogRecord class",
- this.getClass().getName(),
- record.getSourceClassName());
+ assertTrue("LogRecord class",
+ record.getSourceClassName().startsWith(
+ "org.apache.commons.logging.jdk14.CustomConfig"));
if (thrown) {
assertEquals("LogRecord method",
"logExceptionMessages",
@@ -276,11 +287,25 @@
parent = parent.getParent();
}
handlers = parent.getHandlers();
- if ((handlers != null) && (handlers.length == 1) &&
- (handlers[0] instanceof TestHandler)) {
+
+ // The CustomConfig.properties file explicitly defines one handler class
+ // to be attached to the root logger, so if it isn't there then
+ // something is badly wrong...
+ //
+ // Yes this testing is also done in testPristineHandlers but
+ // unfortunately:
+ // * we need to set up the handlers variable here,
+ // * we don't want that to be set up incorrectly, as that can
+ // produce weird error messages in other tests, and
+ // * we can't rely on testPristineHandlers being the first
+ // test to run.
+ // so we need to test things here too.
+ assertNotNull("No Handlers defined for JDK14 logging", handlers);
+ assertEquals("Unexpected number of handlers for JDK14 logging", 1, handlers.length);
+ assertNotNull("Handler is null", handlers[0]);
+ assertTrue("Handler not of expected type", handlers[0] instanceof TestHandler);
handler = (TestHandler) handlers[0];
}
- }
// Set up logger instance
1.2 +183 -183 apache/commons-logging/src/test/org/apache/commons/logging/jdk14/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/jdk14/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:16 -0000 1.2
@@ -36,7 +36,7 @@
* should be automatically configured.</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:16 $
*/
public class DefaultConfigTestCase extends TestCase {
@@ -85,7 +85,7 @@
/**
* Return the tests included in this test suite.
*/
- public static Test suite() {
+ public static Test suite() throws Exception {
return (new TestSuite(DefaultConfigTestCase.class));
}
1.1 date: 2007/02/09 06:57:16; author: starksm; state: Exp;apache/commons-logging/src/test/org/apache/commons/logging/jdk14/CustomConfigFullTestCase.java
Index: CustomConfigFullTestCase.java
===================================================================
/*
* Copyright 2005 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 junit.framework.Test;
import org.apache.commons.logging.PathableTestSuite;
import org.apache.commons.logging.PathableClassLoader;
/**
* TestCase for Jdk14 logging when the commons-logging jar file is in
* the parent classpath.
*/
public class CustomConfigFullTestCase extends CustomConfigTestCase {
public CustomConfigFullTestCase(String name) {
super(name);
}
/**
* Return the tests included in this test suite.
*/
public static Test suite() throws Exception {
PathableClassLoader parent = new PathableClassLoader(null);
parent.useSystemLoader("junit.");
// the TestHandler class must be accessable from the System classloader
// in order for java.util.logging.LogManager.readConfiguration to
// be able to instantiate it. And this test case must see the same
// class in order to be able to access its data. Yes this is ugly
// but the whole jdk14 API is a ******* mess anyway.
parent.useSystemLoader("org.apache.commons.logging.jdk14.TestHandler");
parent.addLogicalLib("commons-logging");
PathableClassLoader child = new PathableClassLoader(parent);
child.addLogicalLib("testclasses");
Class testClass = child.loadClass(CustomConfigFullTestCase.class.getName());
return new PathableTestSuite(testClass, child);
}
}
1.1 date: 2007/02/09 06:57:16; author: starksm; state: Exp;apache/commons-logging/src/test/org/apache/commons/logging/jdk14/CustomConfigAPITestCase.java
Index: CustomConfigAPITestCase.java
===================================================================
/*
* Copyright 2005 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 junit.framework.Test;
import org.apache.commons.logging.PathableTestSuite;
import org.apache.commons.logging.PathableClassLoader;
/**
* TestCase for Jdk14 logging when the commons-logging-api jar file is in
* the parent classpath and commons-logging.jar is in the child.
*/
public class CustomConfigAPITestCase extends CustomConfigTestCase {
public CustomConfigAPITestCase(String name) {
super(name);
}
/**
* Return the tests included in this test suite.
*/
public static Test suite() throws Exception {
PathableClassLoader parent = new PathableClassLoader(null);
parent.useSystemLoader("junit.");
// the TestHandler class must be accessable from the System classloader
// in order for java.util.logging.LogManager.readConfiguration to
// be able to instantiate it. And this test case must see the same
// class in order to be able to access its data. Yes this is ugly
// but the whole jdk14 API is a ******* mess anyway.
parent.useSystemLoader("org.apache.commons.logging.jdk14.TestHandler");
parent.addLogicalLib("commons-logging-api");
PathableClassLoader child = new PathableClassLoader(parent);
child.addLogicalLib("testclasses");
child.addLogicalLib("commons-logging");
Class testClass = child.loadClass(CustomConfigAPITestCase.class.getName());
return new PathableTestSuite(testClass, child);
}
}
More information about the jboss-cvs-commits
mailing list