public class MailerTest {
@Test
public void testSingletons() {
// getter no props
Mailer mailer = new Mailer(new Properties());
assertFieldEquals("Send mail should be false", mailer, "sendMail", false);
assertFieldEquals("Recipients shouldn't have been set because sendMail is false.", mailer, "recipients", null);
assertFieldEquals("Sender should be null", mailer, "automatedSender", null);
// getter with props
Properties props = new Properties();
props.setProperty("mail.enabled", "true");
props.setProperty("mail.host", "localhost");
props.setProperty("mail.port", "25");
props.setProperty("mail.sender.username", "crohr");
props.setProperty("mail.from.address", "crohr");
props.setProperty("mail.sender.password", "password");
props.setProperty("mail.recipients", "crohr@nearinfinity.com|bmarcur@nearinfinity.com");
mailer = new Mailer(props);
assertFieldEquals("Send mail should be true", mailer, "sendMail", true);
assertCollectionFieldEquals("There should be 2 valid recipients", mailer, "recipients", 2);
assertFieldEquals("Sender should be crohr", mailer, "automatedSender", "crohr");
}