You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Ravi_116 <ra...@gmail.com> on 2007/12/19 06:42:26 UTC

Accessing username from Page & Unit test

I have a custom WebSession (Extends AuthenticatedWebSession). What is correct
way to access the user credentials from a Page. I tried to access the user
credentials from the constructor of my custom page. 

((CustomWebSession) getSession()).getUserCredentials();


However, unit testing that page has become very painful. I would not like to
use AuthenticatedWebApplication, but dummy up the MockWebSession for unit
testing my pages. 

Ravi

-- 
View this message in context: http://www.nabble.com/Accessing-username-from-Page---Unit-test-tp14411574p14411574.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: Accessing username from Page & Unit test

Posted by Igor Vaynberg <ig...@gmail.com>.
class mockwebapp extends webapplication { newsession() { return new
mockwebsession(); }}

new WicketTester(new mockwebapp());

-igor

On Dec 19, 2007 8:11 AM, Ravi_116 <ra...@gmail.com> wrote:
>
> Igor,
> Thanks for the reply. How can i set the MockWebSession on the session object
> ? Is there an api available through wicket tester to set mockwebsession ?
> Ravi
>
> --
> View this message in context: http://www.nabble.com/Accessing-username-from-Page---Unit-test-tp14411574p14419916.html
>
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Accessing username from Page & Unit test

Posted by Ravi_116 <ra...@gmail.com>.
Igor,
Thanks for the reply. How can i set the MockWebSession on the session object
? Is there an api available through wicket tester to set mockwebsession ?
Ravi

-- 
View this message in context: http://www.nabble.com/Accessing-username-from-Page---Unit-test-tp14411574p14419916.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: Accessing username from Page & Unit test

Posted by Igor Vaynberg <ig...@gmail.com>.
interface icredentialsprovider { credentials getusercredentials(); }

public class customwebsession extends authenticatedsession implements
icredentialsprovider {
....}

class mocksession extends websession implements icredentialsprovider {
....
}

((icredentialsprovider) getSession()).getUserCredentials();


-igor


On Dec 18, 2007 9:42 PM, Ravi_116 <ra...@gmail.com> wrote:
>
> I have a custom WebSession (Extends AuthenticatedWebSession). What is correct
> way to access the user credentials from a Page. I tried to access the user
> credentials from the constructor of my custom page.
>
> ((CustomWebSession) getSession()).getUserCredentials();
>
>
> However, unit testing that page has become very painful. I would not like to
> use AuthenticatedWebApplication, but dummy up the MockWebSession for unit
> testing my pages.
>
> Ravi
>
> --
> View this message in context: http://www.nabble.com/Accessing-username-from-Page---Unit-test-tp14411574p14411574.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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