Methods Summary |
---|
private void | setHeaderName(java.lang.String headerName)
this.headerName = headerName;
|
private void | setHeaderValue(java.lang.String headerValue)
this.headerValue = headerValue;
|
private void | setupMatcher()
setupMockedMimeMessage();
matcher = new FetchedFrom();
MockMatcherConfig mci = new MockMatcherConfig("FetchedFrom="
+ HEADER_VALUE, new MockMailContext());
matcher.init(mci);
|
private void | setupMockedMail(javax.mail.internet.MimeMessage m)
mockedMail = new MockMail();
mockedMail.setMessage(m);
mockedMail.setRecipients(Arrays.asList(new MailAddress[] {
new MailAddress("test@james.apache.org"),
new MailAddress("test2@james.apache.org") }));
|
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.setHeader(headerName, headerValue);
mockedMimeMessage.setSubject("testmail");
mockedMimeMessage.setText("testtext");
mockedMimeMessage.saveChanges();
|
public void | testHeaderIsMatched()
setHeaderName(HEADER_NAME);
setHeaderValue(HEADER_VALUE);
setupMockedMimeMessage();
setupMockedMail(mockedMimeMessage);
setupMatcher();
Collection matchedRecipients = matcher.match(mockedMail);
assertNotNull(matchedRecipients);
assertEquals(matchedRecipients.size(), mockedMail.getRecipients()
.size());
|
public void | testHeaderIsNotMatched()
setHeaderName(HEADER_NAME);
setHeaderValue(headerValue);
setupMockedMimeMessage();
setupMockedMail(mockedMimeMessage);
setupMatcher();
Collection matchedRecipients = matcher.match(mockedMail);
assertNull(matchedRecipients);
|
public void | testHeaderWasRemovedAfterMatched()
setHeaderName(HEADER_NAME);
setHeaderValue(HEADER_VALUE);
setupMockedMimeMessage();
setupMockedMail(mockedMimeMessage);
setupMatcher();
Collection matchedRecipients = matcher.match(mockedMail);
Collection matchedRecipients2 = matcher.match(mockedMail);
assertNotNull(matchedRecipients);
assertNull(matchedRecipients2);
|