@Test
public void testSuccessfulReadAhead() throws Exception {

  // Mock failure for client.read()
  AbfsClient client = getMockAbfsClient();
  // Success operation mock
  AbfsRestOperation op = getMockRestOp();
  // Stub :
  // Pass all readAheads and fail the post eviction request to
  // prove ReadAhead buffer is used
  // for post eviction check, fail all read aheads
  doReturn(op)
      .doReturn(op)
      .doReturn(op)
      .doThrow(new TimeoutException("Internal Server error for RAH-X"))
      .doThrow(new TimeoutException("Internal Server error for RAH-Y"))
      .doThrow(new TimeoutException("Internal Server error for RAH-Z"))
      .when(client)
      .read(any(String.class), any(Long.class), any(byte[].class),
          any(Integer.class), any(Integer.class), any(String.class),
          any(String.class));
  AbfsInputStream inputStream = getAbfsInputStream(client, "testSuccessfulReadAhead.txt");
  // First read request that triggers readAheads.
  inputStream.read(new byte[ONE_KB]);
  // Only the 3 readAhead threads should have triggered client.read
  verifyReadCallCount(client, 3);
  // Another read request whose requested data is already read ahead.
  inputStream.read(ONE_KB, new byte[ONE_KB], 0, ONE_KB);
  // Once created, mock will remember all interactions.
  // As the above read should not have triggered any server calls, total
  // number of read calls made at this point will be same as last.
  verifyReadCallCount(client, 3);
  // Stub will throw exception for client.read() for 4th and later calls
  // if not using the read-ahead buffer exception will be thrown on read
  checkEvictedStatus(inputStream, 0, true);
}