Add FileSnapshot test testing recognition of file size changes

Change-Id: Ibcd76a5e6e4183ada0be1d4436ce957243f2094d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
Matthias Sohn 2019-05-08 03:25:53 +02:00
parent 43b06f51f9
commit 5d0286eb7c
1 changed files with 17 additions and 0 deletions

View File

@ -163,6 +163,23 @@ public void testSimulatePackfileReplacement() throws Exception {
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);