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 HasHeader();
MockMatcherConfig mci = new MockMatcherConfig("HasHeader="
+ HEADER_NAME, 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()
setupMockedMimeMessage();
setupMockedMail(mockedMimeMessage);
setupMatcher();
Collection matchedRecipients = matcher.match(mockedMail);
assertNull(matchedRecipients);
|