deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject git commit: DELTASPIKE-593 skip mocking support in case of ejbs
Date Fri, 23 May 2014 11:46:44 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 8bfcbb6e9 -> 98d9422b3


DELTASPIKE-593 skip mocking support in case of ejbs


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

Branch: refs/heads/master
Commit: 98d9422b3f66fba837399d2e33953f6106f2aa54
Parents: 8bfcbb6
Author: gpetracek <gpetracek@apache.org>
Authored: Fri May 23 13:42:23 2014 +0200
Committer: gpetracek <gpetracek@apache.org>
Committed: Fri May 23 13:42:23 2014 +0200

----------------------------------------------------------------------
 .../impl/mock/DefaultMockFilter.java            | 27 ++++++++++++--------
 1 file changed, 17 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/98d9422b/deltaspike/modules/test-control/impl/src/main/java/org/apache/deltaspike/testcontrol/impl/mock/DefaultMockFilter.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/main/java/org/apache/deltaspike/testcontrol/impl/mock/DefaultMockFilter.java
b/deltaspike/modules/test-control/impl/src/main/java/org/apache/deltaspike/testcontrol/impl/mock/DefaultMockFilter.java
index 3feecc2..2c1ff34 100644
--- a/deltaspike/modules/test-control/impl/src/main/java/org/apache/deltaspike/testcontrol/impl/mock/DefaultMockFilter.java
+++ b/deltaspike/modules/test-control/impl/src/main/java/org/apache/deltaspike/testcontrol/impl/mock/DefaultMockFilter.java
@@ -36,6 +36,7 @@ public class DefaultMockFilter implements MockFilter
     private static final String DS_BASE_PACKAGE = "org.apache.deltaspike.";
     private static final String JAVA_BASE_PACKAGE = "java.";
     private static final String JAVAX_BASE_PACKAGE = "javax.";
+    private static final String EJB_BASE_PACKAGE = "javax.ejb.";
     private static final String OWB_BASE_PACKAGE = "org.apache.webbeans.";
     private static final String WELD_BASE_PACKAGE = "org.jboss.weld.";
 
@@ -45,9 +46,9 @@ public class DefaultMockFilter implements MockFilter
         Class origin = null;
         if (annotated instanceof AnnotatedType)
         {
-
             origin = ((AnnotatedType)annotated).getJavaClass();
-            if (isAnnotatedTypeWithInterceptorAnnotation(beanManager, annotated.getAnnotations(),
origin.getName()))
+            if (isEjbOrAnnotatedTypeWithInterceptorAnnotation(
+                beanManager, annotated.getAnnotations(), origin.getName()))
             {
                 return false;
             }
@@ -56,7 +57,8 @@ public class DefaultMockFilter implements MockFilter
         {
             Member member = ((AnnotatedMember)annotated).getJavaMember();
             origin = member.getDeclaringClass();
-            if (isAnnotatedTypeWithInterceptorAnnotation(beanManager, annotated.getAnnotations(),
member.toString()))
+            if (isEjbOrAnnotatedTypeWithInterceptorAnnotation(
+                beanManager, annotated.getAnnotations(), member.toString()))
             {
                 return false;
             }
@@ -65,20 +67,25 @@ public class DefaultMockFilter implements MockFilter
         return origin != null && !isInternalPackage(origin.getPackage().getName());
     }
 
-    protected boolean isAnnotatedTypeWithInterceptorAnnotation(BeanManager beanManager,
-                                                               Set<Annotation> annotations,
-                                                               String origin)
+    protected boolean isEjbOrAnnotatedTypeWithInterceptorAnnotation(BeanManager beanManager,
+                                                                    Set<Annotation>
annotations,
+                                                                    String origin)
     {
         for (Annotation annotation : annotations)
         {
+            if (annotation.annotationType().getName().startsWith(EJB_BASE_PACKAGE))
+            {
+                return true;
+            }
+
             if (isStandardAnnotation(annotation))
             {
                 continue;
             }
 
             if (beanManager.isInterceptorBinding(annotation.annotationType()) ||
-                    (beanManager.isStereotype(annotation.annotationType()) &&
-                            isStereotypeWithInterceptor(annotation, beanManager)))
+                (beanManager.isStereotype(annotation.annotationType()) &&
+                    isStereotypeWithInterceptor(annotation, beanManager)))
             {
                 LOG.warning("Skip mocking intercepted bean " + origin);
 
@@ -98,7 +105,7 @@ public class DefaultMockFilter implements MockFilter
             }
 
             if (beanManager.isInterceptorBinding(annotation.annotationType()) ||
-                    isStereotypeWithInterceptor(annotation, beanManager))
+                isStereotypeWithInterceptor(annotation, beanManager))
             {
                 return true;
             }
@@ -109,7 +116,7 @@ public class DefaultMockFilter implements MockFilter
     protected boolean isStandardAnnotation(Annotation annotation)
     {
         return annotation.annotationType().getName().startsWith(JAVA_BASE_PACKAGE) ||
-                annotation.annotationType().getName().startsWith(JAVAX_BASE_PACKAGE);
+            annotation.annotationType().getName().startsWith(JAVAX_BASE_PACKAGE);
     }
 
     protected boolean isInternalPackage(String packageName)


Mime
View raw message