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:
29
src/test/org/apache/commons/logging/DummyException.java
Normal file
29
src/test/org/apache/commons/logging/DummyException.java
Normal 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");
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user