This is an automated email from the ASF dual-hosted git repository.

ggregory 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 7b9598f  The policy uses the file creation time for its comparison. 
The test now also sets the file creation time. Without this change, the test 
fails for me on Windows 10 and Oracle 8.
7b9598f is described below

commit 7b9598f7dc68f5d2c92e5c672dd7e27a79563a62
Author: Gary Gregory <[email protected]>
AuthorDate: Thu Nov 29 18:57:00 2018 -0700

    The policy uses the file creation time for its comparison. The test now
    also sets the file creation time. Without this change, the test fails
    for me on Windows 10 and Oracle 8.
---
 .../log4j/core/appender/rolling/OnStartupTriggeringPolicyTest.java | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicyTest.java
 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicyTest.java
index 35eef6a..28353c3 100644
--- 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicyTest.java
+++ 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicyTest.java
@@ -26,6 +26,8 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.nio.file.StandardCopyOption;
+import java.nio.file.attribute.BasicFileAttributeView;
+import java.nio.file.attribute.FileTime;
 import java.util.Arrays;
 
 import org.apache.logging.log4j.core.config.Configuration;
@@ -33,7 +35,6 @@ import 
org.apache.logging.log4j.core.config.DefaultConfiguration;
 import org.apache.logging.log4j.core.layout.PatternLayout;
 import org.apache.logging.log4j.core.time.internal.format.FastDateFormat;
 import org.apache.logging.log4j.junit.CleanFolders;
-import org.junit.Assert;
 import org.junit.Rule;
 import org.junit.Test;
 
@@ -73,7 +74,9 @@ public class OnStartupTriggeringPolicyTest {
         assertTrue(size > 0);
         assertEquals(copied, size);
 
-        Assert.assertTrue(target.toFile().setLastModified(timeStamp));
+        final FileTime fileTime = FileTime.fromMillis(timeStamp);
+        final BasicFileAttributeView attrs = 
Files.getFileAttributeView(target, BasicFileAttributeView.class);
+        attrs.setTimes(fileTime, fileTime, fileTime);
         final PatternLayout layout = 
PatternLayout.newBuilder().setPattern("%msg").setConfiguration(configuration)
                 .build();
         final RolloverStrategy strategy = 
DefaultRolloverStrategy.newBuilder().setCompressionLevelStr("0")

Reply via email to