@Test
public void testCodingFragmentBufferingMultipleFragmentsBeyondContentLimit() throws Exception {

    final WritableByteChannelMock channel = Mockito.spy(new WritableByteChannelMock(64));
    final SessionOutputBuffer outbuf = Mockito.spy(new SessionOutputBufferImpl(1024, 128));
    final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
    final LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(channel, outbuf, metrics,
        16, 32);
    Assert.assertEquals(5, encoder.write(CodecTestUtils.wrap("stuff")));
    Assert.assertEquals(1, encoder.write(CodecTestUtils.wrap("-")));
    Assert.assertEquals(10, encoder.write(CodecTestUtils.wrap("more stuff; and a lot more stuff")));
    Mockito.verify(channel, Mockito.never()).write(ArgumentMatchers.<ByteBuffer>any());
    Mockito.verify(outbuf, Mockito.times(3)).write(ArgumentMatchers.<ByteBuffer>any());
    Mockito.verify(outbuf, Mockito.never()).flush(channel);
    Assert.assertEquals(0, metrics.getBytesTransferred());
    outbuf.flush(channel);
    final String s = channel.dump(StandardCharsets.US_ASCII);
    Assert.assertEquals("stuff-more stuff", s);
}