From e8a3587ac60a9742dd10475dc4e2204460764873 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sat, 11 May 2024 11:08:11 -0400 Subject: [PATCH 1/5] Fix Javadoc warnings --- .../apache/commons/logging/impl/Log4jApiLogFactory.java | 7 +++++++ .../apache/commons/logging/impl/ServletContextCleaner.java | 7 +++++++ .../org/apache/commons/logging/impl/Slf4jLogFactory.java | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/src/main/java/org/apache/commons/logging/impl/Log4jApiLogFactory.java b/src/main/java/org/apache/commons/logging/impl/Log4jApiLogFactory.java index 668bada..482bffe 100644 --- a/src/main/java/org/apache/commons/logging/impl/Log4jApiLogFactory.java +++ b/src/main/java/org/apache/commons/logging/impl/Log4jApiLogFactory.java @@ -183,6 +183,13 @@ public final class Log4jApiLogFactory extends LogFactory { private final ConcurrentMap attributes = new ConcurrentHashMap<>(); + /** + * Constructs a new instance. + */ + public Log4jApiLogFactory() { + // empty + } + @Override public Object getAttribute(final String name) { return attributes.get(name); diff --git a/src/main/java/org/apache/commons/logging/impl/ServletContextCleaner.java b/src/main/java/org/apache/commons/logging/impl/ServletContextCleaner.java index 674130b..72a0617 100644 --- a/src/main/java/org/apache/commons/logging/impl/ServletContextCleaner.java +++ b/src/main/java/org/apache/commons/logging/impl/ServletContextCleaner.java @@ -50,6 +50,13 @@ public class ServletContextCleaner implements ServletContextListener { private static final Class[] RELEASE_SIGNATURE = { ClassLoader.class }; + /** + * Constructs a new instance. + */ + public ServletContextCleaner() { + // empty + } + /** * Invoked when a webapp is undeployed, this tells the LogFactory * class to release any logging information related to the current diff --git a/src/main/java/org/apache/commons/logging/impl/Slf4jLogFactory.java b/src/main/java/org/apache/commons/logging/impl/Slf4jLogFactory.java index 2a985fd..a16019f 100644 --- a/src/main/java/org/apache/commons/logging/impl/Slf4jLogFactory.java +++ b/src/main/java/org/apache/commons/logging/impl/Slf4jLogFactory.java @@ -266,6 +266,13 @@ public final class Slf4jLogFactory extends LogFactory { private final ConcurrentMap attributes = new ConcurrentHashMap<>(); + /** + * Constructs a new instance. + */ + public Slf4jLogFactory() { + // empty + } + @Override public Object getAttribute(final String name) { return attributes.get(name); From f60da7be702f9d2a27383c78d51f36b92cec52ff Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sat, 11 May 2024 11:08:27 -0400 Subject: [PATCH 2/5] Comment empty code block --- .../java/org/apache/commons/logging/impl/Slf4jLogFactory.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/apache/commons/logging/impl/Slf4jLogFactory.java b/src/main/java/org/apache/commons/logging/impl/Slf4jLogFactory.java index a16019f..140bfc5 100644 --- a/src/main/java/org/apache/commons/logging/impl/Slf4jLogFactory.java +++ b/src/main/java/org/apache/commons/logging/impl/Slf4jLogFactory.java @@ -310,6 +310,7 @@ public final class Slf4jLogFactory extends LogFactory { try { factory.getClass().getMethod("stop").invoke(factory); } catch (final ReflectiveOperationException ignored) { + // empty } } From e37750947d095cdb0cf1f427e6419fc5f8ddeffb Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sat, 11 May 2024 11:18:47 -0400 Subject: [PATCH 3/5] Deprecate org.apache.commons.logging.LogSource.jdk14IsAvailable --- src/changes/changes.xml | 1 + .../org/apache/commons/logging/LogSource.java | 16 +++++------ .../apache/commons/logging/LogSourceTest.java | 28 +++++++++++++++++++ 3 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 src/test/java/org/apache/commons/logging/LogSourceTest.java diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 14fbec0..f9701d9 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -46,6 +46,7 @@ The type attribute can be add,update,fix,remove. Add OSGi metadata to enable Service Loader Mediator #234. Apache commons logging shows 1.4 as latest release instead of 1.3.1. + Deprecate org.apache.commons.logging.LogSource.jdk14IsAvailable. Bump org.apache.commons:commons-parent from 67 to 69 #240. Bump org.slf4j:slf4j-api from 2.0.12 to 2.0.13 #248. diff --git a/src/main/java/org/apache/commons/logging/LogSource.java b/src/main/java/org/apache/commons/logging/LogSource.java index c594ab6..586573f 100644 --- a/src/main/java/org/apache/commons/logging/LogSource.java +++ b/src/main/java/org/apache/commons/logging/LogSource.java @@ -61,8 +61,13 @@ public class LogSource { /** Is Log4j available (in the current classpath) */ static protected boolean log4jIsAvailable; - /** Is JDK 1.4 logging available */ - static protected boolean jdk14IsAvailable; + /** + * Is JDK 1.4 logging available, always true. + * + * @deprecated Java 8 is the baseline and includes JUL. + */ + @Deprecated + static protected boolean jdk14IsAvailable = true; /** Constructor for current log class */ static protected Constructor logImplctor; @@ -77,9 +82,6 @@ public class LogSource { // Is Log4J Available? log4jIsAvailable = isClassForName("org.apache.log4j.Logger"); - // Is JDK 1.4 Logging Available? - jdk14IsAvailable = isClassForName("org.apache.commons.logging.impl.Jdk14Logger"); - // Set the default Log implementation String name = null; try { @@ -104,10 +106,8 @@ public class LogSource { try { if (log4jIsAvailable) { setLogImplementation("org.apache.commons.logging.impl.Log4JLogger"); - } else if (jdk14IsAvailable) { - setLogImplementation("org.apache.commons.logging.impl.Jdk14Logger"); } else { - setLogImplementation("org.apache.commons.logging.impl.NoOpLog"); + setLogImplementation("org.apache.commons.logging.impl.Jdk14Logger"); } } catch (final Throwable t) { try { diff --git a/src/test/java/org/apache/commons/logging/LogSourceTest.java b/src/test/java/org/apache/commons/logging/LogSourceTest.java new file mode 100644 index 0000000..cb572e2 --- /dev/null +++ b/src/test/java/org/apache/commons/logging/LogSourceTest.java @@ -0,0 +1,28 @@ +/* + * 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; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class LogSourceTest { + + @SuppressWarnings("deprecation") + public void testJdk14IsAvailable() throws Exception { + assertTrue(LogSource.jdk14IsAvailable); + } +} From 8b3454ac610c9e0482d965382107c56606e963dd Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sat, 11 May 2024 11:21:55 -0400 Subject: [PATCH 4/5] Fix generics compiler warning --- src/main/java/org/apache/commons/logging/LogFactory.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/apache/commons/logging/LogFactory.java b/src/main/java/org/apache/commons/logging/LogFactory.java index c169906..a751fdf 100644 --- a/src/main/java/org/apache/commons/logging/LogFactory.java +++ b/src/main/java/org/apache/commons/logging/LogFactory.java @@ -1424,12 +1424,11 @@ public abstract class LogFactory { protected static LogFactory newFactory(final String factoryClass, final ClassLoader classLoader, final ClassLoader contextClassLoader) - throws LogConfigurationException { + throws LogConfigurationException { // Note that any unchecked exceptions thrown by the createFactory // method will propagate out of this method; in particular a // ClassCastException can be thrown. - final Object result = AccessController.doPrivileged( - (PrivilegedAction) () -> createFactory(factoryClass, classLoader)); + final Object result = AccessController.doPrivileged((PrivilegedAction) () -> createFactory(factoryClass, classLoader)); if (result instanceof LogConfigurationException) { final LogConfigurationException ex = (LogConfigurationException) result; @@ -1439,8 +1438,7 @@ public abstract class LogFactory { throw ex; } if (isDiagnosticsEnabled()) { - logDiagnostic("Created object " + objectId(result) + " to manage class loader " + - objectId(contextClassLoader)); + logDiagnostic("Created object " + objectId(result) + " to manage class loader " + objectId(contextClassLoader)); } return (LogFactory) result; } From d67eefa4e2c9b6a9db41fb9f2edd137f494de233 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sat, 11 May 2024 11:28:09 -0400 Subject: [PATCH 5/5] Sort imports Whitespace --- .../java/org/apache/commons/logging/LogSource.java | 2 +- .../logging/avalon/AvalonLoggerTestCase.java | 6 +++--- .../logging/config/FirstPriorityConfigTestCase.java | 6 +++--- .../logging/config/PriorityConfigTestCase.java | 6 +++--- .../logging/jdk14/CustomConfigAPITestCase.java | 4 ++-- .../logging/jdk14/CustomConfigFullTestCase.java | 4 ++-- .../commons/logging/jdk14/CustomConfigTestCase.java | 4 ++-- .../logging/jdk14/DefaultConfigTestCase.java | 6 +++--- .../apache/commons/logging/log4j/StandardTests.java | 4 ++-- .../log4j/log4j12/ApiClasspathStandardTestCase.java | 6 +++--- .../log4j/log4j12/AppClasspathStandardTestCase.java | 6 +++--- .../log4j12/ChildClasspathStandardTestCase.java | 6 +++--- .../log4j12/ParentClasspathStandardTestCase.java | 6 +++--- .../logging/log4j2/CallerInformationTestCase.java | 8 +++----- .../commons/logging/logkit/StandardTestCase.java | 4 ++-- .../logging/pathable/ChildFirstTestCase.java | 6 +++--- .../commons/logging/pathable/GeneralTestCase.java | 6 +++--- .../logging/pathable/ParentFirstTestCase.java | 6 +++--- .../logging/security/SecurityAllowedTestCase.java | 6 +++--- .../logging/security/SecurityForbiddenTestCase.java | 6 +++--- .../serviceloader/ServiceLoaderTestCase.java | 4 ++-- .../logging/servlet/BasicServletTestCase.java | 6 +++--- .../logging/simple/CustomConfigTestCase.java | 4 ++-- .../simple/DateTimeCustomConfigTestCase.java | 4 ++-- .../logging/simple/DefaultConfigTestCase.java | 6 +++--- .../logging/slf4j/CallerInformationTestCase.java | 13 +++++-------- .../commons/logging/tccl/BadTCCLTestCase.java | 6 +++--- .../commons/logging/tccl/NullTCCLTestCase.java | 6 +++--- .../logging/tccl/log/TcclDisabledTestCase.java | 6 +++--- .../logging/tccl/log/TcclEnabledTestCase.java | 6 +++--- .../tccl/logfactory/TcclDisabledTestCase.java | 6 +++--- .../tccl/logfactory/TcclEnabledTestCase.java | 6 +++--- 32 files changed, 88 insertions(+), 93 deletions(-) diff --git a/src/main/java/org/apache/commons/logging/LogSource.java b/src/main/java/org/apache/commons/logging/LogSource.java index 586573f..49084ec 100644 --- a/src/main/java/org/apache/commons/logging/LogSource.java +++ b/src/main/java/org/apache/commons/logging/LogSource.java @@ -61,7 +61,7 @@ public class LogSource { /** Is Log4j available (in the current classpath) */ static protected boolean log4jIsAvailable; - /** + /** * Is JDK 1.4 logging available, always true. * * @deprecated Java 8 is the baseline and includes JUL. diff --git a/src/test/java/org/apache/commons/logging/avalon/AvalonLoggerTestCase.java b/src/test/java/org/apache/commons/logging/avalon/AvalonLoggerTestCase.java index 9156cc4..15047e4 100644 --- a/src/test/java/org/apache/commons/logging/avalon/AvalonLoggerTestCase.java +++ b/src/test/java/org/apache/commons/logging/avalon/AvalonLoggerTestCase.java @@ -16,14 +16,14 @@ */ package org.apache.commons.logging.avalon; +import junit.framework.Test; +import junit.framework.TestSuite; + import org.apache.avalon.framework.logger.NullLogger; import org.apache.commons.logging.AbstractLogTest; import org.apache.commons.logging.Log; import org.apache.commons.logging.impl.AvalonLogger; -import junit.framework.Test; -import junit.framework.TestSuite; - /** */ public class AvalonLoggerTestCase extends AbstractLogTest { diff --git a/src/test/java/org/apache/commons/logging/config/FirstPriorityConfigTestCase.java b/src/test/java/org/apache/commons/logging/config/FirstPriorityConfigTestCase.java index 47f3803..aeb2ccd 100644 --- a/src/test/java/org/apache/commons/logging/config/FirstPriorityConfigTestCase.java +++ b/src/test/java/org/apache/commons/logging/config/FirstPriorityConfigTestCase.java @@ -19,13 +19,13 @@ package org.apache.commons.logging.config; import java.net.URL; +import junit.framework.Test; +import junit.framework.TestCase; + import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableTestSuite; -import junit.framework.Test; -import junit.framework.TestCase; - /** * Tests that verify that the process of configuring logging on startup * works correctly by selecting the file with the highest priority. diff --git a/src/test/java/org/apache/commons/logging/config/PriorityConfigTestCase.java b/src/test/java/org/apache/commons/logging/config/PriorityConfigTestCase.java index 440ba00..f7d2e6e 100644 --- a/src/test/java/org/apache/commons/logging/config/PriorityConfigTestCase.java +++ b/src/test/java/org/apache/commons/logging/config/PriorityConfigTestCase.java @@ -19,13 +19,13 @@ package org.apache.commons.logging.config; import java.net.URL; +import junit.framework.Test; +import junit.framework.TestCase; + import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableTestSuite; -import junit.framework.Test; -import junit.framework.TestCase; - /** * Tests that verify that the process of configuring logging on startup * works correctly by selecting the file with the highest priority. diff --git a/src/test/java/org/apache/commons/logging/jdk14/CustomConfigAPITestCase.java b/src/test/java/org/apache/commons/logging/jdk14/CustomConfigAPITestCase.java index 4287446..2af4eb7 100644 --- a/src/test/java/org/apache/commons/logging/jdk14/CustomConfigAPITestCase.java +++ b/src/test/java/org/apache/commons/logging/jdk14/CustomConfigAPITestCase.java @@ -17,11 +17,11 @@ package org.apache.commons.logging.jdk14; +import junit.framework.Test; + import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableTestSuite; -import junit.framework.Test; - /** * TestCase for Jdk14 logging when the commons-logging-api jar file is in * the parent classpath and commons-logging.jar is in the child. diff --git a/src/test/java/org/apache/commons/logging/jdk14/CustomConfigFullTestCase.java b/src/test/java/org/apache/commons/logging/jdk14/CustomConfigFullTestCase.java index 4fd703e..f1f4dff 100644 --- a/src/test/java/org/apache/commons/logging/jdk14/CustomConfigFullTestCase.java +++ b/src/test/java/org/apache/commons/logging/jdk14/CustomConfigFullTestCase.java @@ -17,11 +17,11 @@ package org.apache.commons.logging.jdk14; +import junit.framework.Test; + import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableTestSuite; -import junit.framework.Test; - /** * TestCase for Jdk14 logging when the commons-logging jar file is in * the parent classpath. diff --git a/src/test/java/org/apache/commons/logging/jdk14/CustomConfigTestCase.java b/src/test/java/org/apache/commons/logging/jdk14/CustomConfigTestCase.java index 4781907..1d08137 100644 --- a/src/test/java/org/apache/commons/logging/jdk14/CustomConfigTestCase.java +++ b/src/test/java/org/apache/commons/logging/jdk14/CustomConfigTestCase.java @@ -27,12 +27,12 @@ import java.util.logging.LogManager; import java.util.logging.LogRecord; 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; -import junit.framework.Test; - /** *

TestCase for JDK 1.4 logging when running on a JDK 1.4 system with * custom configuration, so that JDK 1.4 should be selected and an appropriate diff --git a/src/test/java/org/apache/commons/logging/jdk14/DefaultConfigTestCase.java b/src/test/java/org/apache/commons/logging/jdk14/DefaultConfigTestCase.java index 70436ad..680d9c7 100644 --- a/src/test/java/org/apache/commons/logging/jdk14/DefaultConfigTestCase.java +++ b/src/test/java/org/apache/commons/logging/jdk14/DefaultConfigTestCase.java @@ -22,14 +22,14 @@ import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import junit.framework.Test; +import junit.framework.TestCase; + 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 junit.framework.Test; -import junit.framework.TestCase; - /** *

TestCase for JDK 1.4 logging when running on a JDK 1.4 system with * zero configuration, and with Log4J not present (so JDK 1.4 logging diff --git a/src/test/java/org/apache/commons/logging/log4j/StandardTests.java b/src/test/java/org/apache/commons/logging/log4j/StandardTests.java index 7bb6922..b9f66be 100644 --- a/src/test/java/org/apache/commons/logging/log4j/StandardTests.java +++ b/src/test/java/org/apache/commons/logging/log4j/StandardTests.java @@ -24,12 +24,12 @@ import java.io.ObjectOutputStream; import java.util.ArrayList; 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; -import junit.framework.TestCase; - /** * Abstract set of tests that can be executed with various classpaths set. *

diff --git a/src/test/java/org/apache/commons/logging/log4j/log4j12/ApiClasspathStandardTestCase.java b/src/test/java/org/apache/commons/logging/log4j/log4j12/ApiClasspathStandardTestCase.java index 9d555a5..33e02d7 100644 --- a/src/test/java/org/apache/commons/logging/log4j/log4j12/ApiClasspathStandardTestCase.java +++ b/src/test/java/org/apache/commons/logging/log4j/log4j12/ApiClasspathStandardTestCase.java @@ -17,14 +17,14 @@ package org.apache.commons.logging.log4j.log4j12; +import junit.framework.Test; +import junit.framework.TestCase; + import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableTestSuite; import org.apache.commons.logging.impl.Log4JLogger; import org.apache.commons.logging.impl.LogFactoryImpl; -import junit.framework.Test; -import junit.framework.TestCase; - /** * Tests for Log4J logging that emulate a webapp running within * a container where the commons-logging-api jar file is in diff --git a/src/test/java/org/apache/commons/logging/log4j/log4j12/AppClasspathStandardTestCase.java b/src/test/java/org/apache/commons/logging/log4j/log4j12/AppClasspathStandardTestCase.java index cd9d402..a8230bd 100644 --- a/src/test/java/org/apache/commons/logging/log4j/log4j12/AppClasspathStandardTestCase.java +++ b/src/test/java/org/apache/commons/logging/log4j/log4j12/AppClasspathStandardTestCase.java @@ -17,14 +17,14 @@ package org.apache.commons.logging.log4j.log4j12; +import junit.framework.Test; +import junit.framework.TestCase; + import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableTestSuite; import org.apache.commons.logging.impl.Log4JLogger; import org.apache.commons.logging.impl.LogFactoryImpl; -import junit.framework.Test; -import junit.framework.TestCase; - /** * Tests for Log4J logging when there is only one class loader and everything * is in it, as would be the situation for a standalone application. diff --git a/src/test/java/org/apache/commons/logging/log4j/log4j12/ChildClasspathStandardTestCase.java b/src/test/java/org/apache/commons/logging/log4j/log4j12/ChildClasspathStandardTestCase.java index 600e1ce..6c66cf7 100644 --- a/src/test/java/org/apache/commons/logging/log4j/log4j12/ChildClasspathStandardTestCase.java +++ b/src/test/java/org/apache/commons/logging/log4j/log4j12/ChildClasspathStandardTestCase.java @@ -17,14 +17,14 @@ package org.apache.commons.logging.log4j.log4j12; +import junit.framework.Test; +import junit.framework.TestCase; + import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableTestSuite; import org.apache.commons.logging.impl.Log4JLogger; import org.apache.commons.logging.impl.LogFactoryImpl; -import junit.framework.Test; -import junit.framework.TestCase; - /** * Tests for Log4J logging that emulate a webapp running within * a container where all the necessary libs are in the child. diff --git a/src/test/java/org/apache/commons/logging/log4j/log4j12/ParentClasspathStandardTestCase.java b/src/test/java/org/apache/commons/logging/log4j/log4j12/ParentClasspathStandardTestCase.java index 8343d10..76c1b31 100644 --- a/src/test/java/org/apache/commons/logging/log4j/log4j12/ParentClasspathStandardTestCase.java +++ b/src/test/java/org/apache/commons/logging/log4j/log4j12/ParentClasspathStandardTestCase.java @@ -17,14 +17,14 @@ package org.apache.commons.logging.log4j.log4j12; +import junit.framework.Test; +import junit.framework.TestCase; + import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableTestSuite; import org.apache.commons.logging.impl.Log4JLogger; import org.apache.commons.logging.impl.LogFactoryImpl; -import junit.framework.Test; -import junit.framework.TestCase; - /** * Tests for Log4J logging that emulate a webapp running within * a container where all the necessary libs are in the parent. diff --git a/src/test/java/org/apache/commons/logging/log4j2/CallerInformationTestCase.java b/src/test/java/org/apache/commons/logging/log4j2/CallerInformationTestCase.java index 9bad253..23b1277 100644 --- a/src/test/java/org/apache/commons/logging/log4j2/CallerInformationTestCase.java +++ b/src/test/java/org/apache/commons/logging/log4j2/CallerInformationTestCase.java @@ -18,6 +18,8 @@ package org.apache.commons.logging.log4j2; import java.util.List; +import junit.framework.TestCase; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.impl.Log4jApiLogFactory; @@ -31,8 +33,6 @@ import org.apache.logging.log4j.core.test.appender.ListAppender; import org.apache.logging.log4j.message.ObjectMessage; import org.apache.logging.log4j.message.SimpleMessage; -import junit.framework.TestCase; - public class CallerInformationTestCase extends TestCase { private static final Object OBJ = new Object(); @@ -90,9 +90,7 @@ public class CallerInformationTestCase extends TestCase { assertEquals("Correct source file.", "CallerInformationTestCase.java", location.getFileName()); assertEquals("Correct method name.", "testLocationInfo", location.getMethodName()); assertEquals("Correct location class.", getClass().getName(), location.getClassName()); - assertEquals("Correct location line.", - currentLineNumber + 2 * lev + hasThrowable + 1, - location.getLineNumber()); + assertEquals("Correct location line.", currentLineNumber + 2 * lev + hasThrowable + 1, location.getLineNumber()); assertEquals("Correct exception", hasThrowable > 0 ? T : null, event.getThrown()); } } diff --git a/src/test/java/org/apache/commons/logging/logkit/StandardTestCase.java b/src/test/java/org/apache/commons/logging/logkit/StandardTestCase.java index 7feb9d4..12dbb1c 100644 --- a/src/test/java/org/apache/commons/logging/logkit/StandardTestCase.java +++ b/src/test/java/org/apache/commons/logging/logkit/StandardTestCase.java @@ -22,6 +22,8 @@ import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import junit.framework.Test; + import org.apache.commons.logging.AbstractLogTest; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -29,8 +31,6 @@ import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableTestSuite; import org.apache.commons.logging.impl.LogKitLogger; -import junit.framework.Test; - /** * Basic tests for Avalon LogKit logger adapter. */ diff --git a/src/test/java/org/apache/commons/logging/pathable/ChildFirstTestCase.java b/src/test/java/org/apache/commons/logging/pathable/ChildFirstTestCase.java index a0a85ca..49262e3 100644 --- a/src/test/java/org/apache/commons/logging/pathable/ChildFirstTestCase.java +++ b/src/test/java/org/apache/commons/logging/pathable/ChildFirstTestCase.java @@ -23,13 +23,13 @@ import java.util.Enumeration; import java.util.HashSet; import java.util.Set; +import junit.framework.Test; +import junit.framework.TestCase; + import org.apache.commons.logging.Artifacts; import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableTestSuite; -import junit.framework.Test; -import junit.framework.TestCase; - /** * Tests for the PathableTestSuite and PathableClassLoader functionality, * where lookup order for the PathableClassLoader is child-first. diff --git a/src/test/java/org/apache/commons/logging/pathable/GeneralTestCase.java b/src/test/java/org/apache/commons/logging/pathable/GeneralTestCase.java index ed75cdd..1d99932 100644 --- a/src/test/java/org/apache/commons/logging/pathable/GeneralTestCase.java +++ b/src/test/java/org/apache/commons/logging/pathable/GeneralTestCase.java @@ -19,12 +19,12 @@ package org.apache.commons.logging.pathable; import java.net.URL; import java.net.URLClassLoader; -import org.apache.commons.logging.PathableClassLoader; -import org.apache.commons.logging.PathableTestSuite; - import junit.framework.Test; import junit.framework.TestCase; +import org.apache.commons.logging.PathableClassLoader; +import org.apache.commons.logging.PathableTestSuite; + /** * Tests for the PathableTestSuite class. */ diff --git a/src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java b/src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java index a7a8983..77d7f67 100644 --- a/src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java +++ b/src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java @@ -25,13 +25,13 @@ import java.util.Enumeration; import java.util.HashSet; import java.util.Set; +import junit.framework.Test; +import junit.framework.TestCase; + import org.apache.commons.logging.Artifacts; import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableTestSuite; -import junit.framework.Test; -import junit.framework.TestCase; - /** * Tests for the PathableTestSuite and PathableClassLoader functionality, * where lookup order for the PathableClassLoader is parent-first. diff --git a/src/test/java/org/apache/commons/logging/security/SecurityAllowedTestCase.java b/src/test/java/org/apache/commons/logging/security/SecurityAllowedTestCase.java index a71a42a..fe4e5ff 100644 --- a/src/test/java/org/apache/commons/logging/security/SecurityAllowedTestCase.java +++ b/src/test/java/org/apache/commons/logging/security/SecurityAllowedTestCase.java @@ -24,14 +24,14 @@ import java.lang.reflect.Method; import java.security.AllPermission; import java.util.Hashtable; +import junit.framework.Test; +import junit.framework.TestCase; + 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 junit.framework.Test; -import junit.framework.TestCase; - /** * Tests for logging with a security policy that allows JCL access to everything. *

diff --git a/src/test/java/org/apache/commons/logging/security/SecurityForbiddenTestCase.java b/src/test/java/org/apache/commons/logging/security/SecurityForbiddenTestCase.java index 04a96c1..ee1afb8 100644 --- a/src/test/java/org/apache/commons/logging/security/SecurityForbiddenTestCase.java +++ b/src/test/java/org/apache/commons/logging/security/SecurityForbiddenTestCase.java @@ -25,14 +25,14 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.Hashtable; +import junit.framework.Test; +import junit.framework.TestCase; + 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 junit.framework.Test; -import junit.framework.TestCase; - /** * Tests for logging with a security policy that forbids JCL access to anything. *

diff --git a/src/test/java/org/apache/commons/logging/serviceloader/ServiceLoaderTestCase.java b/src/test/java/org/apache/commons/logging/serviceloader/ServiceLoaderTestCase.java index 7ac7c4f..24b561d 100644 --- a/src/test/java/org/apache/commons/logging/serviceloader/ServiceLoaderTestCase.java +++ b/src/test/java/org/apache/commons/logging/serviceloader/ServiceLoaderTestCase.java @@ -16,11 +16,11 @@ */ package org.apache.commons.logging.serviceloader; +import junit.framework.TestCase; + import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.serviceloader.internal.DummyLogFactory; -import junit.framework.TestCase; - public class ServiceLoaderTestCase extends TestCase { public void testServiceLoader() { diff --git a/src/test/java/org/apache/commons/logging/servlet/BasicServletTestCase.java b/src/test/java/org/apache/commons/logging/servlet/BasicServletTestCase.java index 9b39508..4157946 100644 --- a/src/test/java/org/apache/commons/logging/servlet/BasicServletTestCase.java +++ b/src/test/java/org/apache/commons/logging/servlet/BasicServletTestCase.java @@ -17,13 +17,13 @@ package org.apache.commons.logging.servlet; +import junit.framework.Test; +import junit.framework.TestCase; + import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableTestSuite; import org.apache.commons.logging.impl.ServletContextCleaner; -import junit.framework.Test; -import junit.framework.TestCase; - /** * Tests for ServletContextCleaner utility class. */ diff --git a/src/test/java/org/apache/commons/logging/simple/CustomConfigTestCase.java b/src/test/java/org/apache/commons/logging/simple/CustomConfigTestCase.java index a11a5b2..9b45fe4 100644 --- a/src/test/java/org/apache/commons/logging/simple/CustomConfigTestCase.java +++ b/src/test/java/org/apache/commons/logging/simple/CustomConfigTestCase.java @@ -21,14 +21,14 @@ import java.util.ArrayList; import java.util.Iterator; 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; import org.apache.commons.logging.impl.SimpleLog; -import junit.framework.Test; - /** *

TestCase for simple logging when running with custom configuration * properties.

diff --git a/src/test/java/org/apache/commons/logging/simple/DateTimeCustomConfigTestCase.java b/src/test/java/org/apache/commons/logging/simple/DateTimeCustomConfigTestCase.java index cc80518..f29abef 100644 --- a/src/test/java/org/apache/commons/logging/simple/DateTimeCustomConfigTestCase.java +++ b/src/test/java/org/apache/commons/logging/simple/DateTimeCustomConfigTestCase.java @@ -21,11 +21,11 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; +import junit.framework.Test; + import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableTestSuite; -import junit.framework.Test; - /** * Tests custom date time format configuration */ diff --git a/src/test/java/org/apache/commons/logging/simple/DefaultConfigTestCase.java b/src/test/java/org/apache/commons/logging/simple/DefaultConfigTestCase.java index 2ac9e8a..60562dc 100644 --- a/src/test/java/org/apache/commons/logging/simple/DefaultConfigTestCase.java +++ b/src/test/java/org/apache/commons/logging/simple/DefaultConfigTestCase.java @@ -22,15 +22,15 @@ import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import junit.framework.Test; +import junit.framework.TestCase; + 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; -import junit.framework.Test; -import junit.framework.TestCase; - /** *

TestCase for simple logging when running with zero configuration * other than selecting the SimpleLog implementation.

diff --git a/src/test/java/org/apache/commons/logging/slf4j/CallerInformationTestCase.java b/src/test/java/org/apache/commons/logging/slf4j/CallerInformationTestCase.java index fd36345..eebe98f 100644 --- a/src/test/java/org/apache/commons/logging/slf4j/CallerInformationTestCase.java +++ b/src/test/java/org/apache/commons/logging/slf4j/CallerInformationTestCase.java @@ -20,6 +20,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import junit.framework.TestCase; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.impl.Slf4jLogFactory; @@ -35,7 +37,6 @@ import ch.qos.logback.classic.spi.ThrowableProxy; import ch.qos.logback.core.filter.Filter; import ch.qos.logback.core.read.ListAppender; import ch.qos.logback.core.spi.FilterReply; -import junit.framework.TestCase; public class CallerInformationTestCase extends TestCase { @@ -75,7 +76,7 @@ public class CallerInformationTestCase extends TestCase { public void testLocationInfo() { appender.list.clear(); // The following value must match the line number - final int currentLineNumber = 78; + final int currentLineNumber = 79; log.fatal(STRING); log.fatal(STRING, T); log.error(STRING); @@ -100,13 +101,9 @@ public class CallerInformationTestCase extends TestCase { assertTrue("Has location", callerData != null && callerData.length > 0); final StackTraceElement location = callerData[0]; assertEquals("Correct location class.", getClass().getName(), location.getClassName()); - assertEquals("Correct location line.", - currentLineNumber + 2 * lev + hasThrowable + 1, - location.getLineNumber()); + assertEquals("Correct location line.", currentLineNumber + 2 * lev + hasThrowable + 1, location.getLineNumber()); final ThrowableProxy throwableProxy = (ThrowableProxy) event.getThrowableProxy(); - assertEquals("Correct exception", - hasThrowable > 0 ? T : null, - throwableProxy != null ? throwableProxy.getThrowable() : null); + assertEquals("Correct exception", hasThrowable > 0 ? T : null, throwableProxy != null ? throwableProxy.getThrowable() : null); } } } diff --git a/src/test/java/org/apache/commons/logging/tccl/BadTCCLTestCase.java b/src/test/java/org/apache/commons/logging/tccl/BadTCCLTestCase.java index f2d8dcb..4c426f4 100644 --- a/src/test/java/org/apache/commons/logging/tccl/BadTCCLTestCase.java +++ b/src/test/java/org/apache/commons/logging/tccl/BadTCCLTestCase.java @@ -16,14 +16,14 @@ */ package org.apache.commons.logging.tccl; +import junit.framework.Test; +import junit.framework.TestCase; + 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 junit.framework.Test; -import junit.framework.TestCase; - /** * Simulates the case when TCCL is badly set and cannot load JCL. */ diff --git a/src/test/java/org/apache/commons/logging/tccl/NullTCCLTestCase.java b/src/test/java/org/apache/commons/logging/tccl/NullTCCLTestCase.java index 75ca5cf..8590d5d 100644 --- a/src/test/java/org/apache/commons/logging/tccl/NullTCCLTestCase.java +++ b/src/test/java/org/apache/commons/logging/tccl/NullTCCLTestCase.java @@ -16,13 +16,13 @@ */ package org.apache.commons.logging.tccl; +import junit.framework.Test; +import junit.framework.TestCase; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.PathableTestSuite; -import junit.framework.Test; -import junit.framework.TestCase; - /** * Simulates the case when TCCL is set to NULL. */ diff --git a/src/test/java/org/apache/commons/logging/tccl/log/TcclDisabledTestCase.java b/src/test/java/org/apache/commons/logging/tccl/log/TcclDisabledTestCase.java index 8a787fe..9a2798e 100644 --- a/src/test/java/org/apache/commons/logging/tccl/log/TcclDisabledTestCase.java +++ b/src/test/java/org/apache/commons/logging/tccl/log/TcclDisabledTestCase.java @@ -19,15 +19,15 @@ package org.apache.commons.logging.tccl.log; import java.net.URL; +import junit.framework.Test; +import junit.framework.TestCase; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogConfigurationException; import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableTestSuite; -import junit.framework.Test; -import junit.framework.TestCase; - /** * Verify that by default LogFactoryImpl is loaded from the tccl class loader. */ diff --git a/src/test/java/org/apache/commons/logging/tccl/log/TcclEnabledTestCase.java b/src/test/java/org/apache/commons/logging/tccl/log/TcclEnabledTestCase.java index 3aea5e5..4a49113 100644 --- a/src/test/java/org/apache/commons/logging/tccl/log/TcclEnabledTestCase.java +++ b/src/test/java/org/apache/commons/logging/tccl/log/TcclEnabledTestCase.java @@ -19,14 +19,14 @@ package org.apache.commons.logging.tccl.log; import java.net.URL; +import junit.framework.Test; +import junit.framework.TestCase; + 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 junit.framework.Test; -import junit.framework.TestCase; - /** * Verify that by default the standard LogFactoryImpl class loads a * custom Log implementation via the TCCL. diff --git a/src/test/java/org/apache/commons/logging/tccl/logfactory/TcclDisabledTestCase.java b/src/test/java/org/apache/commons/logging/tccl/logfactory/TcclDisabledTestCase.java index e8f2e88..5273668 100644 --- a/src/test/java/org/apache/commons/logging/tccl/logfactory/TcclDisabledTestCase.java +++ b/src/test/java/org/apache/commons/logging/tccl/logfactory/TcclDisabledTestCase.java @@ -19,13 +19,13 @@ package org.apache.commons.logging.tccl.logfactory; import java.net.URL; +import junit.framework.Test; +import junit.framework.TestCase; + import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableTestSuite; -import junit.framework.Test; -import junit.framework.TestCase; - /** * Verify that a commons-logging.properties file can prevent a custom * LogFactoryImpl being loaded from the tccl class loader. diff --git a/src/test/java/org/apache/commons/logging/tccl/logfactory/TcclEnabledTestCase.java b/src/test/java/org/apache/commons/logging/tccl/logfactory/TcclEnabledTestCase.java index 0088070..990d05f 100644 --- a/src/test/java/org/apache/commons/logging/tccl/logfactory/TcclEnabledTestCase.java +++ b/src/test/java/org/apache/commons/logging/tccl/logfactory/TcclEnabledTestCase.java @@ -19,13 +19,13 @@ package org.apache.commons.logging.tccl.logfactory; import java.net.URL; +import junit.framework.Test; +import junit.framework.TestCase; + import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableTestSuite; -import junit.framework.Test; -import junit.framework.TestCase; - /** * Verify that by default a custom LogFactoryImpl is loaded from the * tccl class loader.