WicketTester tester = new WicketTester(new MyApplication());

should do it




Eyal Golan wrote:
> 
> Hi,
> I want to create a small UnitTest for my login page:
>     public void testLoginPageRender() {
>         tester.startPage(Login.class);
>         // Just to ensure that the request has not been
>         // intercepted or redirected
>         tester.assertRenderedPage(Login.class);
>         // A page might render with an error message.
>         // If the Login page does have an associated error message, the
>         // following
>         // method will result in a failed assertion.
>         tester.assertNoErrorMessage();
>     }
> 
> I get a ClassCastException:
> java.lang.ClassCastException: org.apache.wicket.protocol.http.WebSession
>     at com.eurekify.web.Login.<init>(Login.java:101)
> 
> And this is of course because I have this in my Login page:
>         if(((PortalSession)getSession()).isUserLoggedIn()){
>             PageParameters pageParameters = new PageParameters();
>             pageParameters.put("pageId", "");
>             PortalWebPage page = new PortalWebPage(pageParameters);
>             setRedirect( true );
>             setResponsePage(page);
>         }
> 
> My question is, how do I set the WebSession in a testing environment?
> 
> Thanks
> -- 
> Eyal Golan
> [EMAIL PROTECTED]
> 
> Visit: http://jvdrums.sourceforge.net/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Testing-using-WicketTester-tp17403637p17403686.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to