@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); ReadableStreamChannel channel = new ByteBufferReadableStreamChannel(ByteBuffer.wrap(in)); InputStream stream = new ReadableStreamChannelInputStream(channel); doAvailableTest(stream, in, in.length); stream.close(); channel = new NoSizeRSC(ByteBuffer.wrap(in)); stream = new ReadableStreamChannelInputStream(channel); doAvailableTest(stream, in, in.length); stream.close(); List<ByteBuffer> contents = splitContent(in, CONTENT_SPLIT_PART_COUNT); contents.add(null); int partLength = contents.get(0).remaining(); channel = new MockRestRequest(MockRestRequest.DUMMY_DATA, contents); stream = new ReadableStreamChannelInputStream(channel); doAvailableTest(stream, in, partLength); stream.close(); } }
@Override public int available() { return currentChunk == null ? 0 : currentChunk.remaining(); }
ReadableStreamChannelInputStream extends InputStream { @Override public int available() { return currentChunk == null ? 0 : currentChunk.remaining(); } }
ReadableStreamChannelInputStream extends InputStream { @Override public int available() { return currentChunk == null ? 0 : currentChunk.remaining(); } ReadableStreamChannelInputStream(ReadableStreamChannel readableStreamChannel); }
ReadableStreamChannelInputStream extends InputStream { @Override public int available() { return currentChunk == null ? 0 : currentChunk.remaining(); } 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 available() { return currentChunk == null ? 0 : currentChunk.remaining(); } ReadableStreamChannelInputStream(ReadableStreamChannel readableStreamChannel); @Override int available(); @Override int read(); @Override int read(byte b[], int off, int len); @Override void close();  }