Browse Source

Add FileSnapshot test testing recognition of file size changes

Change-Id: Ibcd76a5e6e4183ada0be1d4436ce957243f2094d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-5.1
Matthias Sohn 6 years ago
parent
commit
5d0286eb7c
  1. 17
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileSnapshotTest.java

17
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);

Loading…
Cancel
Save