Skip to content

Commit

Permalink
Add unit test that shows LineBasedFrameDelimiter correctly splits line.
Browse files Browse the repository at this point in the history
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
normanmaurer committed Jan 11, 2017
1 parent 631077c commit 7a4b0c3
Showing 1 changed file with 17 additions and 0 deletions.
Expand Up @@ -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.