Testing jpa entity classes - error Transaction is required

前端 未结 1 451
天涯浪人
天涯浪人 2021-01-16 08:20

Based on an archetype i created a java ee app. There is an included arquillian test that runs fine. it just calls a method on a @Stateless bean that persists an pre-made ent

1条回答
  •  醉话见心
    2021-01-16 08:58

    In order to have transaction support in Arquillian tests you will need to bring in extension which enables this feature. In your case jta dependency should do the job.

    
      org.jboss.arquillian.extension
      arquillian-transaction-jta
      test
    

    In addition, if you are using JBoss, you will need to provide its JNDI for UserTranscation, so put following section in your arquillian.xml:

    
         
    
      
        java:jboss/UserTransaction
      
    
    
    

    This way you can use @Transactional which comes from this extension's API.

    0 讨论(0)
提交回复
热议问题