use of javax.mail.search.SearchTerm in project jodd by oblac.
the class EmailFilter method header.
/**
* Defines filter for header.
*/
public EmailFilter header(String headerName, String pattern) {
SearchTerm term = new HeaderTerm(headerName, pattern);
concat(term);
return this;
}
use of javax.mail.search.SearchTerm in project camel by apache.
the class SearchTermBuilderTest method testSearchTermBuilderFromOrSubject.
public void testSearchTermBuilderFromOrSubject() throws Exception {
SearchTermBuilder build = new SearchTermBuilder();
SearchTerm st = build.subject("Camel").from(or, "admin@apache.org").build();
assertNotNull(st);
// create dummy message
Mailbox.clearAll();
JavaMailSender sender = new DefaultJavaMailSender();
MimeMessage msg = new MimeMessage(sender.getSession());
msg.setSubject("Yeah Camel rocks");
msg.setText("Apache Camel is a cool project. Have a fun ride.");
msg.setFrom(new InternetAddress("someone@somewhere.com"));
assertTrue("Should match message", st.match(msg));
MimeMessage msg2 = new MimeMessage(sender.getSession());
msg2.setSubject("Beware");
msg2.setText("This is from the administrator.");
msg2.setFrom(new InternetAddress("admin@apache.org"));
assertTrue("Should match message, as its from admin", st.match(msg2));
}
use of javax.mail.search.SearchTerm in project camel by apache.
the class SearchTermBuilderTest method testSearchTermBuilderFromAndSubject.
public void testSearchTermBuilderFromAndSubject() throws Exception {
SearchTermBuilder build = new SearchTermBuilder();
SearchTerm st = build.from("someone@somewhere.com").subject("Camel").build();
assertNotNull(st);
// create dummy message
Mailbox.clearAll();
JavaMailSender sender = new DefaultJavaMailSender();
MimeMessage msg = new MimeMessage(sender.getSession());
msg.setSubject("Yeah Camel rocks");
msg.setText("Apache Camel is a cool project. Have a fun ride.");
msg.setFrom(new InternetAddress("someone@somewhere.com"));
assertTrue("Should match message", st.match(msg));
MimeMessage msg2 = new MimeMessage(sender.getSession());
msg2.setSubject("Apache Camel is fantastic");
msg2.setText("I like Camel.");
msg2.setFrom(new InternetAddress("donotreply@somewhere.com"));
assertFalse("Should not match message, as from doesn't match", st.match(msg2));
}
Aggregations