@Test
public void testRead() throws Exception {

  final int bufLen = 256;
  Path readTestFilePath = new Path(this.testRootDir + "/"
      + "testReadSmallFile.txt");
  long fileSize = 5 * Unit.MB;
  ContractTestUtils.generateTestFile(
      this.fs, readTestFilePath, fileSize, 256, 255);
  LOG.info("read test file: " + readTestFilePath + " has created.");
  FSDataInputStream inputStream = this.fs.open(readTestFilePath);
  byte[] buf = new byte[bufLen];
  long bytesRead = 0;
  while (bytesRead < fileSize) {
    int bytes = 0;
    if (fileSize - bytesRead < bufLen) {
      int remaining = (int) (fileSize - bytesRead);
      bytes = inputStream.read(buf, 0, remaining);
    } else {
      bytes = inputStream.read(buf, 0, bufLen);
    }
    bytesRead += bytes;
    if (bytesRead % (1 * Unit.MB) == 0) {
      int available = inputStream.available();
      assertTrue("expected remaining: " + (fileSize - bytesRead) +
          " but got: " + available, (fileSize - bytesRead) == available);
      LOG.info("Bytes read: " +
          Math.round((double) bytesRead / Unit.MB) + "MB");
    }
  }
  assertTrue(inputStream.available() == 0);
  IOUtils.closeStream(inputStream);
}