Author: scabanovich
Date: 2011-10-20 20:10:20 -0400 (Thu, 20 Oct 2011)
New Revision: 35877
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.seam.solder.core.test/src/org/jboss/tools/cdi/seam/solder/core/test/DefaultBeanTest.java
Log:
JBIDE-9988
https://issues.jboss.org/browse/JBIDE-9988
Test for default producer beans without @DefaultBean annotation.
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.seam.solder.core.test/src/org/jboss/tools/cdi/seam/solder/core/test/DefaultBeanTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam.solder.core.test/src/org/jboss/tools/cdi/seam/solder/core/test/DefaultBeanTest.java 2011-10-20
23:23:32 UTC (rev 35876)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.solder.core.test/src/org/jboss/tools/cdi/seam/solder/core/test/DefaultBeanTest.java 2011-10-21
00:10:20 UTC (rev 35877)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.cdi.seam.solder.core.test;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
@@ -24,6 +25,7 @@
import org.jboss.tools.cdi.core.IInjectionPointField;
import org.jboss.tools.cdi.core.IProducerField;
import org.jboss.tools.cdi.core.IProducerMethod;
+import org.jboss.tools.common.java.IParametedType;
/**
*
@@ -44,6 +46,37 @@
doTestDefaultBeanInDependentProject(dependent,
"src/org/jboss/defaultbean/Town2.java");
}
+ public void testLegalTypesOfDefaultProducerBeanWithoutDefaultBeanAnnotation() throws
CoreException {
+ ICDIProject cdi = CDICorePlugin.getCDIProject(getTestProject(), true);
+ IInjectionPointField injection = getInjectionPointField(cdi,
"src/org/jboss/defaultbean/producer/Test1.java", "a");
+ Set<IBean> bs = cdi.getBeans(false, injection);
+ assertEquals(1, bs.size());
+ IBean b = bs.iterator().next();
+ assertTrue(b instanceof IProducerField);
+ Set<IParametedType> ts = b.getLegalTypes();
+ Set<String> ss = new HashSet<String>();
+ for (IParametedType t: ts) {
+ ss.add(t.getType().getFullyQualifiedName());
+ }
+ assertTrue(ss.contains("org.jboss.defaultbean.producer.TypeA"));
+ assertTrue(ss.contains("java.lang.Object"));
+ assertEquals(2, ss.size());
+
+ injection = getInjectionPointField(cdi,
"src/org/jboss/defaultbean/producer/Test1.java", "b");
+ bs = cdi.getBeans(false, injection);
+ assertEquals(1, bs.size());
+ b = bs.iterator().next();
+ assertTrue(b instanceof IProducerMethod);
+ ts = b.getLegalTypes();
+ ss = new HashSet<String>();
+ for (IParametedType t: ts) {
+ ss.add(t.getType().getFullyQualifiedName());
+ }
+ assertTrue(ss.contains("org.jboss.defaultbean.producer.TypeB"));
+ assertTrue(ss.contains("java.lang.Object"));
+ assertEquals(2, ss.size());
+ }
+
/**
* Checks default bean injection resolution.
* If dependent == cdi, executes check of one project, otherwise looks for beans in