ByteBuffer buffer = encoder.encode(value);
for (int i = 1; i < 5; i++) {
int size = buffer.remaining() + i;
IoBuffer extendedBuffer = IoBuffer.wrap(ByteBuffer.allocate(size));
int start = extendedBuffer.position();
extendedBuffer.put(buffer.slice());
extendedBuffer.position(start);
extendedBuffer.limit(start + size);
try {
decoder.decode(extendedBuffer);
assertEquals(i, extendedBuffer.remaining());
} catch (ProtocolDecoderException e) {
fail("Should not throw exception");
}
}
}