use of com.fsck.k9.mail.BodyPart in project k-9 by k9mail.
the class PgpMessageBuilderTest method assertContentOfBodyPartEquals.
private static void assertContentOfBodyPartEquals(String reason, BodyPart signatureBodyPart, String expected) {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
InputStream inputStream = MimeUtility.decodeBody(signatureBodyPart.getBody());
IOUtils.copy(inputStream, bos);
Assert.assertEquals(reason, expected, new String(bos.toByteArray(), Charsets.UTF_8));
} catch (IOException | MessagingException e) {
Assert.fail();
}
}
use of com.fsck.k9.mail.BodyPart in project k-9 by k9mail.
the class PgpMessageBuilderTest method assertContentOfBodyPartEquals.
private static void assertContentOfBodyPartEquals(String reason, BodyPart signatureBodyPart, byte[] expected) {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
signatureBodyPart.getBody().writeTo(bos);
Assert.assertArrayEquals(reason, expected, bos.toByteArray());
} catch (IOException | MessagingException e) {
Assert.fail();
}
}
use of com.fsck.k9.mail.BodyPart in project k-9 by k9mail.
the class TextPartFinderTest method findFirstTextPart_withMultipartMixedContainingMultipartAlternativeWithTextPlainPartLast.
@Test
public void findFirstTextPart_withMultipartMixedContainingMultipartAlternativeWithTextPlainPartLast() throws Exception {
BodyPart expected = createTextPart("text/plain");
Part part = createMultipart("multipart/mixed", createMultipart("multipart/alternative", createTextPart("text/html"), expected));
Part result = textPartFinder.findFirstTextPart(part);
assertEquals(expected, result);
}
use of com.fsck.k9.mail.BodyPart in project k-9 by k9mail.
the class TextPartFinderTest method findFirstTextPart_withMultipartAlternativeContainingOnlyTextHtmlPart.
@Test
public void findFirstTextPart_withMultipartAlternativeContainingOnlyTextHtmlPart() throws Exception {
BodyPart expected = createTextPart("text/html");
Part part = createMultipart("multipart/alternative", createPart("image/gif"), expected, createTextPart("text/html"));
Part result = textPartFinder.findFirstTextPart(part);
assertEquals(expected, result);
}
use of com.fsck.k9.mail.BodyPart in project k-9 by k9mail.
the class TextPartFinderTest method findFirstTextPart_withMultipartAlternativeContainingMultipartRelatedContainingTextHtmlFirst.
@Test
public void findFirstTextPart_withMultipartAlternativeContainingMultipartRelatedContainingTextHtmlFirst() throws Exception {
BodyPart expected = createTextPart("text/plain");
Part part = createMultipart("multipart/alternative", createMultipart("multipart/related", createTextPart("text/html"), createPart("image/jpeg")), expected);
Part result = textPartFinder.findFirstTextPart(part);
assertEquals(expected, result);
}
Aggregations