1
0

Merge branch 'master' into release

This commit is contained in:
Gary Gregory
2024-05-11 17:28:37 +00:00
38 changed files with 149 additions and 105 deletions

View File

@@ -46,6 +46,7 @@ The <action> type attribute can be add,update,fix,remove.
<release version="1.3.2" date="2024-05-11" description="This is a feature and maintenance release. Java 8 or later is required."> <release version="1.3.2" date="2024-05-11" description="This is a feature and maintenance release. Java 8 or later is required.">
<action dev="ggregory" issue="LOGGING-190" type="fix" due-to="Hannes Wellmann, Gary Gregory, Johan Compagner">Add OSGi metadata to enable Service Loader Mediator #234.</action> <action dev="ggregory" issue="LOGGING-190" type="fix" due-to="Hannes Wellmann, Gary Gregory, Johan Compagner">Add OSGi metadata to enable Service Loader Mediator #234.</action>
<action dev="ggregory" issue="LOGGING-191" type="fix" due-to="Hannes Wellmann, Gary Gregory, Johan Compagner">Apache commons logging shows 1.4 as latest release instead of 1.3.1.</action> <action dev="ggregory" issue="LOGGING-191" type="fix" due-to="Hannes Wellmann, Gary Gregory, Johan Compagner">Apache commons logging shows 1.4 as latest release instead of 1.3.1.</action>
<action dev="ggregory" type="fix" due-to="Gary Gregory">Deprecate org.apache.commons.logging.LogSource.jdk14IsAvailable.</action>
<!-- UPDATE --> <!-- UPDATE -->
<action dev="ggregory" type="update" due-to="Dependabot">Bump org.apache.commons:commons-parent from 67 to 69 #240.</action> <action dev="ggregory" type="update" due-to="Dependabot">Bump org.apache.commons:commons-parent from 67 to 69 #240.</action>
<action dev="ggregory" type="update" due-to="Dependabot">Bump org.slf4j:slf4j-api from 2.0.12 to 2.0.13 #248.</action> <action dev="ggregory" type="update" due-to="Dependabot">Bump org.slf4j:slf4j-api from 2.0.12 to 2.0.13 #248.</action>

View File

@@ -1428,8 +1428,7 @@ public abstract class LogFactory {
// Note that any unchecked exceptions thrown by the createFactory // Note that any unchecked exceptions thrown by the createFactory
// method will propagate out of this method; in particular a // method will propagate out of this method; in particular a
// ClassCastException can be thrown. // ClassCastException can be thrown.
final Object result = AccessController.doPrivileged( final Object result = AccessController.doPrivileged((PrivilegedAction<?>) () -> createFactory(factoryClass, classLoader));
(PrivilegedAction) () -> createFactory(factoryClass, classLoader));
if (result instanceof LogConfigurationException) { if (result instanceof LogConfigurationException) {
final LogConfigurationException ex = (LogConfigurationException) result; final LogConfigurationException ex = (LogConfigurationException) result;
@@ -1439,8 +1438,7 @@ public abstract class LogFactory {
throw ex; throw ex;
} }
if (isDiagnosticsEnabled()) { if (isDiagnosticsEnabled()) {
logDiagnostic("Created object " + objectId(result) + " to manage class loader " + logDiagnostic("Created object " + objectId(result) + " to manage class loader " + objectId(contextClassLoader));
objectId(contextClassLoader));
} }
return (LogFactory) result; return (LogFactory) result;
} }

View File

@@ -61,8 +61,13 @@ public class LogSource {
/** Is Log4j available (in the current classpath) */ /** Is Log4j available (in the current classpath) */
static protected boolean log4jIsAvailable; 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 */ /** Constructor for current log class */
static protected Constructor<?> logImplctor; static protected Constructor<?> logImplctor;
@@ -77,9 +82,6 @@ public class LogSource {
// Is Log4J Available? // Is Log4J Available?
log4jIsAvailable = isClassForName("org.apache.log4j.Logger"); 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 // Set the default Log implementation
String name = null; String name = null;
try { try {
@@ -104,10 +106,8 @@ public class LogSource {
try { try {
if (log4jIsAvailable) { if (log4jIsAvailable) {
setLogImplementation("org.apache.commons.logging.impl.Log4JLogger"); setLogImplementation("org.apache.commons.logging.impl.Log4JLogger");
} else if (jdk14IsAvailable) {
setLogImplementation("org.apache.commons.logging.impl.Jdk14Logger");
} else { } else {
setLogImplementation("org.apache.commons.logging.impl.NoOpLog"); setLogImplementation("org.apache.commons.logging.impl.Jdk14Logger");
} }
} catch (final Throwable t) { } catch (final Throwable t) {
try { try {

View File

@@ -183,6 +183,13 @@ public final class Log4jApiLogFactory extends LogFactory {
private final ConcurrentMap<String, Object> attributes = new ConcurrentHashMap<>(); private final ConcurrentMap<String, Object> attributes = new ConcurrentHashMap<>();
/**
* Constructs a new instance.
*/
public Log4jApiLogFactory() {
// empty
}
@Override @Override
public Object getAttribute(final String name) { public Object getAttribute(final String name) {
return attributes.get(name); return attributes.get(name);

View File

@@ -50,6 +50,13 @@ public class ServletContextCleaner implements ServletContextListener {
private static final Class<?>[] RELEASE_SIGNATURE = { ClassLoader.class }; 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 * Invoked when a webapp is undeployed, this tells the LogFactory
* class to release any logging information related to the current * class to release any logging information related to the current

View File

@@ -266,6 +266,13 @@ public final class Slf4jLogFactory extends LogFactory {
private final ConcurrentMap<String, Object> attributes = new ConcurrentHashMap<>(); private final ConcurrentMap<String, Object> attributes = new ConcurrentHashMap<>();
/**
* Constructs a new instance.
*/
public Slf4jLogFactory() {
// empty
}
@Override @Override
public Object getAttribute(final String name) { public Object getAttribute(final String name) {
return attributes.get(name); return attributes.get(name);
@@ -303,6 +310,7 @@ public final class Slf4jLogFactory extends LogFactory {
try { try {
factory.getClass().getMethod("stop").invoke(factory); factory.getClass().getMethod("stop").invoke(factory);
} catch (final ReflectiveOperationException ignored) { } catch (final ReflectiveOperationException ignored) {
// empty
} }
} }

View File

@@ -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);
}
}

View File

@@ -16,14 +16,14 @@
*/ */
package org.apache.commons.logging.avalon; package org.apache.commons.logging.avalon;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.avalon.framework.logger.NullLogger; import org.apache.avalon.framework.logger.NullLogger;
import org.apache.commons.logging.AbstractLogTest; import org.apache.commons.logging.AbstractLogTest;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.impl.AvalonLogger; import org.apache.commons.logging.impl.AvalonLogger;
import junit.framework.Test;
import junit.framework.TestSuite;
/** /**
*/ */
public class AvalonLoggerTestCase extends AbstractLogTest { public class AvalonLoggerTestCase extends AbstractLogTest {

View File

@@ -19,13 +19,13 @@ package org.apache.commons.logging.config;
import java.net.URL; import java.net.URL;
import junit.framework.Test;
import junit.framework.TestCase;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite; 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 * Tests that verify that the process of configuring logging on startup
* works correctly by selecting the file with the highest priority. * works correctly by selecting the file with the highest priority.

View File

@@ -19,13 +19,13 @@ package org.apache.commons.logging.config;
import java.net.URL; import java.net.URL;
import junit.framework.Test;
import junit.framework.TestCase;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite; 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 * Tests that verify that the process of configuring logging on startup
* works correctly by selecting the file with the highest priority. * works correctly by selecting the file with the highest priority.

View File

@@ -17,11 +17,11 @@
package org.apache.commons.logging.jdk14; package org.apache.commons.logging.jdk14;
import junit.framework.Test;
import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite; import org.apache.commons.logging.PathableTestSuite;
import junit.framework.Test;
/** /**
* TestCase for Jdk14 logging when the commons-logging-api jar file is in * TestCase for Jdk14 logging when the commons-logging-api jar file is in
* the parent classpath and commons-logging.jar is in the child. * the parent classpath and commons-logging.jar is in the child.

View File

@@ -17,11 +17,11 @@
package org.apache.commons.logging.jdk14; package org.apache.commons.logging.jdk14;
import junit.framework.Test;
import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite; import org.apache.commons.logging.PathableTestSuite;
import junit.framework.Test;
/** /**
* TestCase for Jdk14 logging when the commons-logging jar file is in * TestCase for Jdk14 logging when the commons-logging jar file is in
* the parent classpath. * the parent classpath.

View File

@@ -27,12 +27,12 @@ import java.util.logging.LogManager;
import java.util.logging.LogRecord; import java.util.logging.LogRecord;
import java.util.logging.Logger; import java.util.logging.Logger;
import junit.framework.Test;
import org.apache.commons.logging.DummyException; import org.apache.commons.logging.DummyException;
import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite; import org.apache.commons.logging.PathableTestSuite;
import junit.framework.Test;
/** /**
* <p>TestCase for JDK 1.4 logging when running on a JDK 1.4 system with * <p>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 * custom configuration, so that JDK 1.4 should be selected and an appropriate

View File

@@ -22,14 +22,14 @@ import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import junit.framework.Test;
import junit.framework.TestCase;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite; import org.apache.commons.logging.PathableTestSuite;
import junit.framework.Test;
import junit.framework.TestCase;
/** /**
* <p>TestCase for JDK 1.4 logging when running on a JDK 1.4 system with * <p>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 * zero configuration, and with Log4J not present (so JDK 1.4 logging

View File

@@ -24,12 +24,12 @@ import java.io.ObjectOutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import junit.framework.TestCase;
import org.apache.commons.logging.DummyException; import org.apache.commons.logging.DummyException;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import junit.framework.TestCase;
/** /**
* Abstract set of tests that can be executed with various classpaths set. * Abstract set of tests that can be executed with various classpaths set.
* <p> * <p>

View File

@@ -17,14 +17,14 @@
package org.apache.commons.logging.log4j.log4j12; 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.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite; import org.apache.commons.logging.PathableTestSuite;
import org.apache.commons.logging.impl.Log4JLogger; import org.apache.commons.logging.impl.Log4JLogger;
import org.apache.commons.logging.impl.LogFactoryImpl; 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 * Tests for Log4J logging that emulate a webapp running within
* a container where the commons-logging-api jar file is in * a container where the commons-logging-api jar file is in

View File

@@ -17,14 +17,14 @@
package org.apache.commons.logging.log4j.log4j12; 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.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite; import org.apache.commons.logging.PathableTestSuite;
import org.apache.commons.logging.impl.Log4JLogger; import org.apache.commons.logging.impl.Log4JLogger;
import org.apache.commons.logging.impl.LogFactoryImpl; 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 * 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. * is in it, as would be the situation for a standalone application.

View File

@@ -17,14 +17,14 @@
package org.apache.commons.logging.log4j.log4j12; 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.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite; import org.apache.commons.logging.PathableTestSuite;
import org.apache.commons.logging.impl.Log4JLogger; import org.apache.commons.logging.impl.Log4JLogger;
import org.apache.commons.logging.impl.LogFactoryImpl; 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 * Tests for Log4J logging that emulate a webapp running within
* a container where all the necessary libs are in the child. * a container where all the necessary libs are in the child.

View File

@@ -17,14 +17,14 @@
package org.apache.commons.logging.log4j.log4j12; 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.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite; import org.apache.commons.logging.PathableTestSuite;
import org.apache.commons.logging.impl.Log4JLogger; import org.apache.commons.logging.impl.Log4JLogger;
import org.apache.commons.logging.impl.LogFactoryImpl; 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 * Tests for Log4J logging that emulate a webapp running within
* a container where all the necessary libs are in the parent. * a container where all the necessary libs are in the parent.

View File

@@ -18,6 +18,8 @@ package org.apache.commons.logging.log4j2;
import java.util.List; import java.util.List;
import junit.framework.TestCase;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.impl.Log4jApiLogFactory; 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.ObjectMessage;
import org.apache.logging.log4j.message.SimpleMessage; import org.apache.logging.log4j.message.SimpleMessage;
import junit.framework.TestCase;
public class CallerInformationTestCase extends TestCase { public class CallerInformationTestCase extends TestCase {
private static final Object OBJ = new Object(); 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 source file.", "CallerInformationTestCase.java", location.getFileName());
assertEquals("Correct method name.", "testLocationInfo", location.getMethodName()); assertEquals("Correct method name.", "testLocationInfo", location.getMethodName());
assertEquals("Correct location class.", getClass().getName(), location.getClassName()); assertEquals("Correct location class.", getClass().getName(), location.getClassName());
assertEquals("Correct location line.", assertEquals("Correct location line.", currentLineNumber + 2 * lev + hasThrowable + 1, location.getLineNumber());
currentLineNumber + 2 * lev + hasThrowable + 1,
location.getLineNumber());
assertEquals("Correct exception", hasThrowable > 0 ? T : null, event.getThrown()); assertEquals("Correct exception", hasThrowable > 0 ? T : null, event.getThrown());
} }
} }

View File

@@ -22,6 +22,8 @@ import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import junit.framework.Test;
import org.apache.commons.logging.AbstractLogTest; import org.apache.commons.logging.AbstractLogTest;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; 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.PathableTestSuite;
import org.apache.commons.logging.impl.LogKitLogger; import org.apache.commons.logging.impl.LogKitLogger;
import junit.framework.Test;
/** /**
* Basic tests for Avalon LogKit logger adapter. * Basic tests for Avalon LogKit logger adapter.
*/ */

View File

@@ -23,13 +23,13 @@ import java.util.Enumeration;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import junit.framework.Test;
import junit.framework.TestCase;
import org.apache.commons.logging.Artifacts; import org.apache.commons.logging.Artifacts;
import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite; import org.apache.commons.logging.PathableTestSuite;
import junit.framework.Test;
import junit.framework.TestCase;
/** /**
* Tests for the PathableTestSuite and PathableClassLoader functionality, * Tests for the PathableTestSuite and PathableClassLoader functionality,
* where lookup order for the PathableClassLoader is child-first. * where lookup order for the PathableClassLoader is child-first.

View File

@@ -19,12 +19,12 @@ package org.apache.commons.logging.pathable;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader; import java.net.URLClassLoader;
import org.apache.commons.logging.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.commons.logging.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite;
/** /**
* Tests for the PathableTestSuite class. * Tests for the PathableTestSuite class.
*/ */

View File

@@ -25,13 +25,13 @@ import java.util.Enumeration;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import junit.framework.Test;
import junit.framework.TestCase;
import org.apache.commons.logging.Artifacts; import org.apache.commons.logging.Artifacts;
import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite; import org.apache.commons.logging.PathableTestSuite;
import junit.framework.Test;
import junit.framework.TestCase;
/** /**
* Tests for the PathableTestSuite and PathableClassLoader functionality, * Tests for the PathableTestSuite and PathableClassLoader functionality,
* where lookup order for the PathableClassLoader is parent-first. * where lookup order for the PathableClassLoader is parent-first.

View File

@@ -24,14 +24,14 @@ import java.lang.reflect.Method;
import java.security.AllPermission; import java.security.AllPermission;
import java.util.Hashtable; import java.util.Hashtable;
import junit.framework.Test;
import junit.framework.TestCase;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite; 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. * Tests for logging with a security policy that allows JCL access to everything.
* <p> * <p>

View File

@@ -25,14 +25,14 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Hashtable; import java.util.Hashtable;
import junit.framework.Test;
import junit.framework.TestCase;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite; 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. * Tests for logging with a security policy that forbids JCL access to anything.
* <p> * <p>

View File

@@ -16,11 +16,11 @@
*/ */
package org.apache.commons.logging.serviceloader; package org.apache.commons.logging.serviceloader;
import junit.framework.TestCase;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.serviceloader.internal.DummyLogFactory; import org.apache.commons.logging.serviceloader.internal.DummyLogFactory;
import junit.framework.TestCase;
public class ServiceLoaderTestCase extends TestCase { public class ServiceLoaderTestCase extends TestCase {
public void testServiceLoader() { public void testServiceLoader() {

View File

@@ -17,13 +17,13 @@
package org.apache.commons.logging.servlet; 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.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite; import org.apache.commons.logging.PathableTestSuite;
import org.apache.commons.logging.impl.ServletContextCleaner; import org.apache.commons.logging.impl.ServletContextCleaner;
import junit.framework.Test;
import junit.framework.TestCase;
/** /**
* Tests for ServletContextCleaner utility class. * Tests for ServletContextCleaner utility class.
*/ */

View File

@@ -21,14 +21,14 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import junit.framework.Test;
import org.apache.commons.logging.DummyException; import org.apache.commons.logging.DummyException;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite; import org.apache.commons.logging.PathableTestSuite;
import org.apache.commons.logging.impl.SimpleLog; import org.apache.commons.logging.impl.SimpleLog;
import junit.framework.Test;
/** /**
* <p>TestCase for simple logging when running with custom configuration * <p>TestCase for simple logging when running with custom configuration
* properties.</p> * properties.</p>

View File

@@ -21,11 +21,11 @@ import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import junit.framework.Test;
import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite; import org.apache.commons.logging.PathableTestSuite;
import junit.framework.Test;
/** /**
* Tests custom date time format configuration * Tests custom date time format configuration
*/ */

View File

@@ -22,15 +22,15 @@ import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import junit.framework.Test;
import junit.framework.TestCase;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite; import org.apache.commons.logging.PathableTestSuite;
import org.apache.commons.logging.impl.SimpleLog; import org.apache.commons.logging.impl.SimpleLog;
import junit.framework.Test;
import junit.framework.TestCase;
/** /**
* <p>TestCase for simple logging when running with zero configuration * <p>TestCase for simple logging when running with zero configuration
* other than selecting the SimpleLog implementation.</p> * other than selecting the SimpleLog implementation.</p>

View File

@@ -20,6 +20,8 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import junit.framework.TestCase;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.impl.Slf4jLogFactory; 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.filter.Filter;
import ch.qos.logback.core.read.ListAppender; import ch.qos.logback.core.read.ListAppender;
import ch.qos.logback.core.spi.FilterReply; import ch.qos.logback.core.spi.FilterReply;
import junit.framework.TestCase;
public class CallerInformationTestCase extends TestCase { public class CallerInformationTestCase extends TestCase {
@@ -75,7 +76,7 @@ public class CallerInformationTestCase extends TestCase {
public void testLocationInfo() { public void testLocationInfo() {
appender.list.clear(); appender.list.clear();
// The following value must match the line number // The following value must match the line number
final int currentLineNumber = 78; final int currentLineNumber = 79;
log.fatal(STRING); log.fatal(STRING);
log.fatal(STRING, T); log.fatal(STRING, T);
log.error(STRING); log.error(STRING);
@@ -100,13 +101,9 @@ public class CallerInformationTestCase extends TestCase {
assertTrue("Has location", callerData != null && callerData.length > 0); assertTrue("Has location", callerData != null && callerData.length > 0);
final StackTraceElement location = callerData[0]; final StackTraceElement location = callerData[0];
assertEquals("Correct location class.", getClass().getName(), location.getClassName()); assertEquals("Correct location class.", getClass().getName(), location.getClassName());
assertEquals("Correct location line.", assertEquals("Correct location line.", currentLineNumber + 2 * lev + hasThrowable + 1, location.getLineNumber());
currentLineNumber + 2 * lev + hasThrowable + 1,
location.getLineNumber());
final ThrowableProxy throwableProxy = (ThrowableProxy) event.getThrowableProxy(); final ThrowableProxy throwableProxy = (ThrowableProxy) event.getThrowableProxy();
assertEquals("Correct exception", assertEquals("Correct exception", hasThrowable > 0 ? T : null, throwableProxy != null ? throwableProxy.getThrowable() : null);
hasThrowable > 0 ? T : null,
throwableProxy != null ? throwableProxy.getThrowable() : null);
} }
} }
} }

View File

@@ -16,14 +16,14 @@
*/ */
package org.apache.commons.logging.tccl; 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.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite; 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. * Simulates the case when TCCL is badly set and cannot load JCL.
*/ */

View File

@@ -16,13 +16,13 @@
*/ */
package org.apache.commons.logging.tccl; 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.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.PathableTestSuite; import org.apache.commons.logging.PathableTestSuite;
import junit.framework.Test;
import junit.framework.TestCase;
/** /**
* Simulates the case when TCCL is set to NULL. * Simulates the case when TCCL is set to NULL.
*/ */

View File

@@ -19,15 +19,15 @@ package org.apache.commons.logging.tccl.log;
import java.net.URL; import java.net.URL;
import junit.framework.Test;
import junit.framework.TestCase;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogConfigurationException; import org.apache.commons.logging.LogConfigurationException;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite; 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. * Verify that by default LogFactoryImpl is loaded from the tccl class loader.
*/ */

View File

@@ -19,14 +19,14 @@ package org.apache.commons.logging.tccl.log;
import java.net.URL; import java.net.URL;
import junit.framework.Test;
import junit.framework.TestCase;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite; import org.apache.commons.logging.PathableTestSuite;
import junit.framework.Test;
import junit.framework.TestCase;
/** /**
* Verify that by default the standard LogFactoryImpl class loads a * Verify that by default the standard LogFactoryImpl class loads a
* custom Log implementation via the TCCL. * custom Log implementation via the TCCL.

View File

@@ -19,13 +19,13 @@ package org.apache.commons.logging.tccl.logfactory;
import java.net.URL; import java.net.URL;
import junit.framework.Test;
import junit.framework.TestCase;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite; 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 * Verify that a commons-logging.properties file can prevent a custom
* LogFactoryImpl being loaded from the tccl class loader. * LogFactoryImpl being loaded from the tccl class loader.

View File

@@ -19,13 +19,13 @@ package org.apache.commons.logging.tccl.logfactory;
import java.net.URL; import java.net.URL;
import junit.framework.Test;
import junit.framework.TestCase;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.PathableClassLoader; import org.apache.commons.logging.PathableClassLoader;
import org.apache.commons.logging.PathableTestSuite; 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 * Verify that by default a custom LogFactoryImpl is loaded from the
* tccl class loader. * tccl class loader.