@Test
public void testEndOfStreamConditionReadingFooters() throws Exception {

    final String s = "10\r\n1234567890123456\r\n" +
            "5\r\n12345\r\n5\r\n12345\r\n0\r\n";
    final ReadableByteChannel channel = new ReadableByteChannelMock(
            new String[] {s}, StandardCharsets.US_ASCII);
    final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, 0, StandardCharsets.US_ASCII);
    final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
    final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
    final ByteBuffer dst = ByteBuffer.allocate(1024);
    int bytesRead = 0;
    while (dst.hasRemaining() && !decoder.isCompleted()) {
        final int i = decoder.read(dst);
        if (i > 0) {
            bytesRead += i;
        }
    }
    Assert.assertEquals(26, bytesRead);
    Assert.assertEquals("12345678901234561234512345", CodecTestUtils.convert(dst));
    Assert.assertTrue(decoder.isCompleted());
}