Utils { public static void deleteQuietly(Path f) { try { Files.walkFileTree(f, new DeleteQuietlyFileVisitor()); } catch (IOException e) { } } private  Utils(); static Properties loadEnvironmentProperties(Map<String, String> env); static void deleteQuietly(Path f);  }
@Test public void delete_non_empty_directory() throws IOException { Path tmpDir = Files.createTempDirectory("junit"); Path folder1 = tmpDir.resolve("folder1"); Files.createDirectories(folder1); Path file1 = folder1.resolve("file1"); Files.write(file1, "test1".getBytes()); Path folder2 = folder1.resolve("folder2"); Files.createDirectories(folder2); Path file2 = folder1.resolve("file2"); Files.write(file2, "test2".getBytes()); assertThat(tmpDir.toFile()).exists(); Utils.deleteQuietly(tmpDir); assertThat(tmpDir.toFile()).doesNotExist(); }