Methods Summary |
---|
private void | setRecipients(org.apache.mailet.MailAddress[] recipients)
this.recipients = recipients;
|
private void | setupMatcher()
setupMockedMimeMessage();
matcher = new HostIs();
MockMatcherConfig mci = new MockMatcherConfig("HostIs=" + HOST_NAME,
new MockMailContext());
matcher.init(mci);
|
private void | setupMockedMail(javax.mail.internet.MimeMessage m)
mockedMail = new MockMail();
mockedMail.setMessage(m);
mockedMail.setRecipients(Arrays.asList(recipients));
|
private void | setupMockedMimeMessage()
String sender = "test@james.apache.org";
String rcpt = "test2@james.apache.org";
mockedMimeMessage = new MockMimeMessage();
mockedMimeMessage.setFrom(new InternetAddress(sender));
mockedMimeMessage.setRecipients(RecipientType.TO, rcpt);
mockedMimeMessage.setSubject("testmail");
mockedMimeMessage.setText("testtext");
mockedMimeMessage.saveChanges();
|
public void | testHostIsMatchedAllRecipients()
setRecipients(new MailAddress[] {
new MailAddress("test@james.apache.org"),
new MailAddress("test2@james.apache.org") });
setupMockedMimeMessage();
setupMockedMail(mockedMimeMessage);
setupMatcher();
Collection matchedRecipients = matcher.match(mockedMail);
assertNotNull(matchedRecipients);
assertEquals(matchedRecipients.size(), mockedMail.getRecipients()
.size());
|
public void | testHostIsMatchedOneRecipient()
setRecipients(new MailAddress[] {
new MailAddress("test@james2.apache.org"),
new MailAddress("test2@james.apache.org") });
setupMockedMimeMessage();
setupMockedMail(mockedMimeMessage);
setupMatcher();
Collection matchedRecipients = matcher.match(mockedMail);
assertNotNull(matchedRecipients);
assertEquals(matchedRecipients.size(), 1);
|
public void | testHostIsNotMatch()
setRecipients(new MailAddress[] {
new MailAddress("test@james2.apache.org"),
new MailAddress("test2@james2.apache.org") });
setupMockedMimeMessage();
setupMockedMail(mockedMimeMessage);
setupMatcher();
Collection matchedRecipients = matcher.match(mockedMail);
assertEquals(matchedRecipients.size(), 0);
|