You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2021/03/04 15:39:19 UTC
[logging-log4j2] branch master updated: Fix unit test on Windows -
I hope
This is an automated email from the ASF dual-hosted git repository.
rgoers pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/master by this push:
new 7dcdf0d Fix unit test on Windows - I hope
7dcdf0d is described below
commit 7dcdf0ddb508c2ed49e0d69380f6b36220cb3e28
Author: Ralph Goers <rg...@apache.org>
AuthorDate: Thu Mar 4 08:39:08 2021 -0700
Fix unit test on Windows - I hope
---
.../rolling/RollingDirectSizeTimeNewDirectoryTest.java | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingDirectSizeTimeNewDirectoryTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingDirectSizeTimeNewDirectoryTest.java
index c387590..eee0d8b 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingDirectSizeTimeNewDirectoryTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingDirectSizeTimeNewDirectoryTest.java
@@ -16,12 +16,12 @@
*/
package org.apache.logging.log4j.core.appender.rolling;
+import java.io.File;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.regex.Pattern;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.appender.RollingFileAppender;
@@ -30,6 +30,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.RuleChain;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
@@ -43,7 +44,6 @@ public class RollingDirectSizeTimeNewDirectoryTest implements RolloverListener {
// Note that the path is hardcoded in the configuration!
private static final String DIR = "target/rolling-size-time-new-directory";
- private static final String FILESEP = Pattern.quote(System.getProperty("file.separator"));
public static LoggerContextRule loggerContextRule =
LoggerContextRule.createShutdownTimeoutLoggerContextRule(CONFIG);
@@ -79,12 +79,11 @@ public class RollingDirectSizeTimeNewDirectoryTest implements RolloverListener {
@Override
public void rolloverComplete(String fileName) {
- String[] parts = fileName.split(FILESEP);
- if (parts.length < 4) {
- System.err.println("Invalid or missing filename: " + fileName);
- return;
- }
- AtomicInteger fileCount = rolloverFiles.computeIfAbsent(parts[2], k -> new AtomicInteger(0));
+ File file = new File(fileName);
+ String logDir = file.getParentFile().getName();
+ AtomicInteger fileCount = rolloverFiles.computeIfAbsent(logDir, k -> new AtomicInteger(0));
fileCount.incrementAndGet();
}
}
+
+