public void testChunkExceed() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableByteChannel channel = newChannel(baos);
HttpParams params = new BasicHttpParams();
SessionOutputBuffer outbuf = new SessionOutputBufferImpl(16, 16, params);
HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
ChunkEncoder encoder = new ChunkEncoder(channel, outbuf, metrics);
ByteBuffer src = wrap("0123456789ABCDEF");
encoder.write(src);
assertTrue(src.hasRemaining());
assertEquals(10, src.remaining());
encoder.write(src);
assertTrue(src.hasRemaining());
assertEquals(4, src.remaining());
encoder.write(src);
assertFalse(src.hasRemaining());
outbuf.flush(channel);
String s = baos.toString("US-ASCII");
assertEquals("6\r\n012345\r\n6\r\n6789AB\r\n4\r\nCDEF\r\n", s);
}