use of com.fsck.k9.mailstore.BinaryMemoryBody in project k-9 by k9mail.
the class MessageExtractorTest method getTextFromPart_withHtmlWithCharsetInContentTypeRawDataBody_shouldReturnHtmlText.
@Test
public void getTextFromPart_withHtmlWithCharsetInContentTypeRawDataBody_shouldReturnHtmlText() throws Exception {
part.setHeader(MimeHeader.HEADER_CONTENT_TYPE, "text/html; charset=UTF-8");
BinaryMemoryBody body = new BinaryMemoryBody("<html><body>Sample text body</body></html>".getBytes(), MimeUtil.ENC_8BIT);
part.setBody(body);
String result = MessageExtractor.getTextFromPart(part);
assertEquals("<html><body>Sample text body</body></html>", result);
}
use of com.fsck.k9.mailstore.BinaryMemoryBody in project k-9 by k9mail.
the class ReconstructMessageFromDatabaseTest method testAddMissingPart.
public void testAddMissingPart() throws MessagingException, IOException {
LocalFolder folder = createFolderInDatabase();
MimeMessage message = new MimeMessage();
message.addHeader("To", "to@example.com");
message.addHeader("MIME-Version", "1.0");
message.addHeader("Content-Type", "text/plain");
message.setServerExtra("text");
saveMessageToDatabase(folder, message);
LocalMessage localMessage = readMessageFromDatabase(folder, message);
assertEquals("to@example.com", localMessage.getHeader("To")[0]);
assertEquals("text/plain", localMessage.getHeader(MimeHeader.HEADER_CONTENT_TYPE)[0]);
assertEquals("text", localMessage.getServerExtra());
assertNull(localMessage.getBody());
Body body = new BinaryMemoryBody("Test message body".getBytes(), MimeUtil.ENC_7BIT);
localMessage.setBody(body);
folder.addPartToMessage(localMessage, localMessage);
LocalMessage completeLocalMessage = readMessageFromDatabase(folder, message);
String reconstructedMessage = writeMessageToString(completeLocalMessage);
assertEquals("To: to@example.com\r\n" + "MIME-Version: 1.0\r\n" + "Content-Type: text/plain\r\n" + "\r\n" + "Test message body", reconstructedMessage);
}
Aggregations