@Test
  public void availableTest() throws Exception {
    int[] sizes = {0, 1024 * CONTENT_SPLIT_PART_COUNT};
    for (int size : sizes) {
      byte[] in = new byte[size];
      new Random().nextBytes(in);

      // channel with size and one piece of content.
      ReadableStreamChannel channel = new ByteBufferReadableStreamChannel(ByteBuffer.wrap(in));
      InputStream stream = new ReadableStreamChannelInputStream(channel);
      doAvailableTest(stream, in, in.length);
      stream.close();

      // channel with no size and multiple pieces of content.
      channel = new NoSizeRSC(ByteBuffer.wrap(in));
      stream = new ReadableStreamChannelInputStream(channel);
      doAvailableTest(stream, in, in.length);
      stream.close();

      // channel with no size and multiple pieces of content.
      List<ByteBuffer> contents = splitContent(in, CONTENT_SPLIT_PART_COUNT);
      contents.add(null);
      // assuming all parts are the same length.
      int partLength = contents.get(0).remaining();
      channel = new MockRestRequest(MockRestRequest.DUMMY_DATA, contents);
      stream = new ReadableStreamChannelInputStream(channel);
      doAvailableTest(stream, in, partLength);
      stream.close();
    }
  }
Tests correctness of {@link ReadableStreamChannelInputStream#available()}.
@throws Exception
ambry-commons/src/test/java/com/github/ambry/commons/ReadableStreamChannelInputStreamTest.java