use of org.apache.james.mime4j.message.MultipartImpl in project sling by apache.
the class MessageStoreImplAttachmentsTest method recursiveMultipartMessageTest.
@Test
public void recursiveMultipartMessageTest() throws IOException {
Multipart multipart = new MultipartImpl("mixed");
BodyPart att1 = createRandomBinaryAttachment(100);
multipart.addBodyPart(att1);
BodyPart att2 = createRandomBinaryAttachment(133);
multipart.addBodyPart(att2);
Multipart nestedMultipart = new MultipartImpl("mixed");
BodyPart nBody = createTextBody("Some sample text here...?!", "plain", false);
nestedMultipart.addBodyPart(nBody);
BodyPart nAtt1 = createRandomBinaryAttachment(300);
nestedMultipart.addBodyPart(nAtt1);
BodyPart NAtt2 = createRandomBinaryAttachment(100);
nestedMultipart.addBodyPart(NAtt2);
BodyPart nAtt3 = createTextBody("Some other text here...<br>?!", "html", true);
nestedMultipart.addBodyPart(nAtt3);
BodyPart nestedMessage = new BodyPart();
nestedMessage.setMultipart(nestedMultipart);
multipart.addBodyPart(nestedMessage);
MessageImpl message = new MessageImpl();
message.setMultipart(multipart);
message.setSubject("Template message");
message.setDate(new Date());
message.getHeader().setField(new RawField(LIST_ID, "<list.example.com>"));
assertSaveMessageWithAttachments(message, 5);
}
use of org.apache.james.mime4j.message.MultipartImpl in project sling by apache.
the class MessageStoreImplAttachmentsTest method simpleMultipartMessageTest.
@Test
public void simpleMultipartMessageTest() throws IOException {
Multipart multipart = new MultipartImpl("mixed");
BodyPart att0 = createTextBody("This is the first part of the template..", "plain", true);
multipart.addBodyPart(att0);
BodyPart att1 = createRandomBinaryAttachment(200);
multipart.addBodyPart(att1);
BodyPart att2 = createRandomBinaryAttachment(300);
multipart.addBodyPart(att2);
BodyPart att3 = createTextBody("Some sample text here...?!", "html", true);
multipart.addBodyPart(att3);
BodyPart att4 = createRandomBinaryAttachment(100);
multipart.addBodyPart(att4);
BodyPart att5 = createTextBody("Some other text here...?!", "plain", true);
multipart.addBodyPart(att5);
MessageImpl message = new MessageImpl();
message.setMultipart(multipart);
message.setSubject("Template message");
message.setDate(new Date());
message.getHeader().setField(new RawField(LIST_ID, "<list.example.com>"));
assertSaveMessageWithAttachments(message, 6);
}
Aggregations