[arquillian-issues] [JBoss JIRA] (ARQGRA-433) FieldAccessValidatorEnricher checks access to fields uniformly

Stefan Miklosovic (JIRA) issues at jboss.org
Thu May 29 05:39:16 EDT 2014


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

Stefan Miklosovic edited comment on ARQGRA-433 at 5/29/14 5:37 AM:
-------------------------------------------------------------------

[~lfryc]

According to irc communication we have come to solution however before implementing it, lets see if it is worth of it.

You have to make difference between test case and bean in order to take (1) into account or not. Enrich method of enricher is called here (2). You would basically add a flag to enrichRecursively method - when set to true, if enricher you want to use is FieldAccessValidator, it would not be skipped, if false, it would be skipped.

However it means you would have to break interface (3) and "repair it" in these cases (4)

Another solution is to check if class is annotated with RunWith (junit case) or extends Arquillian (in case of TestNG) however I am against this solution, you are becoming dependent on specific test runner which is really bad way to do deal with this for various reasons. Additionally, I think you can not even do it, I was trying to do this "runner resolution" in Arquillian Reporter and I didnt work.

I would personaly remove that FieldAccessEnricherValidator from Graphene completely when you are considering to remove it in the future, why not to remove it now ... 

(1) https://github.com/arquillian/arquillian-graphene/blob/master/impl/src/main/java/org/jboss/arquillian/graphene/enricher/FieldAccessValidatorEnricher.java
(2) https://github.com/arquillian/arquillian-graphene/blob/master/impl/src/main/java/org/jboss/arquillian/graphene/enricher/AbstractSearchContextEnricher.java#L74
(3) https://github.com/arquillian/arquillian-graphene/blob/master/spi/src/main/java/org/jboss/arquillian/graphene/spi/enricher/SearchContextTestEnricher.java
(4) https://github.com/arquillian/arquillian-graphene/blob/master/impl/src/main/java/org/jboss/arquillian/graphene/GrapheneExtension.java#L67-L74


was (Author: smikloso):
[~lfryc]

According to irc communication we have come to solution however before implementing it, lets see if it is worth of it.

You have to make difference between test case and bean in order to take (1) into account or not. Enrich method of enricher is called here (2). You would basically add a flag to enrichRecursively method - when set to true, if enricher you want to use is FieldAccessValidator, it would not be skipped, if false, it would be skipped.

However it means you would have to break interface (3) and "repair it" in these cases (4)

I would personaly remove that FieldAccessEnricherValidator from Graphene completely when you are considering to remove it in the future, why not to remove it now ... 

(1) https://github.com/arquillian/arquillian-graphene/blob/master/impl/src/main/java/org/jboss/arquillian/graphene/enricher/FieldAccessValidatorEnricher.java
(2) https://github.com/arquillian/arquillian-graphene/blob/master/impl/src/main/java/org/jboss/arquillian/graphene/enricher/AbstractSearchContextEnricher.java#L74
(3) https://github.com/arquillian/arquillian-graphene/blob/master/spi/src/main/java/org/jboss/arquillian/graphene/spi/enricher/SearchContextTestEnricher.java
(4) https://github.com/arquillian/arquillian-graphene/blob/master/impl/src/main/java/org/jboss/arquillian/graphene/GrapheneExtension.java#L67-L74

> FieldAccessValidatorEnricher checks access to fields uniformly
> --------------------------------------------------------------
>
>                 Key: ARQGRA-433
>                 URL: https://issues.jboss.org/browse/ARQGRA-433
>             Project: Arquillian Graphene
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 2.0.2.Final
>            Reporter: Stefan Miklosovic
>            Priority: Optional
>             Fix For: 2.0.3.Final
>
>
> I have this test
> {code}
>     @Rule
>     public ExpectedException expectedException = ExpectedException.none();
>     @Test
>     @InSequence(2)
>     @ReportMessage("This method should pass.")
>     public void testWithExpectedExceptionRule() {
>         expectedException.expect(RuntimeException.class);
>         throw new RuntimeException("this exception is expected");
>     }
> {code}
> Logger writes this out:
> WARNING: Public field 'expectedException' found in org.arquillian.droidium.devconf.AeroGearTestCase. Direct access to fields outside of the declaring class is not allowed.
> Apr 01, 2014 11:50:27 AM org.jboss.arquillian.graphene.enricher.FieldAccessValidatorEnricher checkFieldValidity
> However that @Rule field _has to be_ public
> {quote}
> A field must be public, not static, and a subtype of TestRule
> {quote}
> So in this case  validation does not make sense.



--
This message was sent by Atlassian JIRA
(v6.2.3#6260)


More information about the arquillian-issues mailing list