5 Replies Latest reply on May 29, 2009 12:46 PM by aaaaaaa aa

    Integration test not running page action

    Tom Nicholls Newbie

      I have a stateful Session EJB running as a Seam component in conversational scope.  It's a simple registration example and when I test it in the browser everything works fine.

      I have a single page action set up in pages.xml which fires a method to create a long-running conversation when the user goes to the registration page:

           <page view-id="/register.xhtml" action="#{Registration.beginRegistration}"/>

      The important bits of my registration bean look like this (with some code omitted such as getters and setters):

      public class Registration implements RegistrationInterface, Serializable {
          @Logger Log log;
          @In EntityManager entityManager;
          @In(create=true, required=false, value="account")
          @Out(required=false) Account account; // the account that is going to be created by the user
          public void beginRegistration() {
               account = new Account();
           public void register()
              log.info("Hello, " + account.getName());
              // details omitted
          public void destroy() {}

      I've written an integration test as follows:

      public class RegistrationInterfaceTest extends SeamTest {
           public void test() throws Exception {
                new FacesRequest("/register.xhtml") {
                     protected void updateModelValues() throws Exception {                    
                          //set form input to model attributes
                          setValue("#{account.name}", "Tom");
                          setValue("#{account.email", "tom@blah.blah");
                     protected void invokeApplication() {
                          //call action methods here
                     protected void renderResponse() {
                          //check model attributes if needed
                          assert getValue("#{account.name}").equals("Tom");

      ...but it doesn't seem to fire the page action defined in pages.xml .  When I go to the page in a browser I can see the method being fired.

      What might I be doing wrong?  Do I need to post more information?  I'm fairly new to Seam and this is my first foray into using the FacesRequest class.

      Thanks in advance for any help...