[webbeans-commits] Webbeans SVN: r259 - in ri/trunk/webbeans-ri/src: main/java/org/jboss/webbeans/model/bean and 2 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Thu Nov 6 09:01:57 EST 2008
Author: pete.muir at jboss.org
Date: 2008-11-06 09:01:57 -0500 (Thu, 06 Nov 2008)
New Revision: 259
Added:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FunnelWeaver.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/impl/SimpleAnnotatedMethod.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/ProducerMethodBeanModel.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ProducerMethodBeanLifecycleTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ProducerMethodBeanModelTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/SpiderProducer.java
Log:
Finish producer model tests
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/impl/SimpleAnnotatedMethod.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/impl/SimpleAnnotatedMethod.java 2008-11-06 13:40:53 UTC (rev 258)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/impl/SimpleAnnotatedMethod.java 2008-11-06 14:01:57 UTC (rev 259)
@@ -2,6 +2,7 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.HashSet;
@@ -14,7 +15,7 @@
public class SimpleAnnotatedMethod<T> extends AbstractAnnotatedMember<T, Method> implements AnnotatedMethod<T>
{
- private static final Type[] actualTypeArgements = new Type[0];
+ private Type[] actualTypeArgements = new Type[0];
private Method method;
@@ -25,6 +26,10 @@
{
super(buildAnnotationMap(method));
this.method = method;
+ if (method.getGenericReturnType() instanceof ParameterizedType)
+ {
+ actualTypeArgements = ((ParameterizedType) method.getGenericReturnType()).getActualTypeArguments();
+ }
}
public Method getAnnotatedMethod()
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/ProducerMethodBeanModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/ProducerMethodBeanModel.java 2008-11-06 13:40:53 UTC (rev 258)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/ProducerMethodBeanModel.java 2008-11-06 14:01:57 UTC (rev 259)
@@ -110,6 +110,16 @@
{
throw new DefinitionException("Producer method cannot have parameter annotated @Disposes");
}
+ else if (getAnnotatedItem().getActualTypeArguments().length > 0)
+ {
+ for (Type type : getAnnotatedItem().getActualTypeArguments())
+ {
+ if (!(type instanceof Class))
+ {
+ throw new DefinitionException("Producer method cannot return type parameterized with type parameter or wildcard");
+ }
+ }
+ }
}
protected void initRemoveMethod(ManagerImpl container)
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ProducerMethodBeanLifecycleTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ProducerMethodBeanLifecycleTest.java 2008-11-06 13:40:53 UTC (rev 258)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ProducerMethodBeanLifecycleTest.java 2008-11-06 14:01:57 UTC (rev 259)
@@ -1,5 +1,7 @@
package org.jboss.webbeans.test;
+import javax.webbeans.DefinitionException;
+
import org.testng.annotations.Test;
public class ProducerMethodBeanLifecycleTest
@@ -40,4 +42,17 @@
assert false;
}
+
+ @Test(groups="producerMethod") @SpecAssertion(section="3.4")
+ public void testProducerMethodReturnsNullIsDependent()
+ {
+ assert false;
+ }
+
+ @Test(groups="producerMethod", expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.4")
+ public void testProducerMethodReturnsNullIsNotDependent()
+ {
+
+ }
+
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ProducerMethodBeanModelTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ProducerMethodBeanModelTest.java 2008-11-06 13:40:53 UTC (rev 258)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ProducerMethodBeanModelTest.java 2008-11-06 14:01:57 UTC (rev 259)
@@ -18,6 +18,7 @@
import org.jboss.webbeans.test.beans.DaddyLongLegs;
import org.jboss.webbeans.test.beans.DeadlyAnimal;
import org.jboss.webbeans.test.beans.DeadlySpider;
+import org.jboss.webbeans.test.beans.FunnelWeaver;
import org.jboss.webbeans.test.beans.LadybirdSpider;
import org.jboss.webbeans.test.beans.Spider;
import org.jboss.webbeans.test.beans.SpiderProducer;
@@ -49,43 +50,39 @@
createProducerModel(String.class, method, manager);
}
- @Test(groups={"producerMethod", "enterpiseBeans"}, expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.4")
+ @Test(groups={"producerMethod", "enterpriseBeans"}, expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.4")
public void testProducerMethodIsNotBusinessMethod() throws Exception
{
assert false;
}
-
@Test(groups="producerMethod") @SpecAssertion(section="3.4")
- public void testProducerMethodReturnsNullIsDependent()
+ public void testParameterizedReturnType() throws Exception
{
- assert false;
+ SimpleBeanModel<SpiderProducer> model = createSimpleModel(SpiderProducer.class, manager);
+ manager.getModelManager().addBeanModel(model);
+ Method method = SpiderProducer.class.getMethod("getFunnelWeaverSpider");
+ createProducerModel(FunnelWeaver.class, method, manager);
}
@Test(groups="producerMethod", expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.4")
- public void testProducerMethodReturnsNullIsNotDependent()
+ public void testParameterizedReturnTypeWithWildcard() throws Exception
{
-
+ SimpleBeanModel<SpiderProducer> model = createSimpleModel(SpiderProducer.class, manager);
+ manager.getModelManager().addBeanModel(model);
+ Method method = SpiderProducer.class.getMethod("getAnotherFunnelWeaver");
+ createProducerModel(FunnelWeaver.class, method, manager);
}
- @Test(groups="producerMethod") @SpecAssertion(section="3.4")
- public void testParameterizedReturnType()
- {
- assert false;
- }
-
@Test(groups="producerMethod", expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.4")
- public void testParameterizedReturnTypeWithWildcard()
+ public void testParameterizedReturnTypeWithTypeParameter() throws Exception
{
- assert false;
+ SimpleBeanModel<SpiderProducer> model = createSimpleModel(SpiderProducer.class, manager);
+ manager.getModelManager().addBeanModel(model);
+ Method method = SpiderProducer.class.getMethod("getFunnelWeaver");
+ createProducerModel(FunnelWeaver.class, method, manager);
}
- @Test(groups="producerMethod", expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.4")
- public void testParameterizedReturnTypeWithTypeParameter()
- {
- assert false;
- }
-
@Test(groups={"producerMethod", "deployment"}) @SpecAssertion(section="3.4")
public void testBeanDeclaresMultipleProducerMethods()
{
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FunnelWeaver.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FunnelWeaver.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FunnelWeaver.java 2008-11-06 14:01:57 UTC (rev 259)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.test.beans;
+
+public class FunnelWeaver<T>
+{
+
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FunnelWeaver.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/SpiderProducer.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/SpiderProducer.java 2008-11-06 13:40:53 UTC (rev 258)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/SpiderProducer.java 2008-11-06 14:01:57 UTC (rev 259)
@@ -69,5 +69,22 @@
{
return ALL_SPIDERS;
}
+
+ @Produces public <T> FunnelWeaver<T> getFunnelWeaver()
+ {
+ return new FunnelWeaver<T>();
+ }
+
+ @Produces public FunnelWeaver<?> getAnotherFunnelWeaver()
+ {
+ return new FunnelWeaver<Object>();
+ }
+
+ @Produces public FunnelWeaver<Spider> getFunnelWeaverSpider()
+ {
+ return new FunnelWeaver<Spider>();
+ }
+
+
}
More information about the weld-commits
mailing list