@Test (timeout = 30000)
public void testGetAllLocalPathsToRead() throws IOException {

  assumeTrue(!isWindows);
  
  String dir0 = buildBufferDir(ROOT, 0);
  String dir1 = buildBufferDir(ROOT, 1);
  try {
    conf.set(CONTEXT, dir0 + "," + dir1);
    assertTrue(localFs.mkdirs(new Path(dir0)));
    assertTrue(localFs.mkdirs(new Path(dir1)));
    
    localFs.create(new Path(dir0 + Path.SEPARATOR + FILENAME));
    localFs.create(new Path(dir1 + Path.SEPARATOR + FILENAME));
    // check both the paths are returned as paths to read:  
    final Iterable<Path> pathIterable = dirAllocator.getAllLocalPathsToRead(FILENAME, conf);
    int count = 0;
    for (final Path p: pathIterable) {
      count++;
      assertEquals(FILENAME, p.getName());
      assertEquals("file", p.getFileSystem(conf).getUri().getScheme());
    }
    assertEquals(2, count);
    // test #next() while no element to iterate any more: 
    try {
      Path p = pathIterable.iterator().next();
      assertFalse("NoSuchElementException must be thrown, but returned ["+p
          +"] instead.", true); // exception expected
    } catch (NoSuchElementException nsee) {
      // okay
    }
    
    // test modification not allowed:
    final Iterable<Path> pathIterable2 = dirAllocator.getAllLocalPathsToRead(FILENAME, conf);
    final Iterator<Path> it = pathIterable2.iterator();
    try {
      it.remove();
      assertFalse(true); // exception expected
    } catch (UnsupportedOperationException uoe) {
      // okay
    }
  } finally {
    Shell.execCommand(new String[] { "chmod", "u+w", BUFFER_DIR_ROOT });
    rmBufferDirs();
  }
}