diff --git a/src/test/org/apache/commons/logging/DummyException.java b/src/test/org/apache/commons/logging/DummyException.java new file mode 100644 index 0000000..3bad543 --- /dev/null +++ b/src/test/org/apache/commons/logging/DummyException.java @@ -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"); + } +} diff --git a/src/test/org/apache/commons/logging/jdk14/CustomConfigTestCase.java b/src/test/org/apache/commons/logging/jdk14/CustomConfigTestCase.java index d1f3ec9..e1883ae 100644 --- a/src/test/org/apache/commons/logging/jdk14/CustomConfigTestCase.java +++ b/src/test/org/apache/commons/logging/jdk14/CustomConfigTestCase.java @@ -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); diff --git a/src/test/org/apache/commons/logging/log4j/StandardTests.java b/src/test/org/apache/commons/logging/log4j/StandardTests.java index d9b2469..5959206 100644 --- a/src/test/org/apache/commons/logging/log4j/StandardTests.java +++ b/src/test/org/apache/commons/logging/log4j/StandardTests.java @@ -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); diff --git a/src/test/org/apache/commons/logging/simple/CustomConfigTestCase.java b/src/test/org/apache/commons/logging/simple/CustomConfigTestCase.java index 7fe141c..e192cec 100644 --- a/src/test/org/apache/commons/logging/simple/CustomConfigTestCase.java +++ b/src/test/org/apache/commons/logging/simple/CustomConfigTestCase.java @@ -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);