play-plugins
play-plugins copied to clipboard
How can I write a testcase to see if mailing works from my app
If I do the following ->
public static FakeApplication app;
@BeforeClass
public static void startApp() {
app = Helpers.fakeApplication();
Helpers.start(app);
}
@AfterClass
public static void stopApp() {
Helpers.stop(app);
}
@Test
public void sendEmail() {
MailerPlugin mailplugin = play.Play.application().plugin(MailerPlugin.class);
MailerAPI mail = mailplugin.email();
mail.setSubject("test for assist app");
mail.addRecipient();
mail.addFrom();
//sends html
//mail.sendHtml("<html>this is a test email</html>" );
//sends text/text
mail.send( "text" );
//sends both text and html
//mail.send( "text", "<html>html</html>");
}
I have a nummpointerexception at MailerAPI mail = mailplugin.email(); which means the factory method -> play.Play.application().plugin(MailerPlugin.class); does not seem to return the plugin class.
I am new to play is this how I supposed to do this ?
thanks
I used Greenmail to check that SMTP functionality was operating properly, and the contents of the email