@Override
  public int read() throws IOException {
    if (this.closed) {
      throw new IOException(FSExceptionMessages.STREAM_IS_CLOSED);
    }

    if (this.partRemaining <= 0 && this.position < this.fileSize) {
      this.reopen(this.position);
    }

    int byteRead = -1;
    if (this.partRemaining != 0) {
      byteRead = this.buffer[
          (int) (this.buffer.length - this.partRemaining)] & 0xff;
    }
    if (byteRead >= 0) {
      this.position++;
      this.partRemaining--;
      if (null != this.statistics) {
        this.statistics.incrementBytesRead(byteRead);
      }
    }

    return byteRead;
  }
@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);
  }