You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by bh...@actrix.gen.nz on 2011/10/02 05:38:18 UTC

Re: Redirect behaves differently between 1.4.15 and 1.4.18

Hi Gert-Jan,

I can't comment on your unit test but I have found a similar issue in
1.5.1:

WicketTester does not handle RedirectToUrlException
https://issues.apache.org/jira/browse/WICKET-4104

IMHO in a page constructor, it is preferable to use
ResetResponseException or RedirectToUrlException.

Otherwise there can be unexpected results with setResponsePage where
contents of both pages are interleaved. However I haven't tried this
in onInitialize.

I would recommend to watch the Jira issue. We could learn from the
outcome.

Regards,

Bernard

On Wed, 21 Sep 2011 10:25:38 +0100, you wrote:

>Hello all!
>
>As I haven't received a single response yet, even though I created a 
>unit test that fails after upgrading to a new version, which seems 
>serious to me, I would like to ask you again:
>
>This week we upgraded to Wicket 1.4.18 from 1.4.15 and suddenly, our 
>unit tests started failing. It seems that it is caused by the fact that 
>redirect behave differently. I have attached a unit test that 
>demostrates this. It passes with 1.4.15, but fails with 1.4.18. To spare 
>you the effort of unpacking the zip, here's the test class (Note: Page1 
>is a simple WebPage that redirects to Page2 in it's onInitialize(), all 
>classes are in the zip):
>
>package com.roboreus.geosweep.wicket;
>
>import org.apache.wicket.PageParameters;
>import org.apache.wicket.RequestCycle;
>import org.apache.wicket.util.tester.WicketTester;
>import org.junit.Test;
>
>import static junit.framework.Assert.assertTrue;
>
>public class RedirectTest {
>
>     @Test
>     public void testRedirect() throws Exception {
>
>         WicketTester tester = new WicketTester();
>         tester.startPage(Page1.class);
>
>         assertTrue("Redirect expected", 
>tester.getServletResponse().isRedirect());
>         String redirectLocation = 
>tester.getServletResponse().getRedirectLocation();
>         assertTrue("Expected redirect location", 
>!(redirectLocation.isEmpty()));
>
>         String redirectUrl = RequestCycle.get().urlFor(Page2.class, new 
>PageParameters()).toString();
>         assertTrue("Expected redirect to '" + redirectUrl + "', but 
>instead got one to '" + redirectLocation + "'.",
>                    redirectLocation.contains(redirectUrl));
>     }
>}
>
>Do any of you know the cause of this and how to solve it?
>
>Thanks and regards!
>
>Gert-Jan Schouten


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