openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject svn commit: r1551736 - in /openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/multiple: BeanD.java MultipleSpecializationTest.java
Date Tue, 17 Dec 2013 22:16:37 GMT
Author: tandraschko
Date: Tue Dec 17 22:16:36 2013
New Revision: 1551736

URL: http://svn.apache.org/r1551736
Log:
OWB-917 - added better unit tests... trying to understand the specialization code next time...

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/multiple/BeanD.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/multiple/MultipleSpecializationTest.java

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/multiple/BeanD.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/multiple/BeanD.java?rev=1551736&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/multiple/BeanD.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/multiple/BeanD.java
Tue Dec 17 22:16:36 2013
@@ -0,0 +1,33 @@
+/*
+ * 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.specalization.multiple;
+
+import javax.enterprise.inject.Specializes;
+import javax.inject.Named;
+
+@Named
+@Specializes
+public class BeanD extends BeanC
+{
+    @Override
+    public Class getBeanClass()
+    {
+        return BeanD.class;
+    }
+}

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=1551736&r1=1551735&r2=1551736&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
Tue Dec 17 22:16:36 2013
@@ -21,11 +21,16 @@ package org.apache.webbeans.newtests.spe
 import java.util.ArrayList;
 import java.util.Collection;
 import junit.framework.Assert;
+import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.exception.inject.InconsistentSpecializationException;
 import org.apache.webbeans.newtests.AbstractUnitTest;
 import org.junit.Test;
 
 public class MultipleSpecializationTest extends AbstractUnitTest
 {
+    /**
+     * Tests that multiple specialization must be possible
+     */
     //@Test
     public void testMultipleSpecialization()
     {
@@ -36,9 +41,36 @@ public class MultipleSpecializationTest 
 
         startContainer(beanClasses, null);
 
-        BeanA bean = getInstance(BeanA.class);
+        BeanA beanA = getInstance(BeanA.class);
+        Assert.assertEquals(BeanC.class, beanA.getBeanClass());
 
-        Assert.assertEquals(BeanC.class, bean.getBeanClass());
+        beanA = getInstance("beanA");
+        Assert.assertEquals(BeanC.class, beanA.getBeanClass());
+
+        shutDownContainer();
+    }
+    
+    /**
+     * Tests that a specialization must not have a @Named annotation
+     */
+    //@Test
+    public void testFailMultipleSpecializationWithNamed()
+    {
+        try
+        {
+            Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+            beanClasses.add(BeanA.class);
+            beanClasses.add(BeanB.class);
+            beanClasses.add(BeanC.class);
+            beanClasses.add(BeanD.class);
+
+            startContainer(beanClasses, null);
+        }
+        catch (Exception e)
+        {
+            Assert.assertEquals(WebBeansConfigurationException.class.getName(), e.getClass().getName());
+            Assert.assertEquals(InconsistentSpecializationException.class.getName(), e.getCause().getClass().getName());
+        }
 
         shutDownContainer();
     }



Mime
View raw message