deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From daniels...@apache.org
Subject deltaspike git commit: DELTASPIKE-839 Data module test deployments pack individual classes instead of JARs
Date Wed, 18 Nov 2015 22:44:12 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 0897df49d -> cf886865c


DELTASPIKE-839 Data module test deployments pack individual classes instead of JARs


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/cf886865
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/cf886865
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/cf886865

Branch: refs/heads/master
Commit: cf886865c3ef765ecad01f4b416da21dae6157c7
Parents: 0897df4
Author: Daniel Cunha <danielsoro@apache.org>
Authored: Wed Nov 18 18:53:05 2015 -0300
Committer: Daniel Cunha <danielsoro@apache.org>
Committed: Wed Nov 18 19:40:13 2015 -0300

----------------------------------------------------------------------
 .../data/impl/DisabledRepositoryTest.java       |   8 +-
 .../impl/audit/AuditEntityListenerTest.java     |   2 +-
 .../data/impl/handler/EntityManagerTest.java    |   1 +
 .../meta/unit/OrmXmlBasedRepositoryTest.java    |   2 +-
 .../impl/meta/unit/PersistenceUnitsTest.java    |  42 ++----
 .../impl/tx/TransactionalQueryRunnerTest.java   |   1 +
 .../data/test/util/TestDeployments.java         | 146 ++++---------------
 7 files changed, 48 insertions(+), 154 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/cf886865/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/DisabledRepositoryTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/DisabledRepositoryTest.java
b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/DisabledRepositoryTest.java
index 4c6ea14..60d0f61 100644
--- a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/DisabledRepositoryTest.java
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/DisabledRepositoryTest.java
@@ -46,9 +46,11 @@ public class DisabledRepositoryTest
                 .addClasses(SimpleRepository.class,
                         RepositoryDeactivator.class,
                         DisabledRepository.class
-                )
-                .addAsWebInfResource("disabled/META-INF/apache-deltaspike.properties",
-                        "classes/META-INF/apache-deltaspike.properties");
+                );
+
+        archive.delete("WEB-INF/classes/META-INF/apache-deltaspike.properties");
+        archive.addAsWebInfResource("disabled/META-INF/apache-deltaspike.properties",
+                "classes/META-INF/apache-deltaspike.properties");
         return archive;
     }
 

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/cf886865/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/audit/AuditEntityListenerTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/audit/AuditEntityListenerTest.java
b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/audit/AuditEntityListenerTest.java
index 3b9efe2..81296df 100644
--- a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/audit/AuditEntityListenerTest.java
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/audit/AuditEntityListenerTest.java
@@ -46,7 +46,7 @@ public class AuditEntityListenerTest extends TransactionalTestCase
     {
         return initDeployment()
                 .addPackage(AuditEntityListener.class.getPackage())
-                .addAsWebInfResource("test-orm.xml", ArchivePaths.create("classes/META-INF/orm.xml"))
+                .addAsWebInfResource("test-orm.xml", "classes/META-INF/orm.xml")
                 .addPackage(AuditedEntity.class.getPackage());
     }
 

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/cf886865/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/handler/EntityManagerTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/handler/EntityManagerTest.java
b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/handler/EntityManagerTest.java
index d995314..d607694 100644
--- a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/handler/EntityManagerTest.java
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/handler/EntityManagerTest.java
@@ -50,6 +50,7 @@ public class EntityManagerTest
     public static Archive<?> deployment()
     {
         return initDeployment()
+                .addPackage(Simple.class.getPackage())
                 .addClasses(SimpleRepositoryWithEntityManager.class,
                         SimpleRepositoryWithEntityManagerResolver.class,
                         QualifiedEntityManagerTestProducer.class,

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/cf886865/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/meta/unit/OrmXmlBasedRepositoryTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/meta/unit/OrmXmlBasedRepositoryTest.java
b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/meta/unit/OrmXmlBasedRepositoryTest.java
index 04a0187..8e072af 100644
--- a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/meta/unit/OrmXmlBasedRepositoryTest.java
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/meta/unit/OrmXmlBasedRepositoryTest.java
@@ -45,7 +45,7 @@ public class OrmXmlBasedRepositoryTest extends TransactionalTestCase
     @Deployment
     public static Archive<?> deployment()
     {
-        return initDeployment("(.*mapped.*)|(.*test.*)")
+        return initDeployment()
                 .addClasses(MappedOneRepository.class)
                 .addAsLibraries(
                         ShrinkWrap.create(JavaArchive.class, "domain.jar")

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/cf886865/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/meta/unit/PersistenceUnitsTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/meta/unit/PersistenceUnitsTest.java
b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/meta/unit/PersistenceUnitsTest.java
index a247151..dfcbf8d 100644
--- a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/meta/unit/PersistenceUnitsTest.java
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/meta/unit/PersistenceUnitsTest.java
@@ -18,17 +18,11 @@
  */
 package org.apache.deltaspike.data.impl.meta.unit;
 
-import static org.apache.deltaspike.data.test.util.TestDeployments.TEST_FILTER;
-import static org.apache.deltaspike.data.test.util.TestDeployments.addDependencies;
-import static org.apache.deltaspike.data.test.util.TestDeployments.createApiArchive;
-import static org.apache.deltaspike.data.test.util.TestDeployments.createImplPackages;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
-import org.apache.deltaspike.data.impl.RepositoryDefinitionException;
-import org.apache.deltaspike.data.impl.RepositoryExtension;
 import org.apache.deltaspike.data.impl.meta.RepositoryEntity;
 import org.apache.deltaspike.data.test.domain.Parent;
 import org.apache.deltaspike.data.test.domain.TeeId;
@@ -36,14 +30,11 @@ import org.apache.deltaspike.data.test.domain.mapped.MappedOne;
 import org.apache.deltaspike.data.test.domain.mapped.MappedThree;
 import org.apache.deltaspike.data.test.domain.mapped.MappedTwo;
 import org.apache.deltaspike.data.test.service.MappedOneRepository;
-import org.apache.deltaspike.data.test.util.Logging;
+import org.apache.deltaspike.data.test.util.TestDeployments;
 import org.apache.deltaspike.test.category.WebProfileCategory;
 import org.jboss.arquillian.container.test.api.Deployment;
 import org.jboss.arquillian.junit.Arquillian;
 import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.ArchivePaths;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.EmptyAsset;
 import org.jboss.shrinkwrap.api.spec.WebArchive;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -57,22 +48,16 @@ public class PersistenceUnitsTest
     @Deployment
     public static Archive<?> deployment()
     {
-        Logging.reconfigure();
-        return addDependencies(ShrinkWrap
-                .create(WebArchive.class, "test.war")
-                .addClass(WebProfileCategory.class)
-                .addAsLibrary(createApiArchive())
-                .addPackages(true, TEST_FILTER, createImplPackages())
-                .addPackages(true, Parent.class.getPackage())
-                .addClasses(RepositoryExtension.class, RepositoryDefinitionException.class,
-                        MappedOneRepository.class)
+        WebArchive war = TestDeployments.initDeployment();
+
+        war.delete("WEB-INF/classes/META-INF/persistence.xml");
+
+        return war.addPackages(true, Parent.class.getPackage())
+                .addClasses(MappedOneRepository.class)
                 .addAsWebInfResource("test-mapped-persistence.xml",
-                        ArchivePaths.create("classes/META-INF/persistence.xml"))
-                .addAsWebInfResource("test-default-orm.xml", ArchivePaths.create("classes/META-INF/orm.xml"))
-                .addAsWebInfResource("test-custom-orm.xml", ArchivePaths.create("classes/META-INF/custom-orm.xml"))
-                .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
-                .addAsWebInfResource("META-INF/services/javax.enterprise.inject.spi.Extension",
-                        ArchivePaths.create("classes/META-INF/services/javax.enterprise.inject.spi.Extension")));
+                        "classes/META-INF/persistence.xml")
+                .addAsWebInfResource("test-default-orm.xml", "classes/META-INF/orm.xml")
+                .addAsWebInfResource("test-custom-orm.xml", "classes/META-INF/custom-orm.xml");
     }
 
     @Test
@@ -149,11 +134,4 @@ public class PersistenceUnitsTest
         assertEquals(Long.class, entity3.getPrimaryClass());
     }
 
-    @Test
-    public void should_read_table_name()
-    {
-        String entityTableName = PersistenceUnits.instance().entityTableName(MappedThree.class);
-        assertEquals("mapped_three_table", entityTableName);
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/cf886865/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/tx/TransactionalQueryRunnerTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/tx/TransactionalQueryRunnerTest.java
b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/tx/TransactionalQueryRunnerTest.java
index eaf6c17..1170457 100644
--- a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/tx/TransactionalQueryRunnerTest.java
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/tx/TransactionalQueryRunnerTest.java
@@ -51,6 +51,7 @@ public class TransactionalQueryRunnerTest
     {
         return initDeployment()
                 .addClasses(ExtendedRepositoryInterface.class)
+                .addClass(TransactionalQueryRunnerWrapper.class)
                 .addPackage(Simple.class.getPackage());
     }
 

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/cf886865/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/util/TestDeployments.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/util/TestDeployments.java
b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/util/TestDeployments.java
index 99db6d7..c2358e2 100755
--- a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/util/TestDeployments.java
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/util/TestDeployments.java
@@ -18,149 +18,61 @@
  */
 package org.apache.deltaspike.data.test.util;
 
+import java.io.File;
 import java.net.URL;
 
-import org.apache.deltaspike.data.api.AbstractEntityRepository;
-import org.apache.deltaspike.data.api.EntityManagerConfig;
-import org.apache.deltaspike.data.api.EntityManagerDelegate;
-import org.apache.deltaspike.data.api.EntityManagerResolver;
-import org.apache.deltaspike.data.api.EntityRepository;
-import org.apache.deltaspike.data.api.FirstResult;
-import org.apache.deltaspike.data.api.MaxResults;
-import org.apache.deltaspike.data.api.Modifying;
-import org.apache.deltaspike.data.api.Query;
-import org.apache.deltaspike.data.api.QueryInvocationException;
-import org.apache.deltaspike.data.api.QueryParam;
-import org.apache.deltaspike.data.api.QueryResult;
-import org.apache.deltaspike.data.api.Repository;
-import org.apache.deltaspike.data.api.SingleResultType;
-import org.apache.deltaspike.data.api.audit.CreatedOn;
-import org.apache.deltaspike.data.api.audit.CurrentUser;
-import org.apache.deltaspike.data.api.audit.ModifiedBy;
-import org.apache.deltaspike.data.api.audit.ModifiedOn;
-import org.apache.deltaspike.data.api.criteria.Criteria;
-import org.apache.deltaspike.data.api.criteria.CriteriaSupport;
-import org.apache.deltaspike.data.api.criteria.QuerySelection;
-import org.apache.deltaspike.data.api.mapping.MappingConfig;
-import org.apache.deltaspike.data.api.mapping.QueryInOutMapper;
-import org.apache.deltaspike.data.api.mapping.SimpleQueryInOutMapperBase;
-import org.apache.deltaspike.data.impl.RepositoryDefinitionException;
-import org.apache.deltaspike.data.impl.RepositoryExtension;
-import org.apache.deltaspike.data.impl.audit.AuditEntityListener;
-import org.apache.deltaspike.data.impl.builder.QueryBuilder;
-import org.apache.deltaspike.data.impl.criteria.QueryCriteria;
-import org.apache.deltaspike.data.impl.handler.QueryHandler;
-import org.apache.deltaspike.data.impl.meta.RepositoryComponents;
-import org.apache.deltaspike.data.impl.meta.RequiresTransaction;
-import org.apache.deltaspike.data.impl.param.Parameters;
-import org.apache.deltaspike.data.impl.property.Property;
-import org.apache.deltaspike.data.impl.tx.TransactionalQueryRunner;
-import org.apache.deltaspike.data.impl.util.EntityUtils;
-import org.apache.deltaspike.data.spi.DelegateQueryHandler;
-import org.apache.deltaspike.data.spi.QueryInvocationContext;
 import org.apache.deltaspike.data.test.TransactionalTestCase;
 import org.apache.deltaspike.data.test.domain.AuditedEntity;
-import org.apache.deltaspike.jpa.impl.transaction.EnvironmentAwareTransactionStrategy;
-import org.apache.deltaspike.test.category.WebProfileCategory;
 import org.jboss.arquillian.container.test.spi.TestDeployment;
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.ArchivePath;
-import org.jboss.shrinkwrap.api.ArchivePaths;
-import org.jboss.shrinkwrap.api.Filter;
 import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
 import org.jboss.shrinkwrap.api.asset.StringAsset;
 import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
 import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.descriptor.api.Descriptors;
-import org.jboss.shrinkwrap.descriptor.api.beans10.BeansDescriptor;
-import org.jboss.shrinkwrap.impl.base.filter.ExcludeRegExpPaths;
 import org.jboss.shrinkwrap.resolver.api.maven.Maven;
 
-public abstract class TestDeployments
-{
+public abstract class TestDeployments {
 
-    public static Filter<ArchivePath> TEST_FILTER = new ExcludeRegExpPaths(".*Test.*class");
-
-    public static WebArchive initDeployment()
-    {
-        return initDeployment(".*test.*");
-    }
+    public static String DS_PROPERTIES_WITH_ENV_AWARE_TX_STRATEGY
+            = "globalAlternatives.org.apache.deltaspike.jpa.spi.transaction.TransactionStrategy="
+            + "org.apache.deltaspike.jpa.impl.transaction.EnvironmentAwareTransactionStrategy";
 
     /**
-     * Create a basic deployment containing API classes, the Extension class and test persistence
/ beans descriptor.
+     * Create a basic deployment with dependencies, beans.xml and persistence descriptor.
      *
      * @return Basic web archive.
      */
-    public static WebArchive initDeployment(String testFilter)
+    public static WebArchive initDeployment()
     {
         Logging.reconfigure();
-        String descriptor = Descriptors.create(BeansDescriptor.class)
-                .addDefaultNamespaces()
-                .getOrCreateAlternatives()
-                    .clazz(EnvironmentAwareTransactionStrategy.class.getName())
-                    .up()
-                .exportAsString();
+
         WebArchive archive = ShrinkWrap
                 .create(WebArchive.class, "test.war")
-                .addAsLibrary(createApiArchive())
-                .addClasses(WebProfileCategory.class, TransactionalTestCase.class, TestData.class)
-                .addClasses(RepositoryExtension.class, RepositoryDefinitionException.class)
-                .addPackages(true, TEST_FILTER, createImplPackages())
+                // used by many tests, shouldn't interfere with others
+                .addClasses(TransactionalTestCase.class, TestData.class)
                 .addPackages(true, AuditedEntity.class.getPackage())
-                .addPackages(true, new ExcludeRegExpPaths(testFilter), TransactionalTestCase.class.getPackage())
-                .addAsWebInfResource("test-persistence.xml",
-                        ArchivePaths.create("classes/META-INF/persistence.xml"))
-                .addAsWebInfResource("META-INF/services/javax.enterprise.inject.spi.Extension",
-                        ArchivePaths.create("classes/META-INF/services/javax.enterprise.inject.spi.Extension"))
-                .addAsWebInfResource(new StringAsset(descriptor), ArchivePaths.create("beans.xml"));
-        return addDependencies(archive);
-    }
-
-    public static Package[] createImplPackages()
-    {
-        return new Package[] {
-                AuditEntityListener.class.getPackage(),
-                QueryBuilder.class.getPackage(),
-                QueryCriteria.class.getPackage(),
-                QueryHandler.class.getPackage(),
-                RepositoryComponents.class.getPackage(),
-                Parameters.class.getPackage(),
-                EntityUtils.class.getPackage(),
-                Property.class.getPackage(),
-                TransactionalQueryRunner.class.getPackage()
-        };
-    }
+                .addAsLibraries(getDeltaSpikeDataWithDependencies())
+                .addAsWebInfResource("test-persistence.xml", "classes/META-INF/persistence.xml")
+                .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
+                .addAsWebInfResource(new StringAsset(DS_PROPERTIES_WITH_ENV_AWARE_TX_STRATEGY),
+                        "classes/META-INF/apache-deltaspike.properties");
 
-    public static Archive<?> createApiArchive()
-    {
-        return ShrinkWrap.create(JavaArchive.class, "archive.jar")
-                .addClasses(AbstractEntityRepository.class, Repository.class, EntityRepository.class,
-                        FirstResult.class, MaxResults.class, Modifying.class,
-                        Query.class, QueryParam.class, QueryResult.class,
-                        EntityManagerConfig.class, EntityManagerResolver.class, SingleResultType.class,
-                        QueryInvocationException.class, EntityManagerDelegate.class)
-                .addClasses(Criteria.class, QuerySelection.class, CriteriaSupport.class)
-                .addClasses(CreatedOn.class, CurrentUser.class, ModifiedBy.class, ModifiedOn.class)
-                .addClasses(MappingConfig.class, QueryInOutMapper.class)
-                .addClasses(DelegateQueryHandler.class, QueryInvocationContext.class, RequiresTransaction.class)
-                .addClasses(SimpleQueryInOutMapperBase.class);
+        return archive;
     }
 
-    public static WebArchive addDependencies(WebArchive archive)
+    public static File[] getDeltaSpikeDataWithDependencies()
     {
-        WebArchive webArchive= archive.addAsLibraries(
-                Maven.resolver().loadPomFromFile("pom.xml").resolve(
-                        "org.apache.deltaspike.core:deltaspike-core-api",
-                        "org.apache.deltaspike.core:deltaspike-core-impl",
-                        "org.apache.deltaspike.modules:deltaspike-partial-bean-module-api",
-                        "org.apache.deltaspike.modules:deltaspike-partial-bean-module-impl",
-                        "org.apache.deltaspike.modules:deltaspike-jpa-module-api",
-                        "org.apache.deltaspike.modules:deltaspike-jpa-module-impl")
-                        .withTransitivity()
-                        .asFile());
-
-        return webArchive;
+        return Maven.resolver().loadPomFromFile("pom.xml").resolve(
+                "org.apache.deltaspike.core:deltaspike-core-api",
+                "org.apache.deltaspike.core:deltaspike-core-impl",
+                "org.apache.deltaspike.modules:deltaspike-partial-bean-module-api",
+                "org.apache.deltaspike.modules:deltaspike-partial-bean-module-impl",
+                "org.apache.deltaspike.modules:deltaspike-jpa-module-api",
+                "org.apache.deltaspike.modules:deltaspike-jpa-module-impl",
+                "org.apache.deltaspike.modules:deltaspike-data-module-api",
+                "org.apache.deltaspike.modules:deltaspike-data-module-impl")
+                .withTransitivity()
+                .asFile();
     }
 
     public static void addToEarManifestIfExists(EnterpriseArchive archive, String resource)


Mime
View raw message