@Test
public void testTooManyFooters() throws Exception {
final String s = "10\r\n1234567890123456\r\n" +
"0\r\nFooter1: blah\r\nFooter2: blah\r\nFooter3: blah\r\nFooter4: blah\r\n\r\n";
final ReadableByteChannel channel1 = new ReadableByteChannelMock(
new String[] {s}, Consts.ASCII);
final SessionInputBuffer inbuf1 = new SessionInputBufferImpl(1024, 256,
MessageConstraints.DEFAULT, Consts.ASCII);
final HttpTransportMetricsImpl metrics1 = new HttpTransportMetricsImpl();
final ChunkDecoder decoder1 = new ChunkDecoder(channel1, inbuf1, metrics1);
final ByteBuffer dst = ByteBuffer.allocate(1024);
final int bytesRead = decoder1.read(dst);
Assert.assertEquals(16, bytesRead);
Assert.assertEquals("1234567890123456", CodecTestUtils.convert(dst));
final Header[] footers = decoder1.getFooters();
Assert.assertNotNull(footers);
Assert.assertEquals(4, footers.length);
final MessageConstraints constraints = MessageConstraints.custom()
.setMaxHeaderCount(3).build();
final ReadableByteChannel channel2 = new ReadableByteChannelMock(
new String[] {s}, Consts.ASCII);
final SessionInputBuffer inbuf2 = new SessionInputBufferImpl(1024, 256,
constraints, Consts.ASCII);
final HttpTransportMetricsImpl metrics2 = new HttpTransportMetricsImpl();
final ChunkDecoder decoder2 = new ChunkDecoder(channel2, inbuf2, constraints, metrics2);