0

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?

Gregor
  • 28
  • 7

1 Answers1

0

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

Community
  • 1
  • 1
Alan Hay
  • 22,665
  • 4
  • 56
  • 110
  • This was quiet close to what I was trying to accomplish. I removed the persistence.xml template and added a hibernate.properties for test and standard environment. This works for me, but has the downside of not allowing the usage of the standard jpa2 connection properties. – Gregor Jul 24 '12 at 14:05