AdeFileUtils { public static void createDirs(File target) throws AdeUsageException { if (!target.exists() && !target.mkdirs()) { throw new AdeUsageException("Failed creating directory " + target.getPath()); } } private  AdeFileUtils(); static void copyFile(File source, File target); static BufferedReader openLogFile(File file); static InputStream openLogFileAsInputStream(File file); static void deleteFile(File file); static void deleteFileOrLog(File file); static void createDir(File target); static void createDirs(File target); static boolean deleteRecursiveOrLog(File path);  }
@Test public void testCreateDirs() throws AdeUsageException, IOException { final File targetDir = temporaryFolder.newFolder("dir1"); final File newDir = new File(targetDir.getPath() + "/newdir1/newdir2"); AdeFileUtils.createDirs(newDir); assertTrue("Verify the directory was created.", newDir.exists()); }
@Test(expected = AdeUsageException.class) public void testCreateDirsBadPath() throws AdeUsageException, IOException { final File badPath = new File(""); AdeFileUtils.createDirs(badPath); }
@Test public void testCreateDirsFileExists() throws AdeUsageException, IOException { final File aFile = temporaryFolder.newFile(); AdeFileUtils.createDirs(aFile); assertTrue("Verify the file is still there.", aFile.exists()); }