Re: WicketTester assertPageLink and BookmarkablePageLink

2009-04-01 Thread Jason Lea
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 

  

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

Martijn

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

2009-04-01 Thread Alan
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 

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


Re: WicketTester assertPageLink and BookmarkablePageLink

2009-04-01 Thread Martijn Dashorst
clickLink("book");
assertRenderedPage(Book.class);

Martijn

On Tue, Mar 31, 2009 at 11:56 PM, rock star  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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



WicketTester assertPageLink and BookmarkablePageLink

2009-03-31 Thread rock star
Hi ! I have a very quick question.
Is there a way to test a BookmarkablePageLink ? Something similar to the
assertPageLink method?
Thanks,
Alan