[seam-commits] Seam SVN: r13699 - in modules/persistence/trunk/impl: src/test/java/org/jboss/seam/persistence/test and 2 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Thu Sep 2 04:32:12 EDT 2010
Author: swd847
Date: 2010-09-02 04:32:11 -0400 (Thu, 02 Sep 2010)
New Revision: 13699
Modified:
modules/persistence/trunk/impl/pom.xml
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/EntityInjectionTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/HibernateSearchTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextELTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextFlushModeTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeInterceptorTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionScopedTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/UserTransactionTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/ArtifactNames.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/MavenArtifactResolver.java
Log:
change tests to run in the intergration-tests phase and borrow upgraded MavenArtifactResolver from welx
Modified: modules/persistence/trunk/impl/pom.xml
===================================================================
--- modules/persistence/trunk/impl/pom.xml 2010-09-02 08:22:41 UTC (rev 13698)
+++ modules/persistence/trunk/impl/pom.xml 2010-09-02 08:32:11 UTC (rev 13699)
@@ -122,6 +122,34 @@
</dependencies>
+ <build>
+ <plugins>
+ <!--
+ skip unit test run, tests to be executed during
+ integration-test
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ <executions>
+ <execution>
+ <id>surefire-it</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
<profiles>
<profile>
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/EntityInjectionTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/EntityInjectionTest.java 2010-09-02 08:22:41 UTC (rev 13698)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/EntityInjectionTest.java 2010-09-02 08:32:11 UTC (rev 13699)
@@ -32,12 +32,8 @@
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.seam.persistence.InjectionEventListener;
import org.jboss.seam.persistence.transaction.DefaultTransaction;
import org.jboss.seam.persistence.transaction.SeamTransaction;
-import org.jboss.seam.persistence.transaction.TransactionExtension;
-import org.jboss.seam.persistence.transaction.scope.TransactionScopeExtension;
-import org.jboss.seam.persistence.util.NamingUtils;
import org.jboss.seam.transactions.test.util.ArtifactNames;
import org.jboss.seam.transactions.test.util.HelloService;
import org.jboss.seam.transactions.test.util.Hotel;
@@ -66,10 +62,7 @@
WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
- war.addPackage(TransactionExtension.class.getPackage());
- war.addPackage(TransactionScopeExtension.class.getPackage());
- war.addPackage(InjectionEventListener.class.getPackage());
- war.addPackage(NamingUtils.class.getPackage());
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_IMPL));
war.addClasses(EntityInjectionTest.class, Hotel.class, ManagedPersistenceContextProvider.class, HelloService.class);
war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
war.addWebResource("META-INF/persistence-orm.xml", "classes/META-INF/persistence.xml");
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/HibernateSearchTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/HibernateSearchTest.java 2010-09-02 08:22:41 UTC (rev 13698)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/HibernateSearchTest.java 2010-09-02 08:32:11 UTC (rev 13699)
@@ -34,12 +34,8 @@
import org.hibernate.search.jpa.FullTextEntityManager;
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.seam.persistence.SePersistenceContextExtension;
import org.jboss.seam.persistence.transaction.DefaultTransaction;
import org.jboss.seam.persistence.transaction.SeamTransaction;
-import org.jboss.seam.persistence.transaction.TransactionExtension;
-import org.jboss.seam.persistence.transaction.scope.TransactionScopeExtension;
-import org.jboss.seam.persistence.util.NamingUtils;
import org.jboss.seam.transactions.test.util.ArtifactNames;
import org.jboss.seam.transactions.test.util.HelloService;
import org.jboss.seam.transactions.test.util.IndexedHotel;
@@ -65,10 +61,7 @@
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.HIBERNATE_SEARCH));
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.LUCENE_ANALYZERS));
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.LUCENE_CORE));
- war.addPackage(TransactionExtension.class.getPackage());
- war.addPackage(SePersistenceContextExtension.class.getPackage());
- war.addPackage(TransactionScopeExtension.class.getPackage());
- war.addPackage(NamingUtils.class.getPackage());
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_IMPL));
war.addClasses(HibernateSearchTest.class, IndexedHotel.class, ManagedPersistenceContextProvider.class, HelloService.class);
war.addWebResource("META-INF/persistence-search.xml", "classes/META-INF/persistence.xml");
war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextELTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextELTest.java 2010-09-02 08:22:41 UTC (rev 13698)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextELTest.java 2010-09-02 08:32:11 UTC (rev 13699)
@@ -31,12 +31,8 @@
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.seam.persistence.SePersistenceContextExtension;
import org.jboss.seam.persistence.transaction.DefaultTransaction;
import org.jboss.seam.persistence.transaction.SeamTransaction;
-import org.jboss.seam.persistence.transaction.TransactionExtension;
-import org.jboss.seam.persistence.transaction.scope.TransactionScopeExtension;
-import org.jboss.seam.persistence.util.NamingUtils;
import org.jboss.seam.transactions.test.util.ArtifactNames;
import org.jboss.seam.transactions.test.util.HelloService;
import org.jboss.seam.transactions.test.util.Hotel;
@@ -59,11 +55,7 @@
WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
- war.addPackage(TransactionExtension.class.getPackage());
- war.addPackage(SePersistenceContextExtension.class.getPackage());
- war.addPackage(TransactionExtension.class.getPackage());
- war.addPackage(TransactionScopeExtension.class.getPackage());
- war.addPackage(NamingUtils.class.getPackage());
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_IMPL));
war.addClasses(ManagedPersistenceContextELTest.class, Hotel.class, ManagedPersistenceContextProvider.class, HotelNameProducer.class, HelloService.class);
war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextFlushModeTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextFlushModeTest.java 2010-09-02 08:22:41 UTC (rev 13698)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextFlushModeTest.java 2010-09-02 08:32:11 UTC (rev 13699)
@@ -39,11 +39,7 @@
import org.jboss.seam.persistence.FlushModeManager;
import org.jboss.seam.persistence.FlushModeType;
import org.jboss.seam.persistence.ManagedPersistenceContext;
-import org.jboss.seam.persistence.SePersistenceContextExtension;
import org.jboss.seam.persistence.PersistenceContexts;
-import org.jboss.seam.persistence.transaction.TransactionExtension;
-import org.jboss.seam.persistence.transaction.scope.TransactionScopeExtension;
-import org.jboss.seam.persistence.util.NamingUtils;
import org.jboss.seam.transactions.test.util.ArtifactNames;
import org.jboss.seam.transactions.test.util.HelloService;
import org.jboss.seam.transactions.test.util.Hotel;
@@ -65,10 +61,7 @@
WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
- war.addPackage(TransactionExtension.class.getPackage());
- war.addPackage(SePersistenceContextExtension.class.getPackage());
- war.addPackage(TransactionScopeExtension.class.getPackage());
- war.addPackage(NamingUtils.class.getPackage());
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_IMPL));
war.addClasses(ManagedPersistenceContextFlushModeTest.class, Hotel.class, ManagedPersistenceContextProvider.class, HelloService.class);
war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTest.java 2010-09-02 08:22:41 UTC (rev 13698)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTest.java 2010-09-02 08:32:11 UTC (rev 13699)
@@ -35,12 +35,8 @@
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.seam.persistence.SePersistenceContextExtension;
import org.jboss.seam.persistence.transaction.DefaultTransaction;
import org.jboss.seam.persistence.transaction.SeamTransaction;
-import org.jboss.seam.persistence.transaction.TransactionExtension;
-import org.jboss.seam.persistence.transaction.scope.TransactionScopeExtension;
-import org.jboss.seam.persistence.util.NamingUtils;
import org.jboss.seam.transactions.test.util.ArtifactNames;
import org.jboss.seam.transactions.test.util.HelloService;
import org.jboss.seam.transactions.test.util.Hotel;
@@ -62,10 +58,7 @@
WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
- war.addPackage(TransactionExtension.class.getPackage());
- war.addPackage(SePersistenceContextExtension.class.getPackage());
- war.addPackage(TransactionScopeExtension.class.getPackage());
- war.addPackage(NamingUtils.class.getPackage());
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_IMPL));
war.addClasses(ManagedPersistenceContextTest.class, Hotel.class, ManagedPersistenceContextProvider.class, HelloService.class);
war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeInterceptorTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeInterceptorTest.java 2010-09-02 08:22:41 UTC (rev 13698)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeInterceptorTest.java 2010-09-02 08:32:11 UTC (rev 13699)
@@ -37,13 +37,9 @@
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.seam.persistence.DefaultPersistenceProvider;
import org.jboss.seam.persistence.transaction.DefaultTransaction;
import org.jboss.seam.persistence.transaction.SeamTransaction;
-import org.jboss.seam.persistence.transaction.TransactionExtension;
import org.jboss.seam.persistence.transaction.TransactionInterceptor;
-import org.jboss.seam.persistence.transaction.scope.TransactionScopeExtension;
-import org.jboss.seam.persistence.util.NamingUtils;
import org.jboss.seam.transactions.test.util.ArtifactNames;
import org.jboss.seam.transactions.test.util.DontRollBackException;
import org.jboss.seam.transactions.test.util.EntityManagerProvider;
@@ -75,10 +71,7 @@
WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
- war.addPackage(TransactionExtension.class.getPackage());
- war.addPackage(DefaultPersistenceProvider.class.getPackage());
- war.addPackage(TransactionScopeExtension.class.getPackage());
- war.addPackage(NamingUtils.class.getPackage());
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_IMPL));
war.addClasses(TransactionAttributeInterceptorTest.class, TransactionAttributeManagedBean.class, HelloService.class, Hotel.class, EntityManagerProvider.class, DontRollBackException.class);
war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
war.addWebResource(new ByteArrayAsset(("<beans><interceptors><class>" + TransactionInterceptor.class.getName() + "</class></interceptors></beans>").getBytes()), "beans.xml");
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java 2010-09-02 08:22:41 UTC (rev 13698)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java 2010-09-02 08:32:11 UTC (rev 13699)
@@ -37,13 +37,9 @@
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.seam.persistence.DefaultPersistenceProvider;
import org.jboss.seam.persistence.transaction.DefaultTransaction;
import org.jboss.seam.persistence.transaction.SeamTransaction;
-import org.jboss.seam.persistence.transaction.TransactionExtension;
import org.jboss.seam.persistence.transaction.TransactionInterceptor;
-import org.jboss.seam.persistence.transaction.scope.TransactionScopeExtension;
-import org.jboss.seam.persistence.util.NamingUtils;
import org.jboss.seam.transactions.test.util.ArtifactNames;
import org.jboss.seam.transactions.test.util.DontRollBackException;
import org.jboss.seam.transactions.test.util.EntityManagerProvider;
@@ -75,10 +71,7 @@
WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
- war.addPackage(TransactionExtension.class.getPackage());
- war.addPackage(TransactionScopeExtension.class.getPackage());
- war.addPackage(NamingUtils.class.getPackage());
- war.addPackage(DefaultPersistenceProvider.class.getPackage());
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_IMPL));
war.addClasses(TransactionInterceptorTest.class, TransactionManagedBean.class, HelloService.class, Hotel.class, EntityManagerProvider.class, DontRollBackException.class);
war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
war.addWebResource(new ByteArrayAsset(("<beans><interceptors><class>" + TransactionInterceptor.class.getName() + "</class></interceptors></beans>").getBytes()), "beans.xml");
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionScopedTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionScopedTest.java 2010-09-02 08:22:41 UTC (rev 13698)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionScopedTest.java 2010-09-02 08:32:11 UTC (rev 13699)
@@ -13,12 +13,8 @@
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.seam.persistence.DefaultPersistenceProvider;
import org.jboss.seam.persistence.transaction.DefaultTransaction;
import org.jboss.seam.persistence.transaction.SeamTransaction;
-import org.jboss.seam.persistence.transaction.TransactionExtension;
-import org.jboss.seam.persistence.transaction.scope.TransactionScopeExtension;
-import org.jboss.seam.persistence.util.NamingUtils;
import org.jboss.seam.transactions.test.util.ArtifactNames;
import org.jboss.seam.transactions.test.util.HelloService;
import org.jboss.seam.transactions.test.util.Hotel;
@@ -39,10 +35,7 @@
WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
- war.addPackage(TransactionExtension.class.getPackage());
- war.addPackage(TransactionScopeExtension.class.getPackage());
- war.addPackage(DefaultPersistenceProvider.class.getPackage());
- war.addPackage(NamingUtils.class.getPackage());
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_IMPL));
war.addClasses(TransactionScopedTest.class, Hotel.class, HelloService.class, TransactionScopedObject.class);
war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/UserTransactionTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/UserTransactionTest.java 2010-09-02 08:22:41 UTC (rev 13698)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/UserTransactionTest.java 2010-09-02 08:32:11 UTC (rev 13699)
@@ -17,8 +17,6 @@
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.seam.persistence.transaction.DefaultTransaction;
import org.jboss.seam.persistence.transaction.SeamTransaction;
-import org.jboss.seam.persistence.transaction.TransactionExtension;
-import org.jboss.seam.persistence.util.NamingUtils;
import org.jboss.seam.transactions.test.util.ArtifactNames;
import org.jboss.seam.transactions.test.util.HelloService;
import org.jboss.seam.transactions.test.util.Hotel;
@@ -39,9 +37,8 @@
WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
- war.addPackage(TransactionExtension.class.getPackage());
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_IMPL));
war.addClasses(UserTransactionTest.class, Hotel.class, HelloService.class);
- war.addPackage(NamingUtils.class.getPackage());
war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/ArtifactNames.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/ArtifactNames.java 2010-09-02 08:22:41 UTC (rev 13698)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/ArtifactNames.java 2010-09-02 08:32:11 UTC (rev 13699)
@@ -4,6 +4,7 @@
{
public static final String WELD_EXTENSIONS = "org.jboss.weld:weld-extensions";
public static final String SEAM_PERSISTENCE_API = "org.jboss.seam.persistence:seam-persistence-api";
+ public static final String SEAM_PERSISTENCE_IMPL = "org.jboss.seam.persistence:seam-persistence-impl";
public static final String HIBERNATE_SEARCH = "org.hibernate:hibernate-search";
public static final String LUCENE_CORE = "org.apache.lucene:lucene-core";
public static final String LUCENE_ANALYZERS = "org.apache.lucene:lucene-analyzers";
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/MavenArtifactResolver.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/MavenArtifactResolver.java 2010-09-02 08:22:41 UTC (rev 13698)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/MavenArtifactResolver.java 2010-09-02 08:32:11 UTC (rev 13699)
@@ -1,6 +1,8 @@
package org.jboss.seam.transactions.test.util;
import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -12,33 +14,151 @@
*/
public class MavenArtifactResolver
{
+
public static File resolve(String groupId, String artifactId)
{
- String classPath = System.getProperty("java.class.path");
- // first look for an artefact from the repo
- String pathString = groupId.replace('.', File.separatorChar) + File.separatorChar + artifactId;
- String regex = "[^:]*" + Pattern.quote(pathString) + "[^:]*";
- Pattern p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
- Matcher matches = p.matcher(classPath);
+ if (groupId == null)
+ {
+ throw new IllegalArgumentException("groupId cannot be null");
+ }
+ if (artifactId == null)
+ {
+ throw new IllegalArgumentException("artifactId cannot be null");
+ }
+ String path = new MavenArtifactResolver(groupId.trim(), artifactId.trim(), System.getProperty("java.class.path"), File.pathSeparatorChar, File.separatorChar).resolve();
+ if (path == null)
+ {
+ throw new IllegalArgumentException("Cannot locate artifact for " + groupId + ":" + artifactId);
+ }
+ return new File(path);
+ }
+ public static File resolve(String qualifiedArtifactId)
+ {
+ String[] segments = qualifiedArtifactId.split(":");
+ if (segments.length == 2)
+ {
+ return resolve(segments[0], segments[1]);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unable to parse " + qualifiedArtifactId + " as a groupId:artifactId");
+ }
+ }
+
+ private final String classPathSeparatorRegex;
+ private final char fileSeparator;
+ private final String groupId;
+ private final String artifactId;
+ private final String classPath;
+
+ MavenArtifactResolver(String groupId, String artifactId, String classPath, char pathSeparator, char fileSeparator)
+ {
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ this.classPath = classPath;
+ this.classPathSeparatorRegex = "[^" + pathSeparator + "]*";
+ this.fileSeparator = fileSeparator;
+ }
+
+ String resolve()
+ {
+ Matcher matches = createFullyQualifiedMatcher();
if (!matches.find())
{
- // find a resource from the local build
- String localResource = Pattern.quote("target" + File.separatorChar + artifactId);
- regex = "[^:]*" + localResource + "[^:]*";
- p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
- matches = p.matcher(classPath);
+ matches = createUnqualifiedMatcher();
if (!matches.find())
{
- throw new RuntimeException("Unable to find maven archive " + groupId + ":" + artifactId + " on the test classpath");
+ matches = createTargetClassesMatcher();
+ if (!matches.find())
+ {
+ return null;
+ }
+ else
+ {
+ String fileName = scanForArtifact(matches);
+ if (fileName == null)
+ {
+ return null;
+ }
+ else
+ {
+ return fileName;
+ }
+ }
}
}
- return new File(matches.group(0));
+ return matches.group(0);
}
- public static File resolve(String qualifiedArtifactId)
+ private String scanForArtifact(Matcher targetClassesMatcher)
{
- String[] segments = qualifiedArtifactId.split(":");
- return resolve(segments[0], segments[1]);
+ // Locate all target/classes in classpath and store the path to all files target/
+ List<String> paths = new ArrayList<String>();
+ do
+ {
+ String path = targetClassesMatcher.group();
+ File target = new File(path.substring(0, path.length() - 8));
+ if (target.exists())
+ {
+ if (!target.isDirectory())
+ {
+ throw new IllegalStateException("Found ${project.dir}/target/ but it is not a directory!");
+ }
+ for (File file : target.listFiles())
+ {
+ paths.add(file.getPath());
+ }
+ }
+ }
+ while (targetClassesMatcher.find());
+ return scanForArtifact(paths);
}
+
+ String scanForArtifact(List<String> paths)
+ {
+ Pattern pattern = Pattern.compile(artifactId + "-[\\d+\\.]+(?:[\\-\\.]\\p{Alpha}*)?.jar$");
+ for (String path : paths)
+ {
+ if (pattern.matcher(path).find())
+ {
+ return path;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Creates a matcher that returns any fully qualified matches of the form
+ * <code>com/acme/acme-core/1.0/acme-core-1.0.jar</code>. This will match
+ * artifacts on the classpath from the Maven repo.
+ */
+ private Matcher createFullyQualifiedMatcher()
+ {
+ String pathString = groupId.replace('.', fileSeparator) + fileSeparator + artifactId;
+ Pattern p = Pattern.compile(classPathSeparatorRegex + Pattern.quote(pathString) + classPathSeparatorRegex, Pattern.CASE_INSENSITIVE);
+ return p.matcher(classPath);
+ }
+
+ /**
+ * Creates a matcher that returns any unqualified matches of the form
+ * <code>target/acme-foo-1.0.jar</code>. This will match artifacts on the
+ * classpath from the reactor.
+ */
+ private Matcher createUnqualifiedMatcher()
+ {
+ Pattern p = Pattern.compile(classPathSeparatorRegex + Pattern.quote("target" + fileSeparator + artifactId) + classPathSeparatorRegex, Pattern.CASE_INSENSITIVE);
+ return p.matcher(classPath);
+ }
+
+ /**
+ * Creates a matcher that returns any unqualified matches of the form
+ * <code>target/acme-foo-1.0.jar</code>. This locates all
+ *
+ */
+ private Matcher createTargetClassesMatcher()
+ {
+ Pattern p = Pattern.compile(classPathSeparatorRegex + Pattern.quote("target" + fileSeparator + "classes") + classPathSeparatorRegex, Pattern.CASE_INSENSITIVE);
+ return p.matcher(classPath);
+ }
}
More information about the seam-commits
mailing list