@Test
  public void incompleteReadsTest() throws IOException {
    // Exception during read
    String exceptionMsg = "@@randomMsg@@";
    Exception exceptionToThrow = new Exception(exceptionMsg);
    ReadableStreamChannel channel = new IncompleteReadReadableStreamChannel(exceptionToThrow);
    InputStream inputStream = new ReadableStreamChannelInputStream(channel);
    try {
      inputStream.read();
      fail("The read should have failed");
    } catch (Exception e) {
      while (e.getCause() != null) {
        e = (Exception) e.getCause();
      }
      assertEquals("Exception messages do not match", exceptionMsg, e.getMessage());
    }

    // incomplete read
    channel = new IncompleteReadReadableStreamChannel(null);
    inputStream = new ReadableStreamChannelInputStream(channel);
    try {
      inputStream.read();
      fail("The read should have failed");
    } catch (IllegalStateException e) {
      // expected. Nothing to do.
    }
  }
Tests for the case when reads are incomplete either because exceptions were thrown or the read simply did not
complete.
@throws IOException
ambry-commons/src/test/java/com/github/ambry/commons/ReadableStreamChannelInputStreamTest.java