### Question:
FileUtil { public static boolean fullyDeleteContents(File dir) { boolean deletionSucceeded = true; File contents[] = dir.listFiles(); if (contents != null) { for (int i = 0; i < contents.length; i++) { if (contents[i].isFile()) { if (!contents[i].delete()) { deletionSucceeded = false; continue; } } else { boolean b = false; b = contents[i].delete(); if (b){ continue; } if (!fullyDelete(contents[i])) { deletionSucceeded = false; continue; } } } } return deletionSucceeded; }  static Path[] stat2Paths(FileStatus[] stats); static Path[] stat2Paths(FileStatus[] stats, Path path); static boolean fullyDelete(File dir); static boolean fullyDeleteContents(File dir); @Deprecated static void fullyDelete(FileSystem fs, Path dir); static boolean copy(FileSystem srcFS, Path src, 
                             FileSystem dstFS, Path dst, 
                             boolean deleteSource,
                             Configuration conf); static boolean copy(FileSystem srcFS, Path[] srcs, 
                             FileSystem dstFS, Path dst,
                             boolean deleteSource, 
                             boolean overwrite, Configuration conf); static boolean copy(FileSystem srcFS, Path src, 
                             FileSystem dstFS, Path dst, 
                             boolean deleteSource,
                             boolean overwrite,
                             Configuration conf); static boolean copyMerge(FileSystem srcFS, Path srcDir, 
                                  FileSystem dstFS, Path dstFile, 
                                  boolean deleteSource,
                                  Configuration conf, String addString); static boolean copy(File src,
                             FileSystem dstFS, Path dst,
                             boolean deleteSource,
                             Configuration conf); static boolean copy(FileSystem srcFS, Path src, 
                             File dst, boolean deleteSource,
                             Configuration conf); static String makeShellPath(String filename); static String makeShellPath(File file); static String makeShellPath(File file, boolean makeCanonicalPath); static long getDU(File dir); static void unZip(File inFile, File unzipDir); static void unTar(File inFile, File untarDir); static int symLink(String target, String linkname); static int chmod(String filename, String perm
                          ); static int chmod(String filename, String perm, boolean recursive); static final File createLocalTempFile(final File basefile,
                                               final String prefix,
                                               final boolean isDeleteOnExit); static void replaceFile(File src, File target); static File[] listFiles(File dir); static String[] list(File dir);  }### Answer:
@Test public void testFullyDeleteContents() throws IOException { setupDirs(); boolean ret = FileUtil.fullyDeleteContents(del); Assert.assertTrue(ret); Assert.assertTrue(del.exists()); Assert.assertEquals(0, del.listFiles().length); validateTmpDir(); }
@Test public void testFailFullyDeleteContents() throws IOException { LOG.info("Running test to verify failure of fullyDeleteContents()"); setupDirsAndNonWritablePermissions(); boolean ret = FileUtil.fullyDeleteContents(new MyFile(del)); validateAndSetWritablePermissions(ret); }