[webbeans-commits] Webbeans SVN: r3492 - ri/trunk/impl/src/main/java/org/jboss/webbeans/bean and 5 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Fri Aug 14 11:12:30 EDT 2009
Author: pete.muir at jboss.org
Date: 2009-08-14 11:12:29 -0400 (Fri, 14 Aug 2009)
New Revision: 3492
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/parameterized/DaoProducer.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/parameterized/MapProducer.java
Removed:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/NoParameterizedCollectionInjection.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/Validator.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Reflections.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ListInstance.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ParameterizedProducer.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ParameterizedProducerTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/AbstractJSR299Test.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/parameterized/AssignabilityOfRawAndParameterizedTypesTest.java
Log:
WBRI-311
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java 2009-08-14 12:58:23 UTC (rev 3491)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java 2009-08-14 15:12:29 UTC (rev 3492)
@@ -669,17 +669,17 @@
throw new IllegalArgumentException("Not a binding type " + annotation);
}
}
- for (Type type : element.getActualTypeArguments())
- {
- if (type instanceof WildcardType)
- {
- throw new IllegalArgumentException("Cannot resolve a type parameterized with a wildcard " + element);
- }
- if (type instanceof TypeVariable<?>)
- {
- throw new IllegalArgumentException("Cannot resolve a type parameterized with a type parameter " + element);
- }
- }
+// for (Type type : element.getActualTypeArguments())
+// {
+// if (type instanceof WildcardType)
+// {
+// throw new IllegalArgumentException("Cannot resolve a type parameterized with a wildcard " + element);
+// }
+// if (type instanceof TypeVariable<?>)
+// {
+// throw new IllegalArgumentException("Cannot resolve a type parameterized with a type parameter " + element);
+// }
+// }
if (bindings != null && bindings.length > element.getMetaAnnotations(BindingType.class).size())
{
throw new IllegalArgumentException("Duplicate bindings (" + Arrays.asList(bindings) + ") type passed " + element.toString());
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/Validator.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/Validator.java 2009-08-14 12:58:23 UTC (rev 3491)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/Validator.java 2009-08-14 15:12:29 UTC (rev 3492)
@@ -158,14 +158,14 @@
ParameterizedType parameterizedType = (ParameterizedType) ij.getType();
for (Type type : parameterizedType.getActualTypeArguments())
{
- if (type instanceof TypeVariable<?>)
- {
- throw new DefinitionException("Injection point cannot have a type variable type parameter " + ij);
- }
- if (type instanceof WildcardType)
- {
- throw new DefinitionException("Injection point cannot have a wildcard type parameter " + ij);
- }
+// if (type instanceof TypeVariable<?>)
+// {
+// throw new DefinitionException("Injection point cannot have a type variable type parameter " + ij);
+// }
+// if (type instanceof WildcardType)
+// {
+// throw new DefinitionException("Injection point cannot have a wildcard type parameter " + ij);
+// }
}
}
checkFacadeInjectionPoint(ij, Instance.class);
@@ -179,7 +179,7 @@
}
if (resolvedBeans.size() > 1)
{
- throw new DeploymentException("The injection point " + ij + " with binding types " + Names.annotationsToString(ij.getBindings()) + " in " + ij.getBean() + " has ambiguous dependencies");
+ throw new DeploymentException("The injection point " + ij + " with binding types " + Names.annotationsToString(ij.getBindings()) + " in " + ij.getBean() + " has ambiguous dependencies " + resolvedBeans);
}
Bean<?> resolvedBean = (Bean<?>) resolvedBeans.iterator().next();
if (beanManager.getServices().get(MetaAnnotationStore.class).getScopeModel(resolvedBean.getScopeType()).isNormal() && !Proxies.isTypeProxyable(ij.getType()))
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-08-14 12:58:23 UTC (rev 3491)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-08-14 15:12:29 UTC (rev 3492)
@@ -329,10 +329,6 @@
{
throw new DefinitionException("Simple bean " + type + " cannot be a non-static inner class");
}
- if (getAnnotatedItem().isParameterizedType())
- {
- throw new DefinitionException("Simple bean " + type + " cannot be a parameterized type");
- }
boolean passivating = manager.getServices().get(MetaAnnotationStore.class).getScopeModel(scopeType).isPassivating();
if (passivating && !Reflections.isSerializable(getBeanClass()))
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java 2009-08-14 12:58:23 UTC (rev 3491)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java 2009-08-14 15:12:29 UTC (rev 3492)
@@ -198,19 +198,19 @@
*/
protected boolean isTypeManagedBeanOrDecorator(WBClass<?> clazz)
{
- Class<?> rawType = clazz.getJavaClass();
+ Class<?> javaClass = clazz.getJavaClass();
EJBApiAbstraction ejbApiAbstraction = manager.getServices().get(EJBApiAbstraction.class);
JsfApiAbstraction jsfApiAbstraction = manager.getServices().get(JsfApiAbstraction.class);
ServletApiAbstraction servletApiAbstraction = manager.getServices().get(ServletApiAbstraction.class);
return !clazz.isNonStaticMemberClass() &&
- !Reflections.isParameterizedType(rawType) &&
- !servletApiAbstraction.SERVLET_CLASS.isAssignableFrom(rawType) &&
- !servletApiAbstraction.FILTER_CLASS.isAssignableFrom(rawType) &&
- !servletApiAbstraction.SERVLET_CONTEXT_LISTENER_CLASS.isAssignableFrom(rawType) &&
- !servletApiAbstraction.HTTP_SESSION_LISTENER_CLASS.isAssignableFrom(rawType) &&
- !servletApiAbstraction.SERVLET_REQUEST_LISTENER_CLASS.isAssignableFrom(rawType) &&
- !ejbApiAbstraction.ENTERPRISE_BEAN_CLASS.isAssignableFrom(rawType) &&
- !jsfApiAbstraction.UICOMPONENT_CLASS.isAssignableFrom(rawType) &&
+ !Reflections.isParamerterizedTypeWithWildcard(javaClass) &&
+ !servletApiAbstraction.SERVLET_CLASS.isAssignableFrom(javaClass) &&
+ !servletApiAbstraction.FILTER_CLASS.isAssignableFrom(javaClass) &&
+ !servletApiAbstraction.SERVLET_CONTEXT_LISTENER_CLASS.isAssignableFrom(javaClass) &&
+ !servletApiAbstraction.HTTP_SESSION_LISTENER_CLASS.isAssignableFrom(javaClass) &&
+ !servletApiAbstraction.SERVLET_REQUEST_LISTENER_CLASS.isAssignableFrom(javaClass) &&
+ !ejbApiAbstraction.ENTERPRISE_BEAN_CLASS.isAssignableFrom(javaClass) &&
+ !jsfApiAbstraction.UICOMPONENT_CLASS.isAssignableFrom(javaClass) &&
hasSimpleWebBeanConstructor(clazz);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Reflections.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Reflections.java 2009-08-14 12:58:23 UTC (rev 3491)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Reflections.java 2009-08-14 15:12:29 UTC (rev 3492)
@@ -30,6 +30,7 @@
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
@@ -47,6 +48,8 @@
public class Reflections
{
+ private static final Type[] EMPTY_TYPES = {};
+
public static class HierarchyDiscovery
{
@@ -82,19 +85,33 @@
private void discoverTypes(Type type)
{
if (type != null)
- {
- add(type);
+ {
if (type instanceof Class)
{
- discoverFromClass((Class<?>) type);
+ Class<?> clazz = (Class<?>) type;
+ if (clazz.getTypeParameters().length > 0)
+ {
+ TypeVariable[] actualTypeParameters = clazz.getTypeParameters();
+ ParameterizedType parameterizedType = new ParameterizedTypeImpl(clazz, actualTypeParameters, clazz.getDeclaringClass());
+ add(parameterizedType);
+ }
+ else
+ {
+ add(clazz);
+ }
+ discoverFromClass(clazz);
}
- else if (type instanceof ParameterizedType)
+ else
{
- Type rawType = ((ParameterizedType) type).getRawType();
- if (rawType instanceof Class)
+ if (type instanceof ParameterizedType)
{
- discoverFromClass((Class<?>) rawType);
+ Type rawType = ((ParameterizedType) type).getRawType();
+ if (rawType instanceof Class)
+ {
+ discoverFromClass((Class<?>) rawType);
+ }
}
+ add(type);
}
}
}
@@ -390,6 +407,30 @@
{
return type.getTypeParameters().length > 0;
}
+
+ public static boolean isParamerterizedTypeWithWildcard(Class<?> type)
+ {
+ if (isParameterizedType(type))
+ {
+ return containsWildcards(type.getTypeParameters());
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public static boolean containsWildcards(Type[] types)
+ {
+ for (Type type : types)
+ {
+ if (type instanceof WildcardType)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
/**
* Invokes a method and wraps exceptions
@@ -579,9 +620,27 @@
*/
public static boolean isAssignableFrom(Class<?> rawType1, Type[] actualTypeArguments1, Class<?> rawType2, Type[] actualTypeArguments2)
{
- return Types.boxedClass(rawType1).isAssignableFrom(Types.boxedClass(rawType2)) && Arrays.equals(actualTypeArguments1, actualTypeArguments2);
+ return Types.boxedClass(rawType1).isAssignableFrom(Types.boxedClass(rawType2)) && isAssignableFrom(actualTypeArguments1, actualTypeArguments2);
}
+ public static boolean isAssignableFrom(Type[] actualTypeArguments1, Type[] actualTypeArguments2)
+ {
+ for (int i = 0; i < actualTypeArguments1.length; i++)
+ {
+ Type type1 = actualTypeArguments1[i];
+ Type type2 = Object.class;
+ if (actualTypeArguments2.length > i)
+ {
+ type2 = actualTypeArguments2[i];
+ }
+ if (!isAssignableFrom(type1, type2))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
public static boolean isAssignableFrom(Type type1, Set<? extends Type> types2)
{
for (Type type2 : types2)
@@ -594,6 +653,18 @@
return false;
}
+ public static boolean isAssignableFrom(Type type1, Type[] types2)
+ {
+ for (Type type2 : types2)
+ {
+ if (isAssignableFrom(type1, type2))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
public static boolean isAssignableFrom(Type type1, Type type2)
{
if (type1 instanceof Class)
@@ -604,32 +675,75 @@
return true;
}
}
- else if (type1 instanceof ParameterizedType)
+ if (type1 instanceof ParameterizedType)
{
- ParameterizedType parameterizedType = (ParameterizedType) type1;
- if (parameterizedType.getRawType() instanceof Class)
+ ParameterizedType parameterizedType1 = (ParameterizedType) type1;
+ if (parameterizedType1.getRawType() instanceof Class)
{
- if (isAssignableFrom((Class<?>) parameterizedType.getRawType(), parameterizedType.getActualTypeArguments(), type2))
+ if (isAssignableFrom((Class<?>) parameterizedType1.getRawType(), parameterizedType1.getActualTypeArguments(), type2))
{
return true;
}
}
}
+ if (type1 instanceof WildcardType)
+ {
+ WildcardType wildcardType = (WildcardType) type1;
+ if (isTypeBounded(type2, wildcardType.getLowerBounds(), wildcardType.getUpperBounds()))
+ {
+ return true;
+ }
+ }
+ if (type2 instanceof WildcardType)
+ {
+ WildcardType wildcardType = (WildcardType) type2;
+ if (isTypeBounded(type1, wildcardType.getUpperBounds(), wildcardType.getLowerBounds()))
+ {
+ return true;
+ }
+ }
+ if (type1 instanceof TypeVariable<?>)
+ {
+ TypeVariable<?> typeVariable = (TypeVariable<?>) type1;
+ if (isTypeBounded(type2, EMPTY_TYPES, typeVariable.getBounds()))
+ {
+ return true;
+ }
+ }
+ if (type2 instanceof TypeVariable<?>)
+ {
+ TypeVariable<?> typeVariable = (TypeVariable<?>) type2;
+ if (isTypeBounded(type1, typeVariable.getBounds(), EMPTY_TYPES))
+ {
+ return true;
+ }
+ }
return false;
}
- public static boolean isAssignableFrom(Class<?> rawType1, Type[] actualTypeArguments1, Type type2)
+ public static boolean isTypeBounded(Type type, Type[] lowerBounds, Type[] upperBounds)
{
- if (type2 instanceof Class)
+ if (lowerBounds.length > 0)
{
- Class<?> clazz = (Class<?>) type2;
- if (isAssignableFrom(rawType1, actualTypeArguments1, clazz, new Type[0]))
+ if (!isAssignableFrom(type, lowerBounds))
{
- return true;
+ return false;
}
}
- else if (type2 instanceof ParameterizedType)
+ if (upperBounds.length > 0)
{
+ if (!isAssignableFrom(upperBounds, type))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static boolean isAssignableFrom(Class<?> rawType1, Type[] actualTypeArguments1, Type type2)
+ {
+ if (type2 instanceof ParameterizedType)
+ {
ParameterizedType parameterizedType = (ParameterizedType) type2;
if (parameterizedType.getRawType() instanceof Class)
{
@@ -639,6 +753,14 @@
}
}
}
+ else if (type2 instanceof Class)
+ {
+ Class<?> clazz = (Class<?>) type2;
+ if (isAssignableFrom(rawType1, actualTypeArguments1, clazz, new Type[0]))
+ {
+ return true;
+ }
+ }
return false;
}
@@ -681,6 +803,18 @@
}
return false;
}
+
+ public static boolean isAssignableFrom(Type[] types1, Type type2)
+ {
+ for (Type type : types1)
+ {
+ if (isAssignableFrom(type, type2))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
public static boolean isSerializable(Class<?> clazz)
{
Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ListInstance.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ListInstance.java 2009-08-14 12:58:23 UTC (rev 3491)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ListInstance.java 2009-08-14 15:12:29 UTC (rev 3492)
@@ -10,9 +10,9 @@
@Any
Instance<List> instance;
- public List get()
+ public Instance<List> get()
{
- return instance.get();
+ return instance;
}
}
Deleted: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/NoParameterizedCollectionInjection.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/NoParameterizedCollectionInjection.java 2009-08-14 12:58:23 UTC (rev 3491)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/NoParameterizedCollectionInjection.java 2009-08-14 15:12:29 UTC (rev 3492)
@@ -1,45 +0,0 @@
-package org.jboss.webbeans.test.unit.implementation.producer.field;
-
-import java.util.Collection;
-
-import javax.enterprise.inject.Current;
-import javax.enterprise.inject.Initializer;
-
-public class NoParameterizedCollectionInjection
-{
-
- private Collection value;
-
- @Current
- private Collection fieldInjection;
-
- private Collection setterInjection;
-
- @Initializer
- public void init(Collection setterInjection)
- {
- this.setterInjection = setterInjection;
- }
-
- @Initializer
- public NoParameterizedCollectionInjection(Collection com)
- {
- this.value = com;
- }
-
- public Collection getValue()
- {
- return value;
- }
-
- public Collection getFieldInjection()
- {
- return fieldInjection;
- }
-
- public Collection getSetterInjection()
- {
- return setterInjection;
- }
-
-}
Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ParameterizedProducer.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ParameterizedProducer.java 2009-08-14 12:58:23 UTC (rev 3491)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ParameterizedProducer.java 2009-08-14 15:12:29 UTC (rev 3492)
@@ -16,12 +16,6 @@
}
@Produces
- public List createList()
- {
- return Arrays.asList(1, 2, 3);
- }
-
- @Produces
public ArrayList<Integer> createIntegerList()
{
List<Integer> list = Arrays.asList(1, 2, 3, 4);
Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ParameterizedProducerTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ParameterizedProducerTest.java 2009-08-14 12:58:23 UTC (rev 3491)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ParameterizedProducerTest.java 2009-08-14 15:12:29 UTC (rev 3492)
@@ -36,17 +36,6 @@
assert item.getSetterInjection().size() == 2;
}
-
- @Test
- public void testNoParameterizedCollectionInjection()
- {
-
- NoParameterizedCollectionInjection item = getCurrentManager().getInstanceByType(NoParameterizedCollectionInjection.class);
- assert item.getFieldInjection().size() == 3;
- assert item.getValue().size() == 3;
- assert item.getSetterInjection().size() == 3;
-
- }
@Test
public void testIntegerCollectionInjection()
@@ -65,7 +54,7 @@
public void testInstanceList()
{
ListInstance listInstance = getCurrentManager().getInstanceByType(ListInstance.class);
- assert listInstance.get().size() == 3;
+ assert listInstance.get().isAmbiguous();
}
@Test
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/AbstractJSR299Test.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/AbstractJSR299Test.java 2009-08-14 12:58:23 UTC (rev 3491)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/AbstractJSR299Test.java 2009-08-14 15:12:29 UTC (rev 3492)
@@ -6,6 +6,7 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.annotation.Annotation;
+import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
@@ -70,13 +71,13 @@
* Checks if all annotations are in a given set of annotations
*
* @param annotations The annotation set
- * @param annotationTypes The annotations to match
+ * @param requiredAnnotationTypes The annotations to match
* @return True if match, false otherwise
*/
- public boolean annotationSetMatches(Set<? extends Annotation> annotations, Class<? extends Annotation>... annotationTypes)
+ public boolean annotationSetMatches(Set<? extends Annotation> annotations, Class<? extends Annotation>... requiredAnnotationTypes)
{
List<Class<? extends Annotation>> annotationTypeList = new ArrayList<Class<? extends Annotation>>();
- annotationTypeList.addAll(Arrays.asList(annotationTypes));
+ annotationTypeList.addAll(Arrays.asList(requiredAnnotationTypes));
for (Annotation annotation : annotations)
{
if (annotationTypeList.contains(annotation.annotationType()))
@@ -90,6 +91,24 @@
}
return annotationTypeList.size() == 0;
}
+
+ public boolean typeSetMatches(Set<Type> types, Class<?>... requiredTypes)
+ {
+ List<Class<?>> typeList = new ArrayList<Class<?>>();
+ typeList.addAll(Arrays.asList(requiredTypes));
+ for (Type type : types)
+ {
+ if (type instanceof Class<?>)
+ {
+ typeList.remove(type);
+ }
+ else if (type instanceof ParameterizedType)
+ {
+ typeList.remove(((ParameterizedType) type).getRawType());
+ }
+ }
+ return typeList.size() == 0;
+ }
public <T> Bean<T> getUniqueBean(Class<T> type, Annotation... bindings)
{
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/parameterized/AssignabilityOfRawAndParameterizedTypesTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/parameterized/AssignabilityOfRawAndParameterizedTypesTest.java 2009-08-14 12:58:23 UTC (rev 3491)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/parameterized/AssignabilityOfRawAndParameterizedTypesTest.java 2009-08-14 15:12:29 UTC (rev 3492)
@@ -17,8 +17,11 @@
package org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.parameterized;
import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
import javax.enterprise.inject.TypeLiteral;
+import javax.enterprise.inject.spi.Bean;
import org.jboss.jsr299.tck.AbstractJSR299Test;
import org.jboss.test.audit.annotations.SpecAssertion;
@@ -32,66 +35,69 @@
public class AssignabilityOfRawAndParameterizedTypesTest extends AbstractJSR299Test
{
- @Test(groups = { "resolution", "ri-broken" })
+ @Test(groups = { "resolution" })
@SpecAssertions({
@SpecAssertion(section = "5.3.3", id = "a"),
@SpecAssertion(section = "2.2.1", id = "f"),
@SpecAssertion(section = "2.2.1", id = "g")
})
- // WBRI-311
public void testAssignabilityToRawType()
{
- assert getBeans(Dao.class).size() == 2; // Dao and ObjectDao
+ Set<Bean<Dao>> beans = getBeans(Dao.class);
+ assert getBeans(Dao.class).size() == 3; // Dao, DaoProducer.getDao() and ObjectDao
}
- @Test(groups= {"resolution", "ri-broken"})
+ @Test(groups= {"resolution"})
@SpecAssertion(section = "5.3.3", id = "b")
- // WBRI-311
public void testAssignabilityOfParameterizedTypeWithActualTypesToParameterizedTypeWithActualTypes()
{
- assert getBeans(new TypeLiteral<HashMap<Integer, Integer>>(){}).size() == 1;
- assert getBeans(new TypeLiteral<HashMap<Integer, Integer>>(){}
- ).iterator().next().getTypes().contains(IntegerHashMap.class);
+ assert getBeans(new TypeLiteral<Map<Integer, Integer>>(){}).size() == 2;
+ assert getBeans(new TypeLiteral<HashMap<Integer, Integer>>(){}).iterator().next().getTypes().contains(IntegerHashMap.class);
}
- @Test(groups = { "resolution", "ri-broken" })
+ @Test(groups = { "resolution"})
@SpecAssertions({
- @SpecAssertion(section = "5.3.2", id = "b"),
@SpecAssertion(section = "5.3.3", id = "c")})
- // WBRI-311
public void testAssignabilityOfParameterizedTypeWithActualTypesToParameterizedTypeWithWildcards()
{
+ assert getBeans(new TypeLiteral<HashMap<? extends Number, ? super Integer>>() {}).size() == 1;
+ assert getBeans(new TypeLiteral<HashMap<? extends Number, ? super Integer>>() {}).iterator().next().getTypes().contains(IntegerHashMap.class);
+ }
+
+ @Test(groups = { "resolution"})
+ @SpecAssertions({
+ @SpecAssertion(section = "5.3.2", id = "b")
+ })
+ public void testAssignabilityOfParameterizedTypeWithActualTypesToParameterizedTypeWithWildcardsAtInjectionPoint()
+ {
assert getInstanceByType(InjectedBean.class).getMap() instanceof IntegerHashMap;
}
- @Test(groups = { "resolution", "ri-broken" })
+ @Test(groups = { "resolution" })
@SpecAssertion(section = "5.3.3", id = "d")
- // WBRI-311
public void testAssignabilityOfParameterizedTypeWithTypeVariablesToParameterizedTypeWithWildcards()
{
- assert getBeans(new TypeLiteral<Result<? extends Throwable, ? super Exception>>(){}).size() == 1;
- assert getBeans(new TypeLiteral<Result<? extends Throwable, ? super Exception>>(){}
- ).iterator().next().getTypes().contains(Result.class);
+ Set<Bean<Result<? extends Throwable, ? super Exception>>> beans = getBeans(new TypeLiteral<Result<? extends Throwable, ? super Exception>>(){});
+ assert beans.size() == 1;
+ assert typeSetMatches(beans.iterator().next().getTypes(), Result.class, Object.class);
}
- @Test(groups = { "resolution", "ri-broken" })
+ @Test(groups = { "resolution" })
@SpecAssertion(section = "5.3.3", id = "e")
- // WBRI-311
public void testAssignabilityOfParameterizedTypeWithTypeVariablesToParameterizedTypeWithActualTypes()
{
- assert getBeans(new TypeLiteral<Result<Exception, Exception>>(){}).size() == 1;
- assert getBeans(new TypeLiteral<Result<Exception, Exception>>(){}
- ).iterator().next().getTypes().contains(Result.class);
+ Set<Bean<Result<Exception, Exception>>> beans = getBeans(new TypeLiteral<Result<Exception, Exception>>(){});
+ assert beans.size() == 1;
+ assert typeSetMatches(beans.iterator().next().getTypes(), Result.class, Object.class);
}
- @Test(groups = { "resolution", "ri-broken" })
+ @Test(groups = { "resolution" })
@SpecAssertion(section = "5.3.3", id = "f")
- // WBRI-311
public <T1 extends Exception, T2 extends Exception> void testAssignabilityOfParameterizedTypeWithTypeVariablesToParameterizedTypeTypeVariable()
{
- assert getBeans(new TypeLiteral<Result<T1, T2>>(){}).size() == 1;
- assert getBeans(new TypeLiteral<Result<Exception, Exception>>(){}
- ).iterator().next().getTypes().contains(Result.class);
+ Set<Bean<Result<T1, T2>>> beans = getBeans(new TypeLiteral<Result<T1, T2>>(){});
+ assert beans.size() == 1;
+ assert typeSetMatches(beans.iterator().next().getTypes(), Result.class, Object.class);
}
}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/parameterized/DaoProducer.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/parameterized/DaoProducer.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/parameterized/DaoProducer.java 2009-08-14 15:12:29 UTC (rev 3492)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.jsr299.tck.tests.lookup.typesafe.resolution.parameterized;
+
+import javax.enterprise.inject.Produces;
+
+/**
+ * @author pmuir
+ *
+ */
+public class DaoProducer
+{
+
+ @Produces
+ public Dao<Object, Object> getDao()
+ {
+ return new Dao<Object, Object>();
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/parameterized/DaoProducer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/parameterized/MapProducer.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/parameterized/MapProducer.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/parameterized/MapProducer.java 2009-08-14 15:12:29 UTC (rev 3492)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.jsr299.tck.tests.lookup.typesafe.resolution.parameterized;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.enterprise.inject.Produces;
+
+/**
+ * @author pmuir
+ *
+ */
+public class MapProducer
+{
+
+ @Produces
+ public Map<Integer, Integer> produceMap()
+ {
+ return new HashMap<Integer, Integer>();
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/parameterized/MapProducer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
More information about the weld-commits
mailing list