openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1477238 - in /openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors: factory/beans/ resolution/ resolution/interceptors/
Date Mon, 29 Apr 2013 18:05:48 GMT
Author: struberg
Date: Mon Apr 29 18:05:48 2013
New Revision: 1477238

URL: http://svn.apache.org/r1477238
Log:
OWB-306 overridden self-interceptors should not run

this unit test proves that it's fixed already

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/interceptors/SelfInterceptionSubclass.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/ClassInterceptedClass.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/SelfInterceptorBeanBuilderTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/interceptors/SelfInterceptedClass.java

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/ClassInterceptedClass.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/ClassInterceptedClass.java?rev=1477238&r1=1477237&r2=1477238&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/ClassInterceptedClass.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/ClassInterceptedClass.java
Mon Apr 29 18:05:48 2013
@@ -61,7 +61,7 @@ public class ClassInterceptedClass
 
     public int getMeaningOfLife() throws NumberFormatException
     {
-        System.out.println("answering the question about life, the universe and everything!");
+        System.out.println("answeringowb-arquillian-parent the question about life, the universe
and everything!");
         System.out.println("and being in " + this.getClass());
         return meaningOfLife;
     }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/SelfInterceptorBeanBuilderTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/SelfInterceptorBeanBuilderTest.java?rev=1477238&r1=1477237&r2=1477238&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/SelfInterceptorBeanBuilderTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/SelfInterceptorBeanBuilderTest.java
Mon Apr 29 18:05:48 2013
@@ -28,6 +28,7 @@ import org.apache.webbeans.component.cre
 import org.apache.webbeans.component.creation.SelfInterceptorBeanBuilder;
 import org.apache.webbeans.newtests.AbstractUnitTest;
 import org.apache.webbeans.newtests.interceptors.resolution.interceptors.SelfInterceptedClass;
+import org.apache.webbeans.newtests.interceptors.resolution.interceptors.SelfInterceptionSubclass;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -55,6 +56,37 @@ public class SelfInterceptorBeanBuilderT
         InterceptorBean<SelfInterceptedClass> bean = ibb.getBean();
         Assert.assertNotNull(bean);
 
+        SelfInterceptedClass interceptedInstance = getInstance(SelfInterceptedClass.class);
+
+        SelfInterceptedClass.interceptionCount = 0;
+        interceptedInstance.someBusinessMethod();
+        Assert.assertEquals(42, interceptedInstance.getMeaningOfLife());
+        Assert.assertEquals(2, SelfInterceptedClass.interceptionCount);
+
+        shutDownContainer();
+    }
+
+    @Test
+    public void testDisablingByOverriding()
+    {
+        startContainer(SelfInterceptedClass.class, SelfInterceptionSubclass.class);
+
+        AnnotatedType<SelfInterceptedClass> annotatedType = getBeanManager().createAnnotatedType(SelfInterceptedClass.class);
+
+        BeanAttributesImpl<SelfInterceptedClass> beanAttributes = BeanAttributesBuilder.forContext(getWebBeansContext()).newBeanAttibutes(annotatedType).build();
+
+        SelfInterceptorBeanBuilder<SelfInterceptedClass> ibb
+                = new SelfInterceptorBeanBuilder<SelfInterceptedClass>(getWebBeansContext(),
annotatedType, beanAttributes);
+        ibb.defineSelfInterceptorRules();
+        InterceptorBean<SelfInterceptedClass> bean = ibb.getBean();
+        Assert.assertNotNull(bean);
+
+        SelfInterceptionSubclass interceptedInstance = getInstance(SelfInterceptionSubclass.class);
+
+        SelfInterceptedClass.interceptionCount = 0;
+        interceptedInstance.someBusinessMethod();
+        Assert.assertEquals(42, interceptedInstance.getMeaningOfLife());
+        Assert.assertEquals(0, SelfInterceptedClass.interceptionCount);
 
         shutDownContainer();
     }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/interceptors/SelfInterceptedClass.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/interceptors/SelfInterceptedClass.java?rev=1477238&r1=1477237&r2=1477238&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/interceptors/SelfInterceptedClass.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/interceptors/SelfInterceptedClass.java
Mon Apr 29 18:05:48 2013
@@ -18,12 +18,14 @@
  */
 package org.apache.webbeans.newtests.interceptors.resolution.interceptors;
 
+import javax.enterprise.context.RequestScoped;
 import javax.interceptor.AroundInvoke;
 import javax.interceptor.InvocationContext;
 
 /**
  * Sample bean which has an AroundInvoke interceptor on itself.
  */
+@RequestScoped
 public class SelfInterceptedClass
 {
     public static int interceptionCount = 0;
@@ -41,7 +43,7 @@ public class SelfInterceptedClass
     }
 
     @AroundInvoke
-    private Object interceptMe(InvocationContext ic) throws Exception
+    protected Object interceptMe(InvocationContext ic) throws Exception
     {
         interceptionCount++;
         return ic.proceed();

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/interceptors/SelfInterceptionSubclass.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/interceptors/SelfInterceptionSubclass.java?rev=1477238&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/interceptors/SelfInterceptionSubclass.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/interceptors/SelfInterceptionSubclass.java
Mon Apr 29 18:05:48 2013
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.newtests.interceptors.resolution.interceptors;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Typed;
+import javax.interceptor.InvocationContext;
+
+/**
+ *
+ */
+@RequestScoped
+@Typed(SelfInterceptionSubclass.class)
+public class SelfInterceptionSubclass extends SelfInterceptedClass
+{
+    /**
+     * This method overrides and thus disables the AroundInvoke method from the superclass.
+     * See Interceptors spec.
+     */
+    @Override
+    protected Object interceptMe(InvocationContext ic) throws Exception
+    {
+        // do nothing.
+        return null;
+    }
+}



Mime
View raw message