### Question:
FileUtils { public static void deleteDirectory(File directory) throws IOException { checkNotNull(directory, "directory"); guardIfWindows(FileUtils::deleteDirectoryInternal, directory); } private  FileUtils(); static void writeCompletely(WritableByteChannel channel, ByteBuffer src); static String getRandomFilename(final String prefix); static String readFile(File file, String charsetName); static String readFileUtf8(File file); static void writeFile(File file, String contents, String encoding); static void writeFileUtf8(File file, String contents); static byte[] readAllBytes(java.nio.file.Path path); static void deleteFileOrDirectory(File file); static void deleteDirectory(File directory); static void deleteDirectoryQuietly(File directory); static void cleanDirectory(File directory); static boolean deletePathIfEmpty(FileSystem fileSystem, Path path); static void copy(Path sourcePath, Path targetPath, boolean executable); static Path compressDirectory(Path directory, Path target); static Path expandDirectory(Path file, Path targetDirectory);  }### Answer:
@Test public void testDeleteDirectory() throws Exception { File doesNotExist = new File(tmp.newFolder(), "abc"); FileUtils.deleteDirectory(doesNotExist); File cannotDeleteParent = tmp.newFolder(); File cannotDeleteChild = new File(cannotDeleteParent, "child"); try { assumeTrue(cannotDeleteChild.createNewFile()); assumeTrue(cannotDeleteParent.setWritable(false)); assumeTrue(cannotDeleteChild.setWritable(false)); FileUtils.deleteDirectory(cannotDeleteParent); fail("this should fail with an exception"); } catch (AccessDeniedException ignored) { } finally { cannotDeleteParent.setWritable(true); cannotDeleteChild.setWritable(true); } }
@Test public void testDeleteDirectoryWhichIsAFile() throws Exception { File file = tmp.newFile(); try { FileUtils.deleteDirectory(file); fail("this should fail with an exception"); } catch (IOException ignored) { } }