assertFalse(itor.hasNext());
// testing directory with 1 file
writeFile(fs, FILE2, FILE_LEN);
itor = fs.listLocatedBlockStatus(DIR1);
LocatedBlockFileStatus stat = itor.next();
assertFalse(itor.hasNext());
assertFalse(stat.isDir());
assertEquals(FILE_LEN, stat.getLen());
assertEquals(-1, stat.getChildrenCount());
assertEquals(fs.makeQualified(FILE2), stat.getPath());
assertEquals(2, stat.getBlockLocations().length);
// test more complicated directory
writeFile(fs, FILE1, FILE_LEN);
writeFile(fs, FILE3, FILE_LEN);
writeFile(fs, FILE4, FILE_LEN);
Set<Path> expectedResults = new TreeSet<Path>();
expectedResults.add(fs.makeQualified(FILE2));
expectedResults.add(fs.makeQualified(FILE3));
for (itor = fs.listLocatedBlockStatus(DIR1); itor.hasNext(); ) {
stat = itor.next();
assertFalse(stat.isDir());
assertTrue(expectedResults.remove(stat.getPath()));
}
assertTrue(expectedResults.isEmpty());
final Path qualifiedDir1 = fs.makeQualified(DIR1);
expectedResults.add(qualifiedDir1);
expectedResults.add(fs.makeQualified(FILE1));
expectedResults.add(fs.makeQualified(FILE4));
for (itor = fs.listLocatedBlockStatus(TEST_DIR); itor.hasNext(); ) {
stat = itor.next();
assertTrue(expectedResults.remove(stat.getPath()));
if (qualifiedDir1.equals(stat.getPath())) {
assertTrue(stat.isDir());
assertEquals(2, stat.getChildrenCount());
} else {
assertFalse(stat.isDir());
assertEquals(-1, stat.getChildrenCount());
}
}
assertTrue(expectedResults.isEmpty());
fs.delete(TEST_DIR, true);