@Test public void testOrganizeFilesMixOfFilesAndDirs() { File dir = FileUtil.createDir("temp7"); File dir3 = createSubDir(dir, "dDir"); File file3 = createFileInDir(dir, "dFile.txt"); File file0 = createFileInDir(dir, "aFile.txt"); File dir1 = createSubDir(dir, "bDir"); File file4 = createFileInDir(dir, "eFile.txt"); File dir4 = createSubDir(dir, "eDir"); File dir0 = createSubDir(dir, "aDir"); File file1 = createFileInDir(dir, "bFile.txt"); File dir2 = createSubDir(dir, "cDir"); File file2 = createFileInDir(dir, "cFile.txt"); assertEquals(10, FileUtil.getDirectoryListing(dir).length); assertEquals(dir0, FileUtil.getDirectoryListing(dir)[0]); assertEquals(dir1, FileUtil.getDirectoryListing(dir)[1]); assertEquals(dir2, FileUtil.getDirectoryListing(dir)[2]); assertEquals(dir3, FileUtil.getDirectoryListing(dir)[3]); assertEquals(dir4, FileUtil.getDirectoryListing(dir)[4]); assertEquals(file0, FileUtil.getDirectoryListing(dir)[5]); assertEquals(file1, FileUtil.getDirectoryListing(dir)[6]); assertEquals(file2, FileUtil.getDirectoryListing(dir)[7]); assertEquals(file3, FileUtil.getDirectoryListing(dir)[8]); assertEquals(file4, FileUtil.getDirectoryListing(dir)[9]); FileUtil.deleteFileSystemDirectory(dir); }
@Test public void testCreateDir() throws Exception { File dir = FileUtil.createDir("temp1"); assertTrue(dir.exists()); assertTrue(dir.isDirectory()); FileUtil.deleteFileSystemDirectory(dir); }
public void testOrganizeFilesOneSubDir() throws Exception { File dir = FileUtil.createDir("temp"); File subDir = createSubDir(dir, "subDir"); assertEquals(1, FileUtil.getDirectoryListing(dir).length); assertEquals(subDir, FileUtil.getDirectoryListing(dir)[0]); FileUtil.deleteFileSystemDirectory(dir); }
public void testOrganizeFilesOneFile() throws Exception { File dir = FileUtil.createDir("temp"); File file = createFileInDir(dir, "file.txt"); assertEquals(1, FileUtil.getDirectoryListing(dir).length); assertEquals(file, FileUtil.getDirectoryListing(dir)[0]); FileUtil.deleteFileSystemDirectory(dir); }
public void testOrganizeFilesFiveSubDirs() throws Exception { File dir = FileUtil.createDir("temp"); File dir3 = createSubDir(dir, "dDir"); File dir1 = createSubDir(dir, "bDir"); File dir4 = createSubDir(dir, "eDir"); File dir0 = createSubDir(dir, "aDir"); File dir2 = createSubDir(dir, "cDir"); assertEquals(5, FileUtil.getDirectoryListing(dir).length); assertEquals(dir0, FileUtil.getDirectoryListing(dir)[0]); assertEquals(dir1, FileUtil.getDirectoryListing(dir)[1]); assertEquals(dir2, FileUtil.getDirectoryListing(dir)[2]); assertEquals(dir3, FileUtil.getDirectoryListing(dir)[3]); assertEquals(dir4, FileUtil.getDirectoryListing(dir)[4]); FileUtil.deleteFileSystemDirectory(dir); }
public void testOrganizeFilesFiveFiles() throws Exception { File dir = FileUtil.createDir("temp"); File file3 = createFileInDir(dir, "dFile.txt"); File file1 = createFileInDir(dir, "bFile.txt"); File file4 = createFileInDir(dir, "eFile.txt"); File file0 = createFileInDir(dir, "aFile.txt"); File file2 = createFileInDir(dir, "cFile.txt"); assertEquals(5, FileUtil.getDirectoryListing(dir).length); assertEquals(file0, FileUtil.getDirectoryListing(dir)[0]); assertEquals(file1, FileUtil.getDirectoryListing(dir)[1]); assertEquals(file2, FileUtil.getDirectoryListing(dir)[2]); assertEquals(file3, FileUtil.getDirectoryListing(dir)[3]); assertEquals(file4, FileUtil.getDirectoryListing(dir)[4]); FileUtil.deleteFileSystemDirectory(dir); }
@Test public void testGetDirectoryListingEmpty() throws Exception { File dir = FileUtil.createDir("temp2"); assertEquals(0, FileUtil.getDirectoryListing(dir).length); FileUtil.deleteFileSystemDirectory(dir); }
private File createSubDir(File dir, String subDirName) { return FileUtil.createDir(FileUtil.buildPath(new String[] {dir.getPath(), subDirName})); }