Author: akazakov
Date: 2010-05-24 13:06:45 -0400 (Mon, 24 May 2010)
New Revision: 22292
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreBuilder.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IClassBean.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/definition/TypeDefinition.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/messages.properties
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/event/broken/observer/isInitializer/AustralianTerrier_Broken.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/jira/browse/JBIDE-2708 Added new CDI validation rules: 1. Bean
class has more than one constructor annotated @Inject; 2. Bean constructor has a parameter
annotated @Disposes; 3. Bean constructor has a parameter annotated @Observes; 4. Observer
method is annotated @Inject; 5. Method has more than one parameter annotated @Observes
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreBuilder.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreBuilder.java 2010-05-24
15:56:44 UTC (rev 22291)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreBuilder.java 2010-05-24
17:06:45 UTC (rev 22292)
@@ -324,8 +324,10 @@
if(srcs[i].isPrefixOf(path)) {
if(f.getName().endsWith(".java")) {
ICompilationUnit unit = EclipseUtil.getCompilationUnit(f);
- IType[] ts = unit.getTypes();
- fileSet.add(f.getFullPath(), ts);
+ if(unit!=null) {
+ IType[] ts = unit.getTypes();
+ fileSet.add(f.getFullPath(), ts);
+ }
}
return false;
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IClassBean.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IClassBean.java 2010-05-24
15:56:44 UTC (rev 22291)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IClassBean.java 2010-05-24
17:06:45 UTC (rev 22292)
@@ -38,7 +38,7 @@
*
* @return a set of bean constructors of the bean.
*/
- Set<IBeanMethod> getBeanConstructor();
+ Set<IBeanMethod> getBeanConstructors();
/**
* Obtains the interceptor bindings of the bean.
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-05-24
15:56:44 UTC (rev 22291)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java 2010-05-24
17:06:45 UTC (rev 22292)
@@ -15,7 +15,6 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -31,7 +30,6 @@
import org.jboss.tools.cdi.core.IClassBean;
import org.jboss.tools.cdi.core.IInjectionPoint;
import org.jboss.tools.cdi.core.IInterceptorBindingDeclaration;
-import org.jboss.tools.cdi.core.IObserverMethod;
import org.jboss.tools.cdi.core.IParametedType;
import org.jboss.tools.cdi.core.IProducer;
import org.jboss.tools.cdi.core.IQualifierDeclaration;
@@ -42,7 +40,6 @@
import org.jboss.tools.cdi.core.ITypeDeclaration;
import org.jboss.tools.cdi.internal.core.impl.definition.FieldDefinition;
import org.jboss.tools.cdi.internal.core.impl.definition.MethodDefinition;
-import org.jboss.tools.cdi.internal.core.impl.definition.ParametedTypeFactory;
import org.jboss.tools.cdi.internal.core.impl.definition.TypeDefinition;
import org.jboss.tools.common.model.project.ext.impl.ValueInfo;
import org.jboss.tools.common.text.ITextSourceReference;
@@ -102,13 +99,22 @@
return (TypeDefinition)definition;
}
- public Set<IBeanMethod> getBeanConstructor() {
+ public Set<IBeanMethod> getBeanConstructors() {
Set<IBeanMethod> result = new HashSet<IBeanMethod>();
+ IBeanMethod defaultConstructor = null;
for (BeanMethod m: methods) {
if(m.getDefinition().isConstructor()) {
- result.add(m);
+ if(m.getAnnotation(CDIConstants.INJECT_ANNOTATION_TYPE_NAME)==null &&
m.getMethod().getNumberOfParameters()==0) {
+ defaultConstructor = m;
+ } else {
+ result.add(m);
+ }
}
}
+ // If a bean class does not explicitly declare a constructor using @Inject, the
constructor that accepts no parameters is the bean constructor.
+ if(result.isEmpty() && defaultConstructor!=null) {
+ result.add(defaultConstructor);
+ }
return result;
}
@@ -180,7 +186,7 @@
public Set<IBeanMethod> getObserverMethods() {
Set<IBeanMethod> result = new HashSet<IBeanMethod>();
for (BeanMethod m: methods) {
- if(m.isDisposer()) {
+ if(m.isObserver()) {
result.add(m);
}
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/TypeDefinition.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/TypeDefinition.java 2010-05-24
15:56:44 UTC (rev 22291)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/TypeDefinition.java 2010-05-24
17:06:45 UTC (rev 22292)
@@ -57,7 +57,7 @@
MethodDefinition m = new MethodDefinition();
m.setTypeDefinition(this);
m.setMethod(ms[i], context);
- if(m.isCDIAnnotated()) {
+ if(m.isCDIAnnotated() || (ms[i].isConstructor() &&
ms[i].getNumberOfParameters()==0)) {
methods.add(m);
}
}
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-05-24
15:56:44 UTC (rev 22291)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2010-05-24
17:06:45 UTC (rev 22292)
@@ -271,6 +271,7 @@
if (reporter.isCancelled() || file == null || !file.isAccessible()) {
return;
}
+ displaySubtask(CDIValidationMessages.VALIDATING_RESOURCE, new String[]
{file.getProject().getName(), file.getName()});
Set<IBean> beans = cdiProject.getBeans(file.getFullPath());
for (IBean bean : beans) {
validateBean(bean);
@@ -337,6 +338,7 @@
private void validateClassBean(IClassBean bean) {
validateDisposers(bean);
+ validateObserves(bean);
if (!(bean instanceof ISessionBean)) {
validateManagedBean(bean);
} else {
@@ -347,7 +349,7 @@
}
private void validateConstructors(IClassBean bean) {
- Set<IBeanMethod> constructors = bean.getBeanConstructor();
+ Set<IBeanMethod> constructors = bean.getBeanConstructors();
if(constructors.size()>1) {
Set<IAnnotationDeclaration> injects = new
HashSet<IAnnotationDeclaration>();
for (IBeanMethod constructor : constructors) {
@@ -368,6 +370,52 @@
}
}
+ private void validateObserves(IClassBean bean) {
+ Set<IBeanMethod> observes = bean.getObserverMethods();
+ if (observes.isEmpty()) {
+ return;
+ }
+ for (IBeanMethod observer : observes) {
+ List<IParameter> params = observer.getParameters();
+ Set<ITextSourceReference> declarations = new
HashSet<ITextSourceReference>();
+ for (IParameter param : params) {
+ ITextSourceReference declaration =
param.getAnnotationPosition(CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME);
+ if (declaration != null) {
+ declarations.add(declaration);
+ }
+ }
+ /*
+ * 10.4.2. Declaring an observer method
+ * - method has more than one parameter annotated @Observes
+ */
+ if(declarations.size()>1) {
+ for (ITextSourceReference declaration : declarations) {
+ addError(CDIValidationMessages.MULTIPLE_OBSERVING_PARAMETERS,
CDIPreferences.MULTIPLE_OBSERVING_PARAMETERS, declaration, bean.getResource());
+ }
+ }
+ /*
+ * 3.7.1. Declaring a bean constructor
+ * - bean constructor has a parameter annotated @Observes
+ *
+ * 10.4.2. Declaring an observer method
+ * - observer method is annotated @Inject
+ */
+ IAnnotationDeclaration injectDeclaration =
observer.getAnnotation(CDIConstants.INJECT_ANNOTATION_TYPE_NAME);
+ try {
+ if (injectDeclaration != null) {
+ String pref =
observer.getMethod().isConstructor()?CDIPreferences.CONSTRUCTOR_PARAMETER_ILLEGALLY_ANNOTATED:CDIPreferences.OBSERVER_ANNOTATED_INJECT;
+ String message =
observer.getMethod().isConstructor()?CDIValidationMessages.CONSTRUCTOR_PARAMETER_ANNOTATED_OBSERVES:CDIValidationMessages.OBSERVER_ANNOTATED_INJECT;
+ addError(message, pref, injectDeclaration, bean.getResource());
+ for (ITextSourceReference declaration : declarations) {
+ addError(message, pref, declaration, bean.getResource());
+ }
+ }
+ } catch (JavaModelException e) {
+ CDICorePlugin.getDefault().logError(e);
+ }
+ }
+ }
+
private void validateDisposers(IClassBean bean) {
Set<IBeanMethod> disposers = bean.getDisposers();
if (disposers.isEmpty()) {
@@ -387,8 +435,7 @@
* disposer methods for a single producer method
*/
for (IBeanMethod disposerMethod : disposerMethods) {
- Set<ITextSourceReference> disposerDeclarations =
CDIUtil.getAnnotationPossitions(disposerMethod,
- CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME);
+ Set<ITextSourceReference> disposerDeclarations =
CDIUtil.getAnnotationPossitions(disposerMethod,
CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME);
for (ITextSourceReference declaration : disposerDeclarations) {
addError(CDIValidationMessages.MULTIPLE_DISPOSERS_FOR_PRODUCER,
CDIPreferences.MULTIPLE_DISPOSERS_FOR_PRODUCER, declaration, bean.getResource());
}
@@ -436,8 +483,7 @@
}
if (observesExists) {
for (ITextSourceReference declaration : declarations) {
- addError(CDIValidationMessages.OBSERVER_PARAMETER_ILLEGALLY_ANNOTATED,
CDIPreferences.OBSERVER_PARAMETER_ILLEGALLY_ANNOTATED, declaration,
- bean.getResource());
+ addError(CDIValidationMessages.OBSERVER_PARAMETER_ILLEGALLY_ANNOTATED,
CDIPreferences.OBSERVER_PARAMETER_ILLEGALLY_ANNOTATED, declaration, bean.getResource());
}
}
@@ -447,13 +493,22 @@
*
* 3.9.1. Declaring an initializer method - an initializer method
* has a parameter annotated @Disposes
+ *
+ * 3.7.1. Declaring a bean constructor
+ * - bean constructor has a parameter annotated @Disposes
*/
IAnnotationDeclaration injectDeclaration =
disposer.getAnnotation(CDIConstants.INJECT_ANNOTATION_TYPE_NAME);
- if (injectDeclaration != null) {
- addError(CDIValidationMessages.DISPOSER_ANNOTATED_INJECT,
CDIPreferences.DISPOSER_ANNOTATED_INJECT, injectDeclaration, bean.getResource());
- for (ITextSourceReference declaration : disposerDeclarations) {
- addError(CDIValidationMessages.DISPOSER_ANNOTATED_INJECT,
CDIPreferences.DISPOSER_ANNOTATED_INJECT, declaration, bean.getResource());
+ try {
+ if (injectDeclaration != null) {
+ String pref =
disposer.getMethod().isConstructor()?CDIPreferences.CONSTRUCTOR_PARAMETER_ILLEGALLY_ANNOTATED:CDIPreferences.DISPOSER_ANNOTATED_INJECT;
+ String message =
disposer.getMethod().isConstructor()?CDIValidationMessages.CONSTRUCTOR_PARAMETER_ANNOTATED_DISPOSES:CDIValidationMessages.DISPOSER_ANNOTATED_INJECT;
+ addError(message, pref, injectDeclaration, bean.getResource());
+ for (ITextSourceReference declaration : disposerDeclarations) {
+ addError(message, pref, declaration, bean.getResource());
+ }
}
+ } catch (JavaModelException e) {
+ CDICorePlugin.getDefault().logError(e);
}
/*
@@ -983,14 +1038,12 @@
}
}
if (!hasDefaultConstructor) {
- addError(CDIValidationMessages.ILLEGAL_SPECIALIZING_MANAGED_BEAN,
CDIPreferences.ILLEGAL_SPECIALIZING_MANAGED_BEAN,
- specializesDeclaration, bean.getResource());
+ addError(CDIValidationMessages.ILLEGAL_SPECIALIZING_MANAGED_BEAN,
CDIPreferences.ILLEGAL_SPECIALIZING_MANAGED_BEAN, specializesDeclaration,
bean.getResource());
}
}
} else {
// The specializing bean extends nothing
- addError(CDIValidationMessages.ILLEGAL_SPECIALIZING_MANAGED_BEAN,
CDIPreferences.ILLEGAL_SPECIALIZING_MANAGED_BEAN, specializesDeclaration,
- bean.getResource());
+ addError(CDIValidationMessages.ILLEGAL_SPECIALIZING_MANAGED_BEAN,
CDIPreferences.ILLEGAL_SPECIALIZING_MANAGED_BEAN, specializesDeclaration,
bean.getResource());
}
} catch (JavaModelException e) {
CDICorePlugin.getDefault().logError(e);
@@ -1095,8 +1148,7 @@
}
}
if (!typeWasFound) {
- addError(CDIValidationMessages.ILLEGAL_TYPE_IN_TYPED_DECLARATION,
CDIPreferences.ILLEGAL_TYPE_IN_TYPED_DECLARATION, typedDeclaration,
- bean.getResource());
+ addError(CDIValidationMessages.ILLEGAL_TYPE_IN_TYPED_DECLARATION,
CDIPreferences.ILLEGAL_TYPE_IN_TYPED_DECLARATION, typedDeclaration, bean.getResource());
}
}
}
@@ -1135,8 +1187,7 @@
}
if (declarationMap.size() > 1) {
for (IStereotypeDeclaration stereotypeDeclaration : declarationMap.values()) {
- addError(CDIValidationMessages.MISSING_SCOPE_WHEN_THERE_IS_NO_DEFAULT_SCOPE,
CDIPreferences.MISSING_SCOPE_WHEN_THERE_IS_NO_DEFAULT_SCOPE,
- stereotypeDeclaration, bean.getResource());
+ addError(CDIValidationMessages.MISSING_SCOPE_WHEN_THERE_IS_NO_DEFAULT_SCOPE,
CDIPreferences.MISSING_SCOPE_WHEN_THERE_IS_NO_DEFAULT_SCOPE, stereotypeDeclaration,
bean.getResource());
}
}
}
@@ -1221,8 +1272,7 @@
Set<IScopeDeclaration> scopeDeclarations = stereotype.getScopeDeclarations();
if (scopeDeclarations.size() > 1) {
for (IScopeDeclaration scope : scopeDeclarations) {
- addError(CDIValidationMessages.STEREOTYPE_DECLARES_MORE_THAN_ONE_SCOPE,
CDIPreferences.STEREOTYPE_DECLARES_MORE_THAN_ONE_SCOPE, scope,
- stereotype.getResource());
+ addError(CDIValidationMessages.STEREOTYPE_DECLARES_MORE_THAN_ONE_SCOPE,
CDIPreferences.STEREOTYPE_DECLARES_MORE_THAN_ONE_SCOPE, scope, stereotype.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-05-24
15:56:44 UTC (rev 22291)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java 2010-05-24
17:06:45 UTC (rev 22292)
@@ -65,7 +65,8 @@
public static String MULTIPLE_DISPOSERS_FOR_PRODUCER;
public static String ILLEGAL_PRODUCER_FIELD_IN_SESSION_BEAN;
public static String MULTIPLE_INJECTION_CONSTRUCTORS;
- public static String CONSTRUCTOR_PARAMETER_ILLEGALLY_ANNOTATED;
+ public static String CONSTRUCTOR_PARAMETER_ANNOTATED_OBSERVES;
+ public static String CONSTRUCTOR_PARAMETER_ANNOTATED_DISPOSES;
public static String GENERIC_METHOD_ANNOTATED_INJECT;
public static String MULTIPLE_OBSERVING_PARAMETERS;
public static String ILLEGAL_OBSERVER_IN_SESSION_BEAN;
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-05-24
15:56:44 UTC (rev 22291)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties 2010-05-24
17:06:45 UTC (rev 22292)
@@ -44,7 +44,8 @@
MULTIPLE_DISPOSERS_FOR_PRODUCER=There are multiple disposer methods for a single producer
method
ILLEGAL_PRODUCER_FIELD_IN_SESSION_BEAN=Non-static field of a session bean class is
annotated @Produces
MULTIPLE_INJECTION_CONSTRUCTORS=Bean class has more than one constructor annotated
@Inject
-CONSTRUCTOR_PARAMETER_ILLEGALLY_ANNOTATED=Bean constructor has a parameter annotated
@Disposes, or @Observes
+CONSTRUCTOR_PARAMETER_ANNOTATED_DISPOSES=Bean constructor has a parameter annotated
@Disposes
+CONSTRUCTOR_PARAMETER_ANNOTATED_OBSERVES=Bean constructor has a parameter annotated
@Observes
GENERIC_METHOD_ANNOTATED_INJECT=Generic method of a bean is annotated @Inject
MULTIPLE_OBSERVING_PARAMETERS=Method has more than one parameter annotated @Observes
ILLEGAL_OBSERVER_IN_SESSION_BEAN=Non-static method of a session bean class has a
parameter annotated @Observes, and the method is not a business method of the EJB
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-05-24
15:56:44 UTC (rev 22291)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java 2010-05-24
17:06:45 UTC (rev 22292)
@@ -78,7 +78,7 @@
new String[][]{
{CDIPreferences.PRODUCER_ANNOTATED_INJECT,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_producerAnnotatedInject_label},
{CDIPreferences.PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_producerParameterIllegallyAnnotated_label},
-// {CDIPreferences.OBSERVER_ANNOTATED_INJECT,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_observerAnnotatedInject_label},
+ {CDIPreferences.OBSERVER_ANNOTATED_INJECT,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_observerAnnotatedInject_label},
{CDIPreferences.OBSERVER_PARAMETER_ILLEGALLY_ANNOTATED,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_observerParameterIllegallyAnnotated_label},
{CDIPreferences.ILLEGAL_PRODUCER_METHOD_IN_SESSION_BEAN,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_illegalProducerMethodInSessionBean_label},
{CDIPreferences.MULTIPLE_DISPOSING_PARAMETERS,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_multipleDisposingParameters_label},
@@ -87,10 +87,10 @@
{CDIPreferences.NO_PRODUCER_MATCHING_DISPOSER,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_noProducerMatchingDisposer_label},
{CDIPreferences.MULTIPLE_DISPOSERS_FOR_PRODUCER,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_multipleDisposersForProducer_label},
{CDIPreferences.ILLEGAL_PRODUCER_FIELD_IN_SESSION_BEAN,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_illegalProducerFieldInSessionBean_label},
-// {CDIPreferences.MULTIPLE_INJECTION_CONSTRUCTORS,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_multipleInjectionConstructors_label},
-// {CDIPreferences.CONSTRUCTOR_PARAMETER_ILLEGALLY_ANNOTATED,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_constructorParameterIllegallyAnnotated_label},
+ {CDIPreferences.MULTIPLE_INJECTION_CONSTRUCTORS,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_multipleInjectionConstructors_label},
+ {CDIPreferences.CONSTRUCTOR_PARAMETER_ILLEGALLY_ANNOTATED,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_constructorParameterIllegallyAnnotated_label},
// {CDIPreferences.GENERIC_METHOD_ANNOTATED_INJECT,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_genericMethodAnnotatedInject_label},
-// {CDIPreferences.MULTIPLE_OBSERVING_PARAMETERS,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_multipleObservingParameters_label},
+ {CDIPreferences.MULTIPLE_OBSERVING_PARAMETERS,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_multipleObservingParameters_label},
// {CDIPreferences.ILLEGAL_OBSERVER_IN_SESSION_BEAN,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_illegalObserverInSessionBean_label},
// {CDIPreferences.ILLEGAL_CONDITIONAL_OBSERVER,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_illegalConditionalObserver_label},
},
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/event/broken/observer/isInitializer/AustralianTerrier_Broken.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/event/broken/observer/isInitializer/AustralianTerrier_Broken.java 2010-05-24
15:56:44 UTC (rev 22291)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/event/broken/observer/isInitializer/AustralianTerrier_Broken.java 2010-05-24
17:06:45 UTC (rev 22292)
@@ -22,7 +22,8 @@
class AustralianTerrier_Broken
{
- public @Inject void observesAfterBeanDiscovery(@Observes AfterBeanDiscovery
discovery)
+ @Inject
+ public void observesAfterBeanDiscovery(@Observes AfterBeanDiscovery discovery)
{
}
}
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-05-24
15:56:44 UTC (rev 22291)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java 2010-05-24
17:06:45 UTC (rev 22292)
@@ -768,6 +768,28 @@
}
/**
+ * 3.7.1. Declaring a bean constructor
+ * - bean constructor has a parameter annotated @Disposes
+ *
+ * @throws Exception
+ */
+ public void testConstructorHasDisposesParameter() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasDisposesParameter/DisposingConstructor.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.CONSTRUCTOR_PARAMETER_ANNOTATED_DISPOSES, 24, 25);
+ }
+
+ /**
+ * 3.7.1. Declaring a bean constructor
+ * - bean constructor has a parameter annotated @Observes
+ *
+ * @throws Exception
+ */
+ public void testConstructorHasObservesParameter() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasObservesParameter/ObservingConstructor.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.CONSTRUCTOR_PARAMETER_ANNOTATED_OBSERVES, 25, 26);
+ }
+
+ /**
* 3.9.1. Declaring an initializer method
* - an initializer method has a parameter annotated @Disposes
*
@@ -792,6 +814,17 @@
/**
* 10.4.2. Declaring an observer method
+ * - method has more than one parameter annotated @Observes
+ *
+ * @throws Exception
+ */
+ public void testObserverMethodMustHaveOnlyOneEventParameter() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/event/broken/observer/tooManyParameters/YorkshireTerrier_Broken.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.MULTIPLE_OBSERVING_PARAMETERS, 24, 24);
+ }
+
+ /**
+ * 10.4.2. Declaring an observer method
* - an observer method is annotated @Produces
*
* @throws Exception
@@ -803,6 +836,17 @@
/**
* 10.4.2. Declaring an observer method
+ * - observer method is annotated @Inject
+ *
+ * @throws Exception
+ */
+ public void testObserverMethodAnnotatedInitializerFails() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/event/broken/observer/isInitializer/AustralianTerrier_Broken.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE, CDIValidationMessages.OBSERVER_ANNOTATED_INJECT,
25, 26);
+ }
+
+ /**
+ * 10.4.2. Declaring an observer method
* - a observer method is annotated @Disposes.
*
* @throws Exception