use of com.axway.ats.action.objects.MimePackage in project ats-framework by Axway.
the class Test_MimePackage method setBody_multiParts_with_textAndHtmlParts.
@Test
public void setBody_multiParts_with_textAndHtmlParts() throws Exception {
// create a new message and add TEXT and HTML parts to it
MimePackage newMailMessage = new MimePackage();
newMailMessage.addPart("text plain body", MimePackage.PART_TYPE_TEXT_PLAIN);
newMailMessage.addPart("html body", MimePackage.PART_TYPE_TEXT_HTML);
MimePart textPart = newMailMessage.getPart(0, false);
assertEquals(textPart.getContent(), "text plain body");
assertEquals(textPart.getContentType(), "text/plain; charset=us-ascii");
MimePart htmlPart = newMailMessage.getPart(1, false);
assertEquals(htmlPart.getContent(), "html body");
assertEquals(htmlPart.getContentType(), "text/html; charset=us-ascii");
// modify both parts
newMailMessage.setBody("new body");
// verify the modifications
MimePart newTextPart = newMailMessage.getPart(0, false);
assertEquals(newTextPart.getContent(), "new body");
assertEquals(newTextPart.getContentType(), "text/plain; charset=us-ascii");
MimePart newHtmlPart = newMailMessage.getPart(1, false);
assertEquals(newHtmlPart.getContent(), "new body");
assertEquals(newHtmlPart.getContentType(), "text/html; charset=us-ascii");
// verify there are no more parts
try {
newMailMessage.getPart(2, false);
assertTrue("There is more than 2 parts, while we expect to have just 2", false);
} catch (NoSuchMimePartException e) {
}
}
use of com.axway.ats.action.objects.MimePackage in project ats-framework by Axway.
the class Test_MimePackage method setHeadersEmptyMessage.
@Test
public void setHeadersEmptyMessage() throws Exception {
MimePackage mimeMessage = new MimePackage();
mimeMessage.setSubject("test subject");
mimeMessage.setSender("sender@sender.com");
mimeMessage.setSenderName("sendercho");
mimeMessage.setRecipient("test0@test.com");
assertEquals("test subject", mimeMessage.getSubject());
assertEquals("sender@sender.com", mimeMessage.getSenderAddress());
assertEquals("sendercho <sender@sender.com>", mimeMessage.getSender());
assertEquals(1, mimeMessage.getRecipientCount(RecipientType.TO));
}
use of com.axway.ats.action.objects.MimePackage in project ats-framework by Axway.
the class Test_MimePackage method testGetContentOfNewlyCreatedAlternativeMail.
// getPlainTextBody() related tests
@Test
public void testGetContentOfNewlyCreatedAlternativeMail() throws PackageException {
MimePackage mimePack = new MimePackage();
// mimePack.setBody( "my test mail content" );
mimePack.setHeader("Content-type", "multipart/alternative");
String contentPlain = "my test mail content";
String contentHtml = "<html>" + contentPlain + "</html>";
mimePack.addPart("dummy", MimePackage.PART_TYPE_TEXT_PLAIN);
mimePack.addPart("dummyHtml", MimePackage.PART_TYPE_TEXT_HTML);
mimePack.setBody(contentPlain, contentHtml);
assertEquals(contentPlain, mimePack.getPlainTextBody());
assertEquals(contentHtml, mimePack.getHtmlTextBody());
}
use of com.axway.ats.action.objects.MimePackage in project ats-framework by Axway.
the class Test_MimePackage method addPartEmptyMessage.
@Test
public void addPartEmptyMessage() throws Exception {
MimePackage mimeMessage = new MimePackage();
mimeMessage.addPart("This is message body", MimePackage.PART_TYPE_TEXT_PLAIN);
assertEquals(1, mimeMessage.getRegularPartCount());
assertEquals(0, mimeMessage.getAttachmentPartCount());
}
use of com.axway.ats.action.objects.MimePackage in project ats-framework by Axway.
the class Test_MimePackage method getPlainTextAsInputStream.
@Test
public void getPlainTextAsInputStream() throws Exception {
MimePackage message = new MimePackage(new FileInputStream(mailMessageDir + "/plainTextAsInputStream.msg"));
assertTrue(message.getPlainTextBody().endsWith("Please see the inline doc fore more information."));
}
Aggregations