Re: Possibile bug in MockHttpServletRequest

2012-12-14 Thread Martin Grigorov
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.dalimo...@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-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




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


Re: Possibile bug in MockHttpServletRequest

2012-12-14 Thread Martin Grigorov
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.dalimo...@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
 differencesetting 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-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




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


Possibile bug in MockHttpServletRequest

2012-01-30 Thread Giovanni Cuccu

Hello,
I'm starting to user WicketTester and I've hit the following behaviour.
I have a IRequestCycleListener wich needs to access to the httpSession. 
In my code I was using

HttpSession httpSession=httpRequest.getSession();
which works fine within the real servlet  container (i.e. tomcat) but 
fails when I use WicketTester

In order to make wicketteset work I had to change the previous line to:
HttpSession httpSession=httpRequest.getSession(true);
But if I look at the servler api specs 
(http://docs.oracle.com/javaee/1.4/api/) the api says:


public HttpSession getSession()
Returns the current session associated with this request, or if the 
request does not have a session, creates one.


So as far as I understand
httpRequest.getSession(); and httpRequest.getSession(true); are equivalent

If my assumption is correct the MockHttpServletRequest implementation is 
incorrect since it returns null in my case.

The code in the mock class is the following one
public HttpSession getSession()
{
if (session instanceof MockHttpSession  
((MockHttpSession)session).isTemporary())

{
return null;
}
return session;
}
Is it a bug or am I missing something?
ciao,
Giovanni


--
Giovanni Cuccu
CUP 2000 Spa
Via del Borgo di S. Pietro, 90/c - 40126 Bologna
e-mail: giovanni.cuccu _at_ cup2000.it


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



Re: Possibile bug in MockHttpServletRequest

2012-01-30 Thread Martin Grigorov
Hi,

It looks like a bug.
Please create a ticket.
Thanks!

On Mon, Jan 30, 2012 at 10:58 AM, Giovanni Cuccu
giovanni.cu...@cup2000.it wrote:
 Hello,
    I'm starting to user WicketTester and I've hit the following behaviour.
 I have a IRequestCycleListener wich needs to access to the httpSession. In
 my code I was using
    HttpSession httpSession=httpRequest.getSession();
 which works fine within the real servlet  container (i.e. tomcat) but fails
 when I use WicketTester
 In order to make wicketteset work I had to change the previous line to:
    HttpSession httpSession=httpRequest.getSession(true);
 But if I look at the servler api specs
 (http://docs.oracle.com/javaee/1.4/api/) the api says:

 public HttpSession getSession()
 Returns the current session associated with this request, or if the request
 does not have a session, creates one.

 So as far as I understand
 httpRequest.getSession(); and httpRequest.getSession(true); are equivalent

 If my assumption is correct the MockHttpServletRequest implementation is
 incorrect since it returns null in my case.
 The code in the mock class is the following one
    public HttpSession getSession()
    {
        if (session instanceof MockHttpSession 
 ((MockHttpSession)session).isTemporary())
        {
            return null;
        }
        return session;
    }
 Is it a bug or am I missing something?
 ciao,
    Giovanni


 --
 Giovanni Cuccu
 CUP 2000 Spa
 Via del Borgo di S. Pietro, 90/c - 40126 Bologna
 e-mail: giovanni.cuccu _at_ cup2000.it


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




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

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



Re: Possibile bug in MockHttpServletRequest

2012-01-30 Thread Giovanni Cuccu

Hi Martin,
done.
https://issues.apache.org/jira/browse/WICKET-4370
ciao,
Giovanni


In
  my code I was using
  HttpSession httpSession=httpRequest.getSession();
  which works fine within the real servlet  container (i.e. tomcat) but fails
  when I use WicketTester
  In order to make wicketteset work I had to change the previous line to:
  HttpSession httpSession=httpRequest.getSession(true);
  But if I look at the servler api specs
  (http://docs.oracle.com/javaee/1.4/api/) the api says:

  public HttpSession getSession()
  Returns the current session associated with this request, or if the request
  does not have a session, creates one.

  So as far as I understand
  httpRequest.getSession(); and httpRequest.getSession(true); are equivalent

  If my assumption is correct the MockHttpServletRequest implementation is
  incorrect since it returns null in my case.
  The code in the mock class is the following one
  public HttpSession getSession()
  {
  if (session instanceof MockHttpSession
  ((MockHttpSession)session).isTemporary())
  {
  return null;
  }
  return session;
  }



--
Giovanni Cuccu
CUP 2000 Spa
Via del Borgo di S. Pietro, 90/c - 40126 Bologna
e-mail: giovanni.cuccu _at_ cup2000.it


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



MockHttpServletRequest

2011-06-07 Thread Adam Gray
My application's base page does checking against the user agent string to
redirect unsupported browsers to a support page.  The problem we're seeing
is that WicketTester is using a hardcoded user agent from a crazy-old
version of firefox.

Is there any recommended way to specify the user-agent used by WicketTester,
or is this a known limitation?  From what I can tell, there doesn't seem to
be a way to get at the actual header data to make the change.


Re: MockHttpServletRequest

2011-06-07 Thread Martin Grigorov
Looking at the code I see a lot of things are not possible to
configure in this area.
The easiest way to allow what you need is to add #setHeader(name,
value) which will override the previous value(s) for this name.

Please create a ticket.

On Tue, Jun 7, 2011 at 4:11 PM, Adam Gray adam.j.g...@gmail.com wrote:
 My application's base page does checking against the user agent string to
 redirect unsupported browsers to a support page.  The problem we're seeing
 is that WicketTester is using a hardcoded user agent from a crazy-old
 version of firefox.

 Is there any recommended way to specify the user-agent used by WicketTester,
 or is this a known limitation?  From what I can tell, there doesn't seem to
 be a way to get at the actual header data to make the change.




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

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



Re: MockHttpServletRequest

2011-06-07 Thread Adam Gray
Will do, thanks.

On Tue, Jun 7, 2011 at 10:23 AM, Martin Grigorov mgrigo...@apache.orgwrote:

 Looking at the code I see a lot of things are not possible to
 configure in this area.
 The easiest way to allow what you need is to add #setHeader(name,
 value) which will override the previous value(s) for this name.

 Please create a ticket.

 On Tue, Jun 7, 2011 at 4:11 PM, Adam Gray adam.j.g...@gmail.com wrote:
  My application's base page does checking against the user agent string to
  redirect unsupported browsers to a support page.  The problem we're
 seeing
  is that WicketTester is using a hardcoded user agent from a crazy-old
  version of firefox.
 
  Is there any recommended way to specify the user-agent used by
 WicketTester,
  or is this a known limitation?  From what I can tell, there doesn't seem
 to
  be a way to get at the actual header data to make the change.
 



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

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