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