openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1429386 - in /openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors: factory/beans/MethodInterceptedClass.java resolution/InterceptorResolutionTest.java
Date Sat, 05 Jan 2013 21:02:17 GMT
Author: struberg
Date: Sat Jan  5 21:02:17 2013
New Revision: 1429386

URL: http://svn.apache.org/viewvc?rev=1429386&view=rev
Log:
OWB-344 add unit test for method-level interceptors

Modified:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/MethodInterceptedClass.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/MethodInterceptedClass.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/MethodInterceptedClass.java?rev=1429386&r1=1429385&r2=1429386&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/MethodInterceptedClass.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/MethodInterceptedClass.java
Sat Jan  5 21:02:17 2013
@@ -19,6 +19,7 @@
 package org.apache.webbeans.newtests.interceptors.factory.beans;
 
 import org.apache.webbeans.test.component.intercept.webbeans.bindings.Transactional;
+import org.apache.webbeans.test.component.intercept.webbeans.bindings.Secure;
 
 /**
  * A simple class which is not intercepted but has some
@@ -44,6 +45,7 @@ public class MethodInterceptedClass
     }
 
     @Transactional
+    @Secure
     public void setMeaningOfLife(int meaningOfLife)
     {
         this.meaningOfLife = meaningOfLife;

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionTest.java?rev=1429386&r1=1429385&r2=1429386&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionTest.java
Sat Jan  5 21:02:17 2013
@@ -29,6 +29,7 @@ import org.apache.webbeans.newtests.Abst
 import org.apache.webbeans.newtests.interceptors.factory.beans.ClassInterceptedClass;
 
 import org.apache.webbeans.newtests.interceptors.factory.beans.ClassMultiInterceptedClass;
+import org.apache.webbeans.newtests.interceptors.factory.beans.MethodInterceptedClass;
 import org.apache.webbeans.test.component.intercept.webbeans.ActionInterceptor;
 import org.apache.webbeans.test.component.intercept.webbeans.SecureInterceptor;
 import org.apache.webbeans.test.component.intercept.webbeans.TransactionalInterceptor;
@@ -123,5 +124,50 @@ public class InterceptorResolutionTest  
         shutDownContainer();
     }
 
+    @Test
+    public void testMethodLevelInterceptor() throws Exception
+    {
+        Collection<String> beanXmls = new ArrayList<String>();
+        beanXmls.add(getXmlPath(this.getClass().getPackage().getName(), this.getClass().getSimpleName()));
+
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        beanClasses.add(MethodInterceptedClass.class);
+        beanClasses.add(Transactional.class);
+        beanClasses.add(Secure.class);
+        beanClasses.add(SecureInterceptor.class);
+        beanClasses.add(TransactionalInterceptor.class);
+
+        startContainer(beanClasses, beanXmls);
+
+        InterceptorResolution ir = new InterceptorResolution(getWebBeansContext());
+        AnnotatedType<MethodInterceptedClass> annotatedType = getBeanManager().createAnnotatedType(MethodInterceptedClass.class);
+
+        InterceptorResolution.BeanInterceptorInfo interceptorInfo = ir.calculateInterceptorInfo(annotatedType);
+        Assert.assertNotNull(interceptorInfo);
+
+        Assert.assertNotNull(interceptorInfo.getInterceptors());
+        Assert.assertEquals(2, interceptorInfo.getInterceptors().size());
+
+        Assert.assertNull(interceptorInfo.getDecorators());
+
+        Map<Method, InterceptorResolution.MethodInterceptorInfo> methodInterceptorInfos
= interceptorInfo.getMethodsInfo();
+        Assert.assertNotNull(methodInterceptorInfos);
+        Assert.assertEquals(2, methodInterceptorInfos.size());
+
+        for (Map.Entry<Method, InterceptorResolution.MethodInterceptorInfo> mi : methodInterceptorInfos.entrySet())
+        {
+            if (mi.getKey().getName().equals("getMeaningOfLife"))
+            {
+                Assert.assertEquals(1, mi.getValue().getMethodCdiInterceptors().size());
+            }
+            else if (mi.getKey().getName().equals("setMeaningOfLife"))
+            {
+                Assert.assertEquals(2, mi.getValue().getMethodCdiInterceptors().size());
+            }
+        }
+
+        shutDownContainer();
+    }
+
 
 }



Mime
View raw message