@Test
public void testBufferFragments() throws Exception {

    final WritableByteChannelMock channel = Mockito.spy(new WritableByteChannelMock(1024));
    final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 1024);
    final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
    final ChunkEncoder encoder = new ChunkEncoder(channel, outbuf, metrics, 1024);
    Assert.assertEquals(16, encoder.write(CodecTestUtils.wrap("0123456789ABCDEF")));
    Assert.assertEquals(16, encoder.write(CodecTestUtils.wrap("0123456789ABCDEF")));
    Assert.assertEquals(16, encoder.write(CodecTestUtils.wrap("0123456789ABCDEF")));
    Mockito.verify(channel, Mockito.never()).write(ArgumentMatchers.<ByteBuffer>any());
    outbuf.flush(channel);
    final String s = channel.dump(StandardCharsets.US_ASCII);
    Assert.assertEquals("10\r\n0123456789ABCDEF\r\n10\r\n0123456789ABCDEF\r\n" +
            "10\r\n0123456789ABCDEF\r\n", s);
}