I have created a linkpage FooPage, sothat when somebody clicks on this link, some text "test test" is desplayed to the user, so far good.
I have created the folloing basic page:
FooPage.java
public class FooPage extends WebPage {
public FooPage() {
add(new Label("label", "test test"));
} }
FooPage.html
<div wicket:id="label"></div>
In MyPnel.java I add the created page as follow:
MyPanel.java
public class MyPanel extends Panel{
add(new BookmarkablePageLink<Void>("foobar", FooPage.class));
}
MyPanel.html:
<a wicket:id="foobar" href="FooPage"></a>
Now when I test the created component with junit as follows:
@Test
public void startPage() {
wicketTester.assertComponent("foobar", FooPage.class);
}
I get the following error:
junit.framework.AssertionFailedError: component ‘BookmarkablePageLink’
is not type:FooPage
Any idea what is the problem or hot to solve this?
As Ian already said,
assertComponentchecks that the type of the component is a subtype of a class. For your usecase you should use