@Test public void testSmtpServerBasic() throws MessagingException { GreenMailUtil.sendTextEmailTest("*****@*****.**", "*****@*****.**", "subject", "body"); MimeMessage[] emails = greenMail.getReceivedMessages(); assertEquals(1, emails.length); assertEquals("subject", emails[0].getSubject()); assertEquals("body", GreenMailUtil.getBody(emails[0])); }
@Test public void testSmtpServerLeadingPeriods() throws MessagingException { String body = ". body with leading period"; GreenMailUtil.sendTextEmailTest("*****@*****.**", "*****@*****.**", "subject", body); MimeMessage[] emails = greenMail.getReceivedMessages(); assertEquals(1, emails.length); assertEquals("subject", emails[0].getSubject()); assertEquals(body, GreenMailUtil.getBody(emails[0])); }
@Test public void testSmtpServerReceiveWithSetup() throws Throwable { assertEquals(0, greenMail.getReceivedMessages().length); String subject = GreenMailUtil.random(); String body = GreenMailUtil.random(); GreenMailUtil.sendTextEmailTest("*****@*****.**", "*****@*****.**", subject, body); greenMail.waitForIncomingEmail(1500, 1); MimeMessage[] emails = greenMail.getReceivedMessages(); assertEquals(1, emails.length); assertEquals(subject, emails[0].getSubject()); assertEquals(body, GreenMailUtil.getBody(emails[0]).trim()); }