Ignoring Datasource during roundtrip test with hyperjaxb
Pregunta
I'm using Hyperjaxb 3 with maven to generate java classes from an xsd. In order to specify the datasource used in the AS, I configured a custom persistence.xml template using the persistenceXml setting in the plugin-configuration (pom.xml)
<configuration>
<variant>jpa2</variant>
<persistenceXml>src/main/etc/persistence.xml</persistenceXml>
</configuration>
Here's the template:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence version="2.0">
<persistence-unit name="##generated">
<jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
<properties>
<property name="hibernate.hbm2ddl.auto" value="update" />
</properties>
</persistence-unit>
</persistence>
Since there is no datasource when running the tests with maven, the roundtrip test fails. Is there a way to ignore the jta-data-source
option and fall back to persistence.properties, or to generate an alternative persistence.xml in src/test/resources
?
Solución
Yes, as you note having a non-container managed datasource for testing would make sense. You can define a seperate definition (or use properties files) under /src/test/resources and this should take precedence over that on src/main/resources when running tests.
Junit run not picking file src/test/resources. For file required by some dependency jar