Author: scabanovich
Date: 2012-05-11 20:29:57 -0400 (Fri, 11 May 2012)
New Revision: 40969
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/src/test/TestE.java
Modified:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/resolver/TypeInfoCollectorTest.java
Log:
JBIDE-11838
https://issues.jboss.org/browse/JBIDE-11838
Test is added.
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/src/test/TestE.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/src/test/TestE.java
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/src/test/TestE.java 2012-05-12
00:29:57 UTC (rev 40969)
@@ -0,0 +1,48 @@
+package test;
+
+public class TestE {
+
+ /**
+ * String property 'name'
+ * @return
+ */
+ public String getName() {
+ return "";
+ }
+
+ /**
+ * Boolean property 'old'
+ * @return
+ */
+ public boolean isOld() {
+ return false;
+ }
+
+ /**
+ * Not a property, has no return type.
+ */
+ public void getAge() {
+ return "";
+ }
+
+ /**
+ * Not a property, return type is not boolean.
+ * @return
+ */
+ public int isBig() {
+ return 0;
+ }
+
+ /**
+ * Not a property, has a parameter.
+ * @param i
+ * @return
+ */
+ public String getState(int i) {
+ return "";
+ }
+
+ public void setColor(String rgb) {
+
+ }
+}
\ No newline at end of file
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/JavaProject2/src/test/TestE.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/resolver/TypeInfoCollectorTest.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/resolver/TypeInfoCollectorTest.java 2012-05-12
00:10:55 UTC (rev 40968)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/resolver/TypeInfoCollectorTest.java 2012-05-12
00:29:57 UTC (rev 40969)
@@ -10,7 +10,9 @@
******************************************************************************/
package org.jboss.tools.common.el.core.test.resolver;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import junit.framework.TestCase;
@@ -97,7 +99,7 @@
public void testMissingInterface() throws CoreException {
IJavaProject jp = JavaCore.create(project2);
- String className = "test.TestD";
+ String className = "test.TestD"; //$NON-NLS-1$
IType bean = jp.findType(className);
TypeInfoCollector.TypeInfo typeInfo = new TypeInfoCollector.TypeInfo(bean, null,
false);
TypeInfoCollector collector = typeInfo.getTypeCollector(false, false);
@@ -105,6 +107,38 @@
assertNotNull(collector);
}
+ public void testProperties() throws CoreException {
+ IJavaProject jp = JavaCore.create(project2);
+ String className = "test.TestE"; //$NON-NLS-1$
+ IType bean = jp.findType(className);
+ TypeInfoCollector.TypeInfo typeInfo = new TypeInfoCollector.TypeInfo(bean, null,
false);
+ TypeInfoCollector collector = typeInfo.getTypeCollector(false, false);
+ List<MemberInfo> ps = collector.getProperties();
+ //Names of methods, recognized as properties
+ Set<String> ns = getNames(ps);
+ assertTrue(ns.contains("getName")); //$NON-NLS-1$
+ assertFalse(ns.contains("getAge")); //$NON-NLS-1$
+ assertTrue(ns.contains("isOld")); //$NON-NLS-1$
+ assertTrue(ns.contains("setColor")); //$NON-NLS-1$
+ assertFalse(ns.contains("isBig")); //$NON-NLS-1$
+ assertFalse(ns.contains("getState")); //$NON-NLS-1$
+ List<MemberInfo> ms = collector.getMethods();
+ //Names of all methods
+ Set<String> ns2 = getNames(ms);
+ //Make sure that methods that were not recognized as properties, do exist.
+ assertTrue(ns2.contains("getAge")); //$NON-NLS-1$
+ assertTrue(ns2.contains("isBig")); //$NON-NLS-1$
+ assertTrue(ns2.contains("getState")); //$NON-NLS-1$
+ }
+
+ Set<String> getNames(List<MemberInfo> ms) {
+ Set<String> result = new HashSet<String>();
+ for (MemberInfo i: ms) {
+ result.add(i.getName());
+ }
+ return result;
+ }
+
private MemberInfo getMethod(TypeInfoCollector collector, String name) {
collector.collectInfo();
List<MemberInfo> mts = collector.getMethods();