As stated in the java.io.File.setLastModified javadoc:
All platforms support file-modification times to the nearest second, but some provide more precision. The argument will be truncated to fit the supported precision. If the operation succeeds and no intervening operations on the file take place, then the next invocation of the lastModified method will return the (possibly truncated) time argument that was passed to this method.
The error is probably caused because the test is not waiting for at least 1 second to change the modifed date.