Author: scabanovich
Date: 2011-09-20 14:31:58 -0400 (Tue, 20 Sep 2011)
New Revision: 34887
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/core/TestInjection2.java
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/CDIUtilTest.java
Log:
JBIDE-9742
https://issues.jboss.org/browse/JBIDE-9742
Fixed CDIUtil.findInjectionPoint()
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/core/TestInjection2.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/core/TestInjection2.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/core/TestInjection2.java 2011-09-20
18:31:58 UTC (rev 34887)
@@ -0,0 +1,41 @@
+package org.jboss.jsr299.tck.tests.jbt.core;
+
+import javax.inject.Inject;
+
+/**
+ * Test contains 10 injection points in methods with the same name and equally named
parameters
+ * but with different parameter types. Method CDIUtil.findInjectionPoint() is tested to
return
+ * correct injection point for each parameter.
+ *
+ */
+public class TestInjection2 {
+
+ @Inject
+ public void initialize(TestBean children) {
+ }
+
+ @Inject
+ public void initialize(FooBean children) {
+ }
+
+ @Inject
+ public void initialize(TestBean children, TestBean children2) {
+ }
+
+ @Inject
+ public void initialize(TestBean children, FooBean children2) {
+ }
+
+ @Inject
+ public void initialize(FooBean children, FooBean children2) {
+ }
+
+ @Inject
+ public void initialize(FooBean children, TestBean children2) {
+ }
+
+ static class TestBean {}
+
+ static class FooBean {}
+
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/core/TestInjection2.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/CDIUtilTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/CDIUtilTest.java 2011-09-20
17:30:11 UTC (rev 34886)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/CDIUtilTest.java 2011-09-20
18:31:58 UTC (rev 34887)
@@ -12,9 +12,13 @@
import java.util.Set;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IJavaElement;
import org.jboss.tools.cdi.core.CDIUtil;
+import org.jboss.tools.cdi.core.IBean;
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.common.java.IAnnotationDeclaration;
/**
@@ -45,4 +49,19 @@
}
}
}
+
+ public void testFindInjectionPoint() throws Exception {
+ String path =
"JavaSource/org/jboss/jsr299/tck/tests/jbt/core/TestInjection2.java";
+ IClassBean bean =
getClassBean("org.jboss.jsr299.tck.tests.jbt.core.TestInjection2", path);
+ Set<IBean> bs = cdiProject.getBeans(new Path("/tck/" + path));
+ Set<IInjectionPointParameter> ps = CDIUtil.getInjectionPointParameters(bean);
+ assertEquals(10, ps.size());
+ for (IInjectionPointParameter p: ps) {
+ for (int pos = p.getStartPosition(); pos < p.getStartPosition() + p.getLength();
pos++) {
+ IJavaElement element = bean.getBeanClass().getCompilationUnit().getElementAt(pos);
+ IInjectionPoint p1 = CDIUtil.findInjectionPoint(bs, element, pos);
+ assertTrue("Injection point is wrong at position " + pos + " for
element " + element, p == p1);
+ }
+ }
+ }
}
\ No newline at end of file