Search in sources :

Example 1 with MockMail

use of org.nhindirect.gateway.smtp.james.mailet.MockMail in project nhin-d by DirectProject.

the class IsNotificationTest method testIsNotification_ecryptedMessage_assertNull.

@SuppressWarnings("unchecked")
public void testIsNotification_ecryptedMessage_assertNull() throws Exception {
    MimeMessage msg = new MimeMessage(null, IOUtils.toInputStream(TestUtils.readMessageResource("EncryptedMessage.txt")));
    IsNotSMIMEEncrypted matcher = new IsNotSMIMEEncrypted();
    final Collection<MailAddress> initialRecips = new ArrayList<MailAddress>();
    for (InternetAddress addr : (InternetAddress[]) msg.getAllRecipients()) initialRecips.add(new MailAddress(addr.getAddress()));
    final MockMail mockMail = new MockMail(msg);
    mockMail.setRecipients(initialRecips);
    Collection<MailAddress> matchAddresses = matcher.match(mockMail);
    assertEquals(null, matchAddresses);
}
Also used : InternetAddress(javax.mail.internet.InternetAddress) MailAddress(org.apache.mailet.MailAddress) MimeMessage(javax.mail.internet.MimeMessage) MockMail(org.nhindirect.gateway.smtp.james.mailet.MockMail) ArrayList(java.util.ArrayList)

Example 2 with MockMail

use of org.nhindirect.gateway.smtp.james.mailet.MockMail in project nhin-d by DirectProject.

the class IsNotificationTest method testIsNotification_nullMessage_assertNull.

@SuppressWarnings("unchecked")
public void testIsNotification_nullMessage_assertNull() throws Exception {
    IsNotification matcher = new IsNotification();
    final MockMail mockMail = new MockMail(null);
    Collection<MailAddress> matchAddresses = matcher.match(mockMail);
    assertEquals(null, matchAddresses);
}
Also used : MailAddress(org.apache.mailet.MailAddress) MockMail(org.nhindirect.gateway.smtp.james.mailet.MockMail)

Example 3 with MockMail

use of org.nhindirect.gateway.smtp.james.mailet.MockMail in project nhin-d by DirectProject.

the class IsNotificationTest method testIsNotification_DSNMessage_assertAllRecips.

@SuppressWarnings("unchecked")
public void testIsNotification_DSNMessage_assertAllRecips() throws Exception {
    MimeMessage msg = new MimeMessage(null, IOUtils.toInputStream(TestUtils.readMessageResource("DSNMessage.txt")));
    IsNotification matcher = new IsNotification();
    final Collection<MailAddress> initialRecips = new ArrayList<MailAddress>();
    for (InternetAddress addr : (InternetAddress[]) msg.getAllRecipients()) initialRecips.add(new MailAddress(addr.getAddress()));
    final MockMail mockMail = new MockMail(msg);
    mockMail.setRecipients(initialRecips);
    Collection<MailAddress> matchAddresses = matcher.match(mockMail);
    assertEquals(1, matchAddresses.size());
    assertEquals(initialRecips.iterator().next().toString(), matchAddresses.iterator().next().toString());
}
Also used : InternetAddress(javax.mail.internet.InternetAddress) MailAddress(org.apache.mailet.MailAddress) MimeMessage(javax.mail.internet.MimeMessage) MockMail(org.nhindirect.gateway.smtp.james.mailet.MockMail) ArrayList(java.util.ArrayList)

Example 4 with MockMail

use of org.nhindirect.gateway.smtp.james.mailet.MockMail in project nhin-d by DirectProject.

the class IsNotificationTest method testIsNotification_plainMessage_assertNull.

@SuppressWarnings("unchecked")
public void testIsNotification_plainMessage_assertNull() throws Exception {
    MimeMessage msg = new MimeMessage(null, IOUtils.toInputStream(TestUtils.readMessageResource("PlainOutgoingMessage.txt")));
    IsNotification matcher = new IsNotification();
    final Collection<MailAddress> initialRecips = new ArrayList<MailAddress>();
    for (InternetAddress addr : (InternetAddress[]) msg.getAllRecipients()) initialRecips.add(new MailAddress(addr.getAddress()));
    final MockMail mockMail = new MockMail(msg);
    mockMail.setRecipients(initialRecips);
    Collection<MailAddress> matchAddresses = matcher.match(mockMail);
    assertEquals(null, matchAddresses);
}
Also used : InternetAddress(javax.mail.internet.InternetAddress) MailAddress(org.apache.mailet.MailAddress) MimeMessage(javax.mail.internet.MimeMessage) MockMail(org.nhindirect.gateway.smtp.james.mailet.MockMail) ArrayList(java.util.ArrayList)

Example 5 with MockMail

use of org.nhindirect.gateway.smtp.james.mailet.MockMail in project nhin-d by DirectProject.

the class IsNotSMIMEEncryptedTest method testIsNotSMIMEMessage_unecryptedMessage_assertAllRecips.

@SuppressWarnings("unchecked")
public void testIsNotSMIMEMessage_unecryptedMessage_assertAllRecips() throws Exception {
    MimeMessage msg = new MimeMessage(null, IOUtils.toInputStream(TestUtils.readMessageResource("PlainOutgoingMessage.txt")));
    IsNotSMIMEEncrypted matcher = new IsNotSMIMEEncrypted();
    final Collection<MailAddress> initialRecips = new ArrayList<MailAddress>();
    for (InternetAddress addr : (InternetAddress[]) msg.getAllRecipients()) initialRecips.add(new MailAddress(addr.getAddress()));
    final MockMail mockMail = new MockMail(msg);
    mockMail.setRecipients(initialRecips);
    Collection<MailAddress> matchAddresses = matcher.match(mockMail);
    assertEquals(1, matchAddresses.size());
    assertEquals(initialRecips.iterator().next().toString(), matchAddresses.iterator().next().toString());
}
Also used : InternetAddress(javax.mail.internet.InternetAddress) MailAddress(org.apache.mailet.MailAddress) MimeMessage(javax.mail.internet.MimeMessage) MockMail(org.nhindirect.gateway.smtp.james.mailet.MockMail) ArrayList(java.util.ArrayList)

Aggregations

MailAddress (org.apache.mailet.MailAddress)8 MockMail (org.nhindirect.gateway.smtp.james.mailet.MockMail)8 ArrayList (java.util.ArrayList)6 InternetAddress (javax.mail.internet.InternetAddress)6 MimeMessage (javax.mail.internet.MimeMessage)6