Integration Testing Seam Mail

Posted by    |       Seam

Here's a quick overview of a feature I've been wanting to add to Seam for ages. It's really easy to use - just create a standard SeamTest and inside the invokeApplication() call getRenderedMailMessage(viewIdOfMailMessageToRender). You can then make assertion's against the returned MimeMessage.

public class MailTest extends SeamTest {
   public void testSimpleMessage() throws Exception {
      new FacesRequest() {

         protected void invokeApplication() throws Exception {
            MimeMessage renderedMessage = getRenderedMailMessage("/simple.xhtml");
            assert renderedMessage.getAllRecipients().length == 1;
            InternetAddress to = (InternetAddress) renderedMessage.getAllRecipients()[0];
            assert to.getAddress().equals("");

This is still a feature under development so if you try it out and can't get it working, post on the forum

Back to top