### Question:
JsonRpcDecoder extends ByteToMessageDecoder { @Override protected void decode(final ChannelHandlerContext ctx, final ByteBuf buf, final List<Object> out) throws IOException { LOG.trace("readable bytes {}, records read {}, incomplete record bytes {}", buf.readableBytes(), recordsRead, lastRecordBytes); if (lastRecordBytes == 0) { if (buf.readableBytes() < 4) { return; } skipSpaces(buf); byte[] buff = new byte[4]; buf.getBytes(buf.readerIndex(), buff); ByteSourceJsonBootstrapper strapper = new ByteSourceJsonBootstrapper(jacksonIOContext, buff, 0, 4); JsonEncoding jsonEncoding = strapper.detectEncoding(); if (!JsonEncoding.UTF8.equals(jsonEncoding)) { throw new InvalidEncodingException(jsonEncoding.getJavaName(), "currently only UTF-8 is supported"); } } int index = lastRecordBytes + buf.readerIndex(); for (; index < buf.writerIndex(); index++) { switch (buf.getByte(index)) { case '{': if (!inS) { leftCurlies++; } break; case '}': if (!inS) { rightCurlies++; } break; case '"': if (buf.getByte(index - 1) != '\\') { inS = !inS; } break; default: break; } if (leftCurlies != 0 && leftCurlies == rightCurlies && !inS) { ByteBuf slice = buf.readSlice(1 + index - buf.readerIndex()); JsonParser jp = JSON_FACTORY.createParser((InputStream) new ByteBufInputStream(slice)); JsonNode root = jp.readValueAsTree(); out.add(root); leftCurlies = 0; rightCurlies = 0; lastRecordBytes = 0; recordsRead++; break; } if (index - buf.readerIndex() >= maxFrameLength && !maxFrameLimitWasReached) { maxFrameLimitWasReached = true; LOG.warn("***** OVSDB Frame limit of {} bytes has been reached! *****", this.maxFrameLength); } } if (index >= buf.writerIndex()) { lastRecordBytes = buf.readableBytes(); } } JsonRpcDecoder(final int maxFrameLength); int getRecordsRead();  }### Answer:
@Test public void testDecode() throws Exception { for (int i = 0; i < 10; i++) { ch.writeInbound(copiedBuffer(testJson, CharsetUtil.UTF_8)); } ch.readInbound(); assertEquals(10, decoder.getRecordsRead()); ch.finish(); }