use of org.jenkinsci.test.acceptance.po.CapybaraPortingLayer in project acceptance-test-harness by jenkinsci.
the class MailService method assertMail.
/**
* Checks that the mail has arrived.
*/
public void assertMail(final Pattern subject, String recipient, Pattern body) throws MessagingException, IOException {
CapybaraPortingLayer hackish = new CapybaraPortingLayerImpl(World.get().getInjector());
MimeMessage msg = hackish.waitFor().withMessage("Email whose subject matches: %s", subject).pollingEvery(5, TimeUnit.SECONDS).until(new MailArrives(subject));
String actualRecipients = Joiner.on(' ').join(msg.getRecipients(TO));
assertThat("recipient", actualRecipients, is(recipient));
Object c = msg.getContent();
if (c instanceof MimeMultipart) {
MimeMultipart content = (MimeMultipart) c;
c = content.getBodyPart(0).getContent();
}
assertThat(c.toString(), containsRegexp(body));
}
Aggregations