Return-Path: X-Original-To: apmail-openwebbeans-commits-archive@www.apache.org Delivered-To: apmail-openwebbeans-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 28C89F8D7 for ; Mon, 29 Apr 2013 18:06:13 +0000 (UTC) Received: (qmail 80264 invoked by uid 500); 29 Apr 2013 18:06:13 -0000 Delivered-To: apmail-openwebbeans-commits-archive@openwebbeans.apache.org Received: (qmail 80243 invoked by uid 500); 29 Apr 2013 18:06:13 -0000 Mailing-List: contact commits-help@openwebbeans.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openwebbeans.apache.org Delivered-To: mailing list commits@openwebbeans.apache.org Received: (qmail 80233 invoked by uid 99); 29 Apr 2013 18:06:13 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Apr 2013 18:06:13 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Apr 2013 18:06:09 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 8B4452388A66; Mon, 29 Apr 2013 18:05:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@openwebbeans.apache.org From: struberg@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130429180548.8B4452388A66@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 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 annotatedType = getBeanManager().createAnnotatedType(SelfInterceptedClass.class); + + BeanAttributesImpl beanAttributes = BeanAttributesBuilder.forContext(getWebBeansContext()).newBeanAttibutes(annotatedType).build(); + + SelfInterceptorBeanBuilder ibb + = new SelfInterceptorBeanBuilder(getWebBeansContext(), annotatedType, beanAttributes); + ibb.defineSelfInterceptorRules(); + InterceptorBean 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; + } +}