@Test public void warnIfDeletingOriginalFileFailedOnWindows() throws IOException { assumeTrue(System.getProperty("os.name").startsWith("Windows")); File originalFile = new File(FileSystem.createTemporaryFile()); File backupFile = new File(FileSystem.createTemporaryFile()); try (FileInputStream stream = new FileInputStream(originalFile)) { new FileTuple(originalFile, backupFile).delete(); } assertThat(systemStream.consumeErrorOutput()) .containsOnlyOnce("WARN") .containsOnlyOnce(originalFile.getPath()); assertThat(originalFile).exists(); assertThat(backupFile).doesNotExist(); }
public void delete() { if (original.isFile() && !original.delete()) { InternalLogger.log(Level.WARN, "Failed to delete log file '" + original + "'"); } if (!backup.equals(original) && backup.isFile() && !backup.delete()) { InternalLogger.log(Level.WARN, "Failed to delete backup file '" + backup + "'"); } }
FileTuple { public void delete() { if (original.isFile() && !original.delete()) { InternalLogger.log(Level.WARN, "Failed to delete log file '" + original + "'"); } if (!backup.equals(original) && backup.isFile() && !backup.delete()) { InternalLogger.log(Level.WARN, "Failed to delete backup file '" + backup + "'"); } } }
FileTuple { public void delete() { if (original.isFile() && !original.delete()) { InternalLogger.log(Level.WARN, "Failed to delete log file '" + original + "'"); } if (!backup.equals(original) && backup.isFile() && !backup.delete()) { InternalLogger.log(Level.WARN, "Failed to delete backup file '" + backup + "'"); } } FileTuple(final File original, final File backup); }
FileTuple { public void delete() { if (original.isFile() && !original.delete()) { InternalLogger.log(Level.WARN, "Failed to delete log file '" + original + "'"); } if (!backup.equals(original) && backup.isFile() && !backup.delete()) { InternalLogger.log(Level.WARN, "Failed to delete backup file '" + backup + "'"); } } FileTuple(final File original, final File backup); File getOriginal(); File getBackup(); long getLastModified(); void delete(); }
FileTuple { public void delete() { if (original.isFile() && !original.delete()) { InternalLogger.log(Level.WARN, "Failed to delete log file '" + original + "'"); } if (!backup.equals(original) && backup.isFile() && !backup.delete()) { InternalLogger.log(Level.WARN, "Failed to delete backup file '" + backup + "'"); } } FileTuple(final File original, final File backup); File getOriginal(); File getBackup(); long getLastModified(); void delete();  }