java - 如何使用 OpenJPA Maven 插件进行测试
问题描述
我需要进行集成测试以检查多线程持久性到 Oracle。我们在应用程序中使用 openjpa,所以我决定使用openjpa-maven-plugin进行测试。
我试图准备一些配置文件来测试
<profiles>
<profile>
<id>integration-test</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<version>${openjpa.version}</version>
<configuration>
<sqlAction>build</sqlAction>
<sqlFile>/src/test/resources/sql/insert.sql</sqlFile>
<connectionDriverName>org.apache.commons.dbcp.BasicDataSource</connectionDriverName>
<connectionProperties>
driverClass=oracle.jdbc.OracleDriver,
jdbc.url=jdbc:oracle:thin:@server-test-ora:1521/bacl,
user=user,
password=root,
minPoolSize=5,
acquireRetryAttempts=3,
maxPoolSize=20
</connectionProperties>
<includes>**/entities/*.class</includes>
<addDefaultConstructor>true</addDefaultConstructor>
<enforcePropertyRestrictions>true</enforcePropertyRestrictions>
</configuration>
<executions>
<execution>
<id>test enhancer</id>
<phase>process-test-classes</phase>
<goals>
<goal>test-enhance</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
<version>${openjpa.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
但实际上,我不明白我需要做什么以及如何进行该测试。如何让 EntityManager 尝试执行我的 insert.sql
INSERT INTO USER (NAME,SURNAME,DATE) VALUES ('NAME','SURNAME',to_date('2018-12-08 17:21:03', 'yyyy-mm-dd hh24:mi:ss'));
我需要什么它正在尝试进行一些并发测试。我有很多,但没有任何数据库,现在我需要测试连接或 inMemoryOracle。
所以我的问题是如何从插件中获取 EntityManager (是否需要创建任何 context.xml 其他?)
解决方案
推荐阅读
- sql-server - How to tell whether a column is of sysname type
- php - Lumen SQL search query on Always Encrypted columns
- r - 更改完成条件的行的顺序
- sql - 将不同的列值获取到数组
- java - 如何将对象类型作为参数传递给构造函数并将变量转换为它(JAVA)?
- r - 在 R Markdown 中制作“谢谢”幻灯片
- php - 如何使用 php 以 .dat 或 .txt 格式导出文件
- intellij-idea - IntelliJ IDEA LiveTemplate 在使用之间自动递增
- java - Android BLE 无法启用 BLE 通知
- php - 从控制器返回数据 - Codeigniter