Testing jpa entity classes - error Transaction is required

人盡茶涼 提交于 2019-12-01 12:10:06

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.

<dependency>
  <groupId>org.jboss.arquillian.extension</groupId>
  <artifactId>arquillian-transaction-jta</artifactId>
  <scope>test</scope>
</dependency>

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

<?xml version="1.0" ?>
<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://jboss.org/schema/arquillian" xsi:schemaLocation="http://jboss.org/schema/arquillian
    http://jboss.org/schema/arquillian/arquillian_1_0.xsd">     

  <extension qualifier="transaction">
    <property name="manager">java:jboss/UserTransaction</property>
  </extension>

</arquillian>

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!