2 Replies Latest reply on Feb 14, 2013 9:54 AM by jmcollin92

    CDI Interceptor at method level are not applied in JUnit setUp

    jmcollin92

      Hello community,

       

      Here is my problem.

      I had a JEE6 application, running well in JBoss AS 7.1.1.

       

      I try to test business classes exposed as EJB, and I use an embedded Weld container to do the tests. All seems to work well.

       

      But ...

      When, in a test case I have a setUp method which do a business method call, interceptor declared at method level are not triggered (but there are trigerred when declared at class level).

       

      Here is some piece of code explaining the problem :

      My EJB :

      @Stateless(name="ServiceAccount")

      @LocalBean

      @Logged(level=EnumLoggedLevel.INFO)   <-- this inteceptor works well

      public class ServiceAccountImpl extends JPAMongoCrudService<Account, VoAccount, DaoAccount> implements ServiceAccount {

       

          @Override

          @Transactional        <-- this one does not work in TestCase.setUp but works well elsewhere

          public void remove(String id) throws ExceptionTechnique, ExceptionFonctionnelle {

              super.remove(id);

          }

       

      My testCase :

      public class ServicesTestCase {

          @Inject

          private ServiceAccountImpl srvAccount;

       

         @Before

          public void setUp() throws Exception {

              // do some cleaning

              srvAccount.remove(...);   <---- Here the @Transactional interceptor is not called ! but the @Logged is well called.

          }

       

      My interceptor declaration :

      @Interceptor

      @Transactional

      public class JPAMongoTransactionalInterceptor implements Serializable {

      ...

          @AroundInvoke

          public Object transactionalMethodEntry(InvocationContext invocationContext) throws Exception {

              log.info("In JPAMongoTransactionalInterceptor");      <--- I don't see this when called in setUp

       

       

      Any help would be greattly appreciated.

       

      JM.