maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Amir Gheibi <aghe...@fmep.ag.gov.bc.ca>
Subject Running surefire:test goal uses wrong resource file
Date Thu, 29 Mar 2012 22:48:58 GMT
Using Maven 3.0.4 with a flat project structure:

|--Parent
|  |____ pom.xml
|
|--Module
| |____ pom.xml
|

I use JPA for persistence and my unit test code uses different persistence configuration file
than the main source. I use an in-memory derby database for unit tests and the actual source
uses an Oracle database. However, running "mvn clean test" updates the oracle database. It
seems surefire's test goal uses the wrong resource file.


Persistence.xml used by unit tests which is located under "Module/src/test/resources/META-INF"

<?xml version="1.0" encoding="UTF-8"?>
<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_2_0.xsd"
       version="2.0">
       <persistence-unit name="xxx" transaction-type="RESOURCE_LOCAL">
              <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
              <class>com.domain.someProject.SomeEntity</class>
              <properties>
                     <property name="eclipselink.target-database" value="DERBY" />
                     <property name="eclipselink.ddl-generation" value="drop-and-create-tables"
/>
                     <property name="eclipselink.logging.level" value="FINE" />
                     <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"
/>
                     <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:testDB;create=true"
/>
                     <property name="javax.persistence.jdbc.user" value="APP" />
                     <property name="javax.persistence.jdbc.password" value="APP" />
              </properties>
       </persistence-unit>
</persistence>



Persistence.xml used by main source which is located under "Module/src/main/resources/META-INF"

<?xml version="1.0" encoding="UTF-8"?>
<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_2_0.xsd"
       version="2.0">
       <persistence-unit name="xxx" transaction-type="RESOURCE_LOCAL">
              <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
              <class>com.domain.someProject.SomeEntity</class>
              <properties>
                     <property name="eclipselink.target-database" value="Oracle" />
                     <property name="eclipselink.logging.level" value="INFO" />
                     <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver"
/>
                     <property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@yyy:1634:XE"
/>
                     <property name="javax.persistence.jdbc.user" value="usr" />
                     <property name="javax.persistence.jdbc.password" value="pass" />
              </properties>
       </persistence-unit>
</persistence>


Would appreciate any input.

- Amir

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message