FileBrowserService { public String[] getFolders(File directory) { if (directory.exists()) { String[] files = directory.list(new FilenameFilter() { public boolean accept(File dir, String name) { return name.charAt(0) != '.' && new File(dir, name).isDirectory(); } }); if (files != null) { Arrays.sort(files, String.CASE_INSENSITIVE_ORDER); return files; } else { return new String[] {}; } } else { throw new ApplicationRuntimeException("Could not open directory because it does not exist: " + directory); } }  String[] getFolders(File directory); File findFileInPath(File directory, String filename, boolean recursive); String decodeDirectoryUrl(String url, String rootDirectory); String separatorsToSystem(String path); String separatorsToWindows(String path); String separatorsToUnix(String path);  }
@Test public void testGetFolders() throws Exception { String[] folders = testling.getFolders(new ClassPathResource("projects").getFile()); Assert.assertNotNull(folders); Assert.assertEquals(folders.length, 6); Assert.assertEquals(folders[0], "ant"); Assert.assertEquals(folders[1], "cucumber"); Assert.assertEquals(folders[2], "java-config"); Assert.assertEquals(folders[3], "maven"); Assert.assertEquals(folders[4], "maven_connector"); Assert.assertEquals(folders[5], "sample"); }