1
0

Use a dummy exception class when calling log(exception). This makes the unit test output less confusing.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/logging/trunk@563165 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Simon Kitching
2007-08-06 15:08:05 +00:00
parent 58eff81387
commit b310a4ef0e
4 changed files with 35 additions and 3 deletions

View File

@@ -0,0 +1,29 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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;
/**
* Dummy exception that unit tests create instances of when they want to test
* logging of an Exception object.
*/
public class DummyException extends Exception {
private static final long serialVersionUID = 1L;
public DummyException() {
// super("Dummy Exception for unit testing");
}
}

View File

@@ -30,6 +30,7 @@ import java.util.logging.Logger;
import junit.framework.Test;
import org.apache.commons.logging.DummyException;
import org.apache.commons.logging.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite;
@@ -329,7 +330,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
// Log the messages with exceptions
protected void logExceptionMessages() {
Throwable t = new IndexOutOfBoundsException();
Throwable t = new DummyException();
log.trace("trace", t); // Should not actually get logged
log.debug("debug", t);
log.info("info", t);

View File

@@ -27,6 +27,7 @@ import java.util.List;
import junit.framework.TestCase;
import org.apache.commons.logging.DummyException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -204,7 +205,7 @@ public abstract class StandardTests extends TestCase {
* Log messages with exceptions
*/
private void logExceptionMessages(Log log) {
Throwable t = new IndexOutOfBoundsException();
Throwable t = new DummyException();
log.trace("trace", t); // Should not actually get logged
log.debug("debug", t); // Should not actually get logged
log.info("info", t);

View File

@@ -24,6 +24,7 @@ import java.util.List;
import junit.framework.Test;
import org.apache.commons.logging.DummyException;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite;
@@ -234,7 +235,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
protected void logExceptionMessages() {
// Generate log records
Throwable t = new IndexOutOfBoundsException();
Throwable t = new DummyException();
log.trace("trace", t); // Should not actually get logged
log.debug("debug", t);
log.info("info", t);