Methods Summary |
---|
private void | setHeaderName(java.lang.String headerName)
this.headerName = headerName;
|
private void | setHeaderValue(java.lang.String headerValue)
this.headerValue = headerValue;
|
private void | setupMailet()
setupMockedMimeMessage();
mailet = new SetMimeHeader();
MockMailetConfig mci = new MockMailetConfig("Test",
new MockMailContext());
mci.setProperty("name", HEADER_NAME);
mci.setProperty("value", HEADER_VALUE);
mailet.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 | testHeaderIsPresent()
setupMockedMimeMessage();
setupMockedMail(mockedMimeMessage);
setupMailet();
mailet.service(mockedMail);
assertEquals(HEADER_VALUE, mockedMail.getMessage().getHeader(
HEADER_NAME)[0]);
|
public void | testHeaderIsReplaced()
setHeaderName(HEADER_NAME);
setHeaderValue(headerValue);
setupMockedMimeMessage();
setupMockedMail(mockedMimeMessage);
setupMailet();
mailet.service(mockedMail);
assertEquals(HEADER_VALUE, mockedMail.getMessage().getHeader(
HEADER_NAME)[0]);
|