Search in sources :

Example 16 with MimePackage

use of com.axway.ats.action.objects.MimePackage in project ats-framework by Axway.

the class Test_MimePackage method constructWithSessionOnly.

@Test
public void constructWithSessionOnly() throws Exception {
    MimePackage message = new MimePackage();
    assertEquals(0, message.getRegularPartCount());
    assertEquals(0, message.getAttachmentPartCount());
}
Also used : MimePackage(com.axway.ats.action.objects.MimePackage) BaseTest(com.axway.ats.action.BaseTest) Test(org.junit.Test)

Example 17 with MimePackage

use of com.axway.ats.action.objects.MimePackage in project ats-framework by Axway.

the class Test_MimePackage method testGetContentOfSavedMailWithAttachmentOnly.

@Test
public void testGetContentOfSavedMailWithAttachmentOnly() throws PackageException {
    // expected null since attachments should not be checked for text/plain or text/html
    String nestedMailPath = Test_MimePackage.class.getResource("getPlainTextBody__attachment_only.eml").getPath();
    MimePackage mimePack = PackageLoader.loadMimePackageFromFile(nestedMailPath);
    String contentText = mimePack.getPlainTextBody();
    assertNull(contentText);
    String contentHtml = mimePack.getHtmlTextBody();
    assertNull(contentHtml);
}
Also used : MimePackage(com.axway.ats.action.objects.MimePackage) BaseTest(com.axway.ats.action.BaseTest) Test(org.junit.Test)

Example 18 with MimePackage

use of com.axway.ats.action.objects.MimePackage in project ats-framework by Axway.

the class Test_MimePackage method getTagWhenNoTagIsSet.

@Test(expected = ObjectNotTaggedException.class)
public void getTagWhenNoTagIsSet() throws Exception {
    MimePackage mimeMessage = new MimePackage();
    mimeMessage.getTag();
}
Also used : MimePackage(com.axway.ats.action.objects.MimePackage) BaseTest(com.axway.ats.action.BaseTest) Test(org.junit.Test)

Example 19 with MimePackage

use of com.axway.ats.action.objects.MimePackage in project ats-framework by Axway.

the class Test_MimePackage method addAttachmentsCheckContentType.

@Test
public void addAttachmentsCheckContentType() throws Exception {
    MimePackage mimeMessage = new MimePackage();
    mimeMessage.addAttachment(mailMessageDir + "/attachmentDir/MSADDNDR.DLL");
    assertEquals("application/octet-stream", mimeMessage.getAttachmentContentType(0));
}
Also used : MimePackage(com.axway.ats.action.objects.MimePackage) BaseTest(com.axway.ats.action.BaseTest) Test(org.junit.Test)

Example 20 with MimePackage

use of com.axway.ats.action.objects.MimePackage in project ats-framework by Axway.

the class Test_Rfc822Headers method getTextBody_HTMLBodyIsLocatedAfterAlternativePart.

/**
     * Test is parsing mail with nested parts, the part 'multipart/alternative' is located before 'text/plain'
     * to test that level 1 in the mail is parsed first.
     *  
     * - multipart/mixed;
     *      - multipart/alternative;
     *          - text/plain
     *          - text/html
     *      - message/rfc822
     *      - text/plain
     */
@Test
public void getTextBody_HTMLBodyIsLocatedAfterAlternativePart() throws Exception {
    String mailMessagePath = Test_MimePackage.class.getResource("textBody_HTMLBodyIsLocatedAfterAlternativePart.eml").getPath();
    MimePackage mimeMessage = PackageLoader.loadMimePackageFromFile(mailMessagePath);
    assertEquals(3, mimeMessage.getRegularPartCount());
    assertEquals(1, mimeMessage.getAttachmentPartCount());
    assertEquals("plain text on 1st level", mimeMessage.getPlainTextBody().trim());
    assertEquals(true, mimeMessage.getHtmlTextBody().contains("test2"));
}
Also used : MimePackage(com.axway.ats.action.objects.MimePackage) 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