### Question:
DelimiterBasedFrameDecoder extends FrameDecoder { @Override protected Object decode( ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception { if (lineBasedDecoder != null) { return lineBasedDecoder.decode(ctx, channel, buffer); } int minFrameLength = Integer.MAX_VALUE; ChannelBuffer minDelim = null; for (ChannelBuffer delim: delimiters) { int frameLength = indexOf(buffer, delim); if (frameLength >= 0 && frameLength < minFrameLength) { minFrameLength = frameLength; minDelim = delim; } } if (minDelim != null) { int minDelimLength = minDelim.capacity(); ChannelBuffer frame; if (discardingTooLongFrame) { discardingTooLongFrame = false; buffer.skipBytes(minFrameLength + minDelimLength); int tooLongFrameLength = this.tooLongFrameLength; this.tooLongFrameLength = 0; if (!failFast) { fail(ctx, tooLongFrameLength); } return null; } if (minFrameLength > maxFrameLength) { buffer.skipBytes(minFrameLength + minDelimLength); fail(ctx, minFrameLength); return null; } if (stripDelimiter) { frame = extractFrame(buffer, buffer.readerIndex(), minFrameLength); } else { frame = extractFrame(buffer, buffer.readerIndex(), minFrameLength + minDelimLength); } buffer.skipBytes(minFrameLength + minDelimLength); return frame; } else { if (!discardingTooLongFrame) { if (buffer.readableBytes() > maxFrameLength) { tooLongFrameLength = buffer.readableBytes(); buffer.skipBytes(buffer.readableBytes()); discardingTooLongFrame = true; if (failFast) { fail(ctx, tooLongFrameLength); } } } else { tooLongFrameLength += buffer.readableBytes(); buffer.skipBytes(buffer.readableBytes()); } return null; } } DelimiterBasedFrameDecoder(int maxFrameLength, ChannelBuffer delimiter);  DelimiterBasedFrameDecoder(
            int maxFrameLength, boolean stripDelimiter, ChannelBuffer delimiter);  DelimiterBasedFrameDecoder(
            int maxFrameLength, boolean stripDelimiter, boolean failFast,
            ChannelBuffer delimiter);  DelimiterBasedFrameDecoder(int maxFrameLength, ChannelBuffer... delimiters);  DelimiterBasedFrameDecoder(
            int maxFrameLength, boolean stripDelimiter, ChannelBuffer... delimiters);  DelimiterBasedFrameDecoder(
            int maxFrameLength, boolean stripDelimiter, boolean failFast, ChannelBuffer... delimiters);   }### Answer:
@Test public void testDecode() throws Exception { DecoderEmbedder<ChannelBuffer> embedder = new DecoderEmbedder<ChannelBuffer>( new DelimiterBasedFrameDecoder(8192, true, Delimiters.lineDelimiter())); Assert.assertTrue(embedder.offer(ChannelBuffers.copiedBuffer("first\r\nsecond\nthird", CharsetUtil.US_ASCII))); Assert.assertTrue(embedder.finish()); Assert.assertEquals("first", embedder.poll().toString(CharsetUtil.US_ASCII)); Assert.assertEquals("second", embedder.poll().toString(CharsetUtil.US_ASCII)); Assert.assertNull(embedder.poll()); }