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 <martijn.dasho...@gmail.com>

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

Martijn

On Tue, Mar 31, 2009 at 11:56 PM, Alan <rckstar2...@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


Reply via email to