assertEquals(1, StringUtil.countMatches(eml, "Content-Disposition: inline; filename=java.gif"));
assertEquals(1, StringUtil.countMatches(eml, "Content-Disposition: inline; filename=bible.jpg"));
}
private MailBuilder createVeryComplexMail() {
MailBuilder builder = new MailBuilder();
// ��������contents��
MultipartContent attachable = new MixedMultipartContent();
attachable.setId("attachable");
MultipartContent alternative = new AlternativeMultipartContent();
alternative.setId("alternative");
TextContent plainText = new TextContent("�Ұ��������д�", "text/plain");
plainText.setId("plainText");
TextContent htmlText = new TextContent("<���������д�>", "text/html");
htmlText.setId("htmlText");
TextTemplateContent plainTextTemplate = new TextTemplateContent("mail/mytemplate.vm", "text/plain");
plainTextTemplate.setId("plainTextTemplate");
AttachmentContent textAttachment = new AttachmentContent("testfile.txt");
textAttachment.setId("textAttachment");
HTMLTemplateContent htmlTemplate = new HTMLTemplateContent("mail/complexhtml.vm");
htmlTemplate.setId("htmlTemplate");
plainTextTemplate.setTemplateService(templateService);
plainTextTemplate.setPullService(pullService);
htmlTemplate.setTemplateService(templateService);
htmlTemplate.setPullService(pullService);
htmlTemplate.setResourceLoader(factory);
htmlTemplate.addInlineResource("image", "/");
textAttachment.setResourceLoader(factory);
// ����builder
builder.setContent(attachable);
{
attachable.addContent(alternative);
{
alternative.addContent(plainText);
alternative.addContent(htmlText);
}
attachable.addContent(plainTextTemplate);
attachable.addContent(textAttachment);
attachable.addContent(htmlTemplate);
}
// ���getId()
assertSame(attachable, builder.getContent("attachable"));
assertSame(alternative, builder.getContent("alternative"));
assertSame(plainText, builder.getContent("plainText"));
assertSame(htmlText, builder.getContent("htmlText"));
assertSame(plainTextTemplate, builder.getContent("plainTextTemplate"));
assertSame(textAttachment, builder.getContent("textAttachment"));
assertSame(htmlTemplate, builder.getContent("htmlTemplate"));
return builder;
}