Search in sources :

Example 41 with MimeMessage

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

the class DefaultTxDetailParser method getMessageDetails.

public Map<String, TxDetail> getMessageDetails(InputStream stream) {
    Map<String, TxDetail> retVal = null;
    if (stream == null)
        throw new IllegalArgumentException("Input stream cannot be null");
    try {
        // convert into a MimeMessage
        final MimeMessage msg = new MimeMessage(null, stream);
        retVal = getMessageDetails(msg);
    }///CLOVER:OFF		
     catch (MessagingException e) {
        LOGGER.warn("Failed to translate input stream into MimeMessage.", e);
    }
    return retVal;
}
Also used : MimeMessage(javax.mail.internet.MimeMessage) MessagingException(javax.mail.MessagingException) TxDetail(org.nhindirect.common.tx.model.TxDetail)

Example 42 with MimeMessage

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

the class DefaultTxDetailParser_getMimeMessageDetailsTest method testGetMessageDetails_noFullHeaders.

@Test
public void testGetMessageDetails_noFullHeaders() throws Exception {
    final MimeMessage msg = TestUtils.readMimeMessageFromFile("MessageWithAttachment.txt");
    final DefaultTxDetailParser parser = new DefaultTxDetailParser() {

        @Override
        public String getHeadersAsStringInternal(MimeMessage msg) {
            return "";
        }
    };
    final Map<String, TxDetail> details = parser.getMessageDetails(msg);
    assertNull(details.get(TxDetailType.MSG_FULL_HEADERS.getType()));
}
Also used : MimeMessage(javax.mail.internet.MimeMessage) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Example 43 with MimeMessage

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

the class TxUtil_getMessageTypeTypeTest method testGetMessageType_SMIMEMessage.

@Test
public void testGetMessageType_SMIMEMessage() throws Exception {
    MimeMessage msg = TestUtils.readMimeMessageFromFile("SMIMEMessage.txt");
    assertEquals(TxMessageType.SMIME, TxUtil.getMessageType(msg));
}
Also used : MimeMessage(javax.mail.internet.MimeMessage) Test(org.junit.Test)

Example 44 with MimeMessage

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

the class TxUtil_isRelAndTimelyTest method testIsTimelyAndRequired_MDNOptionForTimelyMimeMessage_assertTrue.

@Test
public void testIsTimelyAndRequired_MDNOptionForTimelyMimeMessage_assertTrue() throws Exception {
    MimeMessage msg = TestUtils.readMimeMessageFromFile("MessageWithAttachment.txt");
    msg.addHeader(MDNStandard.Headers.DispositionNotificationOptions, MDNStandard.DispositionOption_TimelyAndReliable);
    msg.saveChanges();
    assertTrue(TxUtil.isReliableAndTimelyRequested(msg));
}
Also used : MimeMessage(javax.mail.internet.MimeMessage) Test(org.junit.Test)

Example 45 with MimeMessage

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

the class TxUtil_isRelAndTimelyTest method testIsTimelyAndRequired_NoMDNOptionForTimelyMimeMessage_assertFalse.

@Test
public void testIsTimelyAndRequired_NoMDNOptionForTimelyMimeMessage_assertFalse() throws Exception {
    MimeMessage msg = TestUtils.readMimeMessageFromFile("MessageWithAttachment.txt");
    assertFalse(TxUtil.isReliableAndTimelyRequested(msg));
}
Also used : MimeMessage(javax.mail.internet.MimeMessage) 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