}
public void testChunk(int chunkSize, int count) throws Exception {
MockSender sender = new MockSender((chunkSize * count) + 1024);
MockMonitor monitor = new MockMonitor();
ChunkedConsumer validator = new ChunkedConsumer(new ArrayAllocator());
ChunkedProducer producer = new ChunkedProducer(sender, monitor);
byte[] chunk = new byte[chunkSize];
for(int i = 0; i < chunk.length; i++) {
chunk[i] = (byte)String.valueOf(i).charAt(0);
}
for(int i = 0; i < count; i++) {
producer.produce(chunk, 0, chunkSize);
}
producer.close();
System.err.println(sender.getBuffer().encode("UTF-8"));
Cursor cursor = sender.getCursor();
while(!validator.isFinished()) {
validator.consume(cursor);
}
assertEquals(cursor.ready(), -1);
assertTrue(monitor.isReady());
}