]> source.dussan.org Git - jgit.git/commitdiff
Add FileSnapshot test testing recognition of file size changes 05/141805/14
authorMatthias Sohn <matthias.sohn@sap.com>
Wed, 8 May 2019 01:25:53 +0000 (03:25 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Wed, 29 May 2019 21:41:45 +0000 (23:41 +0200)
Change-Id: Ibcd76a5e6e4183ada0be1d4436ce957243f2094d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileSnapshotTest.java

index 79ede9691950d25fd7f4d74ad2ee6cee98e99ae7..5ebdeb6e8ff45be0a8f4b95871aeaadd4bafb47f 100644 (file)
@@ -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);