use of org.apache.hadoop.fs.PathFilter in project drill by axbaretto.
the class FileSystemUtilTest method testListFilesWithFilter.
@Test
public void testListFilesWithFilter() throws IOException {
List<FileStatus> statuses = FileSystemUtil.listFiles(fs, new Path(base, "a"), false, new PathFilter() {
@Override
public boolean accept(Path path) {
return path.getName().endsWith(".txt");
}
});
assertEquals("File count should match", 3, statuses.size());
Collections.sort(statuses);
assertEquals("File name should match", ".f.txt", statuses.get(0).getPath().getName());
assertEquals("File name should match", "_f.txt", statuses.get(1).getPath().getName());
assertEquals("File name should match", "f.txt", statuses.get(2).getPath().getName());
}
use of org.apache.hadoop.fs.PathFilter in project drill by axbaretto.
the class FileSystemUtilTest method testListDirectoriesEmptyResult.
@Test
public void testListDirectoriesEmptyResult() throws IOException {
List<FileStatus> statuses = FileSystemUtil.listDirectories(fs, base, false, new PathFilter() {
@Override
public boolean accept(Path path) {
return path.getName().startsWith("abc");
}
});
assertEquals("Directory count should match", 0, statuses.size());
}
use of org.apache.hadoop.fs.PathFilter in project drill by axbaretto.
the class FileSystemUtilTest method testListDirectoriesWithFilter.
@Test
public void testListDirectoriesWithFilter() throws IOException {
List<FileStatus> statuses = FileSystemUtil.listDirectories(fs, base, false, new PathFilter() {
@Override
public boolean accept(Path path) {
return path.getName().endsWith("a");
}
});
assertEquals("Directory count should match", 3, statuses.size());
Collections.sort(statuses);
assertEquals("Directory name should match", ".a", statuses.get(0).getPath().getName());
assertEquals("Directory name should match", "_a", statuses.get(1).getPath().getName());
assertEquals("Directory name should match", "a", statuses.get(2).getPath().getName());
}
use of org.apache.hadoop.fs.PathFilter in project drill by axbaretto.
the class FileSystemUtilTest method testListAllWithFilter.
@Test
public void testListAllWithFilter() throws IOException {
List<FileStatus> statuses = FileSystemUtil.listAll(fs, new Path(base, "a"), false, new PathFilter() {
@Override
public boolean accept(Path path) {
return path.getName().endsWith("a") || path.getName().endsWith(".txt");
}
});
assertEquals("Directory and file count should match", 4, statuses.size());
}
use of org.apache.hadoop.fs.PathFilter in project drill by axbaretto.
the class FileSystemUtilTest method testListFilesRecursiveWithFilter.
@Test
public void testListFilesRecursiveWithFilter() throws IOException {
List<FileStatus> statuses = FileSystemUtil.listFiles(fs, base, true, new PathFilter() {
@Override
public boolean accept(Path path) {
return path.getName().endsWith("a") || path.getName().endsWith(".txt");
}
});
assertEquals("File count should match", 8, statuses.size());
}
Aggregations