Author: scabanovich
Date: 2011-05-12 12:33:12 -0400 (Thu, 12 May 2011)
New Revision: 31246
Added:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean3.java
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean4.java
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean5.java
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean6.java
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType3.java
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType4.java
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType5.java
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType6.java
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test05/
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test05/MyBean1.java
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test05/MyBean2.java
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test05/MyQualifier.java
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test05/MyType1.java
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/META-INF/seam-beans.xml
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/src/org/jboss/tools/cdi/seam/config/core/test/SeamBeansTest.java
Log:
JBIDE-8935
https://issues.jboss.org/browse/JBIDE-8935
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/META-INF/seam-beans.xml
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/META-INF/seam-beans.xml 2011-05-12
16:31:33 UTC (rev 31245)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/META-INF/seam-beans.xml 2011-05-12
16:33:12 UTC (rev 31246)
@@ -6,6 +6,7 @@
xmlns:test02="urn:java:org.jboss.beans.test02"
xmlns:test03="urn:java:org.jboss.beans.test03"
xmlns:test04="urn:java:org.jboss.beans.test04"
+ xmlns:test05="urn:java:org.jboss.beans.test05"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://jboss.org/schema/cdi/beans_1_0.xsd">
<!-- Test 01-1 -->
@@ -81,4 +82,55 @@
</test04:myType2>
</test04:MyBean2>
+<!-- Test 04-3 -->
+<test04:MyBean3>
+ <s:modifies/>
+ <test04:myType3>
+ <s:Produces/>
+ </test04:myType3>
+</test04:MyBean3>
+
+<!-- Test 04-4 -->
+<test04:MyBean4>
+ <s:replaces/>
+</test04:MyBean4>
+
+<!-- Test 04-5 -->
+<test04:MyBean5>
+ <s:replaces/>
+ <test04:myType5>
+ <s:Inject/>
+ <test04:MyQualifier kind="kind-04-5-a"/>
+ </test04:myType5>
+</test04:MyBean5>
+
+<!-- Test 04-6 -->
+<test04:MyBean6>
+ <test04:MyQualifier kind="kind-04-6"/>
+ <test04:myType6>
+ <s:Produces/>
+ </test04:myType6>
+</test04:MyBean6>
+
+<!-- Test 05-1 -->
+<test05:MyBean1>
+ <s:modifies/>
+ <test05:createType>
+ <s:Produces/>
+ <test05:MyQualifier/>
+ <s:parameters>
+ <test05:MyType1>
+ </test05:MyType1>
+ </s:parameters>
+ </test05:createType>
+</test05:MyBean1>
+
+<!-- Test 05-2 -->
+<test05:MyBean2>
+ <s:parameters>
+ <test05:MyType1>
+ </test05:MyType1>
+ </s:parameters>
+</test05:MyBean2>
+
</beans>
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean3.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean3.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean3.java 2011-05-12
16:33:12 UTC (rev 31246)
@@ -0,0 +1,27 @@
+package org.jboss.beans.test04;
+
+/**
+ * Test 04-3.
+ * Sources contain class MyBean2 that declares a field of type MyType3,
+ * class MyType3 has no bean constructor.
+ * Seam config xml contains declaration:
+ * <test04:MyBean3>
+ * <s:modifies/>
+ * <test04:myType3>
+ * <s:Produces/>
+ * </test04:myType3>
+ * </test04:MyBean3>
+ *
+ * ASSERT: Model contains 1 bean with type MyType3.
+ * ASSERT: That bean is field producer.
+ * ASSERT: That bean has qualifier MyQualifier with kind="kind-04-3".
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class MyBean3 {
+
+ @MyQualifier(kind="kind-04-3")
+ public MyType3 myType3 = new MyType3("");
+
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean3.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean4.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean4.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean4.java 2011-05-12
16:33:12 UTC (rev 31246)
@@ -0,0 +1,24 @@
+package org.jboss.beans.test04;
+
+import javax.enterprise.inject.Produces;
+
+/**
+ * Test 04-4.
+ * Sources contain class MyBean4 that declares producer field of type MyType4,
+ * class MyType4 has no bean constructor.
+ * Seam config xml contains declaration:
+ * <test04:MyBean4>
+ * <s:replaces/>
+ * </test04:MyBean4>
+ *
+ * ASSERT: Model contains no bean with type MyType4.
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class MyBean4 {
+
+ @Produces
+ public MyType4 myType4 = new MyType4("");
+
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean4.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean5.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean5.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean5.java 2011-05-12
16:33:12 UTC (rev 31246)
@@ -0,0 +1,31 @@
+package org.jboss.beans.test04;
+
+import javax.enterprise.inject.Produces;
+
+/**
+ * Test 04-5.
+ * Sources contain class MyBean5 that declares producer field of type MyType5,
+ * class MyType5 has no bean constructor.
+ * Seam config xml contains declaration:
+ * <test04:MyBean5>
+ * <s:replaces/>
+ * <test04:myType5>
+ * <s:Inject/>
+ * <test04:MyQualifier kind="kind-04-5-a"/>
+ * </test04:myType5>
+ * </test04:MyBean5>
+ *
+ * ASSERT: Model contains no bean with type MyType5.
+ * ASSERT: Model contains 1 bean with type MyBean5.
+ * ASSERT: That bean has injection point field with qualifier MyQualifier with
kind="kind-04-5-a".
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class MyBean5 {
+
+ @Produces
+ @MyQualifier(kind="kind-04-5")
+ public MyType5 myType5 = new MyType5("");
+
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean5.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean6.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean6.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean6.java 2011-05-12
16:33:12 UTC (rev 31246)
@@ -0,0 +1,33 @@
+package org.jboss.beans.test04;
+
+import javax.inject.Inject;
+
+/**
+ * Test 04-6.
+ * Sources contain class MyBean6 that declares field of type MyType6,
+ * class MyType6 has no bean constructor.
+ * Seam config xml contains declaration:
+ * <test04:MyBean6>
+ * <test04:MyQualifier kind="kind-04-6"/>
+ * <test04:myType6>
+ * <s:Produces/>
+ * </test04:myType6>
+ * </test04:MyBean6>
+ *
+ * ASSERT: Model contains 1 bean with type MyType6.
+ * ASSERT: That bean is field producer.
+ * ASSERT: Model contains 1 bean with type MyBean6 with qualifier MyQualifier
+ * ASSERT: That bean has no injection points.
+ * ASSERT: Model contains 1 bean with type MyBean6 with default qualifier..
+ * ASSERT: That bean has 1 injection point.
+ * ASSERT: That injection point is resolved to bean MyType6.
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class MyBean6 {
+
+ @Inject
+ public MyType6 myType6 = new MyType6("");
+
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean6.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType3.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType3.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType3.java 2011-05-12
16:33:12 UTC (rev 31246)
@@ -0,0 +1,13 @@
+package org.jboss.beans.test04;
+
+/**
+ * Test 04-3.
+ * see org.jboss.beans.test04.MyBean3
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class MyType3 {
+ public MyType3(String s) {
+ }
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType3.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType4.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType4.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType4.java 2011-05-12
16:33:12 UTC (rev 31246)
@@ -0,0 +1,13 @@
+package org.jboss.beans.test04;
+
+/**
+ * Test 04-4.
+ * see org.jboss.beans.test04.MyBean4
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class MyType4 {
+ public MyType4(String s) {
+ }
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType4.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType5.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType5.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType5.java 2011-05-12
16:33:12 UTC (rev 31246)
@@ -0,0 +1,13 @@
+package org.jboss.beans.test04;
+
+/**
+ * Test 04-2.
+ * see org.jboss.beans.test04.MyBean2
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class MyType5 {
+ public MyType5(String s) {
+ }
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType5.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType6.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType6.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType6.java 2011-05-12
16:33:12 UTC (rev 31246)
@@ -0,0 +1,13 @@
+package org.jboss.beans.test04;
+
+/**
+ * Test 04-6.
+ * see org.jboss.beans.test04.MyBean6
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class MyType6 {
+ public MyType6(String s) {
+ }
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType6.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test05/MyBean1.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test05/MyBean1.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test05/MyBean1.java 2011-05-12
16:33:12 UTC (rev 31246)
@@ -0,0 +1,35 @@
+package org.jboss.beans.test05;
+
+/**
+ * Test 05-1
+ * Sources contain class MyBean1 that declares method createType
+ * with parameter MyType1.
+ * Seam config xml contains declaration:
+ * <test05:MyBean1>
+ * <test05:createType>
+ * <s:Produces/>
+ * <test05:MyQualifier/>
+ * <s:parameters>
+ * <test05:MyType1>
+ * </test05:MyType1>
+ * </s:parameters>
+ * </test05:createType>
+ * </test05:MyBean1>
+ *
+ * ASSERT: Model contains 1 bean with type MyType1 with qualifier MyQualifier.
+ * ASSERT: That bean is method producer.
+ * ASSERT: That bean has one injection point; it is parameter.
+ * ASSERT: That injection point is resolved to class bean with type MyType1 with default
qualifier.
+ *
+ * @author Viacheslav Kababovich
+ *
+ */
+public class MyBean1 {
+
+ public MyType1 createType(MyType1 template) {
+ MyType1 result = new MyType1();
+ //use template to modify result.
+ return result;
+ }
+
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test05/MyBean1.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test05/MyBean2.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test05/MyBean2.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test05/MyBean2.java 2011-05-12
16:33:12 UTC (rev 31246)
@@ -0,0 +1,28 @@
+package org.jboss.beans.test05;
+
+import javax.inject.Inject;
+
+/**
+ * Test 05-2
+ * Sources contain class MyBean2 that declares constructor.
+ * Seam config xml contains declaration:
+ * <test05:MyBean2>
+ * <s:parameters>
+ * <test05:MyType1>
+ * </test05:MyType1>
+ * </s:parameters>
+ * </test05:MyBean2>
+ *
+ * ASSERT: Model contains 1 bean with type MyBean2.
+ * ASSERT: That bean has one injection point; it is parameter.
+ * ASSERT: That injection point is resolved to class bean with type MyType1 with default
qualifier.
+ *
+ * @author Viacheslav Kababovich
+ *
+ */
+public class MyBean2 {
+
+ public MyBean2(MyType1 type) {
+ }
+
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test05/MyBean2.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test05/MyQualifier.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test05/MyQualifier.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test05/MyQualifier.java 2011-05-12
16:33:12 UTC (rev 31246)
@@ -0,0 +1,20 @@
+package org.jboss.beans.test05;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+public @interface MyQualifier {
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test05/MyQualifier.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test05/MyType1.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test05/MyType1.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test05/MyType1.java 2011-05-12
16:33:12 UTC (rev 31246)
@@ -0,0 +1,11 @@
+package org.jboss.beans.test05;
+
+/**
+ * Test 05-1.
+ * see org.jboss.beans.test05.MyBean1
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class MyType1 {
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test05/MyType1.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/src/org/jboss/tools/cdi/seam/config/core/test/SeamBeansTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/src/org/jboss/tools/cdi/seam/config/core/test/SeamBeansTest.java 2011-05-12
16:31:33 UTC (rev 31245)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/src/org/jboss/tools/cdi/seam/config/core/test/SeamBeansTest.java 2011-05-12
16:33:12 UTC (rev 31246)
@@ -13,13 +13,17 @@
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.CoreException;
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.cdi.core.IProducerField;
-import org.jboss.tools.cdi.core.IQualifier;
+import org.jboss.tools.cdi.core.IProducerMethod;
import org.jboss.tools.cdi.core.IQualifierDeclaration;
/**
@@ -267,6 +271,7 @@
new String[]{"org.jboss.beans.test04.MyQualifier"});
assertEquals(1, beans.size());
IBean b = beans.iterator().next();
+ assertTrue(b instanceof IProducerField);
Set<IQualifierDeclaration> qs = b.getQualifierDeclarations();
Map<String, IQualifierDeclaration> map = new HashMap<String,
IQualifierDeclaration>();
for (IQualifierDeclaration q: qs) {
@@ -276,10 +281,228 @@
assertNotNull(myQualifier);
assertEquals("kind-04-2", myQualifier.getMemberValue("kind"));
assertEquals("test04-2-a", b.getName());
+ }
+
+ /**
+ * Test 04-3.
+ * Sources contain class MyBean2 that declares a field of type MyType3,
+ * class MyType3 has no bean constructor.
+ * Seam config xml contains declaration:
+ * <test04:MyBean3>
+ * <s:modifies/>
+ * <test04:myType3>
+ * <s:Produces/>
+ * </test04:myType3>
+ * </test04:MyBean3>
+ *
+ * ASSERT: Model contains 1 bean with type MyType3.
+ * ASSERT: That bean is field producer.
+ * ASSERT: That bean has qualifier MyQualifier with kind="kind-04-3".
+ */
+ public void testModifyingBeanWithFieldMadeProducer() {
+ Set<IBean> beans = cdiProject.getBeans(false,
"org.jboss.beans.test04.MyType3",
+ new String[]{"org.jboss.beans.test04.MyQualifier"});
+ assertEquals(1, beans.size());
+ IBean b = beans.iterator().next();
+ assertTrue(b instanceof IProducerField);
+ Set<IQualifierDeclaration> qs = b.getQualifierDeclarations();
+ Map<String, IQualifierDeclaration> map = new HashMap<String,
IQualifierDeclaration>();
+ for (IQualifierDeclaration q: qs) {
+ map.put(q.getType().getFullyQualifiedName(), q);
+ }
+ IQualifierDeclaration myQualifier =
map.get("org.jboss.beans.test04.MyQualifier");
+ assertNotNull(myQualifier);
+ assertEquals("kind-04-3", myQualifier.getMemberValue("kind"));
+ }
+
+ /**
+ * Test 04-4.
+ * Sources contain class MyBean4 that declares producer field of type MyType4,
+ * class MyType4 has no bean constructor.
+ * Seam config xml contains declaration:
+ * <test04:MyBean4>
+ * <s:replaces/>
+ * </test04:MyBean4>
+ *
+ * ASSERT: Model contains no bean with type MyType4.
+ */
+ public void testReplacingBeanWithFieldProducer() {
+ Set<IBean> beans = cdiProject.getBeans(false,
"org.jboss.beans.test04.MyType4");
+ assertTrue(beans.isEmpty());
+ }
+
+ /**
+ * Test 04-5.
+ * Sources contain class MyBean5 that declares producer field of type MyType5,
+ * class MyType5 has no bean constructor.
+ * Seam config xml contains declaration:
+ * <test04:MyBean5>
+ * <s:replaces/>
+ * <test04:myType5>
+ * <test04:MyQualifier kind="kind-04-5-a"/>
+ * </test04:myType5>
+ * </test04:MyBean5>
+ *
+ * ASSERT: Model contains no bean with type MyType5.
+ * ASSERT: Model contains 1 bean with type MyBean5.
+ * ASSERT: That bean has injection point field with qualifier MyQualifier with
kind="kind-04-5-a".
+ */
+ public void testReplacingBeanWithModifiedFieldProducer() {
+ Set<IBean> beans = cdiProject.getBeans(false,
"org.jboss.beans.test04.MyType5",
+ new String[]{"org.jboss.beans.test04.MyQualifier"});
+ assertTrue(beans.isEmpty());
+ beans = cdiProject.getBeans(false, "org.jboss.beans.test04.MyBean5", new
String[0]);
+ assertEquals(1, beans.size());
+ IBean b = beans.iterator().next();
+ Set<IInjectionPoint> is = b.getInjectionPoints();
+ assertEquals(1, is.size());
+ IInjectionPoint p = is.iterator().next();
+ Set<IQualifierDeclaration> qs = p.getQualifierDeclarations();
+ Map<String, IQualifierDeclaration> map = new HashMap<String,
IQualifierDeclaration>();
+ for (IQualifierDeclaration q: qs) {
+ map.put(q.getType().getFullyQualifiedName(), q);
+ }
+ IQualifierDeclaration myQualifier =
map.get("org.jboss.beans.test04.MyQualifier");
+ assertNotNull(myQualifier);
+ assertEquals("kind-04-5-a", myQualifier.getMemberValue("kind"));
+ }
+
+ /**
+ * Test 04-6.
+ * Sources contain class MyBean6 that declares field of type MyType6,
+ * class MyType6 has no bean constructor.
+ * Seam config xml contains declaration:
+ * <test04:MyBean6>
+ * <test04:MyQualifier kind="kind-04-6"/>
+ * <test04:myType6>
+ * <s:Produces/>
+ * </test04:myType6>
+ * </test04:MyBean6>
+ *
+ * ASSERT: Model contains 1 bean with type MyType6.
+ * ASSERT: That bean is field producer.
+ * ASSERT: Model contains 1 bean with type MyBean6 with qualifier MyQualifier
+ * ASSERT: That bean has no injection points.
+ * ASSERT: Model contains 1 bean with type MyBean6 with default qualifier..
+ * ASSERT: That bean has 1 injection point.
+ * ASSERT: That injection point is resolved to bean MyType6.
+ */
+ public void testCreatingBeanWithFieldMadeProducer() {
+ Set<IBean> beans = cdiProject.getBeans(false,
"org.jboss.beans.test04.MyType6", new String[0]);
+ assertEquals(1, beans.size());
+ IBean b = beans.iterator().next();
assertTrue(b instanceof IProducerField);
+
+ Set<IBean> beans1 = cdiProject.getBeans(false,
"org.jboss.beans.test04.MyBean6",
+ new String[]{"org.jboss.beans.test04.MyQualifier"});
+ assertEquals(1, beans1.size());
+ IBean b1 = beans1.iterator().next();
+ Set<IInjectionPoint> is1 = b1.getInjectionPoints();
+ assertTrue(is1.isEmpty());
+
+ Set<IBean> beans2 = cdiProject.getBeans(false,
"org.jboss.beans.test04.MyBean6", new String[0]);
+ assertEquals(1, beans2.size());
+ IBean b2 = beans2.iterator().next();
+ Set<IInjectionPoint> is2 = b2.getInjectionPoints();
+ assertEquals(1, is2.size());
+
+ IInjectionPoint p = is2.iterator().next();
+
+ Set<IBean> beansI = cdiProject.getBeans(false, p);
+ assertTrue(beansI.contains(b));
}
+ /**
+ * Test 05-1
+ * Sources contain class MyBean1 that declares method createType
+ * with parameter MyType1.
+ * Seam config xml contains declaration:
+ * <test05:MyBean1>
+ * <test05:createType>
+ * <s:Produces/>
+ * <test05:MyQualifier/>
+ * <s:parameters>
+ * <test05:MyType1>
+ * </test05:MyType1>
+ * </s:parameters>
+ * </test05:createType>
+ * </test05:MyBean1>
+ *
+ * ASSERT: Model contains 1 bean with type MyType1 with qualifier MyQualifier.
+ * ASSERT: That bean is method producer.
+ * ASSERT: That bean has one injection point; it is parameter.
+ * ASSERT: That injection point is resolved to class bean with type MyType1 with default
qualifier.
+ *
+ * @author Viacheslav Kababovich
+ *
+ */
+ public void testCreatingBeanWithMethodMadeProducer() {
+ Set<IBean> beans = cdiProject.getBeans(false,
"org.jboss.beans.test05.MyType1",
+ new String[]{"org.jboss.beans.test05.MyQualifier"});
+ assertEquals(1, beans.size());
+ IBean b = beans.iterator().next();
+ assertTrue(b instanceof IProducerMethod);
+
+ Set<IInjectionPoint> is = b.getInjectionPoints();
+ assertEquals(1, is.size());
+
+ IInjectionPoint p = is.iterator().next();
+ Set<IBean> beansI = cdiProject.getBeans(false, p);
+ assertEquals(1, beansI.size());
+
+ Set<IBean> beans2 = cdiProject.getBeans(false,
"org.jboss.beans.test05.MyType1", new String[0]);
+ assertEquals(1, beans2.size());
+ IBean b2 = beans2.iterator().next();
+
+ assertTrue(beansI.contains(b2));
+ }
+
+ /**
+ * Test 05-2
+ * Sources contain class MyBean2 that declares constructor.
+ * Seam config xml contains declaration:
+ * <test05:MyBean2>
+ * <s:parameters>
+ * <test05:MyType1>
+ * </test05:MyType1>
+ * </s:parameters>
+ * </test05:MyBean2>
+ *
+ * ASSERT: Model contains 1 bean with type MyBean2.
+ * ASSERT: That bean has one injection point; it is parameter.
+ * ASSERT: That injection point is resolved to class bean with type MyType1 with default
qualifier.
+ *
+ */
+ public void testCreatingBeanWithConstructor() {
+ Set<IBean> beans = cdiProject.getBeans(false,
"org.jboss.beans.test05.MyBean2", new String[0]);
+ assertEquals(1, beans.size());
+ IBean b = beans.iterator().next();
+ assertTrue(b instanceof IClassBean);
+
+ Set<IInjectionPoint> is = b.getInjectionPoints();
+ assertFalse(is.isEmpty());
+ IInjectionPoint p = null;
+ Iterator<IInjectionPoint> it = is.iterator();
+ while(it.hasNext()) {
+ IInjectionPoint i = it.next();
+ if(i instanceof IInjectionPointParameter) {
+ p = i;
+ break;
+ }
+ }
+ assertNotNull(p);
+
+ Set<IBean> beansI = cdiProject.getBeans(false, p);
+ assertEquals(1, beansI.size());
+
+ Set<IBean> beans2 = cdiProject.getBeans(false,
"org.jboss.beans.test05.MyType1", new String[0]);
+ assertEquals(1, beans2.size());
+ IBean b2 = beans2.iterator().next();
+
+ assertTrue(beansI.contains(b2));
+ }
+
protected Set<IBean> getBeansByClassName(String className) {
return cdiProject.getBeans(false, className, new String[0]);
}