This content has been marked as final.
Show 2 replies
-
1. Re: pages.xml and SeamTest
kapitanpetko May 21, 2008 3:14 AM (in response to kapitanpetko)
Nikolay Elenkov wrote on May 20, 2008 07:28 PM:
My setup is fairly simple, I have something like the following in pages.xml, and I am trying to persist and entity in my test. (set values in updateModelValues, save in invokeApplication, the usual)Here is some code that used to work with navigation in faces-config:
@Test public void testRegister() throws Exception { new FacesRequest("/login.xhtml") { @Override protected void updateModelValues() throws Exception { assert !isSessionInvalid(); setValue("#{identity.username}", "admin"); setValue("#{identity.password}", "foobar"); } @Override protected void invokeApplication() { invokeAction("#{identity.login}"); } @Override protected void renderResponse() { assert !Manager.instance().isLongRunningConversation(); assert getValue("#{identity.loggedIn}").equals(true); assertEquals("admin", getValue("#{identity.username}")); assert getValue("#{identity.hasRole('ADMINISTRATOR')}").equals( true); } }.run(); String cid = new FacesRequest("/user-list.xhtml") { @Override protected void invokeApplication() { assert invokeAction("#{userManager.register}").equals( "register-system-user"); setOutcome("/user-registration.seam"); } @Override protected void renderResponse() { assert Manager.instance().isLongRunningConversation(); assert getValue("#{identity.loggedIn}").equals(true); assertEquals("admin", getValue("#{identity.username}")); assert getValue("#{identity.hasRole('ADMINISTRATOR')}").equals( true); } }.run(); cid = new FacesRequest("/user-registration.xhtml", cid) { @Override protected void updateModelValues() throws Exception { assert !isSessionInvalid(); assert Manager.instance().isLongRunningConversation(); // (1) setValue("#{user.userName}", "user"); // (2) setValue("#{user.password}", "foobaz"); setValue("#{user.confirmPassword}", "foobaz"); } @Override protected void invokeApplication() { invokeAction("#{userManager.confirmRegistration}"); setOutcome("/user-details.seam"); } @Override protected void renderResponse() { assert Manager.instance().isLongRunningConversation(); assertEquals(getRenderedViewId(), "/user-registration.xhtml"); assertEquals(getValue("#{user.userName}"), "user"); // ... } }.run(); }
The assert (1) fails, and, naturally, if I comment it out, I get a 'user resolved to null' error at 2.
-
2. Re: pages.xml and SeamTest
kapitanpetko May 23, 2008 7:59 PM (in response to kapitanpetko)I don't have the code with me, but here's what works:
protected void invokeApplication() { ... setOutcome("user-registration.seam"); // no leading / }
And apperently SeamTest doesn't like the
<page view-id="*"> <rule from-action="...">
combination... Unfortunately I don't have the time to dig deeper into this.