private void doAvailableTest(InputStream stream, byte[] in, int partLength) throws IOException {
    byte[] out = new byte[in.length / READ_PART_COUNT];
    int totalBytesRead = 0;
    for (int i = 0; totalBytesRead < in.length; i++) {
      int sourceStart = out.length * i;
      // available will be 0 when no chunks have been read.
      int expectedAvailable = sourceStart == 0 ? 0 : partLength - (sourceStart % partLength);
      assertEquals("Available differs from expected", expectedAvailable, stream.available());
      int bytesRead = stream.read(out);
      assertArrayEquals("Byte array obtained from InputStream did not match source",
          Arrays.copyOfRange(in, sourceStart, sourceStart + bytesRead), Arrays.copyOfRange(out, 0, bytesRead));
      totalBytesRead += bytesRead;
    }
    assertEquals("Available should be 0", 0, stream.available());
  }
Tests correctness of {@link ReadableStreamChannelInputStream#available()}.
@param stream the {@link InputStream} to read from.
@param in the original data that is inside {@code stream}.
@param partLength the length of each chunk that is inside the {@link ReadableStreamChannel} backing the
{@code stream}
@throws IOException
ambry-commons/src/test/java/com/github/ambry/commons/ReadableStreamChannelInputStreamTest.java