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/02/20 03:00:42 UTC
[logging-log4j2] branch release-2.x updated: Fix unit test
This is an automated email from the ASF dual-hosted git repository.
rgoers pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/release-2.x by this push:
new 011d128 Fix unit test
011d128 is described below
commit 011d1284972aeaf52eb7e4564fedf845f7f391d3
Author: Ralph Goers <Ra...@dslextreme.com>
AuthorDate: Wed Feb 19 20:00:23 2020 -0700
Fix unit test
---
.../core/appender/rolling/RollingAppenderRestartTest.java | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderRestartTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderRestartTest.java
index ec8a32c..80474b6 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderRestartTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderRestartTest.java
@@ -27,10 +27,9 @@ import org.junit.rules.RuleChain;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
+import java.nio.file.attribute.BasicFileAttributeView;
+import java.nio.file.attribute.FileTime;
import java.time.Instant;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.Month;
import java.time.temporal.ChronoUnit;
import static org.apache.logging.log4j.hamcrest.Descriptors.that;
@@ -38,7 +37,6 @@ import static org.apache.logging.log4j.hamcrest.FileMatchers.hasName;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.hasItemInArray;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
/**
*
@@ -58,8 +56,8 @@ public class RollingAppenderRestartTest {
File file = new File("target/rolling-restart/test.log");
Files.createDirectories(file.toPath().getParent());
Files.write(file.toPath(), "Hello, world".getBytes(), StandardOpenOption.CREATE);
- long old = Instant.now().minus(2, ChronoUnit.DAYS).toEpochMilli();
- assertTrue("Unable to set last modified time", file.setLastModified(old));
+ FileTime newTime = FileTime.from(Instant.now().minus(2, ChronoUnit.DAYS));
+ Files.getFileAttributeView(file.toPath(), BasicFileAttributeView.class).setTimes(newTime, newTime, newTime);
}
@Test