openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1214963 - in /openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb: EjbInterceptor.java EjbInterceptorTest.java ManagedBeanWithEjbInterceptor.java ManagedBeanWithMethodEjbInterceptor.java
Date Thu, 15 Dec 2011 21:45:59 GMT
Author: struberg
Date: Thu Dec 15 21:45:58 2011
New Revision: 1214963

URL: http://svn.apache.org/viewvc?rev=1214963&view=rev
Log:
OWB-634 review @Interceptors tests

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb/ManagedBeanWithMethodEjbInterceptor.java
      - copied, changed from r1214147, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb/ManagedBeanWithEjbInterceptor.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb/EjbInterceptor.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb/EjbInterceptorTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb/ManagedBeanWithEjbInterceptor.java

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb/EjbInterceptor.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb/EjbInterceptor.java?rev=1214963&r1=1214962&r2=1214963&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb/EjbInterceptor.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb/EjbInterceptor.java
Thu Dec 15 21:45:58 2011
@@ -33,8 +33,7 @@ public class EjbInterceptor
     @AroundInvoke
     public Object caller(InvocationContext context) throws Exception
     {        
-        System.out.println(bean);
-        CALLED = true;        
+        CALLED = true;
         return context.proceed();
     }
     

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb/EjbInterceptorTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb/EjbInterceptorTest.java?rev=1214963&r1=1214962&r2=1214963&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb/EjbInterceptorTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb/EjbInterceptorTest.java
Thu Dec 15 21:45:58 2011
@@ -20,10 +20,6 @@ package org.apache.webbeans.newtests.int
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Set;
-
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.spi.Bean;
 
 import junit.framework.Assert;
 
@@ -36,7 +32,6 @@ public class EjbInterceptorTest extends 
 {
 
     @Test
-    @SuppressWarnings("unchecked")
     public void testEjbInterceptor()
     {
         Collection<String> beanXmls = new ArrayList<String>();
@@ -47,18 +42,40 @@ public class EjbInterceptorTest extends 
         beanClasses.add(EjbInterceptor.class);
         
         startContainer(beanClasses, beanXmls);        
-        
-        Set<Bean<?>> beans = getBeanManager().getBeans("org.apache.webbeans.newtests.interceptors.ejb.ManagedBeanWithEjbInterceptor");
-        Assert.assertNotNull(beans);        
-        Bean<ManagedBeanWithEjbInterceptor> bean = (Bean<ManagedBeanWithEjbInterceptor>)beans.iterator().next();
-        
-        CreationalContext<ManagedBeanWithEjbInterceptor> ctx = getBeanManager().createCreationalContext(bean);
-        
-        ManagedBeanWithEjbInterceptor reference = (ManagedBeanWithEjbInterceptor)getBeanManager().getReference(bean,
ManagedBeanWithEjbInterceptor.class, ctx);
+
+        ManagedBeanWithEjbInterceptor reference = getInstance(ManagedBeanWithEjbInterceptor.class);
         Assert.assertNotNull(reference);
-        
+
+        EjbInterceptor.CALLED = false;
         reference.sayHello();
+        Assert.assertTrue(EjbInterceptor.CALLED);
         
         shutDownContainer();
     }
+
+    @Test
+    public void testEjbMethodInterceptor()
+    {
+        Collection<String> beanXmls = new ArrayList<String>();
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        beanClasses.add(RequestScopedBean.class);
+        beanClasses.add(ManagedBeanWithMethodEjbInterceptor.class);
+        beanClasses.add(ApplicationScopedBean.class);
+        beanClasses.add(EjbInterceptor.class);
+
+        startContainer(beanClasses, beanXmls);
+
+        ManagedBeanWithMethodEjbInterceptor reference = getInstance(ManagedBeanWithMethodEjbInterceptor.class);
+        Assert.assertNotNull(reference);
+
+        EjbInterceptor.CALLED = false;
+        reference.sayHello();
+        Assert.assertTrue(EjbInterceptor.CALLED);
+
+        EjbInterceptor.CALLED = false;
+        reference.uninterceptedAction();
+        Assert.assertFalse(EjbInterceptor.CALLED);
+
+        shutDownContainer();
+    }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb/ManagedBeanWithEjbInterceptor.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb/ManagedBeanWithEjbInterceptor.java?rev=1214963&r1=1214962&r2=1214963&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb/ManagedBeanWithEjbInterceptor.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb/ManagedBeanWithEjbInterceptor.java
Thu Dec 15 21:45:58 2011
@@ -18,11 +18,12 @@
  */
 package org.apache.webbeans.newtests.interceptors.ejb;
 
+import javax.enterprise.context.RequestScoped;
 import javax.inject.Named;
 import javax.interceptor.Interceptors;
 
 @Interceptors(value={EjbInterceptor.class})
-@Named("org.apache.webbeans.newtests.interceptors.ejb.ManagedBeanWithEjbInterceptor")
+@RequestScoped
 public class ManagedBeanWithEjbInterceptor
 {        
     public void sayHello()

Copied: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb/ManagedBeanWithMethodEjbInterceptor.java
(from r1214147, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb/ManagedBeanWithEjbInterceptor.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb/ManagedBeanWithMethodEjbInterceptor.java?p2=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb/ManagedBeanWithMethodEjbInterceptor.java&p1=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb/ManagedBeanWithEjbInterceptor.java&r1=1214147&r2=1214963&rev=1214963&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb/ManagedBeanWithEjbInterceptor.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/ejb/ManagedBeanWithMethodEjbInterceptor.java
Thu Dec 15 21:45:58 2011
@@ -18,15 +18,21 @@
  */
 package org.apache.webbeans.newtests.interceptors.ejb;
 
+import javax.enterprise.context.RequestScoped;
 import javax.inject.Named;
 import javax.interceptor.Interceptors;
 
-@Interceptors(value={EjbInterceptor.class})
-@Named("org.apache.webbeans.newtests.interceptors.ejb.ManagedBeanWithEjbInterceptor")
-public class ManagedBeanWithEjbInterceptor
-{        
-    public void sayHello()
+@RequestScoped
+public class ManagedBeanWithMethodEjbInterceptor
+{
+    @Interceptors(value={EjbInterceptor.class})
+    public int sayHello()
     {
-        
+        return 42;
+    }
+
+    public int uninterceptedAction()
+    {
+        return 21;
     }
 }



Mime
View raw message