2 Replies Latest reply on May 13, 2011 2:41 AM by ronny.fraunhofer

    Use @EJB in helper class

    qtrin

      i have written a small test framework for our intergartion test with arquillian and junit. The framework contains some helper classes which use ejb and data source to provide their functions. Therefore i use @EJB and @Resource to inject these dependencies into the helper classes. But they don't work.

      Has anyone an idea?

       

      Thanks

        • 1. Re: Use @EJB in helper class
          aslak

          Only the TestClass itself is managed by Arquillian and is the only one that will be injected.

           

          You would need to have the TestClass extend the Helper classes or similar for them to be targets for injection.

          • 2. Use @EJB in helper class
            ronny.fraunhofer

            I had the same problem an created my own Testenricher.

            In my testcase the helper-class-member is annotated by my own annotation, lets say @Enrich.

            The Testenricher is nearlly similar to the EJBTestEnricher and looks for test-case-members with the @Enrich-annotation.

            If such a member is found, the enricher creates and injects the member (default constructor needed!) and then injects all members annotated with @EJB into the helper-class