// Make sure we fail early for case of large text messages: we should fail as soon as we process // a network packet that exceeds the limit (2nd packet in this case) @Test(expected = ProtocolDecoderException.class) public void sizeLimitDecodeTextFrameFailEarly2() throws Exception { ProtocolCodecSessionEx session = new ProtocolCodecSessionEx(); IoBufferAllocatorEx<?> allocator = session.getBufferAllocator(); ProtocolDecoder decoder = new WsFrameDecoder(allocator, 20); int dataSize = 30; StringBuilder data = new StringBuilder(dataSize); for (int i = 0; i < (dataSize); i++) { data.append((i % 10)); } IoBufferEx in = allocator .wrap(allocator.allocate(dataSize + 2)) .put((byte) 0x81) .put((byte) 30) .putString(data.toString(), UTF_8.newEncoder()) .flip(); decoder.decode(session, (IoBuffer) in.getSlice(10), session.getDecoderOutput()); // Now if we send the next 12 bytes that should exceed the limit (first byte is control byte, // doesn't count) decoder.decode(session, (IoBuffer) in.getSlice(12), session.getDecoderOutput()); }