You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by wicket user <wi...@comley.org> on 2007/08/29 14:49:04 UTC

Testing AbstractAjaxTimerBehavior with WicketTester, executeBehavior???

Hi,

Another noob question here but I'm trying to setup a test case that tests
the abstract timer on my page, like the WorldClock example.

I see there is the executeBehavior method in the WicketTester but I'm not
entirely sure how to set this up.  Basically I want to fire the timer event
that I've setup on the page and check the appropriate changes have been made
to the labels on the page. So for the world clock example it would mean that
I would fire the event in my test then check that the time had updated in
the label.

Help would be much appreciated.

Cheers
Simon

Re: Testing AbstractAjaxTimerBehavior with WicketTester, executeBehavior???

Posted by wicket user <wi...@comley.org>.
Ok this is becoming a habit answering my own questions but I've just worked
it out, please let me know if there is a more elegant solution:

tester.assertComponent("resendLabel", Label.class);
tester.assertLabel("resendLabel", "in 20 seconds");
tester.executeBehavior((AbstractAjaxBehavior)tester.getLastRenderedPage().getBehaviors().get(0));
tester.executeBehavior
((AbstractAjaxBehavior)tester.getLastRenderedPage().getBehaviors().get(0));

Label resendLabel = (Label)tester.getLastRenderedPage().get("resendLabel");
assertEquals("Resend label has not updated", "in 19 seconds",
resendLabel.getModel().toString());


Hope that helps some noob like me.

Thanks
Simon

On 29/08/2007, wicket user <wi...@comley.org> wrote:
>
> Hi,
>
> Another noob question here but I'm trying to setup a test case that tests
> the abstract timer on my page, like the WorldClock example.
>
> I see there is the executeBehavior method in the WicketTester but I'm not
> entirely sure how to set this up.  Basically I want to fire the timer event
> that I've setup on the page and check the appropriate changes have been made
> to the labels on the page. So for the world clock example it would mean that
> I would fire the event in my test then check that the time had updated in
> the label.
>
> Help would be much appreciated.
>
> Cheers
> Simon
>