Thanks.
I actually tried but got an error that it could not find the application
context (we use Spring).
java.lang.IllegalStateException: No WebApplicationContext found: no
ContextLoaderListener registered?
Instead this is what I did:
tester = new WicketTester(new WebApplication() {
@Override
public Session newSession(Request request, Response response) {
return new PortalSession(request);
}
@Override
public Class getHomePage() {
// TODO Auto-generated method stub
return null;
}
});
What do you think?
On Thu, May 22, 2008 at 3:56 PM, richardwilko <
[EMAIL PROTECTED]> wrote:
>
> 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]
>
>
--
Eyal Golan
[EMAIL PROTECTED]
Visit: http://jvdrums.sourceforge.net/