}
@Test
public void testParseHtmlEmailWithAttachments() throws Exception
{
DataSource dataSource;
final Session session = Session.getDefaultInstance(new Properties());
final MimeMessage message = MimeMessageUtils.createMimeMessage(session, new File("./src/test/resources/eml/html-attachment.eml"));
final MimeMessageParser mimeMessageParser = new MimeMessageParser(message);
mimeMessageParser.parse();
assertEquals("Test", mimeMessageParser.getSubject());
assertNotNull(mimeMessageParser.getMimeMessage());
assertTrue(mimeMessageParser.isMultipart());
assertTrue(mimeMessageParser.hasHtmlContent());
assertTrue(mimeMessageParser.hasPlainContent());
assertNotNull(mimeMessageParser.getPlainContent());
assertNotNull(mimeMessageParser.getHtmlContent());
assertTrue(mimeMessageParser.getTo().size() == 1);
assertTrue(mimeMessageParser.getCc().size() == 0);
assertTrue(mimeMessageParser.getBcc().size() == 0);
assertEquals("siegfried.goeschl@it20one.at", mimeMessageParser.getFrom());
assertEquals("siegfried.goeschl@it20one.at", mimeMessageParser.getReplyTo());
assertTrue(mimeMessageParser.hasAttachments());
final List<?> attachmentList = mimeMessageParser.getAttachmentList();
assertTrue(attachmentList.size() == 2);
dataSource = mimeMessageParser.findAttachmentByName("Wasserlilien.jpg");
assertNotNull(dataSource);
assertEquals("image/jpeg", dataSource.getContentType());
dataSource = mimeMessageParser.findAttachmentByName("it20one.pdf");
assertNotNull(dataSource);
assertEquals("application/pdf", dataSource.getContentType());
}