[jboss-user] [JBoss Seam] - Re: Test database with Seam2, Maven and TestNG?
andrew.rw.robinson
do-not-reply at jboss.com
Wed Dec 19 22:48:34 EST 2007
I got it working, but it was a configuration pain. For those that read this post here is a very quick howto:
| * create src/main/conf - this will be files that are added to the war but not added to target/classes on build (and therefore will not interfere with testing)
| * move src/main/resources/META-INF/persistence.xml to src/main/conf/META-INF/persistence.xml
| * create src/test/resources/META-INF/persistence.xml (see below for example)
| * set the base directory for surefire to ensure that the relative paths work
| * configure pom to include src/main/conf
|
src/test/resources/META-INF/persistence.xml:
<persistence
| xmlns="http://java.sun.com/xml/ns/persistence"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
| version="1.0">
| <persistence-unit name="testDatabase" transaction-type="RESOURCE_LOCAL">
| <provider>org.hibernate.ejb.HibernatePersistence</provider>
| <mapping-file>file:classes/META-INF/orm.xml</mapping-file>
| <jar-file>file:classes</jar-file>
| <properties>
| ...
| </properties>
| </persistence-unit>
| </persistence>
The mapping-file and jar-file allow the entities be picked up as if the file was in the src/main/resources/META-INF was used.
pom.xml excerpts:
...
| <plugin>
| <artifactId>maven-surefire-plugin</artifactId>
| <version>2.4-SNAPSHOT</version>
| <configuration>
| <workingDirectory>${project.build.directory}</workingDirectory>
| <includes>
| <include>**/*Test.java</include>
| </includes>
| </configuration>
| </plugin>
| <plugin>
| <artifactId>maven-war-plugin</artifactId>
| <version>2.1-alpha-2-SNAPSHOT</version>
| <configuration>
| <webResources>
| <resource>
| <directory>src/main/conf</directory>
| <targetPath>WEB-INF/classes</targetPath>
| </resource>
| </webResources>
| </configuration>
| </plugin>
| ...
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4114496#4114496
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4114496
More information about the jboss-user
mailing list