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());
}
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);
}
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) {
}
}
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());
}
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));
}
Aggregations