3 Replies Latest reply on Nov 19, 2009 11:31 PM by ifischer

    Testing the EmailTemplate using SeamTest

    Sunil Inteti Newbie
      Hi Guys,

      I want to test the Email functionality using the Seam test.

      My emailTemplate.xhtml is like

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <m:message xmlms = "http://www.w3.org/1999/xhtml"
      xmlns:m="http://jboss.com/products/seam/email"
      importance="normal">

      <m:header name="X-composed-By" value="Jboss Seam"/>
      <m:from name = "customer service" address="customerservice@test.dk"/>
      <m:replyTo address="webmaster@test.dk" />
      <m:to name="user"> test@test.com </m:to>
      <m:subject> New User Registration Information </m:subject>

      <m:body type="plain"> Hey User ,

      Welcome to the Skills website.
      Thanks for the registration.

      </m:body>

      </m:message>

      My RegistrationMailerTest.java

      @Test
              public void testSendWelcomeMail() throws Exception {
                      new FacesRequest() {
                             
                              @Override
                              protected void invokeApplication() throws Exception {
                                     
                                      MimeMessage renderedMessage = getRenderedMailMessage("/emailTemplate.xhtml");
                                      assert renderedMessage.getAllRecipients().length == 1;
                                      assert renderedMessage != null;
                                      System.out.println("The rendered message is : "+ renderedMessage);
                                      InternetAddress to = (InternetAddress) renderedMessage
                                                      .getAllRecipients()[0];
                                      assert to.getAddress().equals("webmaster@mathmagicians.dk");
                              }
                      }.run();
              }


      Running this test gives me Null pointer Exception. Actually the getRenderedMailMessage("/emailTemplate.xhtml") returns Null.

      I am just using the same build.xml generated by Seam-gen. How to fix this ??

      Any help is much appreciated as to how to test the emails.


      Best Regards,
      Sunil