openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1625021 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/config/BeansDeployer.java test/java/org/apache/webbeans/test/decorators/tests/GenericDecoratorTest.java
Date Mon, 15 Sep 2014 12:48:06 GMT
Author: struberg
Date: Mon Sep 15 12:48:05 2014
New Revision: 1625021

URL: http://svn.apache.org/r1625021
Log:
OWB-1006 decorator must implement at least one interface

txs to Reinhard Sandtner (rsandtner) for the patch!

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/decorators/tests/GenericDecoratorTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java?rev=1625021&r1=1625020&r2=1625021&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
Mon Sep 15 12:48:05 2014
@@ -254,6 +254,7 @@ public class BeansDeployer
                 validateInjectionPoints();
                 validateDisposeParameters();
 
+                validateDecoratorDecoratedTypes();
                 validateDecoratorGenericTypes();
 
                 // fire event
@@ -319,6 +320,22 @@ public class BeansDeployer
         }
     }
 
+
+    /**
+     * @throws DefinitionException if {@link javax.enterprise.inject.spi.Decorator#getDecoratedTypes()}
isEmpty
+     */
+    private void validateDecoratorDecoratedTypes()
+    {
+        for (Decorator decorator : webBeansContext.getDecoratorsManager().getDecorators())
+        {
+            if (decorator.getDecoratedTypes().isEmpty())
+            {
+                throw new DefinitionException("Decorator must implement at least one interface
(java.io.Serializeable will be ignored)");
+            }
+
+        }
+    }
+
     // avoid delegate implementing Foo<A> and decorator implementing Foo<B> with
no link between A and B
     private void validateDecoratorGenericTypes()
     {

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/decorators/tests/GenericDecoratorTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/decorators/tests/GenericDecoratorTest.java?rev=1625021&r1=1625020&r2=1625021&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/decorators/tests/GenericDecoratorTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/decorators/tests/GenericDecoratorTest.java
Mon Sep 15 12:48:05 2014
@@ -18,21 +18,14 @@
 */
 package org.apache.webbeans.test.decorators.tests;
 
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
 
-import javax.enterprise.inject.spi.Decorator;
-import javax.enterprise.util.TypeLiteral;
+import javax.enterprise.inject.spi.DefinitionException;
 
 import junit.framework.Assert;
 
 import org.apache.webbeans.test.AbstractUnitTest;
-import org.apache.webbeans.test.decorators.common.Cow;
 import org.apache.webbeans.test.decorators.common.Garphly;
 import org.apache.webbeans.test.decorators.common.GarphlyDecorator;
 import org.apache.webbeans.test.decorators.generic.DecoratedBean;
@@ -52,26 +45,23 @@ public class GenericDecoratorTest extend
     public void testGenericDecorator()
     {
         
-        TypeLiteral<Garphly<Cow>> GARPHLY_LITERAL = new TypeLiteral<Garphly<Cow>>()
-        {
-        };
-
         Collection<Class<?>> classes = new ArrayList<Class<?>>();
         classes.add(Garphly.class);
         classes.add(GarphlyDecorator.class);
         
         Collection<String> xmls = new ArrayList<String>();
         xmls.add(getXmlPath(PACKAGE_NAME, "GenericDecoratorTest"));
-        
-        startContainer(classes,xmls);
-        
-        Set<Type> types = new HashSet<Type>();
-        types.add(GARPHLY_LITERAL.getType());
-        List<Decorator<?>> decorators = getBeanManager().resolveDecorators(types,
new Annotation[]{});
-        
-        Assert.assertTrue(decorators.size() > 0);
-        
-        shutDownContainer();
+
+        try
+        {
+            startContainer(classes, xmls);
+            Assert.fail("DefinitionException expected");
+        }
+        catch (DefinitionException e)
+        {
+            // expected, all ok
+            shutDownContainer();
+        }
     }
 
     @Test



Mime
View raw message