wicket 7 アプリケーションでいくつかのコンポーネントをテストしています。
私のコンポーネントは特別なものではありませんが、から継承しています
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;
}
}
これにより、特定のパネルからいくつかの構成にアクセスできます。
テストで試してみると:
PositionsPanel p = new PositionsPanel("123", asmNumber, Model.of());
tester.startPage(MyPage.class);
tester.startComponentInPage(p);
MyPage は TemplatePage です。
定義された RuntimeException を取得します。私の質問は:
レンダリングするページを定義して、このコンポーネントをテストするにはどうすればよいですか?
高度なヘルプをありがとう。