I am testing some components in my wicket 7 application.
My Component is nothing special but it inherits from
public PageAwarePanel extends Panel {
@Override
protected void onInitialize() {
super.onInitialize();
//refuse if used on page without PageConfig
if (getPageConfigurationModel() == null){
throw new RuntimeException("this component is only allowed inside pages having PageConfigurationModel");
}
}
protected IModel<PageConfiguration> getPageConfigurationModel(){
if (getPage() instanceof TemplatePage){
return ((TemplatePage)getPage()).getPageConfigurationModel();
}
return null;
}
}
With this I can access some configurations from a certain panel.
Now when I try in a test:
PositionsPanel p = new PositionsPanel("123", asmNumber, Model.of());
tester.startPage(MyPage.class);
tester.startComponentInPage(p);
where MyPage is a TemplatePage.
I get the defined RuntimeException. My Question is:
How can I test this component with defining on which page it should be rendered?
Thanks for all the help in advanced.