Search in sources :

Example 6 with MimeBodyPart

use of com.fsck.k9.mail.internet.MimeBodyPart in project k-9 by k9mail.

the class LocalStoreTest method findPartById__withNestedLocalMessagePart.

@Test
public void findPartById__withNestedLocalMessagePart() throws Exception {
    LocalBodyPart searchRoot = new LocalBodyPart(null, null, 1L, -1L);
    LocalMimeMessage needlePart = new LocalMimeMessage(null, null, 123L);
    MimeMultipart mimeMultipart = new MimeMultipart("boundary");
    mimeMultipart.addBodyPart(new MimeBodyPart(needlePart));
    searchRoot.setBody(mimeMultipart);
    Part part = LocalStore.findPartById(searchRoot, 123L);
    assertSame(needlePart, part);
}
Also used : MimeMultipart(com.fsck.k9.mail.internet.MimeMultipart) Part(com.fsck.k9.mail.Part) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) Test(org.junit.Test)

Example 7 with MimeBodyPart

use of com.fsck.k9.mail.internet.MimeBodyPart in project k-9 by k9mail.

the class AttachmentInfoExtractorTest method extractInfoForDb__withNoBody__shouldReturnContentNotAvailable.

@Test
public void extractInfoForDb__withNoBody__shouldReturnContentNotAvailable() throws Exception {
    MimeBodyPart part = new MimeBodyPart();
    AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfoForDatabase(part);
    assertFalse(attachmentViewInfo.isContentAvailable);
}
Also used : MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) AttachmentViewInfo(com.fsck.k9.mailstore.AttachmentViewInfo) Test(org.junit.Test)

Example 8 with MimeBodyPart

use of com.fsck.k9.mail.internet.MimeBodyPart in project k-9 by k9mail.

the class AttachmentInfoExtractorTest method extractInfoForDb__withNoBody__shouldReturnContentAvailable.

@Test
public void extractInfoForDb__withNoBody__shouldReturnContentAvailable() throws Exception {
    MimeBodyPart part = new MimeBodyPart();
    part.setBody(new TextBody("data"));
    AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfoForDatabase(part);
    assertTrue(attachmentViewInfo.isContentAvailable);
}
Also used : TextBody(com.fsck.k9.mail.internet.TextBody) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) AttachmentViewInfo(com.fsck.k9.mailstore.AttachmentViewInfo) Test(org.junit.Test)

Example 9 with MimeBodyPart

use of com.fsck.k9.mail.internet.MimeBodyPart in project k-9 by k9mail.

the class AttachmentInfoExtractorTest method extractInfoForDb__withNoHeaders__shouldReturnEmptyValues.

@Test
public void extractInfoForDb__withNoHeaders__shouldReturnEmptyValues() throws Exception {
    MimeBodyPart part = new MimeBodyPart();
    AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfoForDatabase(part);
    assertEquals(Uri.EMPTY, attachmentViewInfo.internalUri);
    assertEquals(AttachmentViewInfo.UNKNOWN_SIZE, attachmentViewInfo.size);
    assertEquals("noname.txt", attachmentViewInfo.displayName);
    assertEquals("text/plain", attachmentViewInfo.mimeType);
    assertFalse(attachmentViewInfo.inlineAttachment);
}
Also used : MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) AttachmentViewInfo(com.fsck.k9.mailstore.AttachmentViewInfo) Test(org.junit.Test)

Example 10 with MimeBodyPart

use of com.fsck.k9.mail.internet.MimeBodyPart in project k-9 by k9mail.

the class AttachmentInfoExtractorTest method extractInfoForDb__withDispositionAttach__shouldReturnNamedAttachment.

@Test
public void extractInfoForDb__withDispositionAttach__shouldReturnNamedAttachment() throws Exception {
    MimeBodyPart part = new MimeBodyPart();
    part.setHeader(MimeHeader.HEADER_CONTENT_DISPOSITION, "attachment" + "; filename=\"filename.ext\"; meaningless=\"dummy\"");
    AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfoForDatabase(part);
    assertEquals(Uri.EMPTY, attachmentViewInfo.internalUri);
    assertEquals("filename.ext", attachmentViewInfo.displayName);
    assertFalse(attachmentViewInfo.inlineAttachment);
}
Also used : MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) AttachmentViewInfo(com.fsck.k9.mailstore.AttachmentViewInfo) Test(org.junit.Test)

Aggregations

MimeBodyPart (com.fsck.k9.mail.internet.MimeBodyPart)42 Test (org.junit.Test)22 Part (com.fsck.k9.mail.Part)15 MimeMultipart (com.fsck.k9.mail.internet.MimeMultipart)15 TextBody (com.fsck.k9.mail.internet.TextBody)11 AttachmentViewInfo (com.fsck.k9.mailstore.AttachmentViewInfo)11 BodyPart (com.fsck.k9.mail.BodyPart)9 MessagingException (com.fsck.k9.mail.MessagingException)7 Uri (android.net.Uri)5 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)5 PendingIntent (android.app.PendingIntent)4 Body (com.fsck.k9.mail.Body)4 Multipart (com.fsck.k9.mail.Multipart)4 CryptoResultAnnotation (com.fsck.k9.mailstore.CryptoResultAnnotation)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 OutputStream (java.io.OutputStream)4 OpenPgpDataSource (org.openintents.openpgp.util.OpenPgpApi.OpenPgpDataSource)4 Intent (android.content.Intent)3 BinaryTempFileBody (com.fsck.k9.mail.internet.BinaryTempFileBody)3 InputStream (java.io.InputStream)3