Permalink
Browse files

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.
  • Loading branch information...
1 parent 631077c commit 7a4b0c32972b5d3b8d440f98e151b25d6d135ad3 @normanmaurer normanmaurer committed Dec 22, 2016
Showing with 17 additions and 0 deletions.
  1. +17 −0 codec/src/test/java/io/netty/handler/codec/LineBasedFrameDecoderTest.java
@@ -128,4 +128,21 @@ public void testTooLongLineWithFailFast() throws Exception {
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();
+ }
}

0 comments on commit 7a4b0c3

Please sign in to comment.