2013-03-26 4 views
0

Рассмотрим эту структуру:persistence.xml зависимость в тесте Maven

/project 
    /module-1 
     /src/test/resources/META-INF/persistence.xml 
    /module-2 

В модуле-1 тест-банке создается. модуль-1/pom.xml:

<plugin> 
<groupId>org.apache.maven.plugins</groupId> 
<artifactId>maven-jar-plugin</artifactId> 
<executions> 
    <execution> 
     <goals> 
      <goal>test-jar</goal> 
     </goals> 
    </execution> 
</executions> 
</plugin> 

Этот тест баночка является зависимость в модуле-2/pom.xml:

<dependency> 
<groupId>com.domain.test</groupId> 
<artifactId>module-1</artifactId> 
<scope>test</scope> 
<type>jar</type> 
</dependency> 

Проблема заключается в том, что в тестах модуля-2, persitence единиц (PU), определенный в /src/test/resources/META-INF/persistence.xml, не может быть найден. PU создаются программно:

EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory(persistenceUnit); 
EntityManager entityManager = entityManagerFactory.createEntityManager(); 

Как я могу заставить его работать? Благодарю.

>>Download sources here

ответ

0

Зависимости вы объявляли не ориентируется тест-банки вы создали. Вы должны заявить следующее:

<dependency> 
    <groupId>com.domain.test</groupId> 
    <artifactId>test-shared</artifactId> 
    <type>test-jar</type> 
    <scope>test</scope> 
</dependency> 
Смежные вопросы