Author: scabanovich
Date: 2011-09-29 19:33:20 -0400 (Thu, 29 Sep 2011)
New Revision: 35183
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/lookup/NotBean.java
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/lookup/ResolutionByNameTest.java
Log:
JBIDE-9795
https://issues.jboss.org/browse/JBIDE-9795
Test added.
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/lookup/NotBean.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/lookup/NotBean.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/lookup/NotBean.java 2011-09-29
23:33:20 UTC (rev 35183)
@@ -0,0 +1,15 @@
+package org.jboss.jsr299.tck.tests.jbt.lookup;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+@Named("abstractClass")
+public abstract class NotBean {
+
+ @Produces
+ @Named("producerInAbstractClass") NotBean b;
+
+ @Inject @Named("abstractClass") NotBean f1;
+ @Inject @Named("producerInAbstractClass") NotBean f2;
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/lookup/NotBean.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/lookup/ResolutionByNameTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/lookup/ResolutionByNameTest.java 2011-09-29
23:18:08 UTC (rev 35182)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/lookup/ResolutionByNameTest.java 2011-09-29
23:33:20 UTC (rev 35183)
@@ -16,9 +16,16 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IField;
+import org.jboss.tools.cdi.core.CDIConstants;
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.IInjectionPointField;
+import org.jboss.tools.cdi.core.IProducer;
import org.jboss.tools.cdi.core.test.tck.TCKTest;
import org.jboss.tools.cdi.internal.core.impl.CDIProject;
+import org.jboss.tools.common.java.IAnnotationDeclaration;
/**
* @author Alexey Kazakov
@@ -62,4 +69,43 @@
old = ((CDIProject)cdiProject).replaceBeanXML(old);
}
}
+
+ /**
+ * Abstract class NotBean is annotated @Named("abstractClass")
+ * There is no bean with bean name "abstractClass" for EL or injections,
+ * but instance of IClassBean created for NotBean can be obtained through
+ * its members available in model (e.g. producers)
+ *
+ * @throws CoreException
+ */
+ public void testAbstractClassAnnotatedNamed() throws CoreException {
+ String abstractClass = "abstractClass";
+ Set<IBean> beans = cdiProject.getBeans(abstractClass, false);
+ assertTrue(beans.isEmpty());
+
+ beans = cdiProject.getBeans("producerInAbstractClass", false);
+ assertEquals(1, beans.size());
+ IBean b = beans.iterator().next();
+ assertTrue(b instanceof IProducer);
+
+ IClassBean cb = ((IProducer)b).getClassBean();
+ assertNotNull(cb);
+ IAnnotationDeclaration named =
cb.getAnnotation(CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
+ assertEquals(abstractClass, named.getMemberValue(null));
+
+ Set<IInjectionPoint> injections =
cdiProject.getInjections("org.jboss.jsr299.tck.tests.jbt.lookup.NotBean");
+ assertEquals(2, injections.size());
+ for (IInjectionPoint p: injections) {
+ assertTrue(p instanceof IInjectionPointField);
+ IField f = ((IInjectionPointField)p).getField();
+ Set<IBean> bs = cdiProject.getBeans(false, p);
+ if("f1".endsWith(f.getElementName())) {
+ assertEquals("Injection field f1 cannot be resolved to abstract class
bean.", 0, bs.size());
+ } else if("f2".endsWith(f.getElementName())) {
+ assertEquals("Injection field f2 should be resolved to producer.", 1,
bs.size());
+ } else {
+ fail("Unexpected field: " + f.getElementName());
+ }
+ }
+ }
}
\ No newline at end of file