From 7a4b0c32972b5d3b8d440f98e151b25d6d135ad3 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Thu, 22 Dec 2016 10:30:31 +0100 Subject: [PATCH] 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. --- .../codec/LineBasedFrameDecoderTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/codec/src/test/java/io/netty/handler/codec/LineBasedFrameDecoderTest.java b/codec/src/test/java/io/netty/handler/codec/LineBasedFrameDecoderTest.java index a432d929f2..334534830e 100644 --- a/codec/src/test/java/io/netty/handler/codec/LineBasedFrameDecoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/LineBasedFrameDecoderTest.java @@ -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(); + } }