You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.
| Online: | 9 Members of 4089 |
| Forum: Seam Users |
21. Feb 2008, 17:49 CET | Link |
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):
@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...
3 Replies: | |||
|---|---|---|---|
Any help with this would be appreciated. I am runnning the tests using JBoss Tools and the test environment created by the Seam generator within the Tools. Even if someone could point me in the right direction for how to debug why the page action is not being fired in the test, that would be great.
Just to clarify, if I run up the application in JBoss and access the page Tom Nicholls Director CodeClass Java Training tom@codeclass.co.uk |
|||
Hmm. On the Old Forums it was claimed that it Should Work(tm). If a man speaks in the forest and there is no woman around to hear him, is he still wrong? |
|||
Tom Nicholls wrote on Feb 25, 2008 02:05 PM: Yup, you'll need to use a debugger on this. The SeamTest stuff is fairly simple. To use a debugger, run the tests through Eclipse using the debug TestNG runner, and set breakpoints as normal. Read about how to report a bug. |