Author: scabanovich
Date: 2011-05-09 21:19:41 -0400 (Mon, 09 May 2011)
New Revision: 31164
Added:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean1.java
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean2.java
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyQualifier.java
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType1.java
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType2.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-3120
https://issues.jboss.org/browse/JBIDE-3120
Tests for seam config beans: modifying bean with producer with or without modifying that
producer.
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-10
00:53:39 UTC (rev 31163)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/META-INF/seam-beans.xml 2011-05-10
01:19:41 UTC (rev 31164)
@@ -5,6 +5,7 @@
xmlns:test01="urn:java:org.jboss.beans.test01"
xmlns:test02="urn:java:org.jboss.beans.test02"
xmlns:test03="urn:java:org.jboss.beans.test03"
+ xmlns:test04="urn:java:org.jboss.beans.test04"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://jboss.org/schema/cdi/beans_1_0.xsd">
<!-- Test 01-1 -->
@@ -67,4 +68,17 @@
<s:Named>test03-3-c</s:Named>
</test03:MyBean3>
+<!-- Test 04-1 -->
+<test04:MyBean1>
+ <s:modifies/>
+</test04:MyBean1>
+
+<!-- Test 04-2 -->
+<test04:MyBean2>
+ <s:modifies/>
+ <test04:myType2>
+ <s:Named>test04-2-a</s:Named>
+ </test04:myType2>
+</test04: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/MyBean1.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean1.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean1.java 2011-05-10
01:19:41 UTC (rev 31164)
@@ -0,0 +1,26 @@
+package org.jboss.beans.test04;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+/**
+ * Test 04-1.
+ * Sources contain class MyBean1 that declares producer field of type MyType1,
+ * class MyType1 has no bean constructor.
+ * Seam config xml contains declaration:
+ * <test04:MyBean1>
+ * <s:modifies/>
+ * </test04:MyBean1>
+ *
+ * ASSERT: Model contains 1 bean with type MyType1.
+ * ASSERT: That bean is field producer.
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class MyBean1 {
+
+ @Produces
+ public MyType1 myType1 = new MyType1("");
+
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/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/test04/MyBean2.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean2.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyBean2.java 2011-05-10
01:19:41 UTC (rev 31164)
@@ -0,0 +1,31 @@
+package org.jboss.beans.test04;
+
+import javax.enterprise.inject.Produces;
+
+/**
+ * Test 04-2.
+ * Sources contain class MyBean2 that declares producer field of type MyType2,
+ * class MyType2 has no bean constructor.
+ * Seam config xml contains declaration:
+ * <test04:MyBean2>
+ * <s:modifies/>
+ * <test04:myType2>
+ * <s:Named>test04-2-a</s:Named>
+ * </test04:myType2>
+ * </test04:MyBean2>
+ *
+ * ASSERT: Model contains 1 bean with type MyType2.
+ * ASSERT: That bean is field producer.
+ * ASSERT: That bean has qualifier MyQualifier with kind="kind-04-2".
+ * ASSERT: That bean has name "test04-2-a".
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class MyBean2 {
+
+ @Produces
+ @MyQualifier(kind="kind-04-2")
+ public MyType2 myType2 = new MyType2("");
+
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/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/test04/MyQualifier.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyQualifier.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyQualifier.java 2011-05-10
01:19:41 UTC (rev 31164)
@@ -0,0 +1,21 @@
+package org.jboss.beans.test04;
+
+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 {
+ String kind();
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/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/test04/MyType1.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType1.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType1.java 2011-05-10
01:19:41 UTC (rev 31164)
@@ -0,0 +1,14 @@
+package org.jboss.beans.test04;
+
+/**
+ * Test 04-1.
+ * see org.jboss.beans.test04.MyBean1
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class MyType1 {
+ public MyType1(String s) {
+ }
+
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType1.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/MyType2.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType2.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType2.java 2011-05-10
01:19:41 UTC (rev 31164)
@@ -0,0 +1,13 @@
+package org.jboss.beans.test04;
+
+/**
+ * Test 04-2.
+ * see org.jboss.beans.test04.MyBean2
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class MyType2 {
+ public MyType2(String s) {
+ }
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/projects/CDIConfigTest/src/org/jboss/beans/test04/MyType2.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-10
00:53:39 UTC (rev 31163)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/src/org/jboss/tools/cdi/seam/config/core/test/SeamBeansTest.java 2011-05-10
01:19:41 UTC (rev 31164)
@@ -11,11 +11,16 @@
package org.jboss.tools.cdi.seam.config.core.test;
import java.io.IOException;
+import java.util.HashMap;
import java.util.HashSet;
+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.IProducerField;
+import org.jboss.tools.cdi.core.IQualifier;
+import org.jboss.tools.cdi.core.IQualifierDeclaration;
/**
*
@@ -221,6 +226,60 @@
assertTrue(names.contains("test03-3-c"));
}
+ /**
+ * Test 04-1.
+ * Sources contain class MyBean1 that declares producer field of type MyType1,
+ * class MyType1 has no bean constructor.
+ * Seam config xml contains declaration:
+ * <test04:MyBean1>
+ * <s:modifies/>
+ * </test04:MyBean1>
+ *
+ * ASSERT: Model contains 1 bean with type MyType1.
+ * ASSERT: That bean is field producer.
+ */
+ public void testModifyingBeanWithFieldProducer() {
+ Set<IBean> beans = cdiProject.getBeans(false,
"org.jboss.beans.test04.MyType1");
+ assertEquals(1, beans.size());
+ IBean b = beans.iterator().next();
+ assertTrue(b instanceof IProducerField);
+ }
+
+ /**
+ * Test 04-2.
+ * Sources contain class MyBean2 that declares producer field of type MyType2,
+ * class MyType2 has no bean constructor.
+ * Seam config xml contains declaration:
+ * <test04:MyBean2>
+ * <s:modifies/>
+ * <test04:myType2>
+ * <s:Named>test04-2-a</s:Named>
+ * </test04:myType2>
+ * </test04:MyBean2>
+ *
+ * ASSERT: Model contains 1 bean with type MyType2.
+ * ASSERT: That bean is field producer.
+ * ASSERT: That bean has qualifier MyQualifier with kind="kind-04-2".
+ * ASSERT: That bean has name "test04-2-a".
+ */
+ public void testModifyingBeanWithModifiedFieldProducer() {
+ Set<IBean> beans = cdiProject.getBeans(false,
"org.jboss.beans.test04.MyType2",
+ new String[]{"org.jboss.beans.test04.MyQualifier"});
+ assertEquals(1, beans.size());
+ IBean b = beans.iterator().next();
+ 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-2", myQualifier.getMemberValue("kind"));
+ assertEquals("test04-2-a", b.getName());
+
+ assertTrue(b instanceof IProducerField);
+ }
+
protected Set<IBean> getBeansByClassName(String className) {
return cdiProject.getBeans(false, className, new String[0]);
}