### Question:
LineBasedFrameDecoder extends FrameDecoder { private void fail(final ChannelHandlerContext ctx, int length) { fail(ctx, String.valueOf(length)); } LineBasedFrameDecoder(final int maxLength);  LineBasedFrameDecoder(final int maxLength, final boolean stripDelimiter, final boolean failFast);   }### Answer:
@Test public void testTooLongLine1() throws Exception { DecoderEmbedder<ChannelBuffer> embedder = new DecoderEmbedder<ChannelBuffer>( new LineBasedFrameDecoder(16, false, false)); try { embedder.offer(copiedBuffer("12345678901234567890\r\nfirst\nsecond", CharsetUtil.US_ASCII)); fail(); } catch (CodecEmbedderException e) { assertThat(e.getCause(), is(instanceOf(TooLongFrameException.class))); } embedder.offer(wrappedBuffer(new byte[1])); assertThat(embedder.size(), is(1)); assertTrue(embedder.finish()); assertThat(embedder.size(), is(1)); assertThat(embedder.poll().toString(CharsetUtil.US_ASCII), is("first\n")); }
@Test public void testTooLongLine2() throws Exception { DecoderEmbedder<ChannelBuffer> embedder = new DecoderEmbedder<ChannelBuffer>( new LineBasedFrameDecoder(16, false, false)); assertFalse(embedder.offer(copiedBuffer("12345678901234567", CharsetUtil.US_ASCII))); try { embedder.offer(copiedBuffer("890\r\nfirst\r\n", CharsetUtil.US_ASCII)); fail(); } catch (CodecEmbedderException e) { assertThat(e.getCause(), is(instanceOf(TooLongFrameException.class))); } embedder.offer(wrappedBuffer(new byte[1])); assertThat(embedder.size(), is(1)); assertTrue(embedder.finish()); assertThat(embedder.size(), is(1)); assertEquals("first\r\n", embedder.poll().toString(CharsetUtil.US_ASCII)); }
@Test public void testTooLongLineWithFailFast() throws Exception { DecoderEmbedder<ChannelBuffer> embedder = new DecoderEmbedder<ChannelBuffer>( new LineBasedFrameDecoder(16, false, true)); try { embedder.offer(copiedBuffer("12345678901234567", CharsetUtil.US_ASCII)); fail(); } catch (CodecEmbedderException e) { assertThat(e.getCause(), is(instanceOf(TooLongFrameException.class))); } assertThat(embedder.offer(copiedBuffer("890", CharsetUtil.US_ASCII)), is(false)); assertThat(embedder.offer(copiedBuffer("123\r\nfirst\r\n", CharsetUtil.US_ASCII)), is(true)); assertThat(embedder.size(), is(1)); assertTrue(embedder.finish()); assertThat(embedder.size(), is(1)); assertEquals("first\r\n", embedder.poll().toString(CharsetUtil.US_ASCII)); }