Author: akazakov
Date: 2010-06-11 06:06:32 -0400 (Fri, 11 Jun 2010)
New Revision: 22762
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/GameBroken.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/NumberProducer.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/PrimitiveTestQualifer.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/TestQualifer.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/Cat.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/CatInterceptor.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/CatInterceptorBinding.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/InjectInterceptorBroken.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/AssignabilityOfRawAndParameterizedTypesTest.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/EnterpriseResolutionByTypeTest.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBean.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IParametedType.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferenceInitializer.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferences.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ParametedType.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/TypeDeclaration.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/ParametedTypeFactory.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.properties
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/beans.xml
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BeanDefinitionTest.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BeanSpecializationTest.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ResolutionByTypeTest.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java
Log:
https://jira.jboss.org/browse/JBIDE-6418 https://jira.jboss.org/browse/JBIDE-5808
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -106,30 +106,42 @@
}
/**
- * Sorts CDI beans which may be injected. Sets for alternative beans higher
- * position and for nonalternative beans lower position.
- *
+ * Sorts CDI beans which may be injected. The following order will be used:
+ * 1) selected alternative beans
+ * 2) nonalternative beans
+ * 3) non-seleceted alternatives
+ * 4) decorators
+ * 5) interceptors
+ *
* @param beans
- * @param element
*/
public static List<IBean> sortBeans(Set<IBean> beans) {
Set<IBean> alternativeBeans = new HashSet<IBean>();
+ Set<IBean> selectedAlternativeBeans = new HashSet<IBean>();
Set<IBean> nonAlternativeBeans = new HashSet<IBean>();
+ Set<IBean> decorators = new HashSet<IBean>();
+ Set<IBean> interceptors = new HashSet<IBean>();
for (IBean bean : beans) {
-// if (bean == null || bean instanceof IDecorator || bean instanceof IInterceptor) {
-// continue;
-// }
- if (bean.isAlternative()) {
+ if (bean.isSelectedAlternative()) {
+ selectedAlternativeBeans.add(bean);
+ } else if (bean.isAlternative()) {
alternativeBeans.add(bean);
+ } else if (bean instanceof IDecorator) {
+ decorators.add(bean);
+ } else if (bean instanceof IInterceptor) {
+ interceptors.add(bean);
} else {
nonAlternativeBeans.add(bean);
}
}
ArrayList<IBean> sortedBeans = new ArrayList<IBean>();
+ sortedBeans.addAll(selectedAlternativeBeans);
+ sortedBeans.addAll(nonAlternativeBeans);
sortedBeans.addAll(alternativeBeans);
- sortedBeans.addAll(nonAlternativeBeans);
+ sortedBeans.addAll(decorators);
+ sortedBeans.addAll(interceptors);
return sortedBeans;
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBean.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBean.java 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBean.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -115,6 +115,14 @@
boolean isAlternative();
/**
+ * Determines if the bean is a selected alternative.
+ *
+ * @return <tt>true</tt> if the bean is a selected alternative, and
<tt>false</tt>
+ * otherwise.
+ */
+ boolean isSelectedAlternative();
+
+ /**
* Returns the location of @Alternative declaration of this bean. May be
* declared in a stereotype.
*
@@ -166,4 +174,13 @@
* @return "true" if the bean is enabled
*/
boolean isEnabled();
+
+ /**
+ * Determines if the bean is nullable such as a producer method with a non-primitive
+ * return type or a producer field with a non-primitive type.
+ *
+ * @return <tt>true</tt> if the {@code create()} method may return a null
+ * value, and <tt>false</tt> otherwise
+ */
+ boolean isNullable();
}
\ No newline at end of file
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IParametedType.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IParametedType.java 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IParametedType.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -33,4 +33,11 @@
* @return signature of the declaration
*/
public String getSignature();
+
+ /**
+ * Returns true if the type is a primitive type.
+ *
+ * @return true if the type is a primitive type
+ */
+ boolean isPrimitive();
}
\ No newline at end of file
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferenceInitializer.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferenceInitializer.java 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferenceInitializer.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -41,5 +41,8 @@
defaultPreferences.put(CDIPreferences.MISSING_NONBINDING_IN_QUALIFIER_TYPE_MEMBER,
CDIPreferences.WARNING);
defaultPreferences.put(CDIPreferences.UNSATISFIED_INJECTION_POINTS,
CDIPreferences.WARNING);
defaultPreferences.put(CDIPreferences.AMBIGUOUS_INJECTION_POINTS,
CDIPreferences.WARNING);
+ defaultPreferences.put(CDIPreferences.INJECT_RESOLVES_TO_NULLABLE_BEAN,
CDIPreferences.WARNING);
+ defaultPreferences.put(CDIPreferences.INJECTED_DECORATOR, CDIPreferences.WARNING);
+ defaultPreferences.put(CDIPreferences.INJECTED_INTERCEPTOR, CDIPreferences.WARNING);
}
}
\ No newline at end of file
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferences.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferences.java 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferences.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -63,6 +63,8 @@
public static final String PRODUCER_FIELD_TYPE_HAS_WILDCARD =
INSTANCE.createSeverityOption("producerFieldTypeHasWildcard"); //$NON-NLS-1$
// - producer field type is a type variable
public static final String PRODUCER_FIELD_TYPE_IS_VARIABLE =
INSTANCE.createSeverityOption("producerFieldTypeIsVariable"); //$NON-NLS-1$
+// - an injection point of primitive type resolves to a bean that may have null values,
such as a producer method with a non-primitive return type or a producer field with a
non-primitive type
+ public static final String INJECT_RESOLVES_TO_NULLABLE_BEAN =
INSTANCE.createSeverityOption("injectResolvesToNullableBean"); //$NON-NLS-1$
// - matching object in the Java EE component environment is not of the same type
// as the producer field declaration (3.5.1)
public static final String PRODUCER_FIELD_TYPE_DOES_NOT_MATCH_JAVA_EE_OBJECT =
INSTANCE.createSeverityOption("producerFieldTypeDoesNotMatchJavaEeObject");
//$NON-NLS-1$
@@ -193,6 +195,10 @@
public static final String INTERCEPTOR_OR_DECORATOR_IS_ALTERNATIVE =
INSTANCE.createSeverityOption("interceptorOrDecoratorIsAlternative");
//$NON-NLS-1$
// - interceptor declared using @Interceptor does not declare any interceptor binding
(9.2 non-portable)
public static final String MISSING_INTERCEPTOR_BINDING =
INSTANCE.createSeverityOption("missingInterceptorBinding"); //$NON-NLS-1$
+// - a decorator can not be injected
+ public static final String INJECTED_DECORATOR =
INSTANCE.createSeverityOption("injectedDecorator"); //$NON-NLS-1$
+// - an interceptor can not be injected
+ public static final String INJECTED_INTERCEPTOR =
INSTANCE.createSeverityOption("injectedInterceptor"); //$NON-NLS-1$
//Specialization
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -113,4 +113,7 @@
return r == null ? 0 : r.getOffset();
}
-}
+ public boolean isNullable() {
+ return typeDeclaration==null?false:!typeDeclaration.isPrimitive();
+ }
+}
\ No newline at end of file
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -444,4 +444,20 @@
return result;
}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.cdi.core.IBean#isNullable()
+ */
+ public boolean isNullable() {
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.cdi.core.IBean#isSelectedAlternative()
+ */
+ public boolean isSelectedAlternative() {
+ // TODO
+ return isAlternative();
+ }
}
\ No newline at end of file
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ParametedType.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ParametedType.java 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ParametedType.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2009 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -35,6 +35,7 @@
protected String arrayPrefix = "";
protected String signature;
protected List<ParametedType> parameterTypes = new
ArrayList<ParametedType>();
+ protected boolean primitive;
boolean inheritanceIsBuilt = false;
protected ParametedType superType = null;
@@ -49,6 +50,18 @@
public ParametedType() {}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.cdi.core.IParametedType#isPrimitive()
+ */
+ public boolean isPrimitive() {
+ return primitive;
+ }
+
+ public void setPrimitive(boolean primitive) {
+ this.primitive = primitive;
+ }
+
public ParametedTypeFactory getFactory() {
return typeFactory;
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -179,4 +179,13 @@
public IAnnotationDeclaration getProducesAnnotation() {
return getDefinition().getProducesAnnotation();
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.cdi.core.IBean#isSelectedAlternative()
+ */
+ public boolean isSelectedAlternative() {
+ // TODO
+ return isAlternative();
+ }
}
\ No newline at end of file
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -231,4 +231,13 @@
public IAnnotationDeclaration getProducesAnnotation() {
return produces;
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.cdi.core.IBean#isSelectedAlternative()
+ */
+ public boolean isSelectedAlternative() {
+ // TODO
+ return isAlternative();
+ }
}
\ No newline at end of file
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/TypeDeclaration.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/TypeDeclaration.java 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/TypeDeclaration.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2009 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -35,6 +35,7 @@
inheritanceIsBuilt = type.inheritanceIsBuilt;
inheritedTypes = type.inheritedTypes;
superType = type.superType;
+ primitive = type.primitive;
}
public int getLength() {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -86,7 +86,8 @@
for (int i = 0; i < params.length; i++) {
if(ps.length <= i) {
- CDICorePlugin.getDefault().logError(new IllegalArgumentException("Cannot parse
method parameters for " + paramsString));
+ // CDICorePlugin.getDefault().logError(new IllegalArgumentException("Cannot
parse method parameters for " + paramsString));
+ // The source code may be broken. Just ignore such errors.
break;
}
if(!parametersAreInjectionPoints && params[i].indexOf('@') < 0) {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/ParametedTypeFactory.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/ParametedTypeFactory.java 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/ParametedTypeFactory.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -74,6 +74,7 @@
if(primitives.containsKey(typeSignature)) {
typeSignature = primitives.get(typeSignature);
result.setSignature(result.getArrayPrefix() + typeSignature);
+ result.setPrimitive(true);
}
int startToken = typeSignature.indexOf('<');
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -964,17 +964,37 @@
addError(CDIValidationMessages.INJECTION_TYPE_IS_VARIABLE,
CDIPreferences.INJECTION_TYPE_IS_VARIABLE, declaration, injection.getResource());
}
- /*
- * 5.2.1. Unsatisfied and ambiguous dependencies
- * - If an unsatisfied or unresolvable ambiguous dependency exists, the container
automatically detects the problem and treats it as a deployment problem.
- */
- if(declaration!=null && !(injection instanceof IInjectionPointParameter)) {
+ if(declaration!=null && !(injection instanceof IInjectionPointMethod)) {
Set<IBean> beans = cdiProject.getBeans(true, injection);
+ ITextSourceReference reference = injection instanceof
IInjectionPointParameter?injection:declaration;
+ /*
+ * 5.2.1. Unsatisfied and ambiguous dependencies
+ * - If an unsatisfied or unresolvable ambiguous dependency exists, the container
automatically detects the problem and treats it as a deployment problem.
+ */
if(beans.isEmpty()) {
- addError(CDIValidationMessages.UNSATISFIED_INJECTION_POINTS,
CDIPreferences.UNSATISFIED_INJECTION_POINTS, declaration, injection.getResource());
+ addError(CDIValidationMessages.UNSATISFIED_INJECTION_POINTS,
CDIPreferences.UNSATISFIED_INJECTION_POINTS, reference, injection.getResource());
} else if(beans.size()>1) {
- addError(CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS,
CDIPreferences.AMBIGUOUS_INJECTION_POINTS, declaration, injection.getResource());
- }
+ addError(CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS,
CDIPreferences.AMBIGUOUS_INJECTION_POINTS, reference, injection.getResource());
+ } else if(beans.size()==1) {
+ IBean bean = beans.iterator().next();
+ /*
+ * 5.2.4. Primitive types and null values
+ * - injection point of primitive type resolves to a bean that may have null values,
such as a producer method with a non-primitive return type or a producer field with a
non-primitive type
+ */
+ if(bean.isNullable() && injection.getType()!=null &&
injection.getType().isPrimitive()) {
+ addError(CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN,
CDIPreferences.INJECT_RESOLVES_TO_NULLABLE_BEAN, reference, injection.getResource());
+ }
+ /*
+ * 5.1.4. Inter-module injection
+ * - a decorator can not be injected
+ * - an interceptor can not be injected
+ */
+ if(bean instanceof IDecorator) {
+ addError(CDIValidationMessages.INJECTED_DECORATOR,
CDIPreferences.INJECTED_DECORATOR, reference, injection.getResource());
+ } else if(bean instanceof IInterceptor) {
+ addError(CDIValidationMessages.INJECTED_INTERCEPTOR,
CDIPreferences.INJECTED_INTERCEPTOR, reference, injection.getResource());
+ }
+ }
}
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -35,6 +35,7 @@
public static String PRODUCER_FIELD_TYPE_HAS_WILDCARD;
public static String PRODUCER_FIELD_TYPE_IS_VARIABLE;
public static String PRODUCER_FIELD_TYPE_DOES_NOT_MATCH_JAVA_EE_OBJECT;
+ public static String INJECT_RESOLVES_TO_NULLABLE_BEAN;
public static String INJECTION_TYPE_IS_VARIABLE;
public static String STEREOTYPE_IS_ANNOTATED_TYPED;
public static String MISSING_NONBINDING_FOR_ANNOTATION_VALUE_IN_QUALIFIER_TYPE_MEMBER;
@@ -96,6 +97,8 @@
public static String INTERCEPTOR_IS_ALTERNATIVE;
public static String DECORATOR_IS_ALTERNATIVE;
public static String MISSING_INTERCEPTOR_BINDING;
+ public static String INJECTED_DECORATOR;
+ public static String INJECTED_INTERCEPTOR;
public static String ILLEGAL_SPECIALIZING_MANAGED_BEAN;
public static String ILLEGAL_SPECIALIZING_SESSION_BEAN;
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt 2010-06-11
10:06:32 UTC (rev 22762)
@@ -122,20 +122,29 @@
- X specializes Y and Y has a name and X declares a name explicitly, using @Named
- interceptor or decorator is annotated @Specializes (Non-Portable behavior)
+5.2.1. Unsatisfied and ambiguous dependencies
+- If an unsatisfied or unresolvable ambiguous dependency exists, the container
automatically detects the problem and
+ treats it as a deployment problem.
+
5.2.2. Legal injection point types
- injection point type is a type variable
+5.1.4. Inter-module injection
+- a decorator can not be injected
+- an interceptor can not be injected
+
+5.2.4. Primitive types and null values
+- if an injection point of primitive type resolves to a bean that may have null values,
such as a producer method
+ with a non-primitive return type or a producer field with a non-primitive type, the
container automatically detects the problem
+ and treats it as a deployment problem.
+
5.2.5. Qualifier annotations with members
- array-valued or annotation-valued member of a qualifier type is not annotated
@Nonbinding (Non-Portable behavior)
-5.2.1. Unsatisfied and ambiguous dependencies
-- If an unsatisfied or unresolvable ambiguous dependency exists, the container
automatically detects the problem and
- treats it as a deployment problem.
-
5.5.7. Injection point metadata
- bean that declares any scope other than @Dependent has an injection point of type
InjectionPoint and qualifier @Default
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties 2010-06-11
10:06:32 UTC (rev 22762)
@@ -15,6 +15,7 @@
PRODUCER_FIELD_TYPE_IS_VARIABLE=Producer field type is a type variable
PRODUCER_FIELD_TYPE_DOES_NOT_MATCH_JAVA_EE_OBJECT=Matching object in the Java EE
component environment is not of the same type as the producer field declaration
INJECTION_TYPE_IS_VARIABLE=Injection point type is a type variable
+INJECT_RESOLVES_TO_NULLABLE_BEAN=Injection point of primitive type resolves to the bean
that may have a null value
STEREOTYPE_IS_ANNOTATED_TYPED=Stereotype is annotated @Typed
MISSING_NONBINDING_FOR_ANNOTATION_VALUE_IN_QUALIFIER_TYPE_MEMBER=Annotation-valued member
of a qualifier type is not annotated @Nonbinding
MISSING_NONBINDING_FOR_ARRAY_VALUE_IN_QUALIFIER_TYPE_MEMBER=Array-valued member of a
qualifier type is not annotated @Nonbinding
@@ -75,6 +76,8 @@
INTERCEPTOR_IS_ALTERNATIVE=Interceptor is an alternative
DECORATOR_IS_ALTERNATIVE=Decorator is an alternative
MISSING_INTERCEPTOR_BINDING=Interceptor declared using @Interceptor does not declare any
interceptor binding
+INJECTED_DECORATOR=Injection point resolves to a decorator
+INJECTED_INTERCEPTOR=Injection point resolves to an interceptor
ILLEGAL_SPECIALIZING_MANAGED_BEAN=Managed bean class annotated @Specializes does not
directly extend the bean class of another managed bean
ILLEGAL_SPECIALIZING_SESSION_BEAN=Session bean class annotated @Specializes does not
directly extend the bean class of another session bean
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -50,6 +50,7 @@
{CDIPreferences.PRODUCER_FIELD_TYPE_HAS_WILDCARD,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_producerFieldTypeHasWildcard_label},
{CDIPreferences.PRODUCER_FIELD_TYPE_IS_VARIABLE,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_producerFieldTypeIsVariable_label},
// {CDIPreferences.PRODUCER_FIELD_TYPE_DOES_NOT_MATCH_JAVA_EE_OBJECT,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_producerFieldTypeDoesNotMatchJavaEeObject_label},
+ {CDIPreferences.INJECT_RESOLVES_TO_NULLABLE_BEAN,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_injectResolvesToNullableBean_label},
{CDIPreferences.INJECTION_TYPE_IS_VARIABLE,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_injectionTypeIsVariable_label},
{CDIPreferences.STEREOTYPE_IS_ANNOTATED_TYPED,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_stereotypeIsAnnotatedTyped_label},
{CDIPreferences.MISSING_NONBINDING_IN_QUALIFIER_TYPE_MEMBER,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_missingNonbindingInQualifierTypeMember_label},
@@ -117,6 +118,8 @@
// {CDIPreferences.OBSERVER_IN_INTERCEPTOR_OR_DECORATOR,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_observerInInterceptorOrDecorator_label},
{CDIPreferences.INTERCEPTOR_OR_DECORATOR_IS_ALTERNATIVE,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_interceptorOrDecoratorIsAlternative_label},
// {CDIPreferences.MISSING_INTERCEPTOR_BINDING,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_missingInterceptorBinding_label},
+ {CDIPreferences.INJECTED_DECORATOR,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_injectedDecorator_label},
+ {CDIPreferences.INJECTED_INTERCEPTOR,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_injectedInterceptor_label},
},
CDICorePlugin.PLUGIN_ID
);
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.java 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -50,6 +50,7 @@
public static String
CDIValidatorConfigurationBlock_pb_producerFieldTypeHasWildcard_label;
public static String
CDIValidatorConfigurationBlock_pb_producerFieldTypeIsVariable_label;
public static String
CDIValidatorConfigurationBlock_pb_producerFieldTypeDoesNotMatchJavaEeObject_label;
+ public static String
CDIValidatorConfigurationBlock_pb_injectResolvesToNullableBean_label;
public static String CDIValidatorConfigurationBlock_pb_injectionTypeIsVariable_label;
public static String
CDIValidatorConfigurationBlock_pb_stereotypeIsAnnotatedTyped_label;
public static String
CDIValidatorConfigurationBlock_pb_missingNonbindingInQualifierTypeMember_label;
@@ -105,6 +106,8 @@
public static String
CDIValidatorConfigurationBlock_pb_observerInInterceptorOrDecorator_label;
public static String
CDIValidatorConfigurationBlock_pb_interceptorOrDecoratorIsAlternative_label;
public static String CDIValidatorConfigurationBlock_pb_missingInterceptorBinding_label;
+ public static String CDIValidatorConfigurationBlock_pb_injectedDecorator_label;
+ public static String CDIValidatorConfigurationBlock_pb_injectedInterceptor_label;
// Specializing
public static String CDIValidatorConfigurationBlock_section_specializing;
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.properties
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.properties 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.properties 2010-06-11
10:06:32 UTC (rev 22762)
@@ -39,6 +39,7 @@
CDIValidatorConfigurationBlock_pb_producerFieldTypeHasWildcard_label=Wildcard in producer
field type:
CDIValidatorConfigurationBlock_pb_producerFieldTypeIsVariable_label=Variable in producer
field type:
CDIValidatorConfigurationBlock_pb_producerFieldTypeDoesNotMatchJavaEeObject_label=Producer
field type conflicts Java EE object:
+CDIValidatorConfigurationBlock_pb_injectResolvesToNullableBean_label=Injection point of
primitive type resolves to a nullabe bean:
CDIValidatorConfigurationBlock_pb_injectionTypeIsVariable_label=Injection type is
variable:
CDIValidatorConfigurationBlock_pb_stereotypeIsAnnotatedTyped_label=Stereotype has
@Typed:
CDIValidatorConfigurationBlock_pb_missingNonbindingInQualifierTypeMember_label=Missing
@Nonbinding in qualifier type member:
@@ -94,6 +95,8 @@
CDIValidatorConfigurationBlock_pb_observerInInterceptorOrDecorator_label=Interceptor or
decorator has a method annotated @Disposes:
CDIValidatorConfigurationBlock_pb_interceptorOrDecoratorIsAlternative_label=Interceptor
or decorator is an alternative:
CDIValidatorConfigurationBlock_pb_missingInterceptorBinding_label=Missing interceptor
binding:
+CDIValidatorConfigurationBlock_pb_injectedDecorator_label=Decorator can not be injected:
+CDIValidatorConfigurationBlock_pb_injectedInterceptor_label=Interceptor can not be
injected:
##Specializing
CDIValidatorConfigurationBlock_section_specializing=Specializing
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/GameBroken.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/GameBroken.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/GameBroken.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -0,0 +1,24 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.inject;
+
+import javax.inject.Inject;
+
+@SuppressWarnings("unused")
+class GameBroken {
+ @Inject @PrimitiveTestQualifer private int numberBroken;
+
+ @Inject @PrimitiveTestQualifer private Integer number2;
+ @Inject @TestQualifer private int number3;
+ @Inject @TestQualifer private Integer number4;
+
+ @Inject
+ public void setNumber() {
+
+ }
+
+ @Inject
+ public void setNumber2(@PrimitiveTestQualifer int numberBroken,
+ @PrimitiveTestQualifer Integer number2,
+ @TestQualifer int number3,
+ @TestQualifer Integer number4) {
+ }
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/GameBroken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/NumberProducer.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/NumberProducer.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/NumberProducer.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -0,0 +1,18 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.inject;
+
+import javax.enterprise.inject.Produces;
+
+class NumberProducer {
+
+ @Produces
+ @PrimitiveTestQualifer
+ public Integer getNumber() {
+ return null;
+ }
+
+ @Produces
+ @TestQualifer
+ public int getNumber2() {
+ return 0;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/NumberProducer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/PrimitiveTestQualifer.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/PrimitiveTestQualifer.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/PrimitiveTestQualifer.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.inject;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@Qualifier
+public @interface PrimitiveTestQualifer {
+
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/PrimitiveTestQualifer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/TestQualifer.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/TestQualifer.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/TestQualifer.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.inject;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@Qualifier
+public @interface TestQualifer {
+
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/TestQualifer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/Cat.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/Cat.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/Cat.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -0,0 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.jbt.validation.interceptors;
+
+class Cat
+{
+ @CatInterceptorBinding
+ public String hello() {
+ return "hello";
+ }
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/Cat.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/CatInterceptor.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/CatInterceptor.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/CatInterceptor.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.jbt.validation.interceptors;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@Interceptor
+@CatInterceptorBinding
+class CatInterceptor extends Cat
+{
+
+ @AroundInvoke
+ public Object intercept(InvocationContext ctx) throws Exception {
+ return ctx.proceed();
+ }
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/CatInterceptor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/CatInterceptorBinding.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/CatInterceptorBinding.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/CatInterceptorBinding.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.jbt.validation.interceptors;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.interceptor.InterceptorBinding;
+
+@Inherited
+@InterceptorBinding
+@Target( { TYPE, METHOD })
+@Retention(RUNTIME)
+@interface CatInterceptorBinding
+{
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/CatInterceptorBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/InjectInterceptorBroken.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/InjectInterceptorBroken.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/InjectInterceptorBroken.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -0,0 +1,8 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.interceptors;
+
+import javax.inject.Inject;
+
+public class InjectInterceptorBroken {
+
+ @Inject CatInterceptor cat;
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/InjectInterceptorBroken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/beans.xml
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/beans.xml 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/beans.xml 2010-06-11
10:06:32 UTC (rev 22762)
@@ -3,6 +3,7 @@
<class>org.jboss.jsr299.tck.tests.jdt.validation.interceptors.NamedInterceptorBroken</class>
<class>org.jboss.jsr299.tck.tests.jdt.validation.interceptors.FordInterceptor</class>
<class>org.jboss.jsr299.tck.tests.jdt.validation.interceptors.InterceptorWithWrongScopeBroken</class>
-
<class>org.jboss.jsr299.tck.tests.jdt.validation.interceptors.AltrenativeInterceptorBroken</class>
+
<class>org.jboss.jsr299.tck.tests.jdt.validation.interceptors.AlternativeInterceptorBroken</class>
+
<class>org.jboss.jsr299.tck.tests.jdt.validation.interceptors.CatInterceptor</class>
</interceptors>
</beans>
\ No newline at end of file
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -10,17 +10,16 @@
******************************************************************************/
package org.jboss.tools.cdi.core.test;
-import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.internal.core.JavaModelManager;
-//import org.jboss.tools.cdi.core.test.tck.NamedBeanRefactoringTest;
+import org.jboss.tools.cdi.core.test.tck.AssignabilityOfRawAndParameterizedTypesTest;
import org.jboss.tools.cdi.core.test.tck.BeanDefinitionTest;
import org.jboss.tools.cdi.core.test.tck.BeanSpecializationTest;
import org.jboss.tools.cdi.core.test.tck.DefaultNamedTest;
import org.jboss.tools.cdi.core.test.tck.EnterpriseQualifierDefinitionTest;
+import org.jboss.tools.cdi.core.test.tck.EnterpriseResolutionByTypeTest;
import org.jboss.tools.cdi.core.test.tck.EnterpriseScopeDefinitionTest;
import org.jboss.tools.cdi.core.test.tck.EnterpriseStereotypeDefinitionTest;
import org.jboss.tools.cdi.core.test.tck.InjectionPointTest;
@@ -32,7 +31,6 @@
import org.jboss.tools.cdi.core.test.tck.StereotypeDefinitionTest;
import org.jboss.tools.cdi.core.test.tck.StereotypeInheritenceTest;
import org.jboss.tools.cdi.core.test.tck.ValidationTest;
-import org.jboss.tools.tests.AbstractPluginsLoadTest;
/**
* @author Alexey Kazakov
@@ -42,7 +40,7 @@
public static Test suite() {
// it could be done here because it is not needed to be enabled back
JavaModelManager.getIndexManager().disable();
-
+
TestSuite suite = new TestSuite("CDI Core Tests");
suite.addTestSuite(BeanDefinitionTest.class);
suite.addTestSuite(NameDefinitionTest.class);
@@ -58,8 +56,9 @@
suite.addTestSuite(InjectionPointTest.class);
suite.addTestSuite(BeanSpecializationTest.class);
suite.addTestSuite(ResolutionByTypeTest.class);
+ suite.addTestSuite(EnterpriseResolutionByTypeTest.class);
+ suite.addTestSuite(AssignabilityOfRawAndParameterizedTypesTest.class);
suite.addTestSuite(ValidationTest.class);
return new CDICoreTestSetup(suite);
}
-
}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/AssignabilityOfRawAndParameterizedTypesTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/AssignabilityOfRawAndParameterizedTypesTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/AssignabilityOfRawAndParameterizedTypesTest.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.core.test.tck;
+
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.jboss.tools.cdi.core.IBean;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class AssignabilityOfRawAndParameterizedTypesTest extends TCKTest {
+
+ /**
+ * Section 5.2 - Typesafe resolution
+ * kb) Test with a raw type.
+ *
+ * @throws CoreException
+ */
+ public void testAssignabilityToRawType() throws CoreException {
+ Set<IBean> beans =
getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.parameterized.Dao");
+ assertEquals("Wrong number of the beans", 4, beans.size());
+ }
+
+ // TODO continue implementing tests.
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/AssignabilityOfRawAndParameterizedTypesTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BeanDefinitionTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BeanDefinitionTest.java 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BeanDefinitionTest.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -125,7 +125,7 @@
Set<IBean> beans =
getBeans("org.jboss.jsr299.tck.tests.definition.bean.Tarantula");
assertEquals("There should be the only bean with
org.jboss.jsr299.tck.tests.definition.bean.Tarantula type", 1, beans.size());
IBean bean = beans.iterator().next();
- assertContainsBeanType(bean,
"org.jboss.jsr299.tck.tests.definition.bean.Tarantula",
+ assertContainsBeanTypes(bean,
"org.jboss.jsr299.tck.tests.definition.bean.Tarantula",
"org.jboss.jsr299.tck.tests.definition.bean.Spider",
"org.jboss.jsr299.tck.tests.definition.bean.Animal",
"java.lang.Object",
@@ -148,7 +148,7 @@
Set<IBean> beans =
getBeans("org.jboss.jsr299.tck.tests.definition.bean.FriendlyAntelope");
assertEquals("There should be the only bean with
org.jboss.jsr299.tck.tests.definition.bean.FriendlyAntelope type", 1, beans.size());
IBean bean = beans.iterator().next();
- assertContainsBeanType(bean,
"org.jboss.jsr299.tck.tests.definition.bean.FriendlyAntelope",
+ assertContainsBeanTypes(bean,
"org.jboss.jsr299.tck.tests.definition.bean.FriendlyAntelope",
"org.jboss.jsr299.tck.tests.definition.bean.AbstractAntelope",
"org.jboss.jsr299.tck.tests.definition.bean.Animal",
"java.lang.Object");
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BeanSpecializationTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BeanSpecializationTest.java 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BeanSpecializationTest.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -30,7 +30,7 @@
Set<IBean> beans = cdiProject.getBeans(true,
"org.jboss.jsr299.tck.tests.inheritance.specialization.simple.LazyFarmer",
"org.jboss.jsr299.tck.tests.inheritance.specialization.simple.Landowner");
assertEquals("Wrong number of beans.", 1, beans.size());
IBean bean = beans.iterator().next();
- assertContainsBeanType(false, bean,
"org.jboss.jsr299.tck.tests.inheritance.specialization.simple.Farmer");
+ assertContainsBeanTypes(false, bean,
"org.jboss.jsr299.tck.tests.inheritance.specialization.simple.Farmer");
assertContainsQualifierType(true, bean,
"org.jboss.jsr299.tck.tests.inheritance.specialization.simple.Landowner",
"org.jboss.jsr299.tck.tests.inheritance.specialization.simple.Lazy",
@@ -48,7 +48,7 @@
Set<IBean> beans = cdiProject.getBeans(true,
"org.jboss.jsr299.tck.tests.inheritance.specialization.enterprise.LazyFarmerLocal",
"org.jboss.jsr299.tck.tests.inheritance.specialization.enterprise.Landowner");
assertEquals("Wrong number of beans.", 1, beans.size());
IBean bean = beans.iterator().next();
- assertContainsBeanType(false, bean,
"org.jboss.jsr299.tck.tests.inheritance.specialization.enterprise.FarmerLocal");
+ assertContainsBeanTypes(false, bean,
"org.jboss.jsr299.tck.tests.inheritance.specialization.enterprise.FarmerLocal");
assertContainsQualifierType(true, bean,
"org.jboss.jsr299.tck.tests.inheritance.specialization.enterprise.Landowner",
"org.jboss.jsr299.tck.tests.inheritance.specialization.enterprise.Lazy",
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/EnterpriseResolutionByTypeTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/EnterpriseResolutionByTypeTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/EnterpriseResolutionByTypeTest.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.core.test.tck;
+
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.jboss.tools.cdi.core.IBean;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class EnterpriseResolutionByTypeTest extends TCKTest {
+
+ /**
+ * Section 2.2.2 - Restricting the bean types of a bean
+ * b) Check session bean.
+ *
+ * @throws CoreException
+ */
+ public void testBeanTypesOnSessionBean() throws CoreException {
+ Set<IBean> beans =
getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.CapercaillieLocal");
+ assertEquals("Wrong number of the beans", 1, beans.size());
+ assertContainsBeanTypes(beans.iterator().next(),
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.CapercaillieLocal",
"java.lang.Object");
+ beans =
getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.ScottishBirdLocal");
+ assertEquals("Wrong number of the beans", 0, beans.size());
+ }
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/EnterpriseResolutionByTypeTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ResolutionByTypeTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ResolutionByTypeTest.java 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ResolutionByTypeTest.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -37,7 +37,7 @@
public void testDefaultBindingTypeAssumed() throws CoreException {
Set<IBean> beans =
getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Tuna");
assertEquals("Wrong number of the beans", 1, beans.size());
- assertContainsBeanType(false, beans.iterator().next(),
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Tuna");
+ assertContainsBeanTypes(false, beans.iterator().next(),
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Tuna");
}
/**
@@ -131,6 +131,20 @@
}
/**
+ * 5.1.4. Inter-module injection
+ * i) Check a disabled managed bean is not injectable.
+ *
+ * @throws CoreException
+ */
+ public void testPolicyNotAvailableInNonDeploymentArchive() throws CoreException {
+ Set<IBean> beans =
getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Spider");
+ assertFalse("Wrong number of the beans", beans.isEmpty());
+ assertDoesNotContainBeanClasses(beans, new
String[]{"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.CrabSpider",
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.DaddyLongLegs"});
+ beans = cdiProject.getBeans("crabSpider", true);
+ assertTrue("Wrong nuber of the beans", beans.isEmpty());
+ }
+
+ /**
* Section 2.2.2 - Restricting the bean types of a bean
* a) Check managed bean.
*
@@ -142,7 +156,7 @@
IBean bean = beans.iterator().next();
beans =
getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Bird");
assertEquals("Wrong number of the beans", 0, beans.size());
- assertContainsBeanType(bean,
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Canary",
"java.lang.Object");
+ assertContainsBeanTypes(bean,
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Canary",
"java.lang.Object");
}
/**
@@ -166,8 +180,8 @@
beans = cdiProject.getBeans(true, parametedType, new IQualifierDeclaration[0]);
assertEquals("Wrong number of the beans", 0, beans.size());
- assertContainsBeanType(false, bean, "java.lang.Object");
- assertContainsBeanType(false, bean,
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.FlightlessBird");
+ assertContainsBeanTypes(false, bean, "java.lang.Object");
+ assertContainsBeanTypes(false, bean,
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.FlightlessBird");
assertContainsBeanTypeSignatures(false, bean,
"QFlightlessBird<QAustralian;>;");
}
@@ -180,7 +194,7 @@
public void testBeanTypesOnProducerMethod() throws CoreException {
Set<IBean> beans =
getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Parrot");
assertEquals("Wrong number of the beans", 1, beans.size());
- assertContainsBeanType(beans.iterator().next(),
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Parrot",
"java.lang.Object");
+ assertContainsBeanTypes(beans.iterator().next(),
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Parrot",
"java.lang.Object");
beans =
getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Bird");
assertEquals("Wrong number of the beans", 0, beans.size());
@@ -201,8 +215,8 @@
assertEquals("Wrong number of the beans", 1, beans.size());
IBean bean = beans.iterator().next();
- assertContainsBeanType(false, bean, "java.lang.Object");
- assertContainsBeanType(false, bean,
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Cat");
+ assertContainsBeanTypes(false, bean, "java.lang.Object");
+ assertContainsBeanTypes(false, bean,
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Cat");
assertContainsBeanTypeSignatures(false, bean, "QCat<QEuropean;>;");
beans =
getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.DomesticCat",
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Tame");
@@ -224,8 +238,8 @@
assertEquals("Wrong number of the beans", 1, beans.size());
IBean bean = beans.iterator().next();
- assertContainsBeanType(false, bean, "java.lang.Object");
- assertContainsBeanType(false, bean,
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Cat");
+ assertContainsBeanTypes(false, bean, "java.lang.Object");
+ assertContainsBeanTypes(false, bean,
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Cat");
assertContainsBeanTypeSignatures(false, bean, "QCat<QAfrican;>;");
beans =
getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Lion",
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Wild");
@@ -241,7 +255,7 @@
public void testBeanTypesOnProducerField() throws CoreException {
Set<IBean> beans =
getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Dove");
assertEquals("Wrong number of the beans", 1, beans.size());
- assertContainsBeanType(beans.iterator().next(),
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Dove",
"java.lang.Object");
+ assertContainsBeanTypes(beans.iterator().next(),
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Dove",
"java.lang.Object");
beans =
getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Bird");
assertEquals("Wrong number of the beans", 0, beans.size());
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -224,11 +224,11 @@
fail(message.toString());
}
- protected void assertContainsBeanType(IBean bean, String... typeNames) {
- assertContainsBeanType(true, bean, typeNames);
+ protected void assertContainsBeanTypes(IBean bean, String... typeNames) {
+ assertContainsBeanTypes(true, bean, typeNames);
}
- protected void assertContainsBeanType(boolean checkTheNumberOfTypes, IBean bean,
String... typeNames) {
+ protected void assertContainsBeanTypes(boolean checkTheNumberOfTypes, IBean bean,
String... typeNames) {
if(checkTheNumberOfTypes) {
assertEquals("Wrong number of types.", typeNames.length,
bean.getLegalTypes().size());
}
@@ -272,6 +272,17 @@
}
}
+ public static void assertDoesNotContainBeanClasses(Set<IBean> beans, String...
beanClassNames) throws CoreException {
+ StringBuffer sb = new StringBuffer("[");
+ for (String beanClassName : beanClassNames) {
+ sb.append(beanClassName).append("; ");
+ }
+ sb.append("]");
+ for (String beanClassName : beanClassNames) {
+ assertTrue("Found " + beanClassName + " among " + sb.toString(),
doesNotContainBeanClass(beans, beanClassName));
+ }
+ }
+
public static void assertContainsBeanClasses(Set<IBean> beans, String...
beanClassNames) throws CoreException {
assertContainsBeanClasses(true, beans, beanClassNames);
}
@@ -294,6 +305,15 @@
assertTrue("Didn't find " + beanClassName, containsBeanClass(beans,
beanClassName));
}
+ private static boolean doesNotContainBeanClass(Set<IBean> beans, String
beanClassName) throws CoreException {
+ for (IBean bean : beans) {
+ if(beanClassName.equals(bean.getBeanClass().getFullyQualifiedName())) {
+ return false;
+ }
+ }
+ return true;
+ }
+
private static boolean containsBeanClass(Set<IBean> beans, String beanClassName)
throws CoreException {
for (IBean bean : beans) {
if(beanClassName.equals(bean.getBeanClass().getFullyQualifiedName())) {
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java 2010-06-11
09:57:56 UTC (rev 22761)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java 2010-06-11
10:06:32 UTC (rev 22762)
@@ -885,6 +885,28 @@
}
/**
+ * 5.1.4. Inter-module injection
+ * - a decorator can not be injected
+ *
+ * @throws Exception
+ */
+ public void testDecoratorNotResolved() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/decorator/House.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE, CDIValidationMessages.INJECTED_DECORATOR, 23);
+ }
+
+ /**
+ * 5.1.4. Inter-module injection
+ * - an interceptor can not be injected
+ *
+ * @throws Exception
+ */
+ public void testInterceptorNotResolved() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/interceptors/InjectInterceptorBroken.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE, CDIValidationMessages.INJECTED_INTERCEPTOR, 7);
+ }
+
+ /**
* 5.2.1. Unsatisfied and ambiguous dependencies
* - If an unresolvable ambiguous dependency exists, the container automatically
detects the problem and treats it as a deployment problem.
*
@@ -922,6 +944,23 @@
}
/**
+ * 5.2.4. Primitive types and null values
+ * - injection point of primitive type resolves to a bean that may have null values,
such as a producer method with a non-primitive return type or a producer field with a
non-primitive type
+ *
+ * @throws Exception
+ */
+ public void testPrimitiveInjectionPointResolvedToNonPrimitiveProducerMethod() throws
Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/inject/GameBroken.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 7, 19);
+ AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 9);
+ AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 10);
+ AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 11);
+ AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 20);
+ AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 21);
+ AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 22);
+ }
+
+ /**
* 5.2.5. Qualifier annotations with members
* - annotation-valued member of a qualifier type is not annotated @Nonbinding
(Non-Portable behavior)
*