@Test public void incompleteReadsTest() throws IOException { 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()); } channel = new IncompleteReadReadableStreamChannel(null); inputStream = new ReadableStreamChannelInputStream(channel); try { inputStream.read(); fail("The read should have failed"); } catch (IllegalStateException e) { } }
@Override public int read() throws IOException { int data = -1; if (loadData()) { data = currentChunk.get() & 0xFF; reportBytesRead(1); } return data; }
ReadableStreamChannelInputStream extends InputStream { @Override public int read() throws IOException { int data = -1; if (loadData()) { data = currentChunk.get() & 0xFF; reportBytesRead(1); } return data; } }
ReadableStreamChannelInputStream extends InputStream { @Override public int read() throws IOException { int data = -1; if (loadData()) { data = currentChunk.get() & 0xFF; reportBytesRead(1); } return data; } ReadableStreamChannelInputStream(ReadableStreamChannel readableStreamChannel); }
ReadableStreamChannelInputStream extends InputStream { @Override public int read() throws IOException { int data = -1; if (loadData()) { data = currentChunk.get() & 0xFF; reportBytesRead(1); } return data; } ReadableStreamChannelInputStream(ReadableStreamChannel readableStreamChannel); @Override int available(); @Override int read(); @Override int read(byte b[], int off, int len); @Override void close(); }
ReadableStreamChannelInputStream extends InputStream { @Override public int read() throws IOException { int data = -1; if (loadData()) { data = currentChunk.get() & 0xFF; reportBytesRead(1); } return data; } ReadableStreamChannelInputStream(ReadableStreamChannel readableStreamChannel); @Override int available(); @Override int read(); @Override int read(byte b[], int off, int len); @Override void close();  }