Search in sources :

Example 1 with MimeMultipartReport

use of org.apache.mailet.base.mail.MimeMultipartReport in project nhin-d by DirectProject.

the class MDNFactory_createTest method testCreate_withFailure.

public void testCreate_withFailure() throws Exception {
    final Disposition disp = new Disposition(NotificationType.Processed);
    final MdnGateway gateway = new MdnGateway("junitGateway");
    MimeMultipartReport report = MDNFactory.create("test", "junitUA", "junitProduct", "sender@send.com", "final@final.com", "12345", "", gateway, disp, "", "junit failure", new ArrayList<String>());
    assertNotNull(report);
    final InternetHeaders headers = getNotificationFieldsAsHeaders(report);
    assertEquals("junit failure", headers.getHeader("Failure", ","));
}
Also used : MimeMultipartReport(org.apache.mailet.base.mail.MimeMultipartReport) InternetHeaders(javax.mail.internet.InternetHeaders)

Example 2 with MimeMultipartReport

use of org.apache.mailet.base.mail.MimeMultipartReport in project nhin-d by DirectProject.

the class MDNFactory_createTest method testCreate_withWarning.

public void testCreate_withWarning() throws Exception {
    final Disposition disp = new Disposition(NotificationType.Processed);
    final MdnGateway gateway = new MdnGateway("junitGateway");
    MimeMultipartReport report = MDNFactory.create("test", "junitUA", "junitProduct", "sender@send.com", "final@final.com", "12345", "", gateway, disp, "junit warning", "", new ArrayList<String>());
    assertNotNull(report);
    final InternetHeaders headers = getNotificationFieldsAsHeaders(report);
    assertEquals("junit warning", headers.getHeader("Warning", ","));
}
Also used : MimeMultipartReport(org.apache.mailet.base.mail.MimeMultipartReport) InternetHeaders(javax.mail.internet.InternetHeaders)

Example 3 with MimeMultipartReport

use of org.apache.mailet.base.mail.MimeMultipartReport in project nhin-d by DirectProject.

the class MDNFactory_createTest method testCreate_withExtensionNameWithValue.

public void testCreate_withExtensionNameWithValue() throws Exception {
    final Disposition disp = new Disposition(NotificationType.Processed);
    final MdnGateway gateway = new MdnGateway("junitGateway");
    MimeMultipartReport report = MDNFactory.create("test", "junitUA", "junitProduct", "sender@send.com", "final@final.com", "12345", "", gateway, disp, "", "junit failure", Arrays.asList("X-EXTENSION:junit value"));
    assertNotNull(report);
    final InternetHeaders headers = getNotificationFieldsAsHeaders(report);
    assertEquals("junit value", headers.getHeader("X-EXTENSION", ","));
}
Also used : MimeMultipartReport(org.apache.mailet.base.mail.MimeMultipartReport) InternetHeaders(javax.mail.internet.InternetHeaders)

Example 4 with MimeMultipartReport

use of org.apache.mailet.base.mail.MimeMultipartReport in project nhin-d by DirectProject.

the class MDNFactory_createTest method testCreate_withError_oldConstructor.

public void testCreate_withError_oldConstructor() throws Exception {
    final Disposition disp = new Disposition(NotificationType.Processed);
    final MdnGateway gateway = new MdnGateway("junitGateway");
    MimeMultipartReport report = MDNFactory.create("test", "junitUA", "junitProduct", "sender@send.com", "final@final.com", "12345", "junit error", gateway, disp);
    assertNotNull(report);
    final InternetHeaders headers = getNotificationFieldsAsHeaders(report);
    assertEquals("junit error", headers.getHeader("Error", ","));
}
Also used : MimeMultipartReport(org.apache.mailet.base.mail.MimeMultipartReport) InternetHeaders(javax.mail.internet.InternetHeaders)

Example 5 with MimeMultipartReport

use of org.apache.mailet.base.mail.MimeMultipartReport in project nhin-d by DirectProject.

the class MDNFactory_createTest method testCreate_withGernalAttributes.

public void testCreate_withGernalAttributes() throws Exception {
    final Disposition disp = new Disposition(NotificationType.Processed);
    final MdnGateway gateway = new MdnGateway("junitGateway");
    MimeMultipartReport report = MDNFactory.create("test", "junitUA", "junitProduct", "sender@send.com", "final@final.com", "12345", "junit error", gateway, disp, "", "", new ArrayList<String>());
    assertNotNull(report);
    final InternetHeaders headers = getNotificationFieldsAsHeaders(report);
    assertTrue(headers.getHeader(MDNStandard.Headers.ReportingAgent, ",").startsWith("junitUA"));
    assertTrue(headers.getHeader(MDNStandard.Headers.ReportingAgent, ",").endsWith("junitProduct"));
    assertEquals("rfc822; sender@send.com", headers.getHeader(MDNStandard.Headers.OriginalRecipeint, ","));
    assertEquals("rfc822; final@final.com", headers.getHeader(MDNStandard.Headers.FinalRecipient, ","));
    assertTrue(headers.getHeader(MDNStandard.Headers.Gateway, ",").endsWith("junitGateway"));
    assertTrue(headers.getHeader(MDNStandard.Headers.Disposition, ",").endsWith(NotificationType.Processed.toString()));
    BodyPart part0 = report.getBodyPart(0);
    Object obj = part0.getContent();
    assertEquals("test", obj);
}
Also used : MimeMultipartReport(org.apache.mailet.base.mail.MimeMultipartReport) BodyPart(javax.mail.BodyPart) InternetHeaders(javax.mail.internet.InternetHeaders)

Aggregations

MimeMultipartReport (org.apache.mailet.base.mail.MimeMultipartReport)9 InternetHeaders (javax.mail.internet.InternetHeaders)7 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IOException (java.io.IOException)2 DataHandler (javax.activation.DataHandler)2 MimeBodyPart (javax.mail.internet.MimeBodyPart)2 ByteArrayDataSource (javax.mail.util.ByteArrayDataSource)2 BodyPart (javax.mail.BodyPart)1