@Test
public void testSeek() throws Exception {

  Path seekTestFilePath = new Path(this.testRootDir + "/"
      + "seekTestFile");
  long fileSize = 5 * Unit.MB;
  ContractTestUtils.generateTestFile(
      this.fs, seekTestFilePath, fileSize, 256, 255);
  LOG.info("5MB file for seek test has created.");
  FSDataInputStream inputStream = this.fs.open(seekTestFilePath);
  int seekTimes = 5;
  for (int i = 0; i != seekTimes; i++) {
    long pos = fileSize / (seekTimes - i) - 1;
    inputStream.seek(pos);
    assertTrue("expected position at: " +
            pos + ", but got: " + inputStream.getPos(),
        inputStream.getPos() == pos);
    LOG.info("completed seeking at pos: " + inputStream.getPos());
  }
  LOG.info("begin to random position seeking test...");
  Random random = new Random();
  for (int i = 0; i < seekTimes; i++) {
    long pos = Math.abs(random.nextLong()) % fileSize;
    LOG.info("seeking for pos: " + pos);
    inputStream.seek(pos);
    assertTrue("expected position at: " +
            pos + ", but got: " + inputStream.getPos(),
        inputStream.getPos() == pos);
    LOG.info("completed seeking at pos: " + inputStream.getPos());
  }
}