aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java28
1 files changed, 18 insertions, 10 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java
index 9b12011aab..dd7230bdbf 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java
@@ -42,6 +42,7 @@
*/
package org.eclipse.jgit.api;
+import static java.time.Instant.EPOCH;
import static org.eclipse.jgit.api.ResetCommand.ResetType.HARD;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -52,6 +53,9 @@ import static org.junit.Assert.fail;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.attribute.FileTime;
+import java.time.Instant;
import org.eclipse.jgit.api.ResetCommand.ResetType;
import org.eclipse.jgit.api.errors.GitAPIException;
@@ -252,13 +256,13 @@ public class ResetCommandTest extends RepositoryTestCase {
public void testMixedResetRetainsSizeAndModifiedTime() throws Exception {
git = new Git(db);
- writeTrashFile("a.txt", "a").setLastModified(
- System.currentTimeMillis() - 60 * 1000);
+ Files.setLastModifiedTime(writeTrashFile("a.txt", "a").toPath(),
+ FileTime.from(Instant.now().minusSeconds(60)));
assertNotNull(git.add().addFilepattern("a.txt").call());
assertNotNull(git.commit().setMessage("a commit").call());
- writeTrashFile("b.txt", "b").setLastModified(
- System.currentTimeMillis() - 60 * 1000);
+ Files.setLastModifiedTime(writeTrashFile("b.txt", "b").toPath(),
+ FileTime.from(Instant.now().minusSeconds(60)));
assertNotNull(git.add().addFilepattern("b.txt").call());
RevCommit commit2 = git.commit().setMessage("b commit").call();
assertNotNull(commit2);
@@ -268,12 +272,12 @@ public class ResetCommandTest extends RepositoryTestCase {
DirCacheEntry aEntry = cache.getEntry("a.txt");
assertNotNull(aEntry);
assertTrue(aEntry.getLength() > 0);
- assertTrue(aEntry.getLastModified() > 0);
+ assertTrue(aEntry.getLastModifiedInstant().compareTo(EPOCH) > 0);
DirCacheEntry bEntry = cache.getEntry("b.txt");
assertNotNull(bEntry);
assertTrue(bEntry.getLength() > 0);
- assertTrue(bEntry.getLastModified() > 0);
+ assertTrue(bEntry.getLastModifiedInstant().compareTo(EPOCH) > 0);
assertSameAsHead(git.reset().setMode(ResetType.MIXED)
.setRef(commit2.getName()).call());
@@ -282,13 +286,17 @@ public class ResetCommandTest extends RepositoryTestCase {
DirCacheEntry mixedAEntry = cache.getEntry("a.txt");
assertNotNull(mixedAEntry);
- assertEquals(aEntry.getLastModified(), mixedAEntry.getLastModified());
- assertEquals(aEntry.getLastModified(), mixedAEntry.getLastModified());
+ assertEquals(aEntry.getLastModifiedInstant(),
+ mixedAEntry.getLastModifiedInstant());
+ assertEquals(aEntry.getLastModifiedInstant(),
+ mixedAEntry.getLastModifiedInstant());
DirCacheEntry mixedBEntry = cache.getEntry("b.txt");
assertNotNull(mixedBEntry);
- assertEquals(bEntry.getLastModified(), mixedBEntry.getLastModified());
- assertEquals(bEntry.getLastModified(), mixedBEntry.getLastModified());
+ assertEquals(bEntry.getLastModifiedInstant(),
+ mixedBEntry.getLastModifiedInstant());
+ assertEquals(bEntry.getLastModifiedInstant(),
+ mixedBEntry.getLastModifiedInstant());
}
@Test