byteOutput.flush();
final byte[] chunked = byteArrayOutputStream.toByteArray();
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(chunked);
final ByteInput byteInput = new ChunkyByteInput(Marshalling.createByteInput(byteArrayInputStream));
int readLength = 5;
byte[] result = new byte[content.length];
byteInput.read(result, content.length - 6, readLength);
byteInput.close();
byte[] expected = new byte[content.length];
System.arraycopy(content, 0, expected, content.length - 6, readLength);
Assert.assertArrayEquals(expected, result);
Assert.assertEquals(-1, byteInput.read());
}