server.stop();
}
@Test
public void shouldSendEmailOverridingConfig() throws Exception {
SimpleSmtpServer server = SimpleSmtpServer.start(2000); // this starts a fake STMP Server on the specified port
MailProcessorConfig configuration = new MailProcessorConfig();
configuration.setPort(2000);
configuration.setAuth(false);
MailProcessor processor = new MailProcessor(configuration);
Message message = new Message();
message.setProperty("to", "german.escobarc@gmail.com");
message.setProperty("from", "test@localhost");
message.setProperty("subject", "This is the subject");
message.setProperty("text", "This is a test");
processor.process(message);
Assert.assertTrue(server.getReceivedEmailSize() == 1);
SmtpMessage email = (SmtpMessage) server.getReceivedEmail().next();
Assert.assertTrue(email.getHeaderValue("Subject").equals("This is the subject"));
Assert.assertTrue(email.getHeaderValue("From").equals("test@localhost"));
Assert.assertTrue(email.getBody().equals("This is a test"));
server.stop();
}