openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1436265 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/intercept/ main/java/org/apache/webbeans/proxy/ main/java/org/apache/webbeans/util/ test/java/org/apache/webbeans/newtests/ test/java/org/apache/webbeans/new...
Date Mon, 21 Jan 2013 10:35:22 GMT
Author: struberg
Date: Mon Jan 21 10:35:21 2013
New Revision: 1436265

URL: http://svn.apache.org/viewvc?rev=1436265&view=rev
Log:
OWB-344 fix for TCK: detect decoration of final method and throw deployment error

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/FinalMethodDecoratedBean.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/SomeBrokenDecorated.java
  (contents, props changed)
      - copied, changed from r1436233, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/BrokenBean.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/ValidDecorator.java
Removed:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/BrokenBean.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/NormalScopeProxyFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/SubclassProxyFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/AbstractUnitTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/BrokenAlternative.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/BrokenScope.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/BrokenDecoratorTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/InterceptorDecoratorProxyFactoryTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java?rev=1436265&r1=1436264&r2=1436265&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
Mon Jan 21 10:35:21 2013
@@ -116,7 +116,7 @@ public class InterceptorResolutionServic
         // pick up EJB-style interceptors from a class level
         List<Interceptor<?>> classLevelEjbInterceptors = new ArrayList<Interceptor<?>>();
 
-        collectEjbInterceptors(classLevelEjbInterceptors, annotatedType);
+        collectEjbInterceptors(classLevelEjbInterceptors, annotatedType, false);
 
         // pick up the decorators
         List<Decorator<?>> decorators = beanManager.resolveDecorators(beanTypes,
AnnotationUtil.asArray(qualifiers));
@@ -274,11 +274,16 @@ public class InterceptorResolutionServic
         }
     }
 
-    private <T> void collectEjbInterceptors(List<Interceptor<?>> ejbInterceptors,
Annotated annotatedType)
+    private <T> void collectEjbInterceptors(List<Interceptor<?>> ejbInterceptors,
Annotated annotated, boolean unproxyable)
     {
-        Interceptors interceptorsAnnot = annotatedType.getAnnotation(Interceptors.class);
+        Interceptors interceptorsAnnot = annotated.getAnnotation(Interceptors.class);
         if (interceptorsAnnot != null)
         {
+            if (unproxyable)
+            {
+                throw new WebBeansConfigurationException(annotated + " is not proxyable,
but an Interceptor got defined on it!");
+            }
+
             for (Class interceptorClass : interceptorsAnnot.value())
             {
                 Interceptor ejbInterceptor = webBeansContext.getInterceptorsManager().getEjbInterceptorForClass(interceptorClass);
@@ -290,9 +295,11 @@ public class InterceptorResolutionServic
     private void calculateEjbMethodInterceptors(BusinessMethodInterceptorInfo methodInterceptorInfo,
Set<Interceptor<?>> allUsedEjbInterceptors,
                                                 List<Interceptor<?>> classLevelEjbInterceptors,
AnnotatedMethod annotatedMethod)
     {
+        boolean unproxyable = isUnproxyable(annotatedMethod);
+
         List<Interceptor<?>> methodInterceptors = new ArrayList<Interceptor<?>>();
 
-        if (classLevelEjbInterceptors != null && classLevelEjbInterceptors.size()
> 0)
+        if (classLevelEjbInterceptors != null && classLevelEjbInterceptors.size()
> 0 && !unproxyable)
         {
             // add the class level defined Interceptors first
 
@@ -304,7 +311,7 @@ public class InterceptorResolutionServic
             }
         }
 
-        collectEjbInterceptors(methodInterceptors, annotatedMethod);
+        collectEjbInterceptors(methodInterceptors, annotatedMethod, unproxyable);
         allUsedEjbInterceptors.addAll(methodInterceptors);
 
         if (methodInterceptors.size() > 0)
@@ -313,6 +320,12 @@ public class InterceptorResolutionServic
         }
     }
 
+    private boolean isUnproxyable(AnnotatedMethod annotatedMethod)
+    {
+        int modifiers = annotatedMethod.getJavaMember().getModifiers();
+        return Modifier.isFinal(modifiers) || Modifier.isPrivate(modifiers);
+    }
+
 
     private void calculateCdiMethodDecorators(BusinessMethodInterceptorInfo methodInterceptorInfo,
List<Decorator<?>> decorators, AnnotatedMethod annotatedMethod)
     {
@@ -328,6 +341,11 @@ public class InterceptorResolutionServic
             Method decoratingMethod = getDecoratingMethod(decorator, annotatedMethod);
             if (decoratingMethod != null)
             {
+                if (isUnproxyable(annotatedMethod))
+                {
+                    throw new WebBeansConfigurationException(annotatedMethod + " is not proxyable,
but an Decorator got defined on it!");
+                }
+
                 appliedDecorators.put(decorator, decoratingMethod);
             }
         }
@@ -447,10 +465,26 @@ public class InterceptorResolutionServic
     {
         AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
 
+        boolean unproxyable = isUnproxyable(annotatedMethod);
+
         Set<Annotation> cummulatedInterceptorBindings = new HashSet<Annotation>();
         cummulatedInterceptorBindings.addAll(
                 annotationManager.getInterceptorAnnotations(annotatedMethod.getAnnotations()));
 
+        if (unproxyable && cummulatedInterceptorBindings.size() > 0)
+        {
+            if (unproxyable)
+            {
+                throw new WebBeansConfigurationException(annotatedMethod + " is not proxyable,
but an Interceptor got defined on it!");
+            }
+        }
+
+        if (unproxyable)
+        {
+            // don't apply class level interceptors - instead just return
+            return;
+        }
+
         cummulatedInterceptorBindings.addAll(classInterceptorBindings);
 
         if (cummulatedInterceptorBindings.size() == 0)
@@ -517,7 +551,7 @@ public class InterceptorResolutionServic
      */
     private List<AnnotatedMethod> getInterceptableBusinessMethods(AnnotatedType annotatedType)
     {
-        List<Method> interceptableMethods = ClassUtil.getNonPrivateMethods(annotatedType.getJavaClass());
+        List<Method> interceptableMethods = ClassUtil.getNonPrivateMethods(annotatedType.getJavaClass(),
false);
 
         List<AnnotatedMethod> interceptableAnnotatedMethods = new ArrayList<AnnotatedMethod>();
 
@@ -528,7 +562,8 @@ public class InterceptorResolutionServic
             {
                 if (annotatedMethod.getJavaMember().equals(interceptableMethod))
                 {
-                    if (!webBeansContext.getInterceptorUtil().isWebBeansBusinessMethod(annotatedMethod))
+                    int modifiers = annotatedMethod.getJavaMember().getModifiers();
+                    if (Modifier.isPrivate(modifiers) || Modifier.isStatic(modifiers))
                     {
                         // we must only intercept business methods
                         continue;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java?rev=1436265&r1=1436264&r2=1436265&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java
Mon Jan 21 10:35:21 2013
@@ -36,11 +36,6 @@ import org.apache.webbeans.util.Asserts;
 public final class InterceptorUtil
 {
 
-    /**
-     * all the bit flags of private static and final modifiers
-     */
-    public static final int MODIFIER_STATIC_FINAL_PRIVATE = Modifier.STATIC | Modifier.FINAL
| Modifier.PRIVATE;
-
     private final WebBeansContext webBeansContext;
 
     public InterceptorUtil(WebBeansContext webBeansContext)
@@ -96,26 +91,6 @@ public final class InterceptorUtil
         return lifecycleMethods;
     }
 
-    /**
-     * Check if the given method is a 'business method'
-     * in the sense of the Interceptor specification
-     * @param annotatedMethod
-     * @return <code>true</code> if the given method is an interceptable business
method
-     */
-    public boolean isWebBeansBusinessMethod(AnnotatedMethod annotatedMethod)
-    {
-        Method method = annotatedMethod.getJavaMember();
-        int modifiers = method.getModifiers();
-
-        if ((modifiers & MODIFIER_STATIC_FINAL_PRIVATE) != 0)
-        {
-            // static, final and private methods are NO business methods!
-            return false;
-        }
-
-        return true;
-    }
-
     public void checkSimpleWebBeansInterceptorConditions(Class<?> clazz)
     {
         Asserts.nullCheckForClass(clazz);

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java?rev=1436265&r1=1436264&r2=1436265&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
Mon Jan 21 10:35:21 2013
@@ -58,11 +58,13 @@ public final class WebBeansInterceptorCo
     }
 
     /**
+     * TODO: move this method to some other, better place!
+     *
+     * Configure bean instance interceptor stack.
+     *
      * This method gets invoked in the ValidateBean phase and will fill all the
      * interceptor information into the given InjectionTargetBean
      *
-     * TODO: move this method to some other, better place!
-     * Configure bean instance interceptor stack.
      * @param bean bean instance
      */
     public void defineBeanInterceptorStack(InjectionTargetBean<?> bean)
@@ -73,10 +75,7 @@ public final class WebBeansInterceptorCo
             BeanInterceptorInfo interceptorInfo = webBeansContext.getInterceptorResolutionService().
                     calculateInterceptorInfo(bean.getTypes(), bean.getQualifiers(), bean.getAnnotatedType());
 
-            //X TODO decorator stack
-
             Map<Method, List<Interceptor<?>>> methodInterceptors = new
HashMap<Method, List<Interceptor<?>>>();
-            List<Method> nonBusinessMethods = new ArrayList<Method>();
             for (Map.Entry<Method, BusinessMethodInterceptorInfo> miEntry : interceptorInfo.getBusinessMethodsInfo().entrySet())
             {
                 Method interceptedMethod = miEntry.getKey();
@@ -138,10 +137,7 @@ public final class WebBeansInterceptorCo
 
                 injectionTarget.setInterceptorInfo(interceptorInfo, proxyClass, methodInterceptors,
postConstructInterceptors, preDestroyInterceptors);
             }
-            else // we have no interceptors so we have to define lifecycle methods
-            {
-                
-            }
+
         }
 
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java?rev=1436265&r1=1436264&r2=1436265&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
Mon Jan 21 10:35:21 2013
@@ -25,6 +25,7 @@ import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 
 import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.util.ExceptionUtil;
 import org.objectweb.asm.ClassWriter;
 import org.objectweb.asm.Label;
@@ -330,6 +331,12 @@ public class InterceptorDecoratorProxyFa
         final Class<?>[] exceptionTypes = method.getExceptionTypes();
         final int modifiers = method.getModifiers();
 
+        if (Modifier.isFinal(modifiers) || Modifier.isStatic(modifiers))
+        {
+            throw new WebBeansConfigurationException("It's not possible to proxy a final
or static method: " + classToProxy.getName() +
+                                                     " " + method.getName());
+        }
+
         // push the method definition
         int modifier = modifiers & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED);
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/NormalScopeProxyFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/NormalScopeProxyFactory.java?rev=1436265&r1=1436264&r2=1436265&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/NormalScopeProxyFactory.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/NormalScopeProxyFactory.java
Mon Jan 21 10:35:21 2013
@@ -202,7 +202,7 @@ public class NormalScopeProxyFactory ext
         }
         else
         {
-            List<Method> methods = ClassUtil.getNonPrivateMethods(classToProxy);
+            List<Method> methods = ClassUtil.getNonPrivateMethods(classToProxy, true);
             nonInterceptedMethods = methods.toArray(new Method[methods.size()]);
         }
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/SubclassProxyFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/SubclassProxyFactory.java?rev=1436265&r1=1436264&r2=1436265&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/SubclassProxyFactory.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/SubclassProxyFactory.java
Mon Jan 21 10:35:21 2013
@@ -107,7 +107,7 @@ public class SubclassProxyFactory extend
 
         String proxyClassName = getSubClassName(classToProxy);
 
-        List<Method> methods = ClassUtil.getNonPrivateMethods(classToProxy);
+        List<Method> methods = ClassUtil.getNonPrivateMethods(classToProxy, true);
         Method[] businessMethods = methods.toArray(new Method[methods.size()]);
 
         clazz = createProxyClass(classLoader, proxyClassName, classToProxy, businessMethods,
new Method[0]);

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java?rev=1436265&r1=1436264&r2=1436265&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
Mon Jan 21 10:35:21 2013
@@ -241,7 +241,7 @@ public final class ClassUtil
      *
      * Note: we filter out the {@link Object#finalize()} method as users must not deal with
it
      */
-    public static List<Method> getNonPrivateMethods(Class<?> clazz)
+    public static List<Method> getNonPrivateMethods(Class<?> clazz, boolean noFinalMethods)
     {
         Map<String, List<Method>> methodMap = new HashMap<String, List<Method>>();
         List<Method> allMethods = new ArrayList<Method>(10);
@@ -252,8 +252,11 @@ public final class ClassUtil
             {
                 final int modifiers = method.getModifiers();
 
-                if (Modifier.isFinal(modifiers) || Modifier.isPrivate(modifiers) ||
-                    Modifier.isStatic(modifiers) || Modifier.isAbstract(modifiers))
+                if (Modifier.isPrivate(modifiers) || Modifier.isStatic(modifiers) || Modifier.isAbstract(modifiers))
+                {
+                    continue;
+                }
+                if (noFinalMethods && Modifier.isFinal(modifiers))
                 {
                     continue;
                 }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/AbstractUnitTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/AbstractUnitTest.java?rev=1436265&r1=1436264&r2=1436265&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/AbstractUnitTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/AbstractUnitTest.java
Mon Jan 21 10:35:21 2013
@@ -74,7 +74,7 @@ public abstract class AbstractUnitTest
 
     protected void startContainer(Class<?>... beanClasses)
     {
-        startContainer(Arrays.asList(beanClasses), null);
+        startContainer(new ArrayList<Class<?>>(Arrays.asList(beanClasses)), null);
     }
 
     protected void startContainer(Collection<Class<?>> beanClasses)

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/BrokenAlternative.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/BrokenAlternative.java?rev=1436265&r1=1436264&r2=1436265&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/BrokenAlternative.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/BrokenAlternative.java
Mon Jan 21 10:35:21 2013
@@ -32,8 +32,7 @@ public class BrokenAlternative implement
     @Override
     public void broke()
     {
-        // TODO Auto-generated method stub
-        
+
     }
 
 }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/BrokenScope.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/BrokenScope.java?rev=1436265&r1=1436264&r2=1436265&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/BrokenScope.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/BrokenScope.java
Mon Jan 21 10:35:21 2013
@@ -28,7 +28,7 @@ import javax.inject.Inject;
 @RequestScoped
 public class BrokenScope implements IBroken
 {
-    private @Inject @Delegate IBroken borken;
+    private @Inject @Delegate IBroken broken;
     
     @Override
     public void broke()

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/FinalMethodDecoratedBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/FinalMethodDecoratedBean.java?rev=1436265&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/FinalMethodDecoratedBean.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/FinalMethodDecoratedBean.java
Mon Jan 21 10:35:21 2013
@@ -0,0 +1,31 @@
+/*
+ * 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.decorators.broken;
+
+/**
+ *
+ */
+public class FinalMethodDecoratedBean implements IBroken
+{
+    @Override
+    public final void broke()
+    {
+        System.out.println("this should not get reached at all!");
+    }
+}

Copied: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/SomeBrokenDecorated.java
(from r1436233, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/BrokenBean.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/SomeBrokenDecorated.java?p2=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/SomeBrokenDecorated.java&p1=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/BrokenBean.java&r1=1436233&r2=1436265&rev=1436265&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/BrokenBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/SomeBrokenDecorated.java
Mon Jan 21 10:35:21 2013
@@ -18,7 +18,7 @@
  */
 package org.apache.webbeans.newtests.decorators.broken;
 
-public class BrokenBean implements IBroken
+public class SomeBrokenDecorated implements IBroken
 {
 
     @Override

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/SomeBrokenDecorated.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/ValidDecorator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/ValidDecorator.java?rev=1436265&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/ValidDecorator.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/broken/ValidDecorator.java
Mon Jan 21 10:35:21 2013
@@ -0,0 +1,40 @@
+/*
+ * 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.decorators.broken;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.inject.Inject;
+
+/**
+ * In this test not the decorator is broken, but the decorated bean is.
+ */
+@Decorator
+public class ValidDecorator implements IBroken
+{
+    @Inject
+    @Delegate
+    private IBroken broken;
+
+    @Override
+    public void broke()
+    {
+        broken.broke();
+    }
+}

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/BrokenDecoratorTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/BrokenDecoratorTest.java?rev=1436265&r1=1436264&r2=1436265&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/BrokenDecoratorTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/BrokenDecoratorTest.java
Mon Jan 21 10:35:21 2013
@@ -21,11 +21,16 @@ package org.apache.webbeans.newtests.dec
 import java.util.ArrayList;
 import java.util.Collection;
 
+import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.newtests.AbstractUnitTest;
 import org.apache.webbeans.newtests.decorators.broken.BrokenAlternative;
-import org.apache.webbeans.newtests.decorators.broken.BrokenBean;
+import org.apache.webbeans.newtests.decorators.broken.FinalMethodDecoratedBean;
+import org.apache.webbeans.newtests.decorators.broken.SomeBrokenDecorated;
 import org.apache.webbeans.newtests.decorators.broken.BrokenName;
 import org.apache.webbeans.newtests.decorators.broken.BrokenScope;
+import org.apache.webbeans.newtests.decorators.broken.ValidDecorator;
+
+import org.junit.Assert;
 import org.junit.Test;
 
 public class BrokenDecoratorTest extends AbstractUnitTest
@@ -36,17 +41,28 @@ public class BrokenDecoratorTest extends
     public void testWarnings()
     {
         Collection<Class<?>> classes = new ArrayList<Class<?>>();
-        classes.add(BrokenBean.class);
+        classes.add(SomeBrokenDecorated.class);
         classes.add(BrokenScope.class);
         classes.add(BrokenAlternative.class);
         classes.add(BrokenName.class);
         
         Collection<String> xmls = new ArrayList<String>();
         xmls.add(getXmlPath(PACKAGE_NAME, "BrokenDecoratorTest"));
-        
-        startContainer(classes,xmls);
-                
+
+        startContainer(classes, xmls);
+
+
+
         shutDownContainer();
-        
+    }
+
+    @Test(expected = WebBeansConfigurationException.class)
+    public void testDecoratingFinalMethod() throws Exception
+    {
+        addDecorator(ValidDecorator.class);
+
+        startContainer(FinalMethodDecoratedBean.class);
+
+        Assert.fail("this point should not get reached because we had a final method decorated");
     }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/InterceptorDecoratorProxyFactoryTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/InterceptorDecoratorProxyFactoryTest.java?rev=1436265&r1=1436264&r2=1436265&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/InterceptorDecoratorProxyFactoryTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/InterceptorDecoratorProxyFactoryTest.java
Mon Jan 21 10:35:21 2013
@@ -53,7 +53,7 @@ public class InterceptorDecoratorProxyFa
         // we take a fresh URLClassLoader to not blur the test classpath with synthetic classes.
         ClassLoader classLoader = new URLClassLoader(new URL[0]);
 
-        List<Method> methods = ClassUtil.getNonPrivateMethods(ClassInterceptedClass.class);
+        List<Method> methods = ClassUtil.getNonPrivateMethods(ClassInterceptedClass.class,
true);
 
         Method[] interceptedMethods = methods.toArray(new Method[methods.size()]);
         Method[] nonInterceptedMethods = null;



Mime
View raw message