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

2009-10-22 Thread Haulyn R. Jason
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, 25
Mobile: +086-15864011231
email: saharab...@gmail.com, hmp.hau...@foxmail.com
website: http://haulynjason.net
gtalk: saharab...@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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



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

2009-10-22 Thread Martin Grigorov
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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



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

2009-10-22 Thread Haulyn R. Jason
Thanks very much, it works!

On Thu, Oct 22, 2009 at 6:17 PM, Martin Grigorov mcgreg...@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-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org





-- 
Many thanks!

Haulyn Microproduction

You can access me with the following ways:
Location: Shandong Jinan Shumagang 6H-8, 25
Mobile: +086-15864011231
email: saharab...@gmail.com, hmp.hau...@foxmail.com
website: http://haulynjason.net
gtalk: saharab...@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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org