You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Martijn Dashorst <ma...@gmail.com> on 2009/04/01 10:57:04 UTC

Re: WicketTester assertPageLink and BookmarkablePageLink

clickLink("book");
assertRenderedPage(Book.class);

Martijn

On Tue, Mar 31, 2009 at 11:56 PM, rock star <rc...@gmail.com> wrote:
> Hi ! I have a very quick question.
> Is there a way to test a BookmarkablePageLink ? Something similar to the
> assertPageLink method?
> Thanks,
> Alan
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.5 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

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


Re: WicketTester assertPageLink and BookmarkablePageLink

Posted by Jason Lea <ja...@kumachan.net.nz>.
I ran into the same problem the other day.  I quickly added a method to 
our test helper that we extend to do this.  I had a quick look at the 
code to see what it was doing for the assertPageLink, and testing 
Bookmarkable links is easier...
something like

    public void assertBookmarkablePageLink(final String path, final Class expectedPageClass) {
        final BookmarkablePageLink pageLink = (BookmarkablePageLink)getComponentFromLastRenderedPage(path);
        final Class pageClass = pageLink.getPageClass();
        Assert.assertEquals("expect bookmarkablepagelink that links to the expected class",expectedPageClass, pageClass);
    }



Alan wrote:
> Thanks Martijn for your answer, but I think I didn't make myself clear
> enough,
> I'm writing a JUnit test for a custom component (subclass of Panel),
> This custom component is made of several standard components such as Label,
> and BookmarkablePageLink
>
> I want to test that this component is rendered correctly.
> So I use a WicketTester to render the Component, then assertLabel for the
> Label objects. But I didn't find how to test the BookmarkablePageLink
> object.
>
> The only way I found to check that a link is present is to do
> assertComponent("mylink",BookmarkablePageLink.class);
> but it is not explicit enough to test that the BookmarkablePageLink actually
> goes to the Link I have created.
>
> Thus my original question, is there something equivalent to assertLabel, for
> a BookmarkablePageLink ?
> Or am I mistaking totally? [image: :)]
>
> Alan
>
> 2009/4/1 Martijn Dashorst <ma...@gmail.com>
>
>   
>> clickLink("book");
>> assertRenderedPage(Book.class);
>>
>> Martijn
>>
>> On Tue, Mar 31, 2009 at 11:56 PM, Alan <rc...@gmail.com> wrote:
>>     
>>> Hi ! I have a very quick question.
>>> Is there a way to test a BookmarkablePageLink ? Something similar to the
>>> assertPageLink method?
>>> Thanks,
>>> Alan
>>>
>>>       
>>
>>     
>
>   

-- 
Jason Lea



Re: WicketTester assertPageLink and BookmarkablePageLink

Posted by Alan <rc...@gmail.com>.
Thanks Martijn for your answer, but I think I didn't make myself clear
enough,
I'm writing a JUnit test for a custom component (subclass of Panel),
This custom component is made of several standard components such as Label,
and BookmarkablePageLink

I want to test that this component is rendered correctly.
So I use a WicketTester to render the Component, then assertLabel for the
Label objects. But I didn't find how to test the BookmarkablePageLink
object.

The only way I found to check that a link is present is to do
assertComponent("mylink",BookmarkablePageLink.class);
but it is not explicit enough to test that the BookmarkablePageLink actually
goes to the Link I have created.

Thus my original question, is there something equivalent to assertLabel, for
a BookmarkablePageLink ?
Or am I mistaking totally? [image: :)]

Alan

2009/4/1 Martijn Dashorst <ma...@gmail.com>

> clickLink("book");
> assertRenderedPage(Book.class);
>
> Martijn
>
> On Tue, Mar 31, 2009 at 11:56 PM, Alan <rc...@gmail.com> wrote:
> > Hi ! I have a very quick question.
> > Is there a way to test a BookmarkablePageLink ? Something similar to the
> > assertPageLink method?
> > Thanks,
> > Alan
> >
>
>
>