use of com.icegreen.greenmail.smtp.SmtpServer in project concord by walmartlabs.
the class SmtpTaskTest method testNoMessage.
@Test
public void testNoMessage() throws Exception {
SmtpServer server = mail.getSmtp();
Map<String, Object> smtpParams = new HashMap<>();
smtpParams.put("host", "localhost");
smtpParams.put("port", server.getPort());
Map<String, Object> mailParams = new HashMap<>();
mailParams.put("from", "my@mail.com");
mailParams.put("to", "aaa@mail.com");
mailParams.put("subject", "test");
try {
SmtpTask t = new SmtpTask();
t.call(smtpParams, mailParams);
fail("should fail");
} catch (IllegalArgumentException e) {
// expected
}
mail.reset();
}
use of com.icegreen.greenmail.smtp.SmtpServer in project concord by walmartlabs.
the class SmtpTaskTest method testNoSubject.
@Test
public void testNoSubject() throws Exception {
SmtpServer server = mail.getSmtp();
Map<String, Object> smtpParams = new HashMap<>();
smtpParams.put("host", "localhost");
smtpParams.put("port", server.getPort());
Map<String, Object> mailParams = new HashMap<>();
mailParams.put("from", "my@mail.com");
mailParams.put("to", "aaa@mail.com");
mailParams.put("message", "Hello!");
SmtpTask t = new SmtpTask();
t.call(smtpParams, mailParams);
MimeMessage[] messages = mail.getReceivedMessages();
assertEquals(1, messages.length);
assertEquals("Hello!\r\n", messages[0].getContent());
mail.reset();
}
use of com.icegreen.greenmail.smtp.SmtpServer in project concord by walmartlabs.
the class SmtpTaskTest method testNoBcc.
@Test
public void testNoBcc() throws Exception {
SmtpServer server = mail.getSmtp();
SmtpTask t = new SmtpTask();
t.send("localhost", server.getPort(), "my@mail.com", "their@mail.com", "test", "Hello!", null);
MimeMessage[] messages = mail.getReceivedMessages();
assertEquals(1, messages.length);
assertEquals("Hello!\r\n", messages[0].getContent());
assertEquals(1, messages[0].getAllRecipients().length);
mail.reset();
}
use of com.icegreen.greenmail.smtp.SmtpServer in project concord by walmartlabs.
the class SmtpTaskTest method testMultipleTo.
@Test
public void testMultipleTo() throws Exception {
SmtpServer server = mail.getSmtp();
Map<String, Object> smtpParams = new HashMap<>();
smtpParams.put("host", "localhost");
smtpParams.put("port", server.getPort());
Map<String, Object> mailParams = new HashMap<>();
mailParams.put("from", "my@mail.com");
mailParams.put("to", Arrays.asList("aaa@mail.com", "bbb@mail.com"));
mailParams.put("subject", "test");
mailParams.put("message", "Hello!");
SmtpTask t = new SmtpTask();
t.call(smtpParams, mailParams);
MimeMessage[] messages = mail.getReceivedMessages();
assertEquals(2, messages.length);
assertEquals("Hello!\r\n", messages[0].getContent());
mail.reset();
}
use of com.icegreen.greenmail.smtp.SmtpServer in project concord by walmartlabs.
the class SmtpTaskTest method testVariables.
@Test
public void testVariables() throws Exception {
SmtpServer server = mail.getSmtp();
Map<String, Object> smtpParams = new HashMap<>();
smtpParams.put("host", "localhost");
smtpParams.put("port", server.getPort());
Map<String, Object> mailParams = new HashMap<>();
mailParams.put("from", "my@mail.com");
mailParams.put("to", "their@mail.com");
mailParams.put("template", new File(ClassLoader.getSystemResource("test.mustache").toURI()).toString());
Map<String, Object> m = new HashMap<>();
m.put("name", "Concord");
m.put("workDir", "/");
m.put("smtp", smtpParams);
m.put("mail", mailParams);
Context ctx = new MockContext(m);
SmtpTask t = new SmtpTask();
t.execute(ctx);
MimeMessage[] messages = mail.getReceivedMessages();
assertEquals("Hello, Concord!\r\n", messages[0].getContent());
mail.reset();
}
Aggregations