@Test(expected=ProtocolException.class)
public void testReadEvilPackage() throws Exception {

    expect(readableByteChannel.read(EasyMock.anyObject())).andAnswer(new IAnswer<Integer>() {
        @Override
        public Integer answer() throws Throwable {
            ByteBuffer buffer = (ByteBuffer)EasyMock.getCurrentArguments()[0];
            // an attacker could do that to provoke out of memory
            buffer.putInt(Integer.MAX_VALUE-1);
            return 1;
        }
    });
    replay(readableByteChannel);
    codec.read();
}