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