Re: Wickettester, cookies and redirects in Wicket 1.4.15

2011-02-02 Thread Kent Tong
 Hi, I currently have an application reading a cookie in my session. All
 of my unit tests where the pattern is: Create page - submit form -
 redirect to new page fails to read this cookie after the redirect to new
 page.

Have you tried http://wicketpagetest.sourceforge.net which supports
this case automatically.


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



Re: Wickettester, cookies and redirects in Wicket 1.4.15

2011-02-02 Thread Robert Dahlström

Thanks for the tip but I'd prefer to stick with WicketTester for the moment.

Regards
Robert

On 02/02/2011 10:36 AM, Kent Tong wrote:

Hi, I currently have an application reading a cookie in my session. All
of my unit tests where the pattern is: Create page -  submit form -
redirect to new page fails to read this cookie after the redirect to new
page.


Have you tried http://wicketpagetest.sourceforge.net which supports
this case automatically.


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




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



Wickettester, cookies and redirects in Wicket 1.4.15

2011-02-01 Thread Robert Dahlström
Hi, I currently have an application reading a cookie in my session. All 
of my unit tests where the pattern is: Create page - submit form - 
redirect to new page fails to read this cookie after the redirect to new 
page.


The cookie is added both to the response and request before each new 
test (WicketTester gets recreated):

tester.getWicketResponse().addCookie(cookie);
tester.getServletRequest().setCookies(new Cookie[]{cookie});

This works fine during first page rendering and form submission. But 
after the form has been submitted and the redirect to new page takes 
place the cookie does not exist in the new request.


Since I'm a bit unsure if this is the wanted behavior for WicketTester 
or not I'm posting this to all users out there.


In my particular use case I would like the cookie to be persisted 
between original request and new request since that's how it is working 
in the real application.


Codewise (with Wicket 1.4.15):
In MockWebApplication.postProcessRequestCycle:
if (httpResponse.isRedirect())
{
  lastRenderedPage = generateLastRenderedPage(cycle);

  MockHttpServletRequest newHttpRequest = new 
MockHttpServletRequest(application, servletSession, 
application.getServletContext());


...
}

The call to new MockHttpServletRequest will clear all cookies set during 
initialize() and thus my cookie will not be set in the redirect request.


Any ideas on how to tackle this? For me I'd like the WicketTester to 
copy any existing cookies from the original request to the redirect 
request. I'd also be happy if there's another place in the code where I 
can set the cookie to have it available during the redirect request 
phase as well.


I also found an old bug (WICKET-1886) that felt like the same issue when 
I read it.


Regards
Robert

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



Re: Wickettester, cookies and redirects in Wicket 1.4.15

2011-02-01 Thread Pedro Santos
Hi Hobert, I reopened the WICKET-1886

2011/2/1 Robert Dahlström robert.dahlst...@bwin.org

 Hi, I currently have an application reading a cookie in my session. All of
 my unit tests where the pattern is: Create page - submit form - redirect
 to new page fails to read this cookie after the redirect to new page.

 The cookie is added both to the response and request before each new test
 (WicketTester gets recreated):
 tester.getWicketResponse().addCookie(cookie);
 tester.getServletRequest().setCookies(new Cookie[]{cookie});

 This works fine during first page rendering and form submission. But after
 the form has been submitted and the redirect to new page takes place the
 cookie does not exist in the new request.

 Since I'm a bit unsure if this is the wanted behavior for WicketTester or
 not I'm posting this to all users out there.

 In my particular use case I would like the cookie to be persisted between
 original request and new request since that's how it is working in the real
 application.

 Codewise (with Wicket 1.4.15):
 In MockWebApplication.postProcessRequestCycle:
 if (httpResponse.isRedirect())
 {
  lastRenderedPage = generateLastRenderedPage(cycle);

  MockHttpServletRequest newHttpRequest = new
 MockHttpServletRequest(application, servletSession,
 application.getServletContext());

 ...
 }

 The call to new MockHttpServletRequest will clear all cookies set during
 initialize() and thus my cookie will not be set in the redirect request.

 Any ideas on how to tackle this? For me I'd like the WicketTester to copy
 any existing cookies from the original request to the redirect request. I'd
 also be happy if there's another place in the code where I can set the
 cookie to have it available during the redirect request phase as well.

 I also found an old bug (WICKET-1886) that felt like the same issue when I
 read it.

 Regards
 Robert

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




-- 
Pedro Henrique Oliveira dos Santos


Re: Wickettester, cookies and redirects in Wicket 1.4.15

2011-02-01 Thread Robert Dahlström

Thanks, I'll add the info I have to the bug.

Regards
Robert

On 02/01/2011 01:02 PM, Pedro Santos wrote:

Hi Hobert, I reopened the WICKET-1886

2011/2/1 Robert Dahlströmrobert.dahlst...@bwin.org


Hi, I currently have an application reading a cookie in my session. All of
my unit tests where the pattern is: Create page -  submit form -  redirect
to new page fails to read this cookie after the redirect to new page.

The cookie is added both to the response and request before each new test
(WicketTester gets recreated):
tester.getWicketResponse().addCookie(cookie);
tester.getServletRequest().setCookies(new Cookie[]{cookie});

This works fine during first page rendering and form submission. But after
the form has been submitted and the redirect to new page takes place the
cookie does not exist in the new request.

Since I'm a bit unsure if this is the wanted behavior for WicketTester or
not I'm posting this to all users out there.

In my particular use case I would like the cookie to be persisted between
original request and new request since that's how it is working in the real
application.

Codewise (with Wicket 1.4.15):
In MockWebApplication.postProcessRequestCycle:
if (httpResponse.isRedirect())
{
  lastRenderedPage = generateLastRenderedPage(cycle);

  MockHttpServletRequest newHttpRequest = new
MockHttpServletRequest(application, servletSession,
application.getServletContext());

...
}

The call to new MockHttpServletRequest will clear all cookies set during
initialize() and thus my cookie will not be set in the redirect request.

Any ideas on how to tackle this? For me I'd like the WicketTester to copy
any existing cookies from the original request to the redirect request. I'd
also be happy if there's another place in the code where I can set the
cookie to have it available during the redirect request phase as well.

I also found an old bug (WICKET-1886) that felt like the same issue when I
read it.

Regards
Robert

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







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



Re: Wickettester, cookies and redirects in Wicket 1.4.15

2011-02-01 Thread Pedro Santos
I attached an test case, possible simulating your described bug

2011/2/1 Robert Dahlström robert.dahlst...@bwin.org

 Thanks, I'll add the info I have to the bug.

 Regards
 Robert


 On 02/01/2011 01:02 PM, Pedro Santos wrote:

 Hi Hobert, I reopened the WICKET-1886

 2011/2/1 Robert Dahlströmrobert.dahlst...@bwin.org

  Hi, I currently have an application reading a cookie in my session. All
 of
 my unit tests where the pattern is: Create page -  submit form -
  redirect
 to new page fails to read this cookie after the redirect to new page.

 The cookie is added both to the response and request before each new test
 (WicketTester gets recreated):
 tester.getWicketResponse().addCookie(cookie);
 tester.getServletRequest().setCookies(new Cookie[]{cookie});

 This works fine during first page rendering and form submission. But
 after
 the form has been submitted and the redirect to new page takes place the
 cookie does not exist in the new request.

 Since I'm a bit unsure if this is the wanted behavior for WicketTester or
 not I'm posting this to all users out there.

 In my particular use case I would like the cookie to be persisted between
 original request and new request since that's how it is working in the
 real
 application.

 Codewise (with Wicket 1.4.15):
 In MockWebApplication.postProcessRequestCycle:
 if (httpResponse.isRedirect())
 {
  lastRenderedPage = generateLastRenderedPage(cycle);

  MockHttpServletRequest newHttpRequest = new
 MockHttpServletRequest(application, servletSession,
 application.getServletContext());

 ...
 }

 The call to new MockHttpServletRequest will clear all cookies set during
 initialize() and thus my cookie will not be set in the redirect request.

 Any ideas on how to tackle this? For me I'd like the WicketTester to copy
 any existing cookies from the original request to the redirect request.
 I'd
 also be happy if there's another place in the code where I can set the
 cookie to have it available during the redirect request phase as well.

 I also found an old bug (WICKET-1886) that felt like the same issue when
 I
 read it.

 Regards
 Robert

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





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




-- 
Pedro Henrique Oliveira dos Santos