Author: akazakov
Date: 2010-05-24 14:43:55 -0400 (Mon, 24 May 2010)
New Revision: 22294
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/InjectionPointTest.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/internal/core/validation/CDICoreValidator.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreTestSuite.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-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-05-24
17:18:22 UTC (rev 22293)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java 2010-05-24
18:43:55 UTC (rev 22294)
@@ -443,6 +443,23 @@
return null;
}
+ /**
+ * Returns all the injection point parameters of the bean class.
+ *
+ * @param bean
+ * @return
+ */
+ public static Set<IInjectionPointParameter> getInjectionPointParameters(IClassBean
bean) {
+ Set<IInjectionPoint> points = bean.getInjectionPoints();
+ Set<IInjectionPointParameter> params = new
HashSet<IInjectionPointParameter>();
+ for (IInjectionPoint injection : points) {
+ if(injection instanceof IInjectionPointParameter) {
+ params.add((IInjectionPointParameter)injection);
+ }
+ }
+ return params;
+ }
+
private static IType getSuperClass(IType type) throws JavaModelException {
String superclassName = type.getSuperclassName();
if(superclassName!=null) {
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
17:18:22 UTC (rev 22293)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2010-05-24
18:43:55 UTC (rev 22294)
@@ -832,9 +832,8 @@
private void validateInjectionPoint(IInjectionPoint injection) {
/*
- * 3.11. The qualifier @Named at injection points - injection point
- * other than injected field declares a @Named annotation that does not
- * specify the value member
+ * 3.11. The qualifier @Named at injection points
+ * - injection point other than injected field declares a @Named annotation that does
not specify the value member
*/
if(injection instanceof IInjectionPointParameter) {
IInjectionPointParameter pinjection = (IInjectionPointParameter)injection;
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-05-24
17:18:22 UTC (rev 22293)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt 2010-05-24
18:43:55 UTC (rev 22294)
@@ -102,9 +102,6 @@
and qualifier @Default, and may not validly make use of the JTA UserTransaction
according to the Java EE platform specification
-
-
-
3.7.1. Declaring a bean constructor
- bean class has more than one constructor annotated @Inject
- bean constructor has a parameter annotated @Disposes, or @Observes
@@ -112,6 +109,9 @@
3.8.1. Declaring an injected field
- injected field is annotated @Produces
+
+
+
3.9.1. Declaring an initializer method
- generic method of a bean is annotated @Inject (initializer method is a non-abstract,
non-static, non-generic method of a bean class)
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreTestSuite.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreTestSuite.java 2010-05-24
17:18:22 UTC (rev 22293)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreTestSuite.java 2010-05-24
18:43:55 UTC (rev 22294)
@@ -18,6 +18,7 @@
import org.jboss.tools.cdi.core.test.tck.EnterpriseQualifierDefinitionTest;
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;
import org.jboss.tools.cdi.core.test.tck.NameDefinitionTest;
import org.jboss.tools.cdi.core.test.tck.ProducerMethodDefinitionTest;
import org.jboss.tools.cdi.core.test.tck.QualifierDefinitionTest;
@@ -44,6 +45,7 @@
suite.addTestSuite(EnterpriseStereotypeDefinitionTest.class);
suite.addTestSuite(StereotypeInheritenceTest.class);
suite.addTestSuite(ProducerMethodDefinitionTest.class);
+ suite.addTestSuite(InjectionPointTest.class);
suite.addTestSuite(ValidationTest.class);
return suite;
}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/InjectionPointTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/InjectionPointTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/InjectionPointTest.java 2010-05-24
18:43:55 UTC (rev 22294)
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * 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.jboss.tools.cdi.core.CDIUtil;
+import org.jboss.tools.cdi.core.IClassBean;
+import org.jboss.tools.cdi.core.IInjectionPointParameter;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class InjectionPointTest extends TCKTest {
+
+ /**
+ * Section 3.7.1 - Declaring a bean constructor
+ * - All parameters of a bean constructor are injection points.
+ */
+ public void testQualifierTypeAnnotatedConstructor() {
+ IClassBean bean =
getClassBean("JavaSource/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Duck.java");
+ Set<IInjectionPointParameter> points =
CDIUtil.getInjectionPointParameters(bean);
+ assertEquals("There should be two injection point parameters in the bean.",
2, points.size());
+ }
+
+ /**
+ * Section 3.9.1 - Declaring an initializer method
+ * - All initializer method parameters are injection points.
+ */
+ public void testBindingTypeOnInitializerParameter() {
+ IClassBean bean =
getClassBean("JavaSource/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/Mainz.java");
+ Set<IInjectionPointParameter> points =
CDIUtil.getInjectionPointParameters(bean);
+ assertEquals("There should be two injection point parameters in the bean.",
1, points.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/InjectionPointTest.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/TCKTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java 2010-05-24
17:18:22 UTC (rev 22293)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java 2010-05-24
18:43:55 UTC (rev 22294)
@@ -2,6 +2,7 @@
import java.io.File;
import java.io.FileFilter;
+import java.util.HashSet;
import java.util.Set;
import junit.framework.TestCase;
@@ -22,6 +23,9 @@
import org.jboss.tools.cdi.core.IAnnotationDeclaration;
import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.ICDIProject;
+import org.jboss.tools.cdi.core.IClassBean;
+import org.jboss.tools.cdi.core.IInjectionPoint;
+import org.jboss.tools.cdi.core.IInjectionPointParameter;
import org.jboss.tools.cdi.core.IParametedType;
import org.jboss.tools.cdi.core.IQualifier;
import org.jboss.tools.cdi.core.IQualifierDeclaration;
@@ -115,6 +119,18 @@
return beans;
}
+ protected IClassBean getClassBean(String path) {
+ IFile file = tckProject.getFile(path);
+ Set<IBean> beans = cdiProject.getBeans(file.getFullPath());
+ for (IBean bean : beans) {
+ if(bean instanceof IClassBean) {
+ return (IClassBean)bean;
+ }
+ }
+ fail("Can't find a class bean in " + path);
+ return null;
+ }
+
protected IQualifierDeclaration getQualifierDeclarationFromBeanClass(String
beanClassFilePath, String annotationTypeName) throws JavaModelException {
IFile file = tckProject.getFile(beanClassFilePath);
Set<IBean> beans = cdiProject.getBeans(file.getFullPath());
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
17:18:22 UTC (rev 22293)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java 2010-05-24
18:43:55 UTC (rev 22294)
@@ -691,6 +691,9 @@
* 3.4.2. Declaring a producer field
* - producer field is annotated @Inject
*
+ * 3.8.1. Declaring an injected field
+ * - injected field is annotated @Produces
+ *
* @throws Exception
*/
public void testProducerAnnotatedInject() throws Exception {