I'll be the first to admit I'm not very familiar with this code area, but
is it possible that this change could mean that we miss @Specializes added
to the AnnotatedType classes in the super class hierarchy, as you are
walking up the class objects themselves looking for the annotation?

On Wed, Dec 18, 2013 at 1:20 PM, <[email protected]> wrote:

> Author: tandraschko
> Date: Wed Dec 18 18:20:42 2013
> New Revision: 1552050
>
> URL: http://svn.apache.org/r1552050
> Log:
> OWB-917 - Multiple specialization doesn't work
>
> Modified:
>
> openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java
>
> openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/multiple/MultipleSpecializationTest.java
>
> Modified:
> openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java
> URL:
> http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java?rev=1552050&r1=1552049&r2=1552050&view=diff
>
> ==============================================================================
> ---
> openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java
> (original)
> +++
> openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java
> Wed Dec 18 18:20:42 2013
> @@ -511,8 +511,15 @@ public abstract class BeanAttributesBuil
>          {
>              if (getAnnotated().isAnnotationPresent(Specializes.class))
>              {
> -                AnnotatedType<? super C> superAnnotated =
> getSuperAnnotated();
> -                defineName(superAnnotated,
> WebBeansUtil.getManagedBeanDefaultName(superAnnotated.getJavaClass().getSimpleName()));
> +                Class<? super C> classToSpecialize =
> getAnnotated().getJavaClass().getSuperclass();
> +
> +                while
> (classToSpecialize.isAnnotationPresent(Specializes.class))
> +                {
> +                    classToSpecialize = classToSpecialize.getSuperclass();
> +                }
> +
> +                AnnotatedType<? super C> annotatedToSpecialize =
> webBeansContext.getAnnotatedElementFactory().newAnnotatedType(classToSpecialize);
> +                defineName(annotatedToSpecialize,
> WebBeansUtil.getManagedBeanDefaultName(classToSpecialize.getSimpleName()));
>              }
>              if (name == null)
>              {
>
> Modified:
> openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/multiple/MultipleSpecializationTest.java
> URL:
> http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/multiple/MultipleSpecializationTest.java?rev=1552050&r1=1552049&r2=1552050&view=diff
>
> ==============================================================================
> ---
> openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/multiple/MultipleSpecializationTest.java
> (original)
> +++
> openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/multiple/MultipleSpecializationTest.java
> Wed Dec 18 18:20:42 2013
> @@ -22,6 +22,7 @@ import java.util.ArrayList;
>  import java.util.Collection;
>  import junit.framework.Assert;
>  import org.apache.webbeans.exception.WebBeansConfigurationException;
> +import org.apache.webbeans.exception.inject.DefinitionException;
>  import
> org.apache.webbeans.exception.inject.InconsistentSpecializationException;
>  import org.apache.webbeans.newtests.AbstractUnitTest;
>  import org.junit.Test;
> @@ -31,7 +32,7 @@ public class MultipleSpecializationTest
>      /**
>       * Tests that multiple specialization must be possible
>       */
> -    //@Test
> +    @Test
>      public void testMultipleSpecialization()
>      {
>          Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
> @@ -53,9 +54,11 @@ public class MultipleSpecializationTest
>      /**
>       * Tests that a specialization must not have a @Named annotation
>       */
> -    //@Test
> +    @Test
>      public void testFailMultipleSpecializationWithNamed()
>      {
> +        Exception occuredException = null;
> +
>          try
>          {
>              Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
> @@ -68,10 +71,13 @@ public class MultipleSpecializationTest
>          }
>          catch (Exception e)
>          {
> -
>  Assert.assertEquals(WebBeansConfigurationException.class.getName(),
> e.getClass().getName());
> -
>  Assert.assertEquals(InconsistentSpecializationException.class.getName(),
> e.getCause().getClass().getName());
> +            occuredException = e;
>          }
>
> +        Assert.assertNotNull(occuredException);
> +
>  Assert.assertEquals(WebBeansConfigurationException.class.getName(),
> occuredException.getClass().getName());
> +        Assert.assertEquals(DefinitionException.class.getName(),
> occuredException.getCause().getClass().getName());
> +
>          shutDownContainer();
>      }
>  }
>
>
>

Reply via email to