[ 
https://issues.apache.org/jira/browse/CAMEL-8541?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen resolved CAMEL-8541.
--------------------------------
       Resolution: Fixed
    Fix Version/s: 2.16.0
                   2.15.1
                   2.14.3
         Assignee: Claus Ibsen

Thanks for reporting.

> Camel main TestSupport class is incompatible with the CDI specification
> -----------------------------------------------------------------------
>
>                 Key: CAMEL-8541
>                 URL: https://issues.apache.org/jira/browse/CAMEL-8541
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-test
>    Affects Versions: 2.12.5, 2.14.2
>            Reporter: Alex Savitsky
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.14.3, 2.15.1, 2.16.0
>
>
> JUnit4 test support class (org.apache.camel.test.junit4.TestSupport) contains 
> the following declaration:
> {noformat}
>     // CHECKSTYLE:OFF
>     @Rule
>     public TestName testName = new TestName();
>     // CHECKSTYLE:ON
> {noformat}
> In addition to being a terrible idea overall, this public field also breaks 
> CDI integration, as any tests attempted to be bootstrapped in CDI will throw 
> the following error (WELD trace is shown for an example):
> {noformat}
> org.jboss.weld.exceptions.DefinitionException: WELD-000075: Normal scoped 
> managed bean implementation class has a public field:  
> [EnhancedAnnotatedFieldImpl] @Rule public com.netotc.ha.route.TestCDI.testName
>       at 
> org.jboss.weld.bean.ManagedBean.checkBeanImplementation(ManagedBean.java:227)
>       at 
> org.jboss.weld.bean.AbstractClassBean.internalInitialize(AbstractClassBean.java:74)
>       at 
> org.jboss.weld.bean.ManagedBean.internalInitialize(ManagedBean.java:105)
>       at org.jboss.weld.bean.RIBean.initialize(RIBean.java:66)
>       at 
> org.jboss.weld.bootstrap.ConcurrentBeanDeployer$5.doWork(ConcurrentBeanDeployer.java:121)
>       at 
> org.jboss.weld.bootstrap.ConcurrentBeanDeployer$5.doWork(ConcurrentBeanDeployer.java:118)
>       at 
> org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60)
>       at 
> org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53)
>       at java.util.concurrent.FutureTask.run(FutureTask.java:262)
>       at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>       at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>       at java.lang.Thread.run(Thread.java:745)
> {noformat}
> Suggesting to create a getter for this field, making the field private, and 
> moving the @Rule annotation to the getter.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to