private final static String CHUNKED_RESULT
= "123456789012345612345";
// Test for when buffer is larger than chunk size
public void testChunkedInputStreamLargeBuffer() throws IOException {
ChunkedInputStream in = new ChunkedInputStream(
new SessionInputBufferMockup(
EncodingUtils.getBytes(CHUNKED_INPUT, CONTENT_CHARSET)));
byte[] buffer = new byte[300];
ByteArrayOutputStream out = new ByteArrayOutputStream();
int len;
while ((len = in.read(buffer)) > 0) {
out.write(buffer, 0, len);
}
assertEquals(-1, in.read(buffer));
assertEquals(-1, in.read(buffer));
in.close();
String result = EncodingUtils.getString(out.toByteArray(), CONTENT_CHARSET);
assertEquals(result, CHUNKED_RESULT);
Header[] footers = in.getFooters();
assertNotNull(footers);
assertEquals(2, footers.length);
assertEquals("Footer1", footers[0].getName());
assertEquals("abcde", footers[0].getValue());
assertEquals("Footer2", footers[1].getName());