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 2020/08/02 20:46:39 UTC

[logging-log4j2] 01/02: Unit test might create less than 3 files on first and last directory.

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

commit 08865350baf18d58413131939c2d73658bef95bd
Author: Ralph Goers <rg...@apache.org>
AuthorDate: Sun Aug 2 13:46:03 2020 -0700

    Unit test might create less than 3 files on first and last directory.
---
 .../rolling/RollingDirectSizeTimeNewDirectoryTest.java | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 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 a9d3ee5..9978aa8 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
@@ -24,6 +24,7 @@ import org.junit.Test;
 import org.junit.rules.RuleChain;
 
 import java.io.File;
+import java.util.Arrays;
 import java.util.List;
 
 import static java.util.Arrays.asList;
@@ -69,17 +70,20 @@ public class RollingDirectSizeTimeNewDirectoryTest {
         assertNotNull(loggingFolders);
         // Check if two folders were created
         assertTrue("Not enough directories created", loggingFolders.length >= 2);
-        for (File dir : loggingFolders) {
+        Arrays.sort(loggingFolders);
+        for (int i = 0; i < loggingFolders.length; ++i) {
+            File dir = loggingFolders[i];
             File[] files = dir.listFiles();
             assertTrue("No files in directory " + dir.toString(), files != null && files.length > 0);
-            if (files.length < 3) {
-                System.out.println("Only " + files.length + " files created in " + dir.toString());
-                for (File logFile : files) {
-                    System.out.println("File name: " + logFile.getName() + " size: " + logFile.length());
+            if (i > 0 && i < loggingFolders.length - 1) {
+                if (files.length < 3) {
+                    System.out.println("Only " + files.length + " files created in " + dir.toString());
+                    for (File logFile : files) {
+                        System.out.println("File name: " + logFile.getName() + " size: " + logFile.length());
+                    }
+                    fail();
                 }
-                fail();
             }
-
         }
     }
 }