Search in sources :

Example 51 with MimeMessage

use of javax.mail.internet.MimeMessage in project nhin-d by DirectProject.

the class DefaultTxDetailParser_getMimeMessageDetailsTest method testGetMessageDetails_mutlipleTo.

@Test
public void testGetMessageDetails_mutlipleTo() throws Exception {
    final MimeMessage msg = TestUtils.readMimeMessageFromFile("MessageWithAttachment.txt");
    msg.setHeader(MailStandard.Headers.To, "gm2552@cerner.com,ah4626@cerner.com");
    final DefaultTxDetailParser parser = new DefaultTxDetailParser();
    final Map<String, TxDetail> details = parser.getMessageDetails(msg);
    assertEquals(MailStandard.getHeader(msg, MailStandard.Headers.To).toLowerCase(Locale.getDefault()), details.get(TxDetailType.RECIPIENTS.getType()).getDetailValue());
}
Also used : MimeMessage(javax.mail.internet.MimeMessage) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Example 52 with MimeMessage

use of javax.mail.internet.MimeMessage in project nhin-d by DirectProject.

the class DefaultTxDetailParser_getMimeMessageDetailsTest method testGetMessageDetails_generalDNSMessage_noOrigMessageId_getFromReplyTo.

@Test
public void testGetMessageDetails_generalDNSMessage_noOrigMessageId_getFromReplyTo() throws Exception {
    final MimeMessage msg = TestUtils.readMimeMessageFromFile("DSNMessageOrigInReplyTo.txt");
    final DefaultTxDetailParser parser = new DefaultTxDetailParser();
    final Map<String, TxDetail> details = parser.getMessageDetails(msg);
    assertEquals("<9501051053.aa04167@IETF.CNR I.Reston.VA.US>", details.get(TxDetailType.PARENT_MSG_ID.getType()).getDetailValue());
}
Also used : MimeMessage(javax.mail.internet.MimeMessage) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Example 53 with MimeMessage

use of javax.mail.internet.MimeMessage in project nhin-d by DirectProject.

the class DefaultTxDetailParser_getMimeMessageDetailsTest method testGetMessageDetails_noFrom.

@Test
public void testGetMessageDetails_noFrom() throws Exception {
    final MimeMessage msg = TestUtils.readMimeMessageFromFile("MessageWithAttachment.txt");
    msg.setHeader(MailStandard.Headers.From, "");
    final DefaultTxDetailParser parser = new DefaultTxDetailParser();
    final Map<String, TxDetail> details = parser.getMessageDetails(msg);
    assertNull(details.get(TxDetailType.FROM.getType()));
}
Also used : MimeMessage(javax.mail.internet.MimeMessage) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Example 54 with MimeMessage

use of javax.mail.internet.MimeMessage in project nhin-d by DirectProject.

the class DefaultTxDetailParser_getMimeMessageDetailsTest method testGetMessageDetails_generalMDNMessage.

@Test
public void testGetMessageDetails_generalMDNMessage() throws Exception {
    final MimeMessage msg = TestUtils.readMimeMessageFromFile("MDNMessage.txt");
    final DefaultTxDetailParser parser = new DefaultTxDetailParser();
    final Map<String, TxDetail> details = parser.getMessageDetails(msg);
    assertEquals(MDNStandard.getMDNField(msg, MDNStandard.Headers.Disposition).toLowerCase(Locale.getDefault()), details.get(TxDetailType.DISPOSITION.getType()).getDetailValue());
    assertEquals(MDNStandard.getMDNField(msg, MDNStandard.Headers.FinalRecipient).toLowerCase(Locale.getDefault()), details.get(TxDetailType.FINAL_RECIPIENTS.getType()).getDetailValue());
    assertEquals(MDNStandard.getMDNField(msg, MDNStandard.Headers.OriginalMessageID), details.get(TxDetailType.PARENT_MSG_ID.getType()).getDetailValue());
}
Also used : MimeMessage(javax.mail.internet.MimeMessage) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Example 55 with MimeMessage

use of javax.mail.internet.MimeMessage in project nhin-d by DirectProject.

the class DefaultTxDetailParser_getMimeMessageDetailsTest method testGetMessageDetails_generalDNSMessage_noActionOrStatus.

@Test
public void testGetMessageDetails_generalDNSMessage_noActionOrStatus() throws Exception {
    final MimeMessage msg = TestUtils.readMimeMessageFromFile("DSNMessageNoActionOrStatus.txt");
    msg.setHeader(MailStandard.Headers.InReplyTo, "");
    final DefaultTxDetailParser parser = new DefaultTxDetailParser();
    final Map<String, TxDetail> details = parser.getMessageDetails(msg);
    assertNull(details.get(TxDetailType.DSN_ACTION.getType()));
    assertNull(details.get(TxDetailType.DSN_STATUS.getType()));
}
Also used : MimeMessage(javax.mail.internet.MimeMessage) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Aggregations

MimeMessage (javax.mail.internet.MimeMessage)1146 Test (org.junit.Test)374 InternetAddress (javax.mail.internet.InternetAddress)334 MessagingException (javax.mail.MessagingException)299 Session (javax.mail.Session)222 Properties (java.util.Properties)219 MimeMultipart (javax.mail.internet.MimeMultipart)208 MimeBodyPart (javax.mail.internet.MimeBodyPart)178 Date (java.util.Date)153 IOException (java.io.IOException)137 Message (javax.mail.Message)120 MimeMessageHelper (org.springframework.mail.javamail.MimeMessageHelper)107 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)97 ZMimeMessage (com.zimbra.common.zmime.ZMimeMessage)83 InputStream (java.io.InputStream)82 ArrayList (java.util.ArrayList)81 Multipart (javax.mail.Multipart)75 DataHandler (javax.activation.DataHandler)73 ByteArrayOutputStream (java.io.ByteArrayOutputStream)72 BodyPart (javax.mail.BodyPart)70