Add unit test that shows LineBasedFrameDelimiter correctly handles fragmented data.

Motivation:

Verify everything works as expected.

Modifications:

Added testcase.

Result:

More test-coverage.
This commit is contained in:
Johno Crawford 2017-01-11 13:52:01 +01:00 committed by Norman Maurer
parent d771526f8c
commit 84410f97af

View File

@ -145,4 +145,26 @@ public class LineBasedFrameDecoderTest {
buf.release(); buf.release();
buf2.release(); buf2.release();
} }
@Test
public void testFragmentedDecode() throws Exception {
EmbeddedChannel ch = new EmbeddedChannel(new LineBasedFrameDecoder(8192, false, false));
assertFalse(ch.writeInbound(copiedBuffer("huu", CharsetUtil.US_ASCII)));
assertNull(ch.readInbound());
assertFalse(ch.writeInbound(copiedBuffer("haa\r", CharsetUtil.US_ASCII)));
assertNull(ch.readInbound());
assertTrue(ch.writeInbound(copiedBuffer("\nhuuhaa\r\n", CharsetUtil.US_ASCII)));
ByteBuf buf = ch.readInbound();
assertEquals("huuhaa\r\n", buf.toString(CharsetUtil.US_ASCII));
ByteBuf buf2 = ch.readInbound();
assertEquals("huuhaa\r\n", buf2.toString(CharsetUtil.US_ASCII));
assertFalse(ch.finishAndReleaseAll());
buf.release();
buf2.release();
}
} }