@Test
  public void commonCasesTest() throws Exception {
    int bufSize = InputStreamReadableStreamChannel.BUFFER_SIZE;
    int randSizeLessThanBuffer = TestUtils.RANDOM.nextInt(bufSize - 2) + 2;
    int randMultiplier = TestUtils.RANDOM.nextInt(10) + 1;
    int[] testStreamSizes =
        {0, 1, randSizeLessThanBuffer, bufSize, bufSize + 1, bufSize * randMultiplier, bufSize * randMultiplier + 1};
    for (int size : testStreamSizes) {
      byte[] src = TestUtils.getRandomBytes(size);

      InputStream stream = new ByteBufferInputStream(ByteBuffer.wrap(src));
      doReadTest(stream, src, src.length);

      stream = new ByteBufferInputStream(ByteBuffer.wrap(src));
      doReadTest(stream, src, -1);

      stream = new HaltingInputStream(new ByteBufferInputStream(ByteBuffer.wrap(src)));
      doReadTest(stream, src, src.length);

      stream = new HaltingInputStream(new ByteBufferInputStream(ByteBuffer.wrap(src)));
      doReadTest(stream, src, -1);
    }
  }
Tests different types of {@link InputStream} and different sizes of the stream and ensures that the data is read
correctly.
@throws Exception
ambry-commons/src/test/java/com/github/ambry/commons/InputStreamReadableStreamChannelTest.java