我正在使用 arquillian 和 dbunit 进行一组集成测试。我可以很好地运行我的一些测试,但不能运行那些涉及oneToMany
与其中的数据有关系的实体的测试。运行我的测试时,我得到一个 PersistenceException:
Caused by: java.lang.NullPointerException
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.setInverseRelation(JDBCStoreManager.java:451)
我的测试如下所示:
@RunWith(Arquillian.class)
@CreateSchema("sql/masterplanCreateTables.sql")
public class MasterPlanManagerBeanDbIT {
@Rule
public PersistenceUnitRule rule = new PersistenceUnitRule();
@Inject
private MasterplanManager instance;
@PersistenceContext
EntityManager entityManager;
@Deployment
public static WebArchive createDeployment() throws Exception {
return ShrinkWrap
.create(WebArchive.class, .....
}
@Test
@UsingDataSet("/data/integration/uttrans/masterplan/validData_dbInput.xml")
public void updateTrip_givenValidInput_expectsTripToBeUpdated() {
Trip input = givenTrips().get(0);
input.setNote("updated value");
Trip updated = instance.updateTrip(input);
checkEquality(input, updated);//checks field by field for equality
}
}
我的pom.xml
样子是这样的:
...
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.0.1.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
...
<dependencies>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>arquillian-tomee-embedded</artifactId>
<version>${tomee.version}</version>
<scope>test</scope>
</dependency>
...
</dependencies>
...
我确实尝试openjpa-maven-plugin
在构建时增强实体,但这会改变已编译的实体,稍后将部署到我们的生产环境(使用部署时增强)。
考虑到这一点,是否可以在我的 arquillian 测试中启用部署时增强功能?