use of com.fsck.k9.mail.Message in project k-9 by k9mail.
the class MessageBuilderTest method build_withMessageAttachment_shouldAttachAsApplicationOctetStream.
@Test
public void build_withMessageAttachment_shouldAttachAsApplicationOctetStream() throws Exception {
MessageBuilder messageBuilder = createSimpleMessageBuilder();
Attachment attachment = createAttachmentWithContent("message/rfc822", "attach.txt", TEST_ATTACHMENT_TEXT);
messageBuilder.setAttachments(Collections.singletonList(attachment));
messageBuilder.buildAsync(callback);
MimeMessage message = getMessageFromCallback();
assertEquals(MESSAGE_HEADERS + MESSAGE_CONTENT_WITH_MESSAGE_ATTACH, getMessageContents(message));
}
use of com.fsck.k9.mail.Message in project k-9 by k9mail.
the class MessageBuilderTest method build_shouldSucceed.
@Test
public void build_shouldSucceed() throws Exception {
MessageBuilder messageBuilder = createSimpleMessageBuilder();
messageBuilder.buildAsync(callback);
MimeMessage message = getMessageFromCallback();
assertEquals("text/plain", message.getMimeType());
assertEquals(TEST_SUBJECT, message.getSubject());
assertEquals(TEST_IDENTITY_ADDRESS, message.getFrom()[0]);
assertArrayEquals(TEST_TO, message.getRecipients(RecipientType.TO));
assertArrayEquals(TEST_CC, message.getRecipients(RecipientType.CC));
assertArrayEquals(TEST_BCC, message.getRecipients(RecipientType.BCC));
assertEquals(MESSAGE_HEADERS + MESSAGE_CONTENT, getMessageContents(message));
}
use of com.fsck.k9.mail.Message in project k-9 by k9mail.
the class EncryptionDetectorTest method isEncrypted_withPlainTextAndPreambleWithInlinePgp_shouldReturnFalse.
@Test
public void isEncrypted_withPlainTextAndPreambleWithInlinePgp_shouldReturnFalse() throws Exception {
Message message = createTextMessage("text/plain", "" + "preamble" + CRLF + "-----BEGIN PGP MESSAGE-----" + CRLF + "some encrypted stuff here" + CRLF + "-----END PGP MESSAGE-----" + CRLF + "epilogue");
when(textPartFinder.findFirstTextPart(message)).thenReturn(message);
boolean encrypted = encryptionDetector.isEncrypted(message);
assertFalse(encrypted);
}
use of com.fsck.k9.mail.Message in project k-9 by k9mail.
the class EncryptionDetectorTest method isEncrypted_withQuotedInlinePgp_shouldReturnFalse.
@Test
public void isEncrypted_withQuotedInlinePgp_shouldReturnFalse() throws Exception {
Message message = createTextMessage("text/plain", "" + "good talk!" + CRLF + CRLF + "> -----BEGIN PGP MESSAGE-----" + CRLF + "> some encrypted stuff here" + CRLF + "> -----END PGP MESSAGE-----" + CRLF + CRLF + "-- " + CRLF + "my signature");
when(textPartFinder.findFirstTextPart(message)).thenReturn(message);
boolean encrypted = encryptionDetector.isEncrypted(message);
assertFalse(encrypted);
}
use of com.fsck.k9.mail.Message in project k-9 by k9mail.
the class MessagePreviewCreatorTest method createPreview_withTextPart.
@Test
public void createPreview_withTextPart() throws Exception {
Message message = createDummyMessage();
Part textPart = createTextPart("text/plain");
when(encryptionDetector.isEncrypted(message)).thenReturn(false);
when(textPartFinder.findFirstTextPart(message)).thenReturn(textPart);
when(previewTextExtractor.extractPreview(textPart)).thenReturn("expected");
PreviewResult result = previewCreator.createPreview(message);
assertTrue(result.isPreviewTextAvailable());
assertEquals(PreviewType.TEXT, result.getPreviewType());
assertEquals("expected", result.getPreviewText());
}
Aggregations