You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Haulyn R. Jason" <sa...@gmail.com> on 2009/10/22 11:07:27 UTC

How to do unit test for a session protected wicket page?

Hi, all:

I have a page which is protected by MySession.isLogin().

I want to unit test this page and write the following code:

-----------------------------------------------------------------------------------------------------------
        WicketTester tester = new WicketTester(new WebsiteApplication());

        tester.createRequestCycle();
        tester.setupRequestAndResponse();
        tester.startPage(GmailImportPage.class);

        WebsiteSession session = (WebsiteSession)tester.getWicketSession();
        Member m = new Member();
        m.setId(2);
        session.setMember(m);

        tester.assertRenderedPage(GmailImportPage.class);
-----------------------------------------------------------------------------------------------------------
But, the result is: expected: <GmailImportPage> but was <IndexPage>

that right, IndexPage is my Index Page setting by WebsiteApplication,
I think maybe I lost some steps, can anybody help me?

Thanks.



-- 
Many thanks!

Haulyn Microproduction

Location: Shandong Jinan Shumagang 6H-8, 250000
Mobile: +086-15864011231
email: saharabear@gmail.com, hmp.haulyn@foxmail.com
website: http://haulynjason.net
gtalk: saharabear@gmail.com
skype: saharabear
QQ: 378606292
persional Twitter: http://twitter.com/saharabear
persional Linkedin: http://www.linkedin.com/in/haulyn
Haulyn Microproduction Twitter: http://twitter.com/haulynmp


Haulyn Jason

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to do unit test for a session protected wicket page?

Posted by "Haulyn R. Jason" <sa...@gmail.com>.
Thanks very much, it works!

On Thu, Oct 22, 2009 at 6:17 PM, Martin Grigorov <mc...@e-card.bg> wrote:
> El jue, 22-10-2009 a las 17:07 +0800, Haulyn R. Jason escribió:
>> Hi, all:
>>
>> I have a page which is protected by MySession.isLogin().
>>
>> I want to unit test this page and write the following code:
>>
>> -----------------------------------------------------------------------------------------------------------
>>         WicketTester tester = new WicketTester(new WebsiteApplication());
>>
>>         tester.createRequestCycle();
>>         tester.setupRequestAndResponse();
> put a User in the Session here and then isLogin() will pass
>>         tester.startPage(GmailImportPage.class);
>>
>>         WebsiteSession session = (WebsiteSession)tester.getWicketSession();
>>         Member m = new Member();
>>         m.setId(2);
>>         session.setMember(m);
>>
>>         tester.assertRenderedPage(GmailImportPage.class);
>> -----------------------------------------------------------------------------------------------------------
>> But, the result is: expected: <GmailImportPage> but was <IndexPage>
>>
>> that right, IndexPage is my Index Page setting by WebsiteApplication,
>> I think maybe I lost some steps, can anybody help me?
>>
>> Thanks.
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Many thanks!

Haulyn Microproduction

You can access me with the following ways:
Location: Shandong Jinan Shumagang 6H-8, 250000
Mobile: +086-15864011231
email: saharabear@gmail.com, hmp.haulyn@foxmail.com
website: http://haulynjason.net
gtalk: saharabear@gmail.com
skype: saharabear
QQ: 378606292
persional Twitter: http://twitter.com/saharabear
persional Linkedin: http://www.linkedin.com/in/haulyn
Haulyn Microproduction Twitter: http://twitter.com/haulynmp


Haulyn Jason

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to do unit test for a session protected wicket page?

Posted by Martin Grigorov <mc...@e-card.bg>.
El jue, 22-10-2009 a las 17:07 +0800, Haulyn R. Jason escribió:
> Hi, all:
> 
> I have a page which is protected by MySession.isLogin().
> 
> I want to unit test this page and write the following code:
> 
> -----------------------------------------------------------------------------------------------------------
>         WicketTester tester = new WicketTester(new WebsiteApplication());
> 
>         tester.createRequestCycle();
>         tester.setupRequestAndResponse();
put a User in the Session here and then isLogin() will pass
>         tester.startPage(GmailImportPage.class);
> 
>         WebsiteSession session = (WebsiteSession)tester.getWicketSession();
>         Member m = new Member();
>         m.setId(2);
>         session.setMember(m);
> 
>         tester.assertRenderedPage(GmailImportPage.class);
> -----------------------------------------------------------------------------------------------------------
> But, the result is: expected: <GmailImportPage> but was <IndexPage>
> 
> that right, IndexPage is my Index Page setting by WebsiteApplication,
> I think maybe I lost some steps, can anybody help me?
> 
> Thanks.
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org