} catch (IllegalArgumentException e) {
assertThat(e, exception("dataSource"));
}
// DS: text, no name
DataSource dataSource = new ResourceDataSource(factory.getResource("testfile.txt"), null, "text/plain") {
@Override
public String getName() {
return null;
}
};
content = new AttachmentContent(dataSource);
builder.setContent(content);
try {
getMessageAsText();
fail();
} catch (MailBuilderException e) {
assertThat(e, exception("No fileName was specified with "
+ "DataSource[Resource[testfile.txt, loaded by ResourceLoadingService]]"));
}
// DS: text, no name, name specified
content = new AttachmentContent(dataSource, "testfile.txt");
builder.setContent(content);
assert_TextPlain_testfile_QuotedPrintable();
// DS: text, default name
dataSource = new ResourceDataSource(factory.getResource("testfile.txt"), null, "text/plain");
content = new AttachmentContent(dataSource);
builder.setContent(content);
assert_TextPlain_testfile_QuotedPrintable();
// DS: gif image, name specfied
dataSource = new ResourceDataSource(factory.getResource("java.gif"), null, "image/gif");
content = new AttachmentContent(dataSource, "我的图片.gif");
builder.setContent(content);
assert_ImageGif_javagif_我的图片_base64();