Search in sources :

Example 6 with MimePackage

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) {
    }
}
Also used : MimePackage(com.axway.ats.action.objects.MimePackage) MimePart(javax.mail.internet.MimePart) NoSuchMimePartException(com.axway.ats.action.objects.model.NoSuchMimePartException) BaseTest(com.axway.ats.action.BaseTest) Test(org.junit.Test)

Example 7 with MimePackage

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));
}
Also used : MimePackage(com.axway.ats.action.objects.MimePackage) BaseTest(com.axway.ats.action.BaseTest) Test(org.junit.Test)

Example 8 with MimePackage

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());
}
Also used : MimePackage(com.axway.ats.action.objects.MimePackage) BaseTest(com.axway.ats.action.BaseTest) Test(org.junit.Test)

Example 9 with MimePackage

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());
}
Also used : MimePackage(com.axway.ats.action.objects.MimePackage) BaseTest(com.axway.ats.action.BaseTest) Test(org.junit.Test)

Example 10 with MimePackage

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."));
}
Also used : MimePackage(com.axway.ats.action.objects.MimePackage) FileInputStream(java.io.FileInputStream) BaseTest(com.axway.ats.action.BaseTest) Test(org.junit.Test)

Aggregations

MimePackage (com.axway.ats.action.objects.MimePackage)53 Test (org.junit.Test)35 BaseTest (com.axway.ats.action.BaseTest)29 ImapMetaData (com.axway.ats.rbv.imap.ImapMetaData)15 Before (org.junit.Before)7 PackageException (com.axway.ats.action.objects.model.PackageException)6 BaseTest (com.axway.ats.rbv.BaseTest)6 FileInputStream (java.io.FileInputStream)6 MimePart (javax.mail.internet.MimePart)6 NoSuchMimePartException (com.axway.ats.action.objects.model.NoSuchMimePartException)5 RbvException (com.axway.ats.rbv.model.RbvException)5 Test_ImapStorage (com.axway.ats.rbv.imap.Test_ImapStorage)4 StringInMimePartRule (com.axway.ats.rbv.imap.rules.StringInMimePartRule)4 MimePartRule (com.axway.ats.rbv.imap.rules.MimePartRule)2 InputStream (java.io.InputStream)2 MessagingException (javax.mail.MessagingException)2 BeforeClass (org.junit.BeforeClass)2 MailSender (com.axway.ats.action.mail.MailSender)1 MailTransportListener (com.axway.ats.action.mail.model.MailTransportListener)1 DELIVERY_STATE (com.axway.ats.action.mail.model.MailTransportListener.DELIVERY_STATE)1