LOGGING-185: Fix failing tests (#180)
* Fix names of deployed artifacts We remove the obsolete `finalName` property and fix the Maven Failsafe executions. * Fix failing tests * Reenable integration tests * Disable SecurityManager tests on Java 21 * Simplify build workflow * Set `fail-fast` to false * Fix NPEs caused by `String.trim()` * Span a different JVM per test case
This commit is contained in:
15
.github/workflows/maven.yml
vendored
15
.github/workflows/maven.yml
vendored
@@ -26,6 +26,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
continue-on-error: ${{ matrix.experimental }}
|
continue-on-error: ${{ matrix.experimental }}
|
||||||
strategy:
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
java: [ 8, 11, 17, 21 ]
|
java: [ 8, 11, 17, 21 ]
|
||||||
experimental: [false]
|
experimental: [false]
|
||||||
@@ -34,19 +35,15 @@ jobs:
|
|||||||
# experimental: true
|
# experimental: true
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
- name: Checkout repository
|
||||||
with:
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||||
persist-credentials: false
|
|
||||||
- uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
|
|
||||||
with:
|
|
||||||
path: ~/.m2/repository
|
|
||||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-maven-
|
|
||||||
- name: Set up JDK ${{ matrix.java }}
|
- name: Set up JDK ${{ matrix.java }}
|
||||||
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
|
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
|
||||||
with:
|
with:
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
java-version: ${{ matrix.java }}
|
java-version: ${{ matrix.java }}
|
||||||
|
cache: 'maven'
|
||||||
|
|
||||||
- name: Build with Maven
|
- name: Build with Maven
|
||||||
run: mvn --show-version --batch-mode --no-transfer-progress -Ddoclint=none
|
run: mvn --show-version --batch-mode --no-transfer-progress -Ddoclint=none
|
||||||
|
|||||||
71
pom.xml
71
pom.xml
@@ -199,7 +199,7 @@ under the License.
|
|||||||
<!-- TODO spotbugs:check -->
|
<!-- TODO spotbugs:check -->
|
||||||
<!-- TODO replace clirr:check with japicmp:cmp -->
|
<!-- TODO replace clirr:check with japicmp:cmp -->
|
||||||
<!-- The verify goal causes build failures currently, so stop at package for now -->
|
<!-- The verify goal causes build failures currently, so stop at package for now -->
|
||||||
<defaultGoal>clean package apache-rat:check japicmp:cmp javadoc:javadoc checkstyle:check</defaultGoal>
|
<defaultGoal>clean verify apache-rat:check japicmp:cmp javadoc:javadoc checkstyle:check</defaultGoal>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
@@ -218,24 +218,20 @@ under the License.
|
|||||||
- The custom test framework requires the unit test code to be
|
- The custom test framework requires the unit test code to be
|
||||||
- in a jarfile so it can control its place in the classpath.
|
- in a jarfile so it can control its place in the classpath.
|
||||||
-->
|
-->
|
||||||
<id>testjar</id>
|
<id>create-test-jar</id>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>test-jar</goal>
|
<goal>test-jar</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
|
||||||
<finalName>commons-logging</finalName>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
</execution>
|
||||||
|
|
||||||
<execution>
|
<execution>
|
||||||
<id>apijar</id>
|
<id>create-api-jar</id>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>jar</goal>
|
<goal>jar</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<finalName>${project.artifactId}-api-${project.version}</finalName>
|
|
||||||
<classifier>api</classifier>
|
<classifier>api</classifier>
|
||||||
<includes>
|
<includes>
|
||||||
<include>org/apache/commons/logging/*.class</include>
|
<include>org/apache/commons/logging/*.class</include>
|
||||||
@@ -254,13 +250,12 @@ under the License.
|
|||||||
</execution>
|
</execution>
|
||||||
|
|
||||||
<execution>
|
<execution>
|
||||||
<id>adaptersjar</id>
|
<id>create-adapters-jar</id>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>jar</goal>
|
<goal>jar</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<finalName>${project.artifactId}-adapters-${project.version}</finalName>
|
|
||||||
<classifier>adapters</classifier>
|
<classifier>adapters</classifier>
|
||||||
<includes>
|
<includes>
|
||||||
<include>org/apache/commons/logging/impl/**.class</include>
|
<include>org/apache/commons/logging/impl/**.class</include>
|
||||||
@@ -273,22 +268,6 @@ under the License.
|
|||||||
</excludes>
|
</excludes>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
|
||||||
<!--
|
|
||||||
- Define the full jar last, the deploy/install plugin seems to be broken
|
|
||||||
- and takes the last definition from here.
|
|
||||||
-->
|
|
||||||
<execution>
|
|
||||||
<id>fulljar</id>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>jar</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<finalName>${project.artifactId}-${project.version}</finalName>
|
|
||||||
<classifier>full</classifier>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
</executions>
|
||||||
<configuration>
|
<configuration>
|
||||||
<archive combine.children="append">
|
<archive combine.children="append">
|
||||||
@@ -322,38 +301,6 @@ under the License.
|
|||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<!--
|
|
||||||
- Attach the adapters and api jars to the normal artifact. This way
|
|
||||||
- they will be deployed when the normal artifact is deployed.
|
|
||||||
-->
|
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
|
||||||
<artifactId>build-helper-maven-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>attach-artifacts</id>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>attach-artifact</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<artifacts>
|
|
||||||
<artifact>
|
|
||||||
<file>${project.build.directory}/${project.artifactId}-adapters-${project.version}.jar</file>
|
|
||||||
<type>jar</type>
|
|
||||||
<classifier>adapters</classifier>
|
|
||||||
</artifact>
|
|
||||||
<artifact>
|
|
||||||
<file>${project.build.directory}/${project.artifactId}-api-${project.version}.jar</file>
|
|
||||||
<type>jar</type>
|
|
||||||
<classifier>api</classifier>
|
|
||||||
</artifact>
|
|
||||||
</artifacts>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<!--
|
<!--
|
||||||
- Many of JCL's tests use tricky techniques to place the generated
|
- Many of JCL's tests use tricky techniques to place the generated
|
||||||
@@ -398,6 +345,10 @@ under the License.
|
|||||||
-->
|
-->
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-failsafe-plugin</artifactId>
|
<artifactId>maven-failsafe-plugin</artifactId>
|
||||||
|
<!-- Span a different JVM per test -->
|
||||||
|
<configuration>
|
||||||
|
<reuseForks>false</reuseForks>
|
||||||
|
</configuration>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>integration-test</id>
|
<id>integration-test</id>
|
||||||
@@ -428,9 +379,9 @@ under the License.
|
|||||||
<logkit>${logkit:logkit:jar}</logkit>
|
<logkit>${logkit:logkit:jar}</logkit>
|
||||||
<servlet-api>${javax.servlet:servlet-api:jar}</servlet-api>
|
<servlet-api>${javax.servlet:servlet-api:jar}</servlet-api>
|
||||||
<commons-logging>target/${project.build.finalName}.jar</commons-logging>
|
<commons-logging>target/${project.build.finalName}.jar</commons-logging>
|
||||||
<commons-logging-api>target/${project.artifactId}-api-${project.version}.jar</commons-logging-api>
|
<commons-logging-api>target/${project.build.finalName}-api.jar</commons-logging-api>
|
||||||
<commons-logging-adapters>target/${project.artifactId}-adapters-${project.version}.jar</commons-logging-adapters>
|
<commons-logging-adapters>target/${project.build.finalName}-adapters.jar</commons-logging-adapters>
|
||||||
<testclasses>target/commons-logging-tests.jar</testclasses>
|
<testclasses>target/${project.build.finalName}-tests.jar</testclasses>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
|||||||
@@ -434,7 +434,7 @@ public class LogFactoryImpl extends LogFactory {
|
|||||||
final String msg = e.getMessage();
|
final String msg = e.getMessage();
|
||||||
logDiagnostic("The log adapter '" + logAdapterClassName +
|
logDiagnostic("The log adapter '" + logAdapterClassName +
|
||||||
"' is missing dependencies when loaded via classloader " + objectId(currentCL) +
|
"' is missing dependencies when loaded via classloader " + objectId(currentCL) +
|
||||||
": " + msg.trim());
|
": " + trim(msg));
|
||||||
break;
|
break;
|
||||||
} catch (final ExceptionInInitializerError e) {
|
} catch (final ExceptionInInitializerError e) {
|
||||||
// A static initializer block or the initializer code associated
|
// A static initializer block or the initializer code associated
|
||||||
@@ -446,7 +446,7 @@ public class LogFactoryImpl extends LogFactory {
|
|||||||
final String msg = e.getMessage();
|
final String msg = e.getMessage();
|
||||||
logDiagnostic("The log adapter '" + logAdapterClassName +
|
logDiagnostic("The log adapter '" + logAdapterClassName +
|
||||||
"' is unable to initialize itself when loaded via classloader " + objectId(currentCL) +
|
"' is unable to initialize itself when loaded via classloader " + objectId(currentCL) +
|
||||||
": " + msg.trim());
|
": " + trim(msg));
|
||||||
break;
|
break;
|
||||||
} catch (final LogConfigurationException e) {
|
} catch (final LogConfigurationException e) {
|
||||||
// call to handleFlawedHierarchy above must have thrown
|
// call to handleFlawedHierarchy above must have thrown
|
||||||
|
|||||||
52
src/test/java/org/apache/commons/logging/Artifacts.java
Normal file
52
src/test/java/org/apache/commons/logging/Artifacts.java
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* 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 java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Helper class to retrieve the names of all this project artifacts.
|
||||||
|
*/
|
||||||
|
public final class Artifacts {
|
||||||
|
|
||||||
|
private static final String ARTIFACT_ID = "commons-logging";
|
||||||
|
private static final String VERSION;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try (final InputStream pomProperties = Artifacts.class.getResourceAsStream(
|
||||||
|
"/META-INF/maven/commons-logging/commons-logging/pom.properties")) {
|
||||||
|
final Properties props = new Properties();
|
||||||
|
props.load(pomProperties);
|
||||||
|
VERSION = props.getProperty("version");
|
||||||
|
} catch (final IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getMainJarName() {
|
||||||
|
return ARTIFACT_ID + "-" + VERSION + ".jar";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getAdaptersJarName() {
|
||||||
|
return ARTIFACT_ID + "-" + VERSION + "-adapters.jar";
|
||||||
|
}
|
||||||
|
|
||||||
|
private Artifacts() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.commons.logging;
|
package org.apache.commons.logging;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -184,8 +185,12 @@ public class LoadTestCase extends TestCase{
|
|||||||
setAllowFlawedContext(cls, "false");
|
setAllowFlawedContext(cls, "false");
|
||||||
execute(cls);
|
execute(cls);
|
||||||
fail("Logging config succeeded when context classloader was null!");
|
fail("Logging config succeeded when context classloader was null!");
|
||||||
} catch (final LogConfigurationException ex) {
|
} catch (final InvocationTargetException ex) {
|
||||||
// expected; the boot classloader doesn't *have* JCL available
|
final Throwable targetException = ex.getTargetException();
|
||||||
|
// LogConfigurationException is expected; the boot classloader doesn't *have* JCL available
|
||||||
|
if (!(targetException instanceof LogConfigurationException)) {
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Context classloader is the system classloader.
|
// Context classloader is the system classloader.
|
||||||
@@ -209,8 +214,12 @@ public class LoadTestCase extends TestCase{
|
|||||||
execute(cls);
|
execute(cls);
|
||||||
fail("Error: somehow downcast a Logger loaded via system classloader"
|
fail("Error: somehow downcast a Logger loaded via system classloader"
|
||||||
+ " to the Log interface loaded via a custom classloader");
|
+ " to the Log interface loaded via a custom classloader");
|
||||||
} catch (final LogConfigurationException ex) {
|
} catch (final InvocationTargetException ex) {
|
||||||
// expected
|
final Throwable targetException = ex.getTargetException();
|
||||||
|
// LogConfigurationException is expected
|
||||||
|
if (!(targetException instanceof LogConfigurationException)) {
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import java.util.Collections;
|
|||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A ClassLoader which sees only specified classes, and which can be
|
* A ClassLoader which sees only specified classes, and which can be
|
||||||
@@ -121,7 +122,11 @@ public class PathableClassLoader extends URLClassLoader {
|
|||||||
final String fileName = System.getProperty(logicalLib);
|
final String fileName = System.getProperty(logicalLib);
|
||||||
if (fileName != null) {
|
if (fileName != null) {
|
||||||
try {
|
try {
|
||||||
final URL libUrl = new File(fileName).toURL();
|
final File file = new File(fileName);
|
||||||
|
if (!file.exists()) {
|
||||||
|
Assert.fail("Unable to add logical library " + fileName);
|
||||||
|
}
|
||||||
|
final URL libUrl = file.toURL();
|
||||||
addURL(libUrl);
|
addURL(libUrl);
|
||||||
return;
|
return;
|
||||||
} catch (final java.net.MalformedURLException e) {
|
} catch (final java.net.MalformedURLException e) {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import java.util.Set;
|
|||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
@@ -42,6 +43,7 @@ import org.apache.commons.logging.PathableTestSuite;
|
|||||||
|
|
||||||
public class ChildFirstTestCase extends TestCase {
|
public class ChildFirstTestCase extends TestCase {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up a custom classloader hierarchy for this test case.
|
* Sets up a custom classloader hierarchy for this test case.
|
||||||
* The hierarchy is:
|
* The hierarchy is:
|
||||||
@@ -66,6 +68,7 @@ public class ChildFirstTestCase extends TestCase {
|
|||||||
// this class, so use that as the source for future access to classes
|
// this class, so use that as the source for future access to classes
|
||||||
// from the junit package.
|
// from the junit package.
|
||||||
parent.useExplicitLoader("junit.", thisClassLoader);
|
parent.useExplicitLoader("junit.", thisClassLoader);
|
||||||
|
parent.useExplicitLoader("org.junit.", thisClassLoader);
|
||||||
|
|
||||||
// Make the commons-logging.jar classes visible via the parent
|
// Make the commons-logging.jar classes visible via the parent
|
||||||
parent.addLogicalLib("commons-logging");
|
parent.addLogicalLib("commons-logging");
|
||||||
@@ -230,7 +233,7 @@ public class ChildFirstTestCase extends TestCase {
|
|||||||
resource = childLoader.getResource("org/apache/commons/logging/impl/Log4JLogger.class");
|
resource = childLoader.getResource("org/apache/commons/logging/impl/Log4JLogger.class");
|
||||||
assertNotNull("Unable to locate Log4JLogger.class resource", resource);
|
assertNotNull("Unable to locate Log4JLogger.class resource", resource);
|
||||||
assertTrue("Incorrect source for Log4JLogger class",
|
assertTrue("Incorrect source for Log4JLogger class",
|
||||||
resource.toString().indexOf("/commons-logging-adapters-1.") > 0);
|
resource.toString().indexOf(Artifacts.getAdaptersJarName()) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -310,8 +313,8 @@ public class ChildFirstTestCase extends TestCase {
|
|||||||
urlsToStrings[1] = urls[1].toString();
|
urlsToStrings[1] = urls[1].toString();
|
||||||
Arrays.sort(urlsToStrings);
|
Arrays.sort(urlsToStrings);
|
||||||
assertTrue("Incorrect source for Log4JLogger class",
|
assertTrue("Incorrect source for Log4JLogger class",
|
||||||
urlsToStrings[0].indexOf("/commons-logging-1.") > 0);
|
urlsToStrings[0].indexOf(Artifacts.getAdaptersJarName()) > 0);
|
||||||
assertTrue("Incorrect source for Log4JLogger class",
|
assertTrue("Incorrect source for Log4JLogger class",
|
||||||
urlsToStrings[1].indexOf("/commons-logging-adapters-1.") > 0);
|
urlsToStrings[1].indexOf(Artifacts.getMainJarName()) > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import java.util.Set;
|
|||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
@@ -67,6 +68,7 @@ public class ParentFirstTestCase extends TestCase {
|
|||||||
// this class, so use that as the source for future access to classes
|
// this class, so use that as the source for future access to classes
|
||||||
// from the junit package.
|
// from the junit package.
|
||||||
parent.useExplicitLoader("junit.", thisClassLoader);
|
parent.useExplicitLoader("junit.", thisClassLoader);
|
||||||
|
parent.useExplicitLoader("org.junit.", thisClassLoader);
|
||||||
|
|
||||||
// make the commons-logging.jar classes visible via the parent
|
// make the commons-logging.jar classes visible via the parent
|
||||||
parent.addLogicalLib("commons-logging");
|
parent.addLogicalLib("commons-logging");
|
||||||
@@ -228,7 +230,7 @@ public class ParentFirstTestCase extends TestCase {
|
|||||||
resource = childLoader.getResource("org/apache/commons/logging/impl/Log4JLogger.class");
|
resource = childLoader.getResource("org/apache/commons/logging/impl/Log4JLogger.class");
|
||||||
assertNotNull("Unable to locate Log4JLogger.class resource", resource);
|
assertNotNull("Unable to locate Log4JLogger.class resource", resource);
|
||||||
assertTrue("Incorrect source for Log4JLogger class",
|
assertTrue("Incorrect source for Log4JLogger class",
|
||||||
resource.toString().indexOf("/commons-logging-1.") > 0);
|
resource.toString().indexOf(Artifacts.getMainJarName()) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -301,9 +303,9 @@ public class ParentFirstTestCase extends TestCase {
|
|||||||
urlsToStrings[1] = urls[1].toString();
|
urlsToStrings[1] = urls[1].toString();
|
||||||
Arrays.sort(urlsToStrings);
|
Arrays.sort(urlsToStrings);
|
||||||
assertTrue("Incorrect source for Log4JLogger class",
|
assertTrue("Incorrect source for Log4JLogger class",
|
||||||
urlsToStrings[0].indexOf("/commons-logging-1.") > 0);
|
urlsToStrings[0].indexOf(Artifacts.getAdaptersJarName()) > 0);
|
||||||
assertTrue("Incorrect source for Log4JLogger class",
|
assertTrue("Incorrect source for Log4JLogger class",
|
||||||
urlsToStrings[1].indexOf("/commons-logging-adapters-1.") > 0);
|
urlsToStrings[1].indexOf(Artifacts.getMainJarName()) > 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ 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.junit.Assume;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
@@ -87,6 +88,10 @@ public class SecurityAllowedTestCase extends TestCase
|
|||||||
* overrides should take effect.
|
* overrides should take effect.
|
||||||
*/
|
*/
|
||||||
public void testAllAllowed() {
|
public void testAllAllowed() {
|
||||||
|
// Ignore on Java 21
|
||||||
|
if (System.getProperty("java.version").startsWith("21.")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
System.setProperty(
|
System.setProperty(
|
||||||
LogFactory.HASHTABLE_IMPLEMENTATION_PROPERTY,
|
LogFactory.HASHTABLE_IMPLEMENTATION_PROPERTY,
|
||||||
CustomHashtable.class.getName());
|
CustomHashtable.class.getName());
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ 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.junit.Assume;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
@@ -63,6 +64,7 @@ public class SecurityForbiddenTestCase extends TestCase
|
|||||||
public static Test suite() throws Exception {
|
public static Test suite() throws Exception {
|
||||||
final PathableClassLoader parent = new PathableClassLoader(null);
|
final PathableClassLoader parent = new PathableClassLoader(null);
|
||||||
parent.useExplicitLoader("junit.", Test.class.getClassLoader());
|
parent.useExplicitLoader("junit.", Test.class.getClassLoader());
|
||||||
|
parent.useExplicitLoader("org.junit.", Test.class.getClassLoader());
|
||||||
parent.addLogicalLib("commons-logging");
|
parent.addLogicalLib("commons-logging");
|
||||||
parent.addLogicalLib("testclasses");
|
parent.addLogicalLib("testclasses");
|
||||||
|
|
||||||
@@ -117,6 +119,10 @@ public class SecurityForbiddenTestCase extends TestCase
|
|||||||
* should fall back to the built-in defaults.
|
* should fall back to the built-in defaults.
|
||||||
*/
|
*/
|
||||||
public void testAllForbidden() {
|
public void testAllForbidden() {
|
||||||
|
// Ignore on Java 21
|
||||||
|
if (System.getProperty("java.version").startsWith("21.")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
System.setProperty(
|
System.setProperty(
|
||||||
LogFactory.HASHTABLE_IMPLEMENTATION_PROPERTY,
|
LogFactory.HASHTABLE_IMPLEMENTATION_PROPERTY,
|
||||||
CustomHashtable.class.getName());
|
CustomHashtable.class.getName());
|
||||||
@@ -166,6 +172,10 @@ public class SecurityForbiddenTestCase extends TestCase
|
|||||||
* than the context classloader of the current thread tries to log something.
|
* than the context classloader of the current thread tries to log something.
|
||||||
*/
|
*/
|
||||||
public void testContextClassLoader() {
|
public void testContextClassLoader() {
|
||||||
|
// Ignore on Java 21
|
||||||
|
if (System.getProperty("java.version").startsWith("21.")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
System.setProperty(
|
System.setProperty(
|
||||||
LogFactory.HASHTABLE_IMPLEMENTATION_PROPERTY,
|
LogFactory.HASHTABLE_IMPLEMENTATION_PROPERTY,
|
||||||
CustomHashtable.class.getName());
|
CustomHashtable.class.getName());
|
||||||
|
|||||||
Reference in New Issue
Block a user