You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Leonardo D'Alimonte <le...@loginet.it> on 2012/12/14 11:51:56 UTC

Re: Possibile bug in MockHttpServletRequest

Hi guys,
I have a problem with the implementation of
MockHttpServletRequest.getSession(boolean):

		HttpSession sess = null;
		if (session instanceof MockHttpSession)
		{
			MockHttpSession mockHttpSession = (MockHttpSession) session;
			if (b)
			{
				mockHttpSession.setTemporary(false);
			}

			if (mockHttpSession.isTemporary() == false)
			{
				sess = session;
			}
		}
		return sess;

With parameter false, i never get the session even if it actually exists.
Field "session" is an instance of MockHttpSession, the first "if" is never
executed with boolean "false" and so also the second one..thus session
remain null.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Possibile-bug-in-MockHttpServletRequest-tp4340419p4654811.html
Sent from the Users forum 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: Possibile bug in MockHttpServletRequest

Posted by Martin Grigorov <mg...@apache.org>.
Servlet sessions are like Wicket statefulness:
Initially there is no session. Once you call getSession(true) you create
one.
Wicket pages are stateless by default. Once you add a stateful
component/behavior in the page tree you make it stateful.

This should answer your question - WicketTester should start with no http
session (for some reason this is represented as temporary http session) and
create one (i.e. make it non-temporary) once the application uses its first
stateful page.


On Fri, Dec 14, 2012 at 5:37 PM, Leonardo D'Alimonte <
leonardo.dalimonte@loginet.it> wrote:

> Hi Martin,
> thanks for the explanation.
> Is ti possible the BaseWicketTester instantiate a MockHttpSession without
> setting anymore the temporary flag to "false"?
> I checked the source for Wicket 1.4.20 and I found this
> difference....setting this flag to false inside my WicketTester turned back
> my test to green..
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Possibile-bug-in-MockHttpServletRequest-tp4340419p4654823.html
> Sent from the Users forum 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
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Re: Possibile bug in MockHttpServletRequest

Posted by Leonardo D'Alimonte <le...@loginet.it>.
Hi Martin,
thanks for the explanation.
Is ti possible the BaseWicketTester instantiate a MockHttpSession without
setting anymore the temporary flag to "false"?
I checked the source for Wicket 1.4.20 and I found this
difference....setting this flag to false inside my WicketTester turned back
my test to green..



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Possibile-bug-in-MockHttpServletRequest-tp4340419p4654823.html
Sent from the Users forum 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: Possibile bug in MockHttpServletRequest

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

If mockHttpSession is temporary then it is not bound and calling
getSession(false) will not return it.
You have to call getSession()/getSession(true) to bind it and from there on
getSession(false) will return it.


On Fri, Dec 14, 2012 at 12:51 PM, Leonardo D'Alimonte <
leonardo.dalimonte@loginet.it> wrote:

> Hi guys,
> I have a problem with the implementation of
> MockHttpServletRequest.getSession(boolean):
>
>                 HttpSession sess = null;
>                 if (session instanceof MockHttpSession)
>                 {
>                         MockHttpSession mockHttpSession =
> (MockHttpSession) session;
>                         if (b)
>                         {
>                                 mockHttpSession.setTemporary(false);
>                         }
>
>                         if (mockHttpSession.isTemporary() == false)
>                         {
>                                 sess = session;
>                         }
>                 }
>                 return sess;
>
> With parameter false, i never get the session even if it actually exists.
> Field "session" is an instance of MockHttpSession, the first "if" is never
> executed with boolean "false" and so also the second one..thus session
> remain null.
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Possibile-bug-in-MockHttpServletRequest-tp4340419p4654811.html
> Sent from the Users forum 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
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>