sb.append(expected.getLast() + "\r\n");
expected.add("Subject: A subject");
sb.append(expected.getLast());
MimeStreamParser parser = new MimeStreamParser();
parser.setContentHandler(new AbstractContentHandler() {
@Override
public void field(Field field) {
assertEquals(expected.removeFirst(), decode(field.getRaw()));
}
});
parser.parse(new ByteArrayInputStream(sb.toString().getBytes()));
assertEquals(0, expected.size());
sb = new StringBuilder();
expected.clear();
expected.add("From: some@one.com");
sb.append(expected.getLast() + "\r\n");
expected.add("Subject: A subject");
sb.append(expected.getLast() + "\r\n");
parser = new MimeStreamParser();
parser.setContentHandler(new AbstractContentHandler() {
@Override
public void field(Field field) {
assertEquals(expected.removeFirst(), decode(field.getRaw()));
}
});