Search in sources :

Example 1 with RawField

use of org.apache.james.mime4j.stream.RawField 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);
}
Also used : BodyPart(org.apache.james.mime4j.message.BodyPart) Multipart(org.apache.james.mime4j.dom.Multipart) MultipartImpl(org.apache.james.mime4j.message.MultipartImpl) RawField(org.apache.james.mime4j.stream.RawField) MessageImpl(org.apache.james.mime4j.message.MessageImpl) Date(java.util.Date) Test(org.junit.Test)

Example 2 with RawField

use of org.apache.james.mime4j.stream.RawField 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);
}
Also used : BodyPart(org.apache.james.mime4j.message.BodyPart) Multipart(org.apache.james.mime4j.dom.Multipart) MultipartImpl(org.apache.james.mime4j.message.MultipartImpl) RawField(org.apache.james.mime4j.stream.RawField) MessageImpl(org.apache.james.mime4j.message.MessageImpl) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Date (java.util.Date)2 Multipart (org.apache.james.mime4j.dom.Multipart)2 BodyPart (org.apache.james.mime4j.message.BodyPart)2 MessageImpl (org.apache.james.mime4j.message.MessageImpl)2 MultipartImpl (org.apache.james.mime4j.message.MultipartImpl)2 RawField (org.apache.james.mime4j.stream.RawField)2 Test (org.junit.Test)2