[
https://issues.apache.org/jira/browse/WICKET-4318?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Martin Grigorov resolved WICKET-4318.
-------------------------------------
Resolution: Fixed
Fix Version/s: 6.0.0
1.5.4
Assignee: Martin Grigorov
> BaseWicketTester#startComponentInPage swallows useful exceptions
> ----------------------------------------------------------------
>
> Key: WICKET-4318
> URL: https://issues.apache.org/jira/browse/WICKET-4318
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.5.3
> Environment: JUnit 4.8.2
> Reporter: Dan Alvizu
> Assignee: Martin Grigorov
> Fix For: 1.5.4, 6.0.0
>
> Attachments: wicket-4318.patch
>
>
> The method BaseWicketTester#startComponentInPage (final Class<C>
> componentClass, final IMarkupFragment pageMarkup) starts a panel inside of
> page markup through reflection, and captures all of the exceptions
> (InvocationTargetException, NoSuchMethodException, etc...) in one big try
> /catch:
> C comp = null;
> try
> {
> Constructor<C> c =
> componentClass.getConstructor(String.class);
> comp = c.newInstance(ComponentInPage.ID);
> componentInPage = new ComponentInPage();
> componentInPage.component = comp;
> componentInPage.isInstantiated = true;
> }
> catch (Exception e)
> {
> fail(e.getMessage());
> }
> There are two issues with this:
> 1) This fail() will often not print out anything helpful about the exception
> that caused the error. For a NullPointerException (along with many other
> exceptions) you'll simply get back: "junit.framework.AssertionFailedError:
> null"
> 2) You cannot write tests that expect an exception in the constructor, for
> example if you were using auth-roles and expect to see an
> UnauthorizedInstantiationException if you provide the wrong role, you cannot
> test this. You could test this scenario if it were a page, however, because
> these Exceptions will not be swallowed.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira