You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Lauri Piispanen - Conmio Ltd <la...@conmio.com> on 2008/01/18 12:24:33 UTC

WicketTester and continueToOriginalDestination

Hi all,

I'm having problems trying to test interception pages with WicketTester 
in Wicket 1.3. For some reason my application homepage is used instead 
of the one that threw the RestartResponseAtInterceptPageException. I 
have the same code running fine in the servlet environment, so I think 
the issue is most likely with WicketTester. Either that, or it's 
actually due to my erroneous use of it. Here's my test case:

    public void testContinueToOriginalDestination() throws Exception {
        tester.startPage(TargetPage.class);
        tester.assertRenderedPage(InterceptPage.class);
       
        tester.submitForm("form");
        tester.assertRenderedPage(TargetPage.class); // This line fails, 
as the rendered page is actually the application home page.
    }

TargetPage is set to throw a RestartResponseAtInterceptException at 
first request:

    private boolean firstTime = true;
   
    public TargetPage() {
        if (firstTime) {
            firstTime = false;
            throw new 
RestartResponseAtInterceptPageException(InterceptPage.class);
        }
    }

My intercept page simply has a form with a 
continueToOriginalDestination() when submit:

    public InterceptPage() {
        add(new Form("form") {
            @Override
            protected void onSubmit() {
                continueToOriginalDestination();
            }

        });
    }

Can anyone help me with this, or have I encountered some bug with the 
tester? I have test cases that reproduce the issue.

Sincerely,

-- 

Lauri Piispanen

+358 45 630 2546
Senior Product Architect
Conmio Ltd
http://www.conmio.com


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


Re: WicketTester and continueToOriginalDestination

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Is this the same problem as I posted before with the title "Raw urls
using WicketTester 1.3.0" ? Appears so on the surface. I will try the
workaround.

Let me know about the jira id, I am eager to try to contribute as soon
as this has been confirmed to be a bug instead of just a stupid
newuser ;)

**
Martin

2008/1/18, Johan Compagner <jc...@gmail.com>:
> please make a jira issue for this
>
> On 1/18/08, Lauri Piispanen - Conmio Ltd <la...@conmio.com> wrote:
> >
> > Hi all,
> >
> > I'm having problems trying to test interception pages with WicketTester
> > in Wicket 1.3. For some reason my application homepage is used instead
> > of the one that threw the RestartResponseAtInterceptPageException. I
> > have the same code running fine in the servlet environment, so I think
> > the issue is most likely with WicketTester. Either that, or it's
> > actually due to my erroneous use of it. Here's my test case:
> >
> >    public void testContinueToOriginalDestination() throws Exception {
> >        tester.startPage(TargetPage.class);
> >        tester.assertRenderedPage(InterceptPage.class);
> >
> >        tester.submitForm("form");
> >        tester.assertRenderedPage(TargetPage.class); // This line fails,
> > as the rendered page is actually the application home page.
> >    }
> >
> > TargetPage is set to throw a RestartResponseAtInterceptException at
> > first request:
> >
> >    private boolean firstTime = true;
> >
> >    public TargetPage() {
> >        if (firstTime) {
> >            firstTime = false;
> >            throw new
> > RestartResponseAtInterceptPageException(InterceptPage.class);
> >        }
> >    }
> >
> > My intercept page simply has a form with a
> > continueToOriginalDestination() when submit:
> >
> >    public InterceptPage() {
> >        add(new Form("form") {
> >            @Override
> >            protected void onSubmit() {
> >                continueToOriginalDestination();
> >            }
> >
> >        });
> >    }
> >
> > Can anyone help me with this, or have I encountered some bug with the
> > tester? I have test cases that reproduce the issue.
> >
> > Sincerely,
> >
> > --
> >
> > Lauri Piispanen
> >
> > +358 45 630 2546
> > Senior Product Architect
> > Conmio Ltd
> > http://www.conmio.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: WicketTester and continueToOriginalDestination

Posted by Johan Compagner <jc...@gmail.com>.
please make a jira issue for this

On 1/18/08, Lauri Piispanen - Conmio Ltd <la...@conmio.com> wrote:
>
> Hi all,
>
> I'm having problems trying to test interception pages with WicketTester
> in Wicket 1.3. For some reason my application homepage is used instead
> of the one that threw the RestartResponseAtInterceptPageException. I
> have the same code running fine in the servlet environment, so I think
> the issue is most likely with WicketTester. Either that, or it's
> actually due to my erroneous use of it. Here's my test case:
>
>    public void testContinueToOriginalDestination() throws Exception {
>        tester.startPage(TargetPage.class);
>        tester.assertRenderedPage(InterceptPage.class);
>
>        tester.submitForm("form");
>        tester.assertRenderedPage(TargetPage.class); // This line fails,
> as the rendered page is actually the application home page.
>    }
>
> TargetPage is set to throw a RestartResponseAtInterceptException at
> first request:
>
>    private boolean firstTime = true;
>
>    public TargetPage() {
>        if (firstTime) {
>            firstTime = false;
>            throw new
> RestartResponseAtInterceptPageException(InterceptPage.class);
>        }
>    }
>
> My intercept page simply has a form with a
> continueToOriginalDestination() when submit:
>
>    public InterceptPage() {
>        add(new Form("form") {
>            @Override
>            protected void onSubmit() {
>                continueToOriginalDestination();
>            }
>
>        });
>    }
>
> Can anyone help me with this, or have I encountered some bug with the
> tester? I have test cases that reproduce the issue.
>
> Sincerely,
>
> --
>
> Lauri Piispanen
>
> +358 45 630 2546
> Senior Product Architect
> Conmio Ltd
> http://www.conmio.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: WicketTester and continueToOriginalDestination

Posted by Maurice Marrink <ma...@gmail.com>.
Maybe you could wait until Johan replies, if it was something that
easily could be fixed Johan probably would have done so by now. Given
that he hasn't it either slipped his mind or is not doable without
serious refactorings. You can always create a Jira issue if Johan
gives the green light.

Maurice

On Jan 18, 2008 12:49 PM, Lauri Piispanen - Conmio Ltd
<la...@conmio.com> wrote:
> Hi Maurice,
>
> Great, that solves the problem and my bar is green again! :)
>
> I can still post the issue to JIRA along with my test cases if you want
> me to, just so it doesn't get buried.
>
> Sincerely,
>
> Lauri Piispanen
>
> +358 45 630 2546
> Senior Product Architect
> Conmio Ltd
> http://www.conmio.com
>
>
>
>
> Maurice Marrink wrote:
> > I believe there is indeed a problem with continueTo...
> > I have talked with Johan about it a long time ago, i don't recall what
> > the problem was but ever since i am using the following work around to
> > test continueTo.... behavior.
> >
> > // continueToOriginaldestination does not work if there is no url
> > available, so we need to fake one here(testing only hack)
> > mock.setupRequestAndResponse();
> > WebRequestCycle cycle = mock.createRequestCycle();
> > String url1 = cycle.urlFor(new
> > BookmarkablePageRequestTarget(YOUR_PAGE_HERE.class, null)).toString();
> > mock.getServletRequest().setURL("/GeneralTest$1/GeneralTest$1/" + url1);
> > mock.processRequestCycle();
> >
> > mock is the WicketTester.
> > GeneralTest$1 from the url is the classname of your application
> > without the package. (in my case it is an anonymous inner class hence
> > the $1) Note that this classname appears twice in the url.
> >
> > Maurice
> >
> >
> > On Jan 18, 2008 12:24 PM, Lauri Piispanen - Conmio Ltd
> > <la...@conmio.com> wrote:
> >
> >> Hi all,
> >>
> >> I'm having problems trying to test interception pages with WicketTester
> >> in Wicket 1.3. For some reason my application homepage is used instead
> >> of the one that threw the RestartResponseAtInterceptPageException. I
> >> have the same code running fine in the servlet environment, so I think
> >> the issue is most likely with WicketTester. Either that, or it's
> >> actually due to my erroneous use of it. Here's my test case:
> >>
> >>     public void testContinueToOriginalDestination() throws Exception {
> >>         tester.startPage(TargetPage.class);
> >>         tester.assertRenderedPage(InterceptPage.class);
> >>
> >>         tester.submitForm("form");
> >>         tester.assertRenderedPage(TargetPage.class); // This line fails,
> >> as the rendered page is actually the application home page.
> >>     }
> >>
> >> TargetPage is set to throw a RestartResponseAtInterceptException at
> >> first request:
> >>
> >>     private boolean firstTime = true;
> >>
> >>     public TargetPage() {
> >>         if (firstTime) {
> >>             firstTime = false;
> >>             throw new
> >> RestartResponseAtInterceptPageException(InterceptPage.class);
> >>         }
> >>     }
> >>
> >> My intercept page simply has a form with a
> >> continueToOriginalDestination() when submit:
> >>
> >>     public InterceptPage() {
> >>         add(new Form("form") {
> >>             @Override
> >>             protected void onSubmit() {
> >>                 continueToOriginalDestination();
> >>             }
> >>
> >>         });
> >>     }
> >>
> >> Can anyone help me with this, or have I encountered some bug with the
> >> tester? I have test cases that reproduce the issue.
> >>
> >> Sincerely,
> >>
> >> --
> >>
> >> Lauri Piispanen
> >>
> >> +358 45 630 2546
> >> Senior Product Architect
> >> Conmio Ltd
> >> http://www.conmio.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
> >
> >
>
> ---------------------------------------------------------------------
> 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: WicketTester and continueToOriginalDestination

Posted by Lauri Piispanen - Conmio Ltd <la...@conmio.com>.
Hi Maurice,

Great, that solves the problem and my bar is green again! :)

I can still post the issue to JIRA along with my test cases if you want 
me to, just so it doesn't get buried.

Sincerely,

Lauri Piispanen

+358 45 630 2546
Senior Product Architect
Conmio Ltd
http://www.conmio.com



Maurice Marrink wrote:
> I believe there is indeed a problem with continueTo...
> I have talked with Johan about it a long time ago, i don't recall what
> the problem was but ever since i am using the following work around to
> test continueTo.... behavior.
>
> // continueToOriginaldestination does not work if there is no url
> available, so we need to fake one here(testing only hack)
> mock.setupRequestAndResponse();
> WebRequestCycle cycle = mock.createRequestCycle();
> String url1 = cycle.urlFor(new
> BookmarkablePageRequestTarget(YOUR_PAGE_HERE.class, null)).toString();
> mock.getServletRequest().setURL("/GeneralTest$1/GeneralTest$1/" + url1);
> mock.processRequestCycle();
>
> mock is the WicketTester.
> GeneralTest$1 from the url is the classname of your application
> without the package. (in my case it is an anonymous inner class hence
> the $1) Note that this classname appears twice in the url.
>
> Maurice
>
>
> On Jan 18, 2008 12:24 PM, Lauri Piispanen - Conmio Ltd
> <la...@conmio.com> wrote:
>   
>> Hi all,
>>
>> I'm having problems trying to test interception pages with WicketTester
>> in Wicket 1.3. For some reason my application homepage is used instead
>> of the one that threw the RestartResponseAtInterceptPageException. I
>> have the same code running fine in the servlet environment, so I think
>> the issue is most likely with WicketTester. Either that, or it's
>> actually due to my erroneous use of it. Here's my test case:
>>
>>     public void testContinueToOriginalDestination() throws Exception {
>>         tester.startPage(TargetPage.class);
>>         tester.assertRenderedPage(InterceptPage.class);
>>
>>         tester.submitForm("form");
>>         tester.assertRenderedPage(TargetPage.class); // This line fails,
>> as the rendered page is actually the application home page.
>>     }
>>
>> TargetPage is set to throw a RestartResponseAtInterceptException at
>> first request:
>>
>>     private boolean firstTime = true;
>>
>>     public TargetPage() {
>>         if (firstTime) {
>>             firstTime = false;
>>             throw new
>> RestartResponseAtInterceptPageException(InterceptPage.class);
>>         }
>>     }
>>
>> My intercept page simply has a form with a
>> continueToOriginalDestination() when submit:
>>
>>     public InterceptPage() {
>>         add(new Form("form") {
>>             @Override
>>             protected void onSubmit() {
>>                 continueToOriginalDestination();
>>             }
>>
>>         });
>>     }
>>
>> Can anyone help me with this, or have I encountered some bug with the
>> tester? I have test cases that reproduce the issue.
>>
>> Sincerely,
>>
>> --
>>
>> Lauri Piispanen
>>
>> +358 45 630 2546
>> Senior Product Architect
>> Conmio Ltd
>> http://www.conmio.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
>
>   

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


Re: WicketTester and continueToOriginalDestination

Posted by Maurice Marrink <ma...@gmail.com>.
I believe there is indeed a problem with continueTo...
I have talked with Johan about it a long time ago, i don't recall what
the problem was but ever since i am using the following work around to
test continueTo.... behavior.

// continueToOriginaldestination does not work if there is no url
available, so we need to fake one here(testing only hack)
mock.setupRequestAndResponse();
WebRequestCycle cycle = mock.createRequestCycle();
String url1 = cycle.urlFor(new
BookmarkablePageRequestTarget(YOUR_PAGE_HERE.class, null)).toString();
mock.getServletRequest().setURL("/GeneralTest$1/GeneralTest$1/" + url1);
mock.processRequestCycle();

mock is the WicketTester.
GeneralTest$1 from the url is the classname of your application
without the package. (in my case it is an anonymous inner class hence
the $1) Note that this classname appears twice in the url.

Maurice


On Jan 18, 2008 12:24 PM, Lauri Piispanen - Conmio Ltd
<la...@conmio.com> wrote:
> Hi all,
>
> I'm having problems trying to test interception pages with WicketTester
> in Wicket 1.3. For some reason my application homepage is used instead
> of the one that threw the RestartResponseAtInterceptPageException. I
> have the same code running fine in the servlet environment, so I think
> the issue is most likely with WicketTester. Either that, or it's
> actually due to my erroneous use of it. Here's my test case:
>
>     public void testContinueToOriginalDestination() throws Exception {
>         tester.startPage(TargetPage.class);
>         tester.assertRenderedPage(InterceptPage.class);
>
>         tester.submitForm("form");
>         tester.assertRenderedPage(TargetPage.class); // This line fails,
> as the rendered page is actually the application home page.
>     }
>
> TargetPage is set to throw a RestartResponseAtInterceptException at
> first request:
>
>     private boolean firstTime = true;
>
>     public TargetPage() {
>         if (firstTime) {
>             firstTime = false;
>             throw new
> RestartResponseAtInterceptPageException(InterceptPage.class);
>         }
>     }
>
> My intercept page simply has a form with a
> continueToOriginalDestination() when submit:
>
>     public InterceptPage() {
>         add(new Form("form") {
>             @Override
>             protected void onSubmit() {
>                 continueToOriginalDestination();
>             }
>
>         });
>     }
>
> Can anyone help me with this, or have I encountered some bug with the
> tester? I have test cases that reproduce the issue.
>
> Sincerely,
>
> --
>
> Lauri Piispanen
>
> +358 45 630 2546
> Senior Product Architect
> Conmio Ltd
> http://www.conmio.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