Add unit test that shows LineBasedFrameDelimiter correctly splits line.

Motivation:

Thought there may be a bug so added a testcase to verify everything works as expected.

Modifications:

Added testcase

Result:

More test-coverage.
This commit is contained in:
Norman Maurer 2016-12-22 10:30:31 +01:00
parent 631077c793
commit 7a4b0c3297

View File

@ -128,4 +128,21 @@ public class LineBasedFrameDecoderTest {
buf.release();
buf2.release();
}
@Test
public void testDecodeSplitsCorrectly() throws Exception {
EmbeddedChannel ch = new EmbeddedChannel(new LineBasedFrameDecoder(8192, false, false));
assertTrue(ch.writeInbound(copiedBuffer("line\r\n.\r\n", CharsetUtil.US_ASCII)));
ByteBuf buf = ch.readInbound();
assertEquals("line\r\n", buf.toString(CharsetUtil.US_ASCII));
ByteBuf buf2 = ch.readInbound();
assertEquals(".\r\n", buf2.toString(CharsetUtil.US_ASCII));
assertFalse(ch.finishAndReleaseAll());
buf.release();
buf2.release();
}
}