@Test public void testMultipleReads() throws IOException { final int srcArraySize = (3 * chunkSize) + 42; final byte[] srcArray = new byte[srcArraySize]; random.nextBytes(srcArray); final ByteArrayBodyGenerator babGen = new ByteArrayBodyGenerator(srcArray); final Body body = babGen.createBody(); final ByteBuf chunkBuffer = Unpooled.buffer(chunkSize); try { int reads = 0; int bytesRead = 0; while (body.transferTo(chunkBuffer) != BodyState.STOP) { reads += 1; bytesRead += chunkBuffer.readableBytes(); chunkBuffer.clear(); } assertEquals(reads, 4, "reads to drain generator"); assertEquals(bytesRead, srcArraySize, "bytes read"); } finally { chunkBuffer.release(); } }
@Override public Body createBody() { return new ByteBody(); }
ByteArrayBodyGenerator implements BodyGenerator { @Override public Body createBody() { return new ByteBody(); } }
ByteArrayBodyGenerator implements BodyGenerator { @Override public Body createBody() { return new ByteBody(); } ByteArrayBodyGenerator(byte[] bytes); }
ByteArrayBodyGenerator implements BodyGenerator { @Override public Body createBody() { return new ByteBody(); } ByteArrayBodyGenerator(byte[] bytes); @Override Body createBody(); }
ByteArrayBodyGenerator implements BodyGenerator { @Override public Body createBody() { return new ByteBody(); } ByteArrayBodyGenerator(byte[] bytes); @Override Body createBody();  }