[arquillian-issues] [JBoss JIRA] (ARQGRA-308) Should throw exception if page fragment not instantiable

Jan Papousek (JIRA) jira-events at lists.jboss.org
Thu Jun 13 09:49:56 EDT 2013


    [ https://issues.jboss.org/browse/ARQGRA-308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12781422#comment-12781422 ] 

Jan Papousek commented on ARQGRA-308:
-------------------------------------

Graphene executes a few enrichers and each of them has loops over fields of the test class. The enricher detect from the field type whether the enrichment should be performed or shouldn't be. Explanation why the Page Fragment Enricher doesn't throw an exception is simple -> the field class is final, so the enrichment of the field is skipped (and maybe there is another enricher which is able to handle it).

I suggest to log WARN instead of throwing an exception.

Btw. the code which checks whether the field should be enriched or not by the Page Fragment Enricher is:

{code}
    protected final boolean isPageFragmentClass(Class<?> clazz) {
        // check whether it isn't interface or final class
        if (Modifier.isInterface(clazz.getModifiers()) || Modifier.isFinal(clazz.getModifiers())
                || Modifier.isAbstract(clazz.getModifiers())) {
            return false;
        }

        Class<?> outerClass = clazz.getDeclaringClass();

        // check whether there is an empty constructor
        if (outerClass == null || Modifier.isStatic(clazz.getModifiers())) {
            return ReflectionHelper.hasConstructor(clazz);
            // check whether there is an empty constructor with outer class
        } else {
            return ReflectionHelper.hasConstructor(clazz, outerClass);
        }
    }
{code}

(from https://github.com/arquillian/arquillian-graphene/blob/master/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/enricher/PageFragmentEnricher.java#L94)
                
> Should throw exception if page fragment not instantiable
> --------------------------------------------------------
>
>                 Key: ARQGRA-308
>                 URL: https://issues.jboss.org/browse/ARQGRA-308
>             Project: Arquillian Graphene
>          Issue Type: Bug
>    Affects Versions: 2.0.0.Alpha4
>            Reporter: Bernard Labno
>
> If page fragment is inner final class then it's not injected into field annotated with @FindBy and no exception is thrown.
> Graphene should throw exception that desired class cannot be instantiated.
> Right now user spends lots of time debugging and wondering if the selector is wrong. It's hard to find out that it's the "final" word to be blamed here:
> public static final class InvitedSupplier

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the arquillian-issues mailing list