openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1308123 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/container/ test/java/org/apache/webbeans/newtests/concepts/alternatives/common/ test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/ test/reso...
Date Sun, 01 Apr 2012 14:24:33 GMT
Author: struberg
Date: Sun Apr  1 14:24:32 2012
New Revision: 1308123

URL: http://svn.apache.org/viewvc?rev=1308123&view=rev
Log:
OWB-658 AnnotationTest cleanup finished

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeProducerMethodTest.java
  (contents, props changed)
      - copied, changed from r1308092, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeTest.java
    openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnClassOnly.xml
      - copied, changed from r1308092, openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnProducerMethodOnly.xml
Removed:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeTest.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnClassOnlyBean.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnProducerMethodOnlyBean.java
    openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnClassAndProducerMethod.xml
    openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnProducerMethodOnly.xml

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java?rev=1308123&r1=1308122&r2=1308123&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
Sun Apr  1 14:24:32 2012
@@ -491,16 +491,17 @@ public class InjectionResolver
             if (returnAll)
             {
                 resolvedComponents.add(component);
-                continue;
             }
-
-            for (Type componentApiType : component.getTypes())
+            else
             {
-
-                if (ClassUtil.isAssignable(componentApiType, injectionPointType))
+                for (Type componentApiType : component.getTypes())
                 {
-                    resolvedComponents.add(component);
-                    break;
+
+                    if (ClassUtil.isAssignable(componentApiType, injectionPointType))
+                    {
+                        resolvedComponents.add(component);
+                        break;
+                    }
                 }
             }
         }
@@ -508,8 +509,14 @@ public class InjectionResolver
         // Look for qualifiers
         resolvedComponents = findByQualifier(resolvedComponents, qualifiers);
 
-        // Look for alternative
-        resolvedComponents = findByAlternatives(resolvedComponents, bdaBeansXMLFilePath);
+        if (!injectionPointType.equals(Object.class))
+        {
+            // see OWB-658 skip if all Object.class instances are requested
+            // as there is no way to Alternative Object.class
+
+            // Look for alternative
+            resolvedComponents = findByAlternatives(resolvedComponents, bdaBeansXMLFilePath);
+        }
 
         // Ambigious resolution, check for specialization
         if (resolvedComponents.size() > 1)

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnClassOnlyBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnClassOnlyBean.java?rev=1308123&r1=1308122&r2=1308123&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnClassOnlyBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnClassOnlyBean.java
Sun Apr  1 14:24:32 2012
@@ -24,6 +24,13 @@ import javax.enterprise.inject.Produces;
 
 /**
  * This one has the @Alternative on the class and NOT on the producer method
+ *
+ * See Spec 5.1.1
+ * <pre>
+ * An alternative is selected for the bean archive if ...
+ *   * the alternative is a producer method, field or resource, and the bean class
+ *     that declares the method or field is listed ..
+ * </pre>
  */
 @Alternative
 public class AlternativeOnClassOnlyBean

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnProducerMethodOnlyBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnProducerMethodOnlyBean.java?rev=1308123&r1=1308122&r2=1308123&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnProducerMethodOnlyBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnProducerMethodOnlyBean.java
Sun Apr  1 14:24:32 2012
@@ -22,7 +22,8 @@ import javax.enterprise.inject.Alternati
 import javax.enterprise.inject.Produces;
 
 /**
- * This one has the &#064;Alternative ONLY on the producer method
+ * This one has the &#064;Alternative ONLY on the producer method.
+ * This must result in an Exception.
  */
 public class AlternativeOnProducerMethodOnlyBean
 {

Copied: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeProducerMethodTest.java
(from r1308092, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeTest.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeProducerMethodTest.java?p2=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeProducerMethodTest.java&p1=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeTest.java&r1=1308092&r2=1308123&rev=1308123&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeProducerMethodTest.java
Sun Apr  1 14:24:32 2012
@@ -32,12 +32,14 @@ import org.apache.webbeans.newtests.conc
 import org.apache.webbeans.newtests.concepts.alternatives.common.IProducedBean;
 import org.apache.webbeans.newtests.concepts.alternatives.common.QualifierProducerBased;
 import org.junit.Test;
+import org.junit.Ignore;
 
-public class AlternativeTest extends AbstractUnitTest {
+public class AlternativeProducerMethodTest extends AbstractUnitTest {
+
+    private static final String PACKAGE_NAME = AlternativeProducerMethodTest.class.getPackage().getName();
 
     @Test
-    @SuppressWarnings("unchecked")
-    public void testAlternativeOnClassOnlyBean()
+    public void testNotEnabledAlternativeOnClassOnlyBean()
     {
         Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
         beanClasses.add(DefaultBeanProducer.class);
@@ -57,10 +59,36 @@ public class AlternativeTest extends Abs
         Assert.assertEquals("default", model.getProducerType());
 
         shutDownContainer();
-        
     }
 
     @Test
+    @Ignore("need to clarify this with the EG")
+    //X TODO It's not yet clear how paragraph 5.1.1 is to be interpreted
+    public void testAlternativeOnClassOnlyBean()
+    {
+        Collection<String> beanXmls = new ArrayList<String>();
+        beanXmls.add(getXmlPath(PACKAGE_NAME, "AlternativeOnClassOnly"));
+
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        beanClasses.add(DefaultBeanProducer.class);
+        beanClasses.add(AlternativeOnClassOnlyBean.class);
+
+        startContainer(beanClasses, null);
+
+        Annotation[] anns = new Annotation[1];
+        anns[0] = new AnnotationLiteral<QualifierProducerBased>()
+        {
+        };
+
+        IProducedBean model = getInstance(IProducedBean.class, anns);
+        Assert.assertNotNull(model);
+        Assert.assertEquals("AlternativeOnClassOnlyBean", model.getProducerType());
+
+        shutDownContainer();
+    }
+
+
+    @Test
     public void testAlternativeOnClassAndProducerMethodBean()
     {
         Collection<String> beanXmls = new ArrayList<String>();
@@ -86,4 +114,6 @@ public class AlternativeTest extends Abs
     }
 
 
+    //X TODO add tests for disposal methods
+
 }

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeProducerMethodTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnClassAndProducerMethod.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnClassAndProducerMethod.xml?rev=1308123&r1=1308122&r2=1308123&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnClassAndProducerMethod.xml
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnClassAndProducerMethod.xml
Sun Apr  1 14:24:32 2012
@@ -19,6 +19,6 @@ under the License.
 -->
 <beans>
     <alternatives>
-        <class>org.apache.webbeans.newtests.concepts.alternatives.common.AlternativeBeanProducer4</class>
+        <class>org.apache.webbeans.newtests.concepts.alternatives.common.AlternativeOnClassAndProducerMethodBean</class>
     </alternatives>
 </beans>

Copied: openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnClassOnly.xml
(from r1308092, openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnProducerMethodOnly.xml)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnClassOnly.xml?p2=openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnClassOnly.xml&p1=openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnProducerMethodOnly.xml&r1=1308092&r2=1308123&rev=1308123&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnProducerMethodOnly.xml
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnClassOnly.xml
Sun Apr  1 14:24:32 2012
@@ -19,6 +19,6 @@ under the License.
 -->
 <beans>
     <alternatives>
-        <class>org.apache.webbeans.newtests.concepts.alternatives.common.AlternativeBeanProducer4</class>
+        <class>org.apache.webbeans.newtests.concepts.alternatives.common.AlternativeOnClassOnlyBean</class>
     </alternatives>
 </beans>

Modified: openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnProducerMethodOnly.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnProducerMethodOnly.xml?rev=1308123&r1=1308122&r2=1308123&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnProducerMethodOnly.xml
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnProducerMethodOnly.xml
Sun Apr  1 14:24:32 2012
@@ -19,6 +19,6 @@ under the License.
 -->
 <beans>
     <alternatives>
-        <class>org.apache.webbeans.newtests.concepts.alternatives.common.AlternativeBeanProducer4</class>
+        <class>org.apache.webbeans.newtests.concepts.alternatives.common.AlternativeOnProducerMethodOnlyBean</class>
     </alternatives>
 </beans>



Mime
View raw message