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"

      <m:message xmlms = "http://www.w3.org/1999/xhtml"

      <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.



      My RegistrationMailerTest.java

              public void testSendWelcomeMail() throws Exception {
                      new FacesRequest() {
                              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
                                      assert to.getAddress().equals("webmaster@mathmagicians.dk");

      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,