@Test
public void testDirectoryListing() {
try {
String path = EvolizerCorePlugin.getAbsoluteFSPath("test_data/folder");
DirectoryListing content = new DirectoryListing(new File(path), new IPredicate<File>() {
public boolean evaluate(File f) {
return f.getName().endsWith(".txt");
}
});
Iterator<File> fileIterator = content.iterator();
assertEquals(path + "afile.txt", fileIterator.next().getAbsolutePath());
assertEquals(path + "subfolder/cfile.txt", fileIterator.next().getAbsolutePath());
assertFalse(fileIterator.hasNext());
content = new DirectoryListing(new File(path), new IPredicate<File>() {
public boolean evaluate(File f) {
return f.getName().endsWith(".egf");
}
});
fileIterator = content.iterator();
assertEquals(path + "subfolder/bfile.egf", fileIterator.next().getAbsolutePath());
assertFalse(fileIterator.hasNext());
} catch (IOException e) {
fail();
e.printStackTrace();