private void testFromDFS(DistributedFileSystem dfs, String src, int repCount, String localhost)
    throws Exception {
    // Multiple times as the order is random
    for (int i = 0; i < 10; i++) {
      LocatedBlocks lbs;
      // The NN gets the block list asynchronously, so we may need multiple tries to get the list
      final long max = EnvironmentEdgeManager.currentTime() + 10000;
      boolean done;
      do {
        Assert.assertTrue("Can't get enouth replica", EnvironmentEdgeManager.currentTime() < max);
        lbs = getNamenode(dfs.getClient()).getBlockLocations(src, 0, 1);
        Assert.assertNotNull("Can't get block locations for " + src, lbs);
        Assert.assertNotNull(lbs.getLocatedBlocks());
        Assert.assertTrue(lbs.getLocatedBlocks().size() > 0);

        done = true;
        for (int y = 0; y < lbs.getLocatedBlocks().size() && done; y++) {
          done = getLocatedBlockLocations(lbs.get(y)).length == repCount;
        }
      } while (!done);

      for (int y = 0; y < lbs.getLocatedBlocks().size() && done; y++) {
        Assert.assertEquals(localhost,
          getLocatedBlockLocations(lbs.get(y))[repCount - 1].getHostName());
      }
    }
  }
Test that the hook works within HBase, including when there are multiple blocks.
hbase-server/src/test/java/org/apache/hadoop/hbase/fs/TestBlockReorderMultiBlocks.java