assertEquals(cursor.ready(), -1);
assertEquals(consumer.getBody().getContent(), NORMAL);
}
public void testMixed() throws Exception {
PartData list = new PartData();
PartSeriesConsumer consumer = new PartSeriesConsumer(new ArrayAllocator(), list, "AaB03x".getBytes("UTF-8"));
Cursor cursor = new StreamCursor(MIXED);
while(!consumer.isFinished()) {
consumer.consume(cursor);
}
assertEquals(list.getParts().size(), 4);
assertEquals(list.getParts().get(0).getContentType().getPrimary(), "text");
assertEquals(list.getParts().get(0).getContentType().getSecondary(), "plain");
assertEquals(list.getParts().get(0).getHeader("Content-Disposition"), "form-data; name='pics'; filename='file1.txt'");
assertEquals(list.getParts().get(0).getContent(), "example contents of file1.txt");
assertEquals(list.getParts().get(1).getContentType().getPrimary(), "text");
assertEquals(list.getParts().get(1).getContentType().getSecondary(), "plain");
assertEquals(list.getParts().get(1).getHeader("Content-Disposition"), "form-data; name='pics'; filename='file2.txt'");
assertEquals(list.getParts().get(1).getContent(), "example contents of file2.txt ...");
assertEquals(list.getParts().get(2).getContentType().getPrimary(), "text");
assertEquals(list.getParts().get(2).getContentType().getSecondary(), "plain");
assertEquals(list.getParts().get(2).getHeader("Content-Disposition"), "form-data; name='pics'; filename='file3.txt'");
assertEquals(list.getParts().get(2).getContent(), "example contents of file3.txt ...");
assertEquals(list.getParts().get(3).getContentType().getPrimary(), "text");
assertEquals(list.getParts().get(3).getContentType().getSecondary(), "plain");
assertEquals(list.getParts().get(3).getHeader("Content-Disposition"), "form-data; name='pics'; filename='file4.txt'");
assertEquals(list.getParts().get(3).getContent(), "example contents of file4.txt ...");
assertEquals(cursor.ready(), -1);
assertEquals(consumer.getBody().getContent(), MIXED);
}