deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject deltaspike git commit: DELTASPIKE-419 enabled test
Date Tue, 17 Feb 2015 18:43:52 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 77be425a7 -> 7b77e9587


DELTASPIKE-419 enabled test


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

Branch: refs/heads/master
Commit: 7b77e958734cf7c95c76a2e4fd05a1e48b2d3dd9
Parents: 77be425
Author: gpetracek <gpetracek@apache.org>
Authored: Tue Feb 17 19:37:37 2015 +0100
Committer: gpetracek <gpetracek@apache.org>
Committed: Tue Feb 17 19:41:32 2015 +0100

----------------------------------------------------------------------
 deltaspike/modules/partial-bean/impl/pom.xml    |  6 ++++++
 .../shared/CustomInterceptorImpl.java           | 15 ++++++++++----
 .../uc005/ScopedPartialBeanTest.java            |  6 ------
 ...lBeanAsAbstractClassWithInterceptorTest.java | 21 ++++++--------------
 4 files changed, 23 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/7b77e958/deltaspike/modules/partial-bean/impl/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/modules/partial-bean/impl/pom.xml b/deltaspike/modules/partial-bean/impl/pom.xml
index 0304fbd..b0a650b 100644
--- a/deltaspike/modules/partial-bean/impl/pom.xml
+++ b/deltaspike/modules/partial-bean/impl/pom.xml
@@ -92,6 +92,12 @@
         </dependency>
 
         <dependency>
+            <groupId>org.apache.deltaspike.core</groupId>
+            <artifactId>deltaspike-core-impl</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
             <groupId>org.apache.deltaspike.modules</groupId>
             <artifactId>deltaspike-partial-bean-module-api</artifactId>
         </dependency>

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/7b77e958/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/shared/CustomInterceptorImpl.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/shared/CustomInterceptorImpl.java
b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/shared/CustomInterceptorImpl.java
index 075e1db..206427e 100644
--- a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/shared/CustomInterceptorImpl.java
+++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/shared/CustomInterceptorImpl.java
@@ -18,6 +18,8 @@
  */
 package org.apache.deltaspike.test.core.api.partialbean.shared;
 
+import org.apache.deltaspike.core.util.ClassUtils;
+
 import javax.interceptor.AroundInvoke;
 import javax.interceptor.Interceptor;
 import javax.interceptor.InvocationContext;
@@ -30,11 +32,16 @@ public class CustomInterceptorImpl implements Serializable
     @AroundInvoke
     public Object interceptIt(InvocationContext invocationContext) throws Exception
     {
-        Object target = invocationContext.getTarget();
-
-        if (target instanceof TestInterceptorAware)
+        //interceptor gets enabled globally -> restrict it the the use-case which contains
the test for it
+        if (ClassUtils.tryToLoadClassForName(
+            "org.apache.deltaspike.test.core.api.partialbean.uc007.PartialBean") != null)
         {
-            ((TestInterceptorAware)target).setIntercepted(true);
+            Object target = invocationContext.getTarget();
+
+            if (target instanceof TestInterceptorAware)
+            {
+                ((TestInterceptorAware)target).setIntercepted(true);
+            }
         }
 
         return invocationContext.proceed();

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/7b77e958/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc005/ScopedPartialBeanTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc005/ScopedPartialBeanTest.java
b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc005/ScopedPartialBeanTest.java
index a80179c..02d9be0 100644
--- a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc005/ScopedPartialBeanTest.java
+++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc005/ScopedPartialBeanTest.java
@@ -42,12 +42,6 @@ public class ScopedPartialBeanTest
     @Deployment
     public static WebArchive war()
     {
-        if (CdiContainerUnderTest.is(CONTAINER_OWB_1_2_x_BEFORE_1_2_8)
-                || CdiContainerUnderTest.is(CONTAINER_TOMEE_1_7_x))
-        {
-            return ShrinkWrap.create(WebArchive.class, "empty.war");
-        }
-
         String simpleName = ScopedPartialBeanTest.class.getSimpleName();
         String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);
 

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/7b77e958/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/PartialBeanAsAbstractClassWithInterceptorTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/PartialBeanAsAbstractClassWithInterceptorTest.java
b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/PartialBeanAsAbstractClassWithInterceptorTest.java
index 2df6a45..b570bcd 100644
--- a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/PartialBeanAsAbstractClassWithInterceptorTest.java
+++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/PartialBeanAsAbstractClassWithInterceptorTest.java
@@ -20,10 +20,10 @@ package org.apache.deltaspike.test.core.api.partialbean.uc007;
 
 import org.apache.deltaspike.core.api.provider.BeanProvider;
 import org.apache.deltaspike.partialbean.spi.PartialBeanProvider;
+import org.apache.deltaspike.test.category.WebEE7ProfileCategory;
 import org.apache.deltaspike.test.core.api.partialbean.shared.CustomInterceptorImpl;
 import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding;
 import org.apache.deltaspike.test.core.api.partialbean.util.ArchiveUtils;
-import org.apache.deltaspike.test.utils.CdiContainerUnderTest;
 import org.jboss.arquillian.container.test.api.Deployment;
 import org.jboss.arquillian.junit.Arquillian;
 import org.jboss.shrinkwrap.api.ShrinkWrap;
@@ -32,27 +32,20 @@ import org.jboss.shrinkwrap.api.asset.StringAsset;
 import org.jboss.shrinkwrap.api.spec.JavaArchive;
 import org.jboss.shrinkwrap.api.spec.WebArchive;
 import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.Ignore;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 import org.junit.runner.RunWith;
 
 @RunWith(Arquillian.class)
-@Ignore("1) currently fails on wildfly/jboss because interceptors doesn't work on partial
beans"
-        + "2) arquillian doesn't deploy the TestPartialBeanProvider if tested != *-build-managed
profiles")
+@Category(WebEE7ProfileCategory.class)
+//weld creates synthetic BDAs for classes added via BeforeBeanDiscovery#addAnnotatedType
+//-> only globally enabled interceptors will get active for such beans
+//in case of ee7+ it works due to GlobalInterceptorExtension
 public class PartialBeanAsAbstractClassWithInterceptorTest
 {
-    public static final String CONTAINER_WELD_2_0_0 = "weld-2\\.0\\.0\\..*";
-
     @Deployment
     public static WebArchive war()
     {
-        // test doesn't work correclty on Weld 2.0.0 because PostConstruct isn't called on
the partial bean
-        if (CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0))
-        {
-            return ShrinkWrap.create(WebArchive.class, "empty.war");
-        }
-
         Asset beansXml = new StringAsset(
             "<beans><interceptors><class>" +
                     CustomInterceptorImpl.class.getName() +
@@ -77,8 +70,6 @@ public class PartialBeanAsAbstractClassWithInterceptorTest
     @Test
     public void testPartialBeanAsAbstractClassWithInterceptor() throws Exception
     {
-        Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0));
-
         PartialBean partialBean = BeanProvider.getContextualReference(PartialBean.class);
         Assert.assertNotNull(partialBean);
 


Mime
View raw message