BaseWicketTester can't find the pageLink field using reflection when you 
override the PageLink class.
-----------------------------------------------------------------------------------------------------

                 Key: WICKET-2030
                 URL: https://issues.apache.org/jira/browse/WICKET-2030
             Project: Wicket
          Issue Type: Bug
          Components: wicket
    Affects Versions: 1.4-RC1
            Reporter: Maarten Billemont


Currently, BaseWicketTester (line 524) does this:

        public <C extends Page> Result isPageLink(String path, Class<C> 
expectedPageClass)
        {
                PageLink<?> pageLink = 
(PageLink<?>)getComponentFromLastRenderedPage(path);
                try
                {
                        Field iPageLinkField = 
pageLink.getClass().getDeclaredField("pageLink");
                        iPageLinkField.setAccessible(true);
                        IPageLink iPageLink = 
(IPageLink)iPageLinkField.get(pageLink);
                        return isEqual(expectedPageClass, 
iPageLink.getPageIdentity());
                }

The problem manifests when you want to customize a page link's onClick by 
overriding it like this:

new PageLink<AuthPage>("pageLink", AuthPage.class) {

            private static final long serialVersionUID = 1L;

            @Override
            public void onClick() {

                Foo.bar();

                super.onClick();
            }
});


As a result; the BaseWicketTester tries to look for the pageLink field in the 
anonymous class instead of the privately declared pageLink field in the 
PageLink class.

BaseWicketTester should either go down the tree:

for(Class type = pageLink.getClass(); type != Object.class; type = 
type.getSuperclass())

Or a getter should be made for the pageLink field. (This is what Java wants you 
to do).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to