diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2019-05-08 03:25:53 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2019-05-29 23:41:45 +0200 |
commit | 5d0286eb7c206f95b1c0ffb99294abcd7696faa1 (patch) | |
tree | 180c0284ae9e485a46f380b096badd5771b02cbc | |
parent | 43b06f51f96dddc3d512904f9e1f0bb6b5cc5984 (diff) | |
download | jgit-5d0286eb7c206f95b1c0ffb99294abcd7696faa1.tar.gz jgit-5d0286eb7c206f95b1c0ffb99294abcd7696faa1.zip |
Add FileSnapshot test testing recognition of file size changes
Change-Id: Ibcd76a5e6e4183ada0be1d4436ce957243f2094d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileSnapshotTest.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileSnapshotTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileSnapshotTest.java index 79ede96919..5ebdeb6e8f 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileSnapshotTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileSnapshotTest.java @@ -163,6 +163,23 @@ public class FileSnapshotTest { save.wasLastModifiedRacilyClean()); } + /** + * Append a character to a file to change its size and set original + * lastModified + * + * @throws Exception + */ + @Test + public void testFileSizeChanged() throws Exception { + File f = createFile("file"); + FileTime timestamp = Files.getLastModifiedTime(f.toPath()); + FileSnapshot save = FileSnapshot.save(f); + append(f, (byte) 'x'); + Files.setLastModifiedTime(f.toPath(), timestamp); + assertTrue(save.isModified(f)); + assertTrue(save.wasSizeChanged()); + } + private File createFile(String string) throws IOException { trash.mkdirs(); File f = File.createTempFile(string, "tdat", trash); |