Remove extraneous module
diff --git a/log4j-api-test/pom.xml b/log4j-api-test/pom.xml
deleted file mode 100644
index 7f23e59..0000000
--- a/log4j-api-test/pom.xml
+++ /dev/null
@@ -1,124 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ 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.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>3.0.0-SNAPSHOT</version>
- <relativePath>../</relativePath>
- </parent>
- <artifactId>log4j-api-test</artifactId>
- <packaging>jar</packaging>
- <name>Apache Log4j API Test Utilities</name>
- <description>Apache Log4j API Test Utilities</description>
- <properties>
- <log4jParentDir>${basedir}/..</log4jParentDir>
- <docLabel>API Documentation</docLabel>
- <projectDir>/api</projectDir>
- <revapi.skip>true</revapi.skip>
- <maven.doap.skip>true</maven.doap.skip>
- <module.name>org.apache.logging.log4j.test</module.name>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-migrationsupport</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-params</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>compile</scope>
- <exclusions>
- <exclusion>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-core</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <scope>compile</scope>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <id>default-jar</id>
- <goals>
- <goal>jar</goal>
- </goals>
- <configuration combine.self="override">
- </configuration>
- </execution>
- </executions>
- </plugin>
- <!-- Include the standard NOTICE and LICENSE -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-remote-resources-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>process</goal>
- </goals>
- <configuration>
- <skip>false</skip>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-deploy-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- <plugin>
- <groupId>com.github.spotbugs</groupId>
- <artifactId>spotbugs-maven-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
-
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/AbstractExternalFileCleaner.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/AbstractExternalFileCleaner.java
deleted file mode 100644
index c144b35..0000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/AbstractExternalFileCleaner.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * 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.logging.log4j.test.junit;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.junit.Assert;
-import org.junit.rules.ExternalResource;
-
-/**
- * This class should not perform logging using Log4j to avoid accidentally
- * loading or re-loading Log4j configurations.
- */
-public abstract class AbstractExternalFileCleaner extends ExternalResource {
-
- protected static final String CLEANER_MARKER = "CLEANER";
-
- private static final int SLEEP_RETRY_MILLIS = 200;
- private final boolean cleanAfter;
- private final boolean cleanBefore;
- private final Set<Path> files;
- private final int maxTries;
- private final PrintStream printStream;
-
- public AbstractExternalFileCleaner(final boolean before, final boolean after, final int maxTries,
- final PrintStream logger, final File... files) {
- this.cleanBefore = before;
- this.cleanAfter = after;
- this.maxTries = maxTries;
- this.files = new HashSet<>(files.length);
- this.printStream = logger;
- for (final File file : files) {
- this.files.add(file.toPath());
- }
- }
-
- public AbstractExternalFileCleaner(final boolean before, final boolean after, final int maxTries,
- final PrintStream logger, final Path... files) {
- this.cleanBefore = before;
- this.cleanAfter = after;
- this.maxTries = maxTries;
- this.printStream = logger;
- this.files = new HashSet<>(Arrays.asList(files));
- }
-
- public AbstractExternalFileCleaner(final boolean before, final boolean after, final int maxTries,
- final PrintStream logger, final String... fileNames) {
- this.cleanBefore = before;
- this.cleanAfter = after;
- this.maxTries = maxTries;
- this.printStream = logger;
- this.files = new HashSet<>(fileNames.length);
- for (final String fileName : fileNames) {
- this.files.add(Paths.get(fileName));
- }
- }
-
- @Override
- protected void after() {
- if (cleanAfter()) {
- this.clean();
- }
- }
-
- @Override
- protected void before() {
- if (cleanBefore()) {
- this.clean();
- }
- }
-
- protected void clean() {
- final Map<Path, IOException> failures = new HashMap<>();
- // Clean and gather failures
- for (final Path path : getPaths()) {
- if (Files.exists(path)) {
- for (int i = 0; i < getMaxTries(); i++) {
- try {
- if (clean(path, i)) {
- if (failures.containsKey(path)) {
- failures.remove(path);
- }
- break;
- }
- } catch (final IOException e) {
- println(CLEANER_MARKER + ": Caught exception cleaning: " + this);
- printStackTrace(e);
- // We will try again.
- failures.put(path, e);
- }
- try {
- Thread.sleep(SLEEP_RETRY_MILLIS);
- } catch (final InterruptedException ignored) {
- // ignore
- }
- }
- }
- }
- // Fail on failures
- if (failures.size() > 0) {
- final StringBuilder sb = new StringBuilder();
- boolean first = true;
- for (final Map.Entry<Path, IOException> failure : failures.entrySet()) {
- failure.getValue().printStackTrace();
- if (!first) {
- sb.append(", ");
- }
- sb.append(failure.getKey()).append(" failed with ").append(failure.getValue());
- first = false;
- }
- Assert.fail(sb.toString());
- }
- }
-
- protected abstract boolean clean(Path path, int tryIndex) throws IOException;
-
- public boolean cleanAfter() {
- return cleanAfter;
- }
-
- public boolean cleanBefore() {
- return cleanBefore;
- }
-
- public int getMaxTries() {
- return maxTries;
- }
-
- public Set<Path> getPaths() {
- return files;
- }
-
- public PrintStream getPrintStream() {
- return printStream;
- }
-
- protected void printf(final String format, final Object... args) {
- if (printStream != null) {
- printStream.printf(format, args);
- }
- }
-
- protected void println(final String msg) {
- if (printStream != null) {
- printStream.println(msg);
- }
- }
-
- protected void printStackTrace(final Throwable t) {
- if (printStream != null) {
- t.printStackTrace(printStream);
- }
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName() + " [files=" + files + ", cleanAfter=" + cleanAfter + ", cleanBefore="
- + cleanBefore + "]";
- }
-
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/AbstractFileCleaner.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/AbstractFileCleaner.java
deleted file mode 100644
index 38fe293..0000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/AbstractFileCleaner.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * 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.logging.log4j.test.junit;
-
-import org.junit.jupiter.api.extension.AfterEachCallback;
-import org.junit.jupiter.api.extension.BeforeEachCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Collection;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
-
-import static org.junit.jupiter.api.Assertions.fail;
-
-abstract class AbstractFileCleaner implements BeforeEachCallback, AfterEachCallback {
-
- private static final int MAX_TRIES = Integer.getInteger("log4j2.junit.fileCleanerMaxTries", 10);
-
- private static final int SLEEP_PERIOD_MILLIS = Integer.getInteger("log4j2.junit.fileCleanerSleepPeriodMillis", 200);
-
- @Override
- public void beforeEach(final ExtensionContext context) throws Exception {
- clean(context);
- }
-
- @Override
- public void afterEach(final ExtensionContext context) throws Exception {
- clean(context);
- }
-
- private void clean(final ExtensionContext context) {
- final Collection<Path> paths = getPathsForTest(context);
- if (paths.isEmpty()) {
- return;
- }
- final Map<Path, IOException> failures = new ConcurrentHashMap<>();
- for (final Path path : paths) {
- if (Files.exists(path)) {
- for (int i = 0; i < MAX_TRIES; i++) {
- try {
- if (delete(path)) {
- failures.remove(path);
- break;
- }
- } catch (final IOException e) {
- failures.put(path, e);
- }
- try {
- TimeUnit.MILLISECONDS.sleep(SLEEP_PERIOD_MILLIS);
- } catch (final InterruptedException ignored) {
- failures.put(path, new InterruptedIOException());
- Thread.currentThread().interrupt();
- break;
- }
- }
- }
- }
- if (!failures.isEmpty()) {
- final String message = failures.entrySet().stream()
- .map(e -> e.getKey() + " failed with " + e.getValue())
- .collect(Collectors.joining(", "));
- fail(message);
- }
- }
-
- abstract Collection<Path> getPathsForTest(final ExtensionContext context);
-
- abstract boolean delete(final Path path) throws IOException;
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/CleanFiles.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/CleanFiles.java
deleted file mode 100644
index 43aafd6..0000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/CleanFiles.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.logging.log4j.test.junit;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-
-import org.apache.logging.log4j.test.junit.AbstractExternalFileCleaner;
-
-/**
- * A JUnit test rule to automatically delete files after a test is run.
- * <p>
- * For example:
- * </p>
- *
- * <pre>
- * @Rule
- * public CleanFiles files = new CleanFiles("path/to/file.txt");
- * </pre>
- * <p>
- * This class should not perform logging using Log4j to avoid accidentally
- * loading or re-loading Log4j configurations.
- * </p>
- *
- */
-public class CleanFiles extends AbstractExternalFileCleaner {
- private static final int MAX_TRIES = 10;
-
- public CleanFiles(final boolean before, final boolean after, final int maxTries, final File... files) {
- super(before, after, maxTries, null, files);
- }
-
- public CleanFiles(final boolean before, final boolean after, final int maxTries, final String... fileNames) {
- super(before, after, maxTries, null, fileNames);
- }
-
- public CleanFiles(final File... files) {
- super(true, true, MAX_TRIES, null, files);
- }
-
- public CleanFiles(final Path... paths) {
- super(true, true, MAX_TRIES, null, paths);
- }
-
- public CleanFiles(final String... fileNames) {
- super(true, true, MAX_TRIES, null, fileNames);
- }
-
- @Override
- protected boolean clean(final Path path, final int tryIndex) throws IOException {
- return Files.deleteIfExists(path);
- }
-
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/CleanFolders.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/CleanFolders.java
deleted file mode 100644
index 9264d7d..0000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/CleanFolders.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * 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.logging.log4j.test.junit;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.nio.file.FileVisitResult;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
-
-import org.apache.logging.log4j.test.junit.AbstractExternalFileCleaner;
-
-/**
- * A JUnit test rule to automatically delete folders recursively before
- * (optional) and after (optional) a test is run.
- * <p>
- * This class should not perform logging using Log4j to avoid accidentally
- * loading or re-loading Log4j configurations.
- * </p>
- */
-public class CleanFolders extends AbstractExternalFileCleaner {
-
- public static final class DeleteAllFileVisitor extends SimpleFileVisitor<Path> {
-
- private final PrintStream printStream;
-
- public DeleteAllFileVisitor(final PrintStream logger) {
- this.printStream = logger;
- }
-
- @Override
- public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
- printf("%s Deleting directory %s\n", CLEANER_MARKER, dir);
- final boolean deleted = Files.deleteIfExists(dir);
- printf("%s Deleted directory %s: %s\n", CLEANER_MARKER, dir, deleted);
- return FileVisitResult.CONTINUE;
- }
-
- protected void printf(final String format, final Object... args) {
- if (printStream != null) {
- printStream.printf(format, args);
- }
- }
-
- @Override
- public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
- printf("%s Deleting file %s with %s\n", CLEANER_MARKER, file, attrs);
- final boolean deleted = Files.deleteIfExists(file);
- printf(CLEANER_MARKER, "%s Deleted file %s: %s\n", file, deleted);
- return FileVisitResult.CONTINUE;
- }
- }
-
- private static final int MAX_TRIES = 10;
-
- public CleanFolders(final boolean before, final boolean after, final int maxTries, final File... files) {
- super(before, after, maxTries, null, files);
- }
-
- public CleanFolders(final boolean before, final boolean after, final int maxTries, final Path... paths) {
- super(before, after, maxTries, null, paths);
- }
-
- public CleanFolders(final boolean before, final boolean after, final int maxTries, final String... fileNames) {
- super(before, after, maxTries, null, fileNames);
- }
-
- public CleanFolders(final File... folders) {
- super(true, true, MAX_TRIES, null, folders);
- }
-
- public CleanFolders(final Path... paths) {
- super(true, true, MAX_TRIES, null, paths);
- }
-
- public CleanFolders(final PrintStream logger, final File... folders) {
- super(true, true, MAX_TRIES, logger, folders);
- }
-
- public CleanFolders(final String... folderNames) {
- super(true, true, MAX_TRIES, null, folderNames);
- }
-
- @Override
- protected boolean clean(final Path path, final int tryIndex) throws IOException {
- cleanFolder(path, tryIndex);
- return true;
- }
-
- private void cleanFolder(final Path folder, final int tryIndex) throws IOException {
- if (Files.exists(folder) && Files.isDirectory(folder)) {
- Files.walkFileTree(folder, new DeleteAllFileVisitor(getPrintStream()));
- }
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/CleanUpDirectories.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/CleanUpDirectories.java
deleted file mode 100644
index 619d6f2..0000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/CleanUpDirectories.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.logging.log4j.test.junit;
-
-import org.junit.jupiter.api.extension.ExtendWith;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * JUnit extension to automatically clean up a list of directories and their contents before and after test execution.
- * This will automatically retry deletion up to 10 times per file while pausing for 200ms each time.
- * These can be overridden with system properties {@code log4j2.junit.fileCleanerMaxTries} and
- * {@code log4j2.junit.fileCleanerSleepPeriodMillis}.
- *
- * @see DirectoryCleaner
- * @see CleanUpFiles
- * @since 2.14.0
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE, ElementType.METHOD})
-@Documented
-@Inherited
-@ExtendWith(DirectoryCleaner.class)
-public @interface CleanUpDirectories {
- String[] value();
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/CleanUpFiles.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/CleanUpFiles.java
deleted file mode 100644
index c1a9b9a..0000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/CleanUpFiles.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.logging.log4j.test.junit;
-
-import org.junit.jupiter.api.extension.ExtendWith;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * JUnit extension to automatically clean up a list of files before and after test execution.
- * This will automatically retry deletion up to 10 times per file while pausing for 200ms each time.
- * These can be overridden with system properties {@code log4j2.junit.fileCleanerMaxTries} and
- * {@code log4j2.junit.fileCleanerSleepPeriodMillis}.
- *
- * @see FileCleaner
- * @see CleanUpDirectories
- * @since 2.14.0
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE, ElementType.METHOD})
-@Documented
-@Inherited
-@ExtendWith(FileCleaner.class)
-public @interface CleanUpFiles {
- String[] value();
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/DirectoryCleaner.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/DirectoryCleaner.java
deleted file mode 100644
index 9ac7e84..0000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/DirectoryCleaner.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.logging.log4j.test.junit;
-
-import org.junit.jupiter.api.extension.ExtensionContext;
-
-import java.io.IOException;
-import java.nio.file.FileVisitResult;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.Collection;
-import java.util.HashSet;
-
-class DirectoryCleaner extends AbstractFileCleaner {
- @Override
- Collection<Path> getPathsForTest(final ExtensionContext context) {
- final Collection<Path> paths = new HashSet<>();
- final CleanUpDirectories testClassAnnotation = context.getRequiredTestClass().getAnnotation(CleanUpDirectories.class);
- if (testClassAnnotation != null) {
- for (final String path : testClassAnnotation.value()) {
- paths.add(Paths.get(path));
- }
- }
- final CleanUpDirectories testMethodAnnotation = context.getRequiredTestMethod().getAnnotation(CleanUpDirectories.class);
- if (testMethodAnnotation != null) {
- for (final String path : testMethodAnnotation.value()) {
- paths.add(Paths.get(path));
- }
- }
- return paths;
- }
-
- @Override
- boolean delete(final Path path) throws IOException {
- if (Files.exists(path) && Files.isDirectory(path)) {
- Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
- @Override
- public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
- Files.deleteIfExists(file);
- return FileVisitResult.CONTINUE;
- }
-
- @Override
- public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
- Files.deleteIfExists(dir);
- return FileVisitResult.CONTINUE;
- }
- });
- }
- return true;
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/FileCleaner.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/FileCleaner.java
deleted file mode 100644
index c76ce21..0000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/FileCleaner.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.logging.log4j.test.junit;
-
-import org.junit.jupiter.api.extension.ExtensionContext;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Collection;
-import java.util.HashSet;
-
-class FileCleaner extends AbstractFileCleaner {
- @Override
- Collection<Path> getPathsForTest(final ExtensionContext context) {
- final Collection<Path> paths = new HashSet<>();
- final CleanUpFiles testClassAnnotation = context.getRequiredTestClass().getAnnotation(CleanUpFiles.class);
- if (testClassAnnotation != null) {
- for (final String path : testClassAnnotation.value()) {
- paths.add(Paths.get(path));
- }
- }
- final CleanUpFiles testMethodAnnotation = context.getRequiredTestMethod().getAnnotation(CleanUpFiles.class);
- if (testMethodAnnotation != null) {
- for (final String path : testMethodAnnotation.value()) {
- paths.add(Paths.get(path));
- }
- }
- return paths;
- }
-
- @Override
- boolean delete(final Path path) throws IOException {
- return Files.deleteIfExists(path);
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/Mutable.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/Mutable.java
deleted file mode 100644
index 2e89bd1..0000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/Mutable.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.logging.log4j.test.junit;
-
-/**
- * Helper class for JUnit tests.
- */
-public class Mutable {
- private String value;
-
- public Mutable set(final String value) {
- this.value = value;
- return this;
- }
-
- @Override
- public String toString() {
- return this.value;
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/SecurityManagerTestRule.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/SecurityManagerTestRule.java
deleted file mode 100644
index 57a9f71..0000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/SecurityManagerTestRule.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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.logging.log4j.test.junit;
-
-import org.junit.rules.TestRule;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-
-/**
- * Sets a security manager for a test run. The current security manager is first saved then restored after the test is
- * run.
- * <p>
- * Using a security manager can mess up other tests so this is best used from integration tests (classes that end in
- * "IT" instead of "Test" and "TestCase".)
- * </p>
- *
- * <p>
- * When this test rule is evaluated, it will:
- * </p>
- * <ol>
- * <li>Save the current SecurityManager.</li>
- * <li>Set the SecurityManager to the instance supplied to this rule.</li>
- * <li>Evaluate the test statement.</li>
- * <li>Reset the current SecurityManager to the one from step (1).</li>
- * </ol>
- *
- * @since 2.11.0
- */
-public class SecurityManagerTestRule implements TestRule {
-
- /**
- * Constructs a new instance with the given {@link SecurityManager}.
- * <p>
- * When this test rule is evaluated, it will:
- * </p>
- * <ol>
- * <li>Save the current SecurityManager.</li>
- * <li>Set the SecurityManager to the instance supplied to this rule.</li>
- * <li>Evaluate the test statement.</li>
- * <li>Reset the current SecurityManager to the one from step (1).</li>
- * </ol>
- *
- * @param securityManager
- * the {@link SecurityManager} to use while running a test.
- */
- public SecurityManagerTestRule(final SecurityManager securityManager) {
- super();
- this.securityManager = securityManager;
- }
-
- private SecurityManager securityManagerBefore;
- private final SecurityManager securityManager;
-
- @Override
- public Statement apply(final Statement base, final Description description) {
- return new Statement() {
- @Override
- public void evaluate() throws Throwable {
- before();
- try {
- base.evaluate();
- } finally {
- after();
- }
- }
-
- private void after() {
- System.setSecurityManager(securityManagerBefore);
- }
-
- private void before() {
- securityManagerBefore = System.getSecurityManager();
- System.setSecurityManager(securityManager);
-
- }
- };
- }
-
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/SerialUtil.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/SerialUtil.java
deleted file mode 100644
index 52ca0e2..0000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/SerialUtil.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.logging.log4j.test.junit;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-
-/**
- * Utility class to facilitate serializing and deserializing objects.
- */
-public class SerialUtil {
- private SerialUtil() {
- }
-
- /**
- * Serializes the specified object and returns the result as a byte array.
- * @param obj the object to serialize
- * @return the serialized object
- */
- public static byte[] serialize(final Serializable obj) {
- try {
- final ByteArrayOutputStream bas = new ByteArrayOutputStream(8192);
- final ObjectOutputStream oos = new ObjectOutputStream(bas);
- oos.writeObject(obj);
- oos.flush();
- return bas.toByteArray();
- } catch (final Exception ex) {
- throw new IllegalStateException("Could not serialize", ex);
- }
- }
-
- /**
- * Deserialize an object from the specified byte array and returns the result.
- * @param data byte array representing the serialized object
- * @return the deserialized object
- */
- @SuppressWarnings("unchecked")
- public static <T> T deserialize(final byte[] data) {
- try {
- final ByteArrayInputStream bas = new ByteArrayInputStream(data);
- final ObjectInputStream ois = new ObjectInputStream(bas);
- return (T) ois.readObject();
- } catch (final Exception ex) {
- throw new IllegalStateException("Could not deserialize", ex);
- }
- }
-}
diff --git a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/URLStreamHandlerFactoryRule.java b/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/URLStreamHandlerFactoryRule.java
deleted file mode 100644
index 287b591..0000000
--- a/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/URLStreamHandlerFactoryRule.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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.logging.log4j.test.junit;
-
-import java.lang.reflect.Field;
-import java.net.URL;
-import java.net.URLStreamHandler;
-import java.net.URLStreamHandlerFactory;
-import java.util.Hashtable;
-
-import org.junit.Assert;
-import org.junit.rules.TestRule;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-
-/**
- * Installs and restores the URL URLStreamHandlerFactory before and after tests.
- * <p>
- * Might need tweaking for different JREs.
- * </p>
- */
-public class URLStreamHandlerFactoryRule implements TestRule {
-
- public URLStreamHandlerFactoryRule() {
- this(null);
- }
-
- public URLStreamHandlerFactoryRule(final URLStreamHandlerFactory newURLStreamHandlerFactory) {
- this.newURLStreamHandlerFactory = newURLStreamHandlerFactory;
- }
-
- private final URLStreamHandlerFactory newURLStreamHandlerFactory;
-
- void clearURLHandlers() throws Exception {
- final Field handlersFields = URL.class.getDeclaredField("handlers");
- if (handlersFields != null) {
- if (!handlersFields.isAccessible()) {
- handlersFields.setAccessible(true);
- }
- @SuppressWarnings("unchecked")
- final
- Hashtable<String, URLStreamHandler> handlers = (Hashtable<String, URLStreamHandler>) handlersFields
- .get(null);
- if (handlers != null) {
- handlers.clear();
- }
- }
- }
-
- @Override
- public Statement apply(final Statement base, final Description description) {
- return new Statement() {
- @Override
- public void evaluate() throws Throwable {
- Field factoryField = null;
- int matches = 0;
- URLStreamHandlerFactory oldFactory = null;
- for (final Field field : URL.class.getDeclaredFields()) {
- if (URLStreamHandlerFactory.class.equals(field.getType())) {
- factoryField = field;
- matches++;
- factoryField.setAccessible(true);
- oldFactory = (URLStreamHandlerFactory) factoryField.get(null);
- break;
- }
- }
- Assert.assertNotNull("java.net URL does not declare a java.net.URLStreamHandlerFactory field",
- factoryField);
- Assert.assertEquals("java.net.URL declares multiple java.net.URLStreamHandlerFactory fields.", 1,
- matches); // FIXME There is a break in the loop so always 0 or 1
- URL.setURLStreamHandlerFactory(newURLStreamHandlerFactory);
- try {
- base.evaluate();
- } finally {
- clearURLHandlers();
- factoryField.set(null, null);
- URL.setURLStreamHandlerFactory(oldFactory);
- }
- }
- };
- }
-}