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:
parent
d771526f8c
commit
84410f97af
@ -145,4 +145,26 @@ public class LineBasedFrameDecoderTest {
|
||||
buf.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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user