Search in sources :

Example 11 with MimePackage

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

the class Test_MimePackage method constructFromSessionAndInputStream.

@Test
public void constructFromSessionAndInputStream() throws Exception {
    MimePackage message = new MimePackage(new FileInputStream(mailMessagePath));
    assertEquals(4, message.getRegularPartCount());
    assertEquals(2, message.getAttachmentPartCount());
}
Also used : MimePackage(com.axway.ats.action.objects.MimePackage) FileInputStream(java.io.FileInputStream) BaseTest(com.axway.ats.action.BaseTest) Test(org.junit.Test)

Example 12 with MimePackage

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

the class Test_MimePackage method testGetContentOfSavedMailWithAttachmentAndAnotherBody.

@Test
public void testGetContentOfSavedMailWithAttachmentAndAnotherBody() throws PackageException {
    // expected to get contents of inline body, not of attachment body
    String nestedMailPath = Test_MimePackage.class.getResource("getPlainTextBody__body_and_attachment.eml").getPath();
    MimePackage mimePack = PackageLoader.loadMimePackageFromFile(nestedMailPath);
    String contentText = mimePack.getPlainTextBody();
    assertEquals("TEST", 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 13 with MimePackage

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

the class Test_MimePackage method setBody_multiParts_with_htmlPart_only.

@Test
public void setBody_multiParts_with_htmlPart_only() throws Exception {
    // create a new message and add HTML part to it
    MimePackage newMailMessage = new MimePackage();
    newMailMessage.addPart("html body", MimePackage.PART_TYPE_TEXT_HTML);
    MimePart htmlPart = newMailMessage.getPart(0, false);
    assertEquals(htmlPart.getContent(), "html body");
    assertEquals(htmlPart.getContentType(), "text/html; charset=us-ascii");
    // modify the only part
    newMailMessage.setBody("new body");
    // verify the modifications
    MimePart newHtmlPart = newMailMessage.getPart(0, false);
    assertEquals(newHtmlPart.getContent(), "new body");
    assertEquals(newHtmlPart.getContentType(), "text/html; charset=us-ascii");
    // verify there are no more parts
    try {
        newMailMessage.getPart(1, false);
        assertTrue("There is more than 1 part, while we expect to have just 1", 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 14 with MimePackage

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

the class Test_MimePackage method constructFromInputStreamWithJpeg.

@Test
public void constructFromInputStreamWithJpeg() throws Exception {
    MimePackage message = new MimePackage(new FileInputStream(mailMessageDir + "/jpeg.msg"));
    assertEquals(1, message.getRegularPartCount());
    assertEquals(1, message.getAttachmentPartCount());
}
Also used : MimePackage(com.axway.ats.action.objects.MimePackage) FileInputStream(java.io.FileInputStream) BaseTest(com.axway.ats.action.BaseTest) Test(org.junit.Test)

Example 15 with MimePackage

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

the class Test_MimePackage method addAlternativePartEmptyMessage.

@Test
public void addAlternativePartEmptyMessage() throws Exception {
    MimePackage mimeMessage = new MimePackage();
    mimeMessage.addAlternativePart("text123", "<html>alternative</html>");
    assertEquals(2, mimeMessage.getRegularPartCount());
    assertEquals(0, mimeMessage.getAttachmentPartCount());
    mimeMessage = new MimePackage();
    mimeMessage.addAlternativePart("text123", "<html>alternative</html>", "utf-8");
    assertEquals(2, mimeMessage.getRegularPartCount());
    assertEquals(0, mimeMessage.getAttachmentPartCount());
    assertEquals("utf-8", mimeMessage.getRegularPartCharset(0));
    assertEquals("utf-8", mimeMessage.getRegularPartCharset(1));
}
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