private void doReadPartByPartTest(InputStream stream, byte[] in) throws IOException {
    byte[] out = new byte[in.length];
    for (int start = 0; start < in.length; ) {
      int end = Math.min(start + in.length / READ_PART_COUNT, in.length);
      int len = end - start;
      assertEquals("Bytes read did not match what was requested", len, stream.read(out, start, len));
      assertArrayEquals("Byte array obtained from InputStream did not match source", Arrays.copyOfRange(in, start, end),
          Arrays.copyOfRange(out, start, end));
      start = end;
    }
    if (out.length > 0) {
      assertEquals("Did not receive expected EOF", -1, stream.read(out, 0, out.length));
    }
    assertEquals("Did not receive expected EOF", -1, stream.read());
  }
Tests reading {@link InputStream} part by part.
@param stream the {@link InputStream} to test.
@param in the original data that is inside {@code stream}.
@throws IOException
ambry-commons/src/test/java/com/github/ambry/commons/ReadableStreamChannelInputStreamTest.java