void (String filePath, final @Nullable String newContent) { try { File file = new File(FileUtil.toSystemDependentName(filePath)); assertTrue("File " + file.getAbsolutePath() + " doesn't exist", file.exists()); if (newContent != null) { FileUtil.writeToFile(file, newContent); } long oldTimestamp = FSOperations.lastModified(file); long time = System.currentTimeMillis(); setLastModified(file, time); if (FSOperations.lastModified(file) <= oldTimestamp) { setLastModified(file, time + 1); long newTimeStamp = FSOperations.lastModified(file); if (newTimeStamp <= oldTimestamp) { //Mac OS and some versions of Linux truncates timestamp to nearest second setLastModified(file, time + 1000); newTimeStamp = FSOperations.lastModified(file); assertTrue("Failed to change timestamp for " + file.getAbsolutePath(), newTimeStamp > oldTimestamp); } sleepUntil(newTimeStamp); } } catch (IOException e) { throw new RuntimeException(e); } }