Integration test not running page action
tnicholls Feb 21, 2008 5:49 PMI 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):
@Stateful
@Scope(ScopeType.CONVERSATION)
@Name("Registration")
public class Registration implements RegistrationInterface, Serializable {
@Logger Log log;
@PersistenceContext(type=PersistenceContextType.EXTENDED)
@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
@Begin
public void beginRegistration() {
log.info("beginRegistration()");
account = new Account();
}
@End
public void register()
{
log.info("register()");
log.info("Hello, " + account.getName());
// details omitted
entityManager.persist(account);
}
@Remove
@Destroy
public void destroy() {}
}
I've written an integration test as follows:
public class RegistrationInterfaceTest extends SeamTest {
@Test
public void test() throws Exception {
new FacesRequest("/register.xhtml") {
@Override
protected void updateModelValues() throws Exception {
//set form input to model attributes
setValue("#{account.name}", "Tom");
setValue("#{account.email", "tom@blah.blah");
}
@Override
protected void invokeApplication() {
//call action methods here
invokeMethod("#{Registration.register}");
}
@Override
protected void renderResponse() {
//check model attributes if needed
assert getValue("#{account.name}").equals("Tom");
}
}.run();
}
...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...