JUnit test plugin for the EL Symbols plugin.
diff --git a/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/.classpath b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/.classpath
new file mode 100644
index 0000000..751c8f2
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/.cvsignore b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/.cvsignore
new file mode 100644
index 0000000..ba077a4
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/.project b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/.project
new file mode 100644
index 0000000..28a1842
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.jst.jsf.context.symbol.tests</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/META-INF/MANIFEST.MF b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..bd13fb2
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.jst.jsf.context.symbol.tests; singleton:=true
+Bundle-Version: 1.0.0
+Bundle-ClassPath: .
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Export-Package: org.eclipse.jst.jsf.context.symbol.tests
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.jst.jsf.context.symbol;visibility:=reexport,
+ org.eclipse.emf.ecore.xmi;visibility:=reexport,
+ org.junit;visibility:=reexport,
+ org.eclipse.jst.jsf.test.util,
+ org.eclipse.jdt.core,
+ org.eclipse.jst.jsf.core.tests,
+ org.eclipse.ui
+Eclipse-LazyStart: true
+Bundle-Activator: org.eclipse.jst.jsf.context.symbol.tests.ContextSymbolTestPlugin
diff --git a/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/build.properties b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/build.properties
new file mode 100644
index 0000000..1ab825d
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/build.properties
@@ -0,0 +1,12 @@
+# <copyright>
+# </copyright>
+#
+# $Id: build.properties,v 1.1 2006/07/20 19:31:24 cbateman Exp $
+
+bin.includes = .,\
+ META-INF/,\
+ plugin.xml,\
+ plugin.properties
+jars.compile.order = .
+source.. = src/
+output.. = bin/
\ No newline at end of file
diff --git a/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/plugin.properties b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/plugin.properties
new file mode 100644
index 0000000..f7e9643
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/plugin.properties
@@ -0,0 +1,20 @@
+# <copyright>
+# </copyright>
+#
+# $Id: plugin.properties,v 1.1 2006/07/20 19:31:24 cbateman Exp $
+
+# ====================================================================
+# To code developer:
+# Do NOT change the properties between this line and the
+# "%%% END OF TRANSLATED PROPERTIES %%%" line.
+# Make a new property name, append to the end of the file and change
+# the code to use the new property.
+# ====================================================================
+
+# ====================================================================
+# %%% END OF TRANSLATED PROPERTIES %%%
+# ====================================================================
+
+pluginName = My Tests
+providerName = www.example.org
+
diff --git a/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/plugin.xml b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/plugin.xml
new file mode 100644
index 0000000..d0bc80e
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/plugin.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+
+<!--
+ <copyright>
+ </copyright>
+
+ $Id: plugin.xml,v 1.1 2006/07/20 19:31:24 cbateman Exp $
+-->
+
+<plugin>
+</plugin>
+
diff --git a/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/src/org/eclipse/jst/jsf/context/symbol/tests/ContextSymbolTestPlugin.java b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/src/org/eclipse/jst/jsf/context/symbol/tests/ContextSymbolTestPlugin.java
new file mode 100644
index 0000000..7de7ff7
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/src/org/eclipse/jst/jsf/context/symbol/tests/ContextSymbolTestPlugin.java
@@ -0,0 +1,52 @@
+package org.eclipse.jst.jsf.context.symbol.tests;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class ContextSymbolTestPlugin extends AbstractUIPlugin
+{
+ /**
+ * The plug-in ID
+ */
+ public static final String PLUGIN_ID = "org.eclipse.jst.jsf.context.symbol.tests";
+
+ // The shared instance
+ private static ContextSymbolTestPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public ContextSymbolTestPlugin() {
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static ContextSymbolTestPlugin getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/src/org/eclipse/jst/jsf/context/symbol/tests/TestIJavaTypeDescriptor2.java b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/src/org/eclipse/jst/jsf/context/symbol/tests/TestIJavaTypeDescriptor2.java
new file mode 100644
index 0000000..fb18e70
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/src/org/eclipse/jst/jsf/context/symbol/tests/TestIJavaTypeDescriptor2.java
@@ -0,0 +1,933 @@
+package org.eclipse.jst.jsf.context.symbol.tests;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.Signature;
+import org.eclipse.jst.jsf.context.symbol.SymbolFactory;
+import org.eclipse.jst.jsf.context.symbol.SymbolPackage;
+import org.eclipse.jst.jsf.context.symbol.internal.provisional.IBeanInstanceSymbol;
+import org.eclipse.jst.jsf.context.symbol.internal.provisional.IBeanMethodSymbol;
+import org.eclipse.jst.jsf.context.symbol.internal.provisional.IBeanPropertySymbol;
+import org.eclipse.jst.jsf.context.symbol.internal.provisional.IJavaTypeDescriptor2;
+import org.eclipse.jst.jsf.core.tests.TestsPlugin;
+import org.eclipse.jst.jsf.test.util.JDTTestEnvironment;
+import org.eclipse.jst.jsf.test.util.JavaCodeResource;
+import org.eclipse.jst.jsf.test.util.ProjectTestEnvironment;
+import org.osgi.framework.Bundle;
+
+/**
+ * Test the IJavaTypeDescriptor
+ *
+ * @author cbateman
+ *
+ */
+public class TestIJavaTypeDescriptor2 extends TestCase
+{
+ private JDTTestEnvironment _jdtTestEnvironment;
+ private Map _beanProperties;
+ private Map _beanSubclassProperties;
+ private Map _beanMethods;
+ private Map _beanMethodsSubclass;
+
+ private IBeanInstanceSymbol _testBean1Symbol;
+ private IBeanInstanceSymbol _testBean1SubclassSymbol;
+ private IBeanInstanceSymbol _testBean2Symbol;
+ private IBeanInstanceSymbol _testBean2SubclassSymbol;
+
+ private final static String srcFolderName = "src";
+ private final static String packageName1 = "com.test";
+ private final static String testBeanName1 = "TestBean1";
+ private final static String testBeanSubclass1 = "TestBean1Subclass";
+ private final static String testBeanName2 = "TestBean2";
+ private final static String testBean2Subclass = "TestBean2Subclass";
+
+ private final static String overloadedMethodName = "overloadedMethod";
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ final ProjectTestEnvironment projectTestEnvironment =
+ new ProjectTestEnvironment("TestJDTBeanIntrospectorProject");
+ projectTestEnvironment.createProject();
+
+ _jdtTestEnvironment = new JDTTestEnvironment(projectTestEnvironment);
+
+ // load ITestBean2 first due to later dependencies
+ loadSourceClass(ContextSymbolTestPlugin.getDefault().getBundle(), "/testdata/ITestBean2.java.data", "ITestBean2");
+ assertNotNull(_jdtTestEnvironment.getJavaProject().findType(packageName1+"."+"ITestBean2"));
+
+ // load another bean first since others have a dependency on on it
+ loadSourceClass(TestsPlugin.getDefault().getBundle(), "/testfiles/AnotherBean.java.data", "AnotherBean");
+ assertNotNull(_jdtTestEnvironment.getJavaProject().findType(packageName1+"."+"AnotherBean"));
+
+ _beanProperties = new HashMap();
+ _testBean1Symbol =
+ setupBeanProperty("/testfiles/TestBean1.java.data", testBeanName1, _beanProperties);
+
+ _beanSubclassProperties = new HashMap();
+ _testBean1SubclassSymbol =
+ setupBeanProperty("/testfiles/TestBean1Subclass.java.data", testBeanSubclass1, _beanSubclassProperties);
+
+ _beanMethods = new HashMap();
+ _testBean2Symbol =
+ setupBeanMethods("/testdata/TestBean2.java.data", testBeanName2, _beanMethods);
+
+ _beanMethodsSubclass = new HashMap();
+ _testBean2SubclassSymbol =
+ setupBeanMethods("/testdata/TestBean2Subclass.java.data", testBean2Subclass, _beanMethodsSubclass);
+ }
+
+
+ private IBeanInstanceSymbol setupBeanProperty(String fileName, String beanClassName, Map properties) throws Exception
+ {
+ loadSourceClass(TestsPlugin.getDefault().getBundle(), fileName, beanClassName);
+
+ final IType testBean1Type =
+ _jdtTestEnvironment.getJavaProject().findType(packageName1+"."+beanClassName);
+ assertNotNull(testBean1Type);
+
+ final IJavaTypeDescriptor2 testBeanDescriptor =
+ SymbolFactory.eINSTANCE.createIJavaTypeDescriptor2();
+ testBeanDescriptor.setType(testBean1Type);
+
+ IBeanInstanceSymbol bean =
+ SymbolFactory.eINSTANCE.createIBeanInstanceSymbol();
+ bean.setTypeDescriptor(testBeanDescriptor);
+ bean.setName(beanClassName);
+ List propertyList = bean.getProperties();
+ for(final Iterator it = propertyList.iterator(); it.hasNext();)
+ {
+ final IBeanPropertySymbol property =
+ (IBeanPropertySymbol) it.next();
+ properties.put(property.getName(), property);
+ }
+
+ return bean;
+ }
+
+ private void loadSourceClass(final Bundle bundle, final String fileName, final String beanClassName) throws Exception
+ {
+ JavaCodeResource codeRes = new JavaCodeResource();
+ codeRes.load(bundle, fileName);
+ String code = codeRes.getCode();
+ _jdtTestEnvironment.addSourceFile(srcFolderName, packageName1, beanClassName, code);
+ }
+
+ private IBeanInstanceSymbol setupBeanMethods(String fileName, String beanClassName, Map methods) throws Exception
+ {
+ loadSourceClass(ContextSymbolTestPlugin.getDefault().getBundle(), fileName, beanClassName);
+
+ final IType testBean1Type =
+ _jdtTestEnvironment.getJavaProject().findType(packageName1+"."+beanClassName);
+ assertNotNull(testBean1Type);
+
+ final IJavaTypeDescriptor2 testBeanDescriptor =
+ SymbolFactory.eINSTANCE.createIJavaTypeDescriptor2();
+ testBeanDescriptor.setType(testBean1Type);
+
+ IBeanInstanceSymbol bean =
+ SymbolFactory.eINSTANCE.createIBeanInstanceSymbol();
+ bean.setTypeDescriptor(testBeanDescriptor);
+ bean.setName(beanClassName);
+ List methodList = bean.getMethods();
+ for(final Iterator it = methodList.iterator(); it.hasNext();)
+ {
+ final IBeanMethodSymbol method = (IBeanMethodSymbol) it.next();
+
+ // exclude the overloaded methods as these are handled separately
+ if (!overloadedMethodName.equals(method.getName()))
+ {
+ methods.put(method.getName(), method);
+ }
+ }
+
+ return bean;
+ }
+
+ /**
+ * Basic high-level sanity check on the generate properties map
+ */
+ public void testMapSanity()
+ {
+ assertEquals("Check extra or missing properties",_beanProperties.size(), 12);
+ assertEquals("Check extra or missing properties",_beanSubclassProperties.size(), 13);
+ assertEquals("Check extra or missing methods",_beanMethods.size(), 5);
+ assertEquals("Check extra or missing methods",_beanMethodsSubclass.size(), 6);
+ }
+
+ /**
+ *
+ */
+ public void testStringProp1()
+ {
+ testStringProp1(_beanProperties);
+ }
+
+ /**
+ * test inherited
+ */
+ public void testStringProp1SubClass()
+ {
+ testStringProp1(_beanSubclassProperties);
+ }
+
+ /**
+ * @param properties
+ */
+ private void testStringProp1(Map properties)
+ {
+ IBeanPropertySymbol property =
+ (IBeanPropertySymbol) properties.get("stringProp1");
+ assertNotNull(property);
+
+ assertTrue(property.isReadable());
+ assertTrue(property.isWritable());
+ assertEquals("Signature must be for a String",
+ "Ljava.lang.String;", property.getTypeDescriptor().getTypeSignature());
+ }
+
+ /**
+ * test property
+ */
+ public void testBooleanIsProp1()
+ {
+ testBooleanIsProp1(_beanProperties);
+ }
+
+ /**
+ * test inherited
+ */
+ public void testBooleanIsProp1SubClass()
+ {
+ testBooleanIsProp1(_beanSubclassProperties);
+ }
+
+
+ /**
+ * @param properties
+ */
+ private void testBooleanIsProp1(Map properties)
+ {
+ IBeanPropertySymbol property =
+ (IBeanPropertySymbol) properties.get("booleanIsProp1");
+ assertNotNull(property);
+
+ assertTrue(property.isReadable());
+ assertTrue(property.isWritable());
+ assertEquals("Signature must be for a boolean",
+ Signature.SIG_BOOLEAN, property.getTypeDescriptor().getTypeSignature());
+ }
+
+ /**
+ *
+ */
+ public void testBooleanIsProp2()
+ {
+ testBooleanIsProp2(_beanProperties);
+ }
+
+ /**
+ * test inherited
+ */
+ public void testBooleanIsProp2SubClass()
+ {
+ testBooleanIsProp2(_beanSubclassProperties);
+ }
+
+ /**
+ * @param properties
+ */
+ private void testBooleanIsProp2(Map properties)
+ {
+ IBeanPropertySymbol property =
+ (IBeanPropertySymbol) properties.get("booleanIsProp2");
+ assertNotNull(property);
+
+ assertTrue(property.isReadable());
+ assertTrue(property.isWritable());
+ assertEquals("Signature must be for a boolean",
+ Signature.SIG_BOOLEAN, property.getTypeDescriptor().getTypeSignature());
+ }
+
+ /**
+ *
+ */
+ public void testNotBooleanIsProp1()
+ {
+ testNotBooleanIsProp1(_beanProperties);
+ }
+
+ /**
+ * test inherited
+ */
+ public void testNotBooleanIsProp1SubClass()
+ {
+ testNotBooleanIsProp1(_beanSubclassProperties);
+ }
+
+ /**
+ *
+ */
+ private void testNotBooleanIsProp1(Map properties)
+ {
+ IBeanPropertySymbol property =
+ (IBeanPropertySymbol) properties.get("notBooleanIsProp1");
+ assertNotNull(property);
+
+ assertTrue(property.isReadable());
+ assertTrue(property.isWritable());
+ assertEquals("Signature must be for a boolean",
+ Signature.SIG_BOOLEAN, property.getTypeDescriptor().getTypeSignature());
+ }
+
+ /**
+ *
+ */
+ public void testStringProperty2()
+ {
+ testStringProperty2(_beanProperties);
+ }
+
+ /**
+ * test inherited
+ */
+ public void testStringProperty2SubClass()
+ {
+ testStringProperty2(_beanSubclassProperties);
+ }
+
+ /**
+ *
+ */
+ private void testStringProperty2(Map properties)
+ {
+ IBeanPropertySymbol property =
+ (IBeanPropertySymbol) properties.get("stringProperty2");
+ assertNotNull(property);
+
+ assertTrue(property.isReadable());
+ assertFalse("No setter for this property", property.isWritable());
+ assertEquals("Signature must be for a String",
+ "Ljava.lang.String;", property.getTypeDescriptor().getTypeSignature());
+ }
+
+ /**
+ *
+ */
+ public void testReadonlyStringProperty()
+ {
+ testReadonlyStringProperty(_beanProperties);
+ }
+
+ /**
+ * test inhertied
+ */
+ public void testReadonlyStringPropertySubClass()
+ {
+ testReadonlyStringProperty(_beanSubclassProperties);
+ }
+
+
+ /**
+ *
+ */
+ private void testReadonlyStringProperty(Map properties)
+ {
+ IBeanPropertySymbol property =
+ (IBeanPropertySymbol) properties.get("readonlyStringProperty");
+ assertNotNull(property);
+
+ assertTrue(property.isReadable());
+ assertFalse("No setter for this property", property.isWritable());
+ assertEquals("Signature must be for a String",
+ "Ljava.lang.String;", property.getTypeDescriptor().getTypeSignature());
+ }
+
+ /**
+ *
+ */
+ public void testReadonlyBooleanProperty()
+ {
+ testReadonlyBooleanProperty(_beanProperties);
+ }
+
+ /**
+ * test inherited
+ */
+ public void testReadonlyBooleanPropertySubClass()
+ {
+ testReadonlyBooleanProperty(_beanSubclassProperties);
+ }
+
+ /**
+ *
+ */
+ private void testReadonlyBooleanProperty(Map properties)
+ {
+ IBeanPropertySymbol property =
+ (IBeanPropertySymbol) properties.get("readonlyBooleanProperty");
+ assertNotNull(property);
+
+ assertTrue(property.isReadable());
+ assertFalse("No setter for this property", property.isWritable());
+ assertEquals("Signature must be for a boolean",
+ Signature.SIG_BOOLEAN, property.getTypeDescriptor().getTypeSignature());
+ }
+
+ /**
+ *
+ */
+ public void testStringArrayProperty()
+ {
+ testStringArrayProperty(_beanProperties);
+ }
+
+ /**
+ * test inherited
+ */
+ public void testStringArrayPropertySubClass()
+ {
+ testStringArrayProperty(_beanSubclassProperties);
+ }
+
+ /**
+ *
+ */
+ private void testStringArrayProperty(Map properties)
+ {
+ IBeanPropertySymbol property =
+ (IBeanPropertySymbol) properties.get("stringArrayProperty");
+ assertNotNull(property);
+
+ assertTrue(property.isReadable());
+ assertTrue(property.isWritable());
+ assertEquals("Signature must be for a String[]",
+ "[Ljava.lang.String;", property.getTypeDescriptor().getTypeSignature());
+ }
+
+ /**
+ *
+ */
+ public void testCollectionProperty()
+ {
+ testCollectionProperty(_beanProperties);
+ }
+
+ /**
+ * test inhertited
+ */
+ public void testCollectionPropertySubClass()
+ {
+ testCollectionProperty(_beanSubclassProperties);
+ }
+
+ /**
+ *
+ */
+ private void testCollectionProperty(Map properties)
+ {
+ IBeanPropertySymbol property =
+ (IBeanPropertySymbol) properties.get("collectionProperty");
+ assertNotNull(property);
+
+ assertTrue(property.isReadable());
+ assertTrue(property.isWritable());
+ assertEquals("Signature must be for a Collection",
+ "Ljava.util.Collection;", property.getTypeDescriptor().getTypeSignature());
+ }
+
+ /**
+ *
+ */
+ public void testMapProperty()
+ {
+ testMapProperty(_beanProperties);
+ }
+
+ /**
+ * test inherited
+ */
+ public void testMapPropertySubClass()
+ {
+ testMapProperty(_beanProperties);
+ }
+
+ /**
+ *
+ */
+ private void testMapProperty(Map properties)
+ {
+ IBeanPropertySymbol property =
+ (IBeanPropertySymbol) properties.get("mapProperty");
+ assertNotNull(property);
+
+ assertTrue(property.isReadable());
+ assertTrue(property.isWritable());
+ assertEquals("Signature must be for a Map",
+ "Ljava.util.Map;", property.getTypeDescriptor().getTypeSignature());
+ }
+
+ /**
+ *
+ */
+ public void testWriteonlyStringProperty()
+ {
+ testWriteonlyStringProperty(_beanProperties);
+ }
+
+ /**
+ * inherited
+ */
+ public void testWriteonlyStringPropertySubClass()
+ {
+ testWriteonlyStringProperty(_beanSubclassProperties);
+ }
+
+ /**
+ *
+ */
+ private void testWriteonlyStringProperty(Map properties)
+ {
+ IBeanPropertySymbol property =
+ (IBeanPropertySymbol) properties.get("writeonlyStringProperty");
+ assertNotNull(property);
+
+ assertFalse("No getter for this property", property.isReadable());
+ assertTrue(property.isWritable());
+ assertEquals("Signature must be for a String",
+ "Ljava.lang.String;", property.getTypeDescriptor().getTypeSignature());
+ }
+
+ /**
+ * test a locally defined bean type
+ */
+ public void testAnotherBean()
+ {
+ testAnotherBean(_beanProperties);
+ }
+
+ /**
+ * test inherited
+ */
+ public void testAnotherBeanSubClass()
+ {
+ testAnotherBean(_beanSubclassProperties);
+ }
+
+ private void testAnotherBean(Map properties)
+ {
+ IBeanPropertySymbol property =
+ (IBeanPropertySymbol) properties.get("anotherBean");
+ assertNotNull(property);
+
+ assertTrue(property.isReadable());
+ assertTrue("No setter for this property",property.isWritable());
+ assertEquals("Signature must be for a com.test.AnotherBean",
+ "Lcom.test.AnotherBean;", property.getTypeDescriptor().getTypeSignature());
+ }
+
+ /**
+ * Test bean.anotherBean.property for TestBean1
+ */
+ public void testPropertyOfProperty()
+ {
+ testPropertyOfProperty(_beanProperties);
+ }
+
+ /**
+ * Test in inherited anotherBean property
+ */
+ public void testPropertyOfPropertyInSubclass()
+ {
+ testPropertyOfProperty(_beanSubclassProperties);
+ }
+
+ private void testPropertyOfProperty(Map properties)
+ {
+ final IBeanPropertySymbol property =
+ (IBeanPropertySymbol) properties.get("anotherBean");
+ assertNotNull(property);
+
+ boolean foundNestedProperty = false;
+
+ final List anotherBeanProps =
+ property.getTypeDescriptor().getProperties();
+ assertTrue("The nested properties has properties", anotherBeanProps.size()>0);
+
+ SEARCH_FOR_NESTED_PROPERTY:for
+ (final Iterator it = anotherBeanProps.iterator(); it.hasNext();)
+ {
+ final IBeanPropertySymbol nestedProp = (IBeanPropertySymbol) it.next();
+
+ // looking for a property of AnotherBean called property
+ if ("property".equals(nestedProp.getName()))
+ {
+ foundNestedProperty = true;
+ break SEARCH_FOR_NESTED_PROPERTY;
+ }
+ }
+
+ assertTrue(foundNestedProperty);
+ }
+
+ /**
+ * Test a property that's in the sub-class but not the parent
+ */
+ public void testSubclassOnly()
+ {
+ final String inheritedPropertyName = "locallyDefinedProperty";
+
+ // ensure we didn't some how put an inherited property into the
+ // parent
+ assertNull(_beanProperties.get(inheritedPropertyName));
+ IBeanPropertySymbol property = (IBeanPropertySymbol) _beanSubclassProperties.get(inheritedPropertyName);
+ assertNotNull(property);
+
+ assertTrue(property.isReadable());
+ // no setter
+ assertFalse(property.isWritable());
+ assertEquals("Signature must be for a String",
+ "Ljava.lang.String;", property.getTypeDescriptor().getTypeSignature());
+ }
+
+/* ------ Method signature testing -----------------------*/
+
+ /**
+ * test no arg boolean method
+ */
+ public void testABooleanMethodWithNoArgs()
+ {
+ testABooleanMethodWithNoArgs(_beanMethods);
+ }
+
+ /**
+ * test inherited no arg boolean method
+ */
+ public void testABooleanMethodWithNoArgsSubclass()
+ {
+ testABooleanMethodWithNoArgs(_beanMethodsSubclass);
+ }
+
+
+ /**
+ *
+ */
+ private void testABooleanMethodWithNoArgs(Map properties)
+ {
+ IBeanMethodSymbol method =
+ (IBeanMethodSymbol) properties.get("aBooleanMethodWithNoArgs");
+
+ assertEquals("()"+Signature.SIG_BOOLEAN,
+ method.getSignature());
+ }
+
+ /**
+ * test no args string method
+ */
+ public void testAStringMethodWithNoArgs()
+ {
+ testAStringMethodWithNoArgs(_beanMethods);
+ }
+
+ /**
+ * test inherited no args string method
+ */
+ public void testAStringMethodWithNoArgsSubclass()
+ {
+ testAStringMethodWithNoArgs(_beanMethodsSubclass);
+ }
+
+ /**
+ *
+ */
+ private void testAStringMethodWithNoArgs(Map properties)
+ {
+ IBeanMethodSymbol method =
+ (IBeanMethodSymbol) properties.get("aStringMethodWithNoArgs");
+
+ assertEquals("()Ljava.lang.String;",
+ method.getSignature());
+ }
+
+ /**
+ * test is accessor method
+ */
+ public void testIsAnIsAccessor()
+ {
+ testIsAnIsAccessor(_beanMethods);
+ }
+
+ /**
+ * test inherited
+ */
+ public void testIsAnIsAccessorSubclass()
+ {
+ testIsAnIsAccessor(_beanMethodsSubclass);
+ }
+
+ /**
+ *
+ */
+ private void testIsAnIsAccessor(Map properties)
+ {
+ IBeanMethodSymbol method =
+ (IBeanMethodSymbol) properties.get("isAnIsAccessor");
+
+ assertEquals("()Z",
+ method.getSignature());
+ }
+
+ /**
+ *
+ */
+ public void testAIntegerMethodThatTakesAString()
+ {
+ testAIntegerMethodThatTakesAString(_beanMethods);
+ }
+
+ /**
+ * inherited
+ */
+ public void testAIntegerMethodThatTakesAStringSubclass()
+ {
+ testAIntegerMethodThatTakesAString(_beanMethodsSubclass);
+ }
+
+ /**
+ *
+ */
+ private void testAIntegerMethodThatTakesAString(Map properties)
+ {
+ IBeanMethodSymbol method =
+ (IBeanMethodSymbol) properties.get("aIntegerMethodThatTakesAString");
+
+ assertEquals("(Ljava.lang.String;)"+Signature.SIG_INT,
+ method.getSignature());
+ }
+
+ /**
+ *
+ */
+ public void testAIntegerMethodThatTakesAStringAndLong()
+ {
+ testAIntegerMethodThatTakesAStringAndLong(_beanMethods);
+ }
+
+ /**
+ * inherited
+ */
+ public void testAIntegerMethodThatTakesAStringAndLongSubclass()
+ {
+ testAIntegerMethodThatTakesAStringAndLong(_beanMethodsSubclass);
+ }
+
+ /**
+ * @param arg1
+ * @param arg2
+ */
+ private void testAIntegerMethodThatTakesAStringAndLong(Map properties)
+ {
+ IBeanMethodSymbol method =
+ (IBeanMethodSymbol) properties.get("aIntegerMethodThatTakesAStringAndLong");
+
+ assertEquals("(Ljava.lang.String;Ljava.lang.Long;)"+Signature.SIG_INT,
+ method.getSignature());
+ }
+
+ /**
+ * test that the overloaded methods are both there
+ */
+ public void testOverloadedMethod()
+ {
+ testOverloadedMethod(_testBean2Symbol);
+ }
+
+ /**
+ * test the inherited
+ */
+ public void testOverloadedMethodSubclass()
+ {
+ testOverloadedMethod(_testBean2SubclassSymbol);
+ }
+
+ private void testOverloadedMethod(IBeanInstanceSymbol bean)
+ {
+ final String intMethodSignature =
+ "("+Signature.SIG_INT+")"+Signature.SIG_VOID;
+ final String stringMethodSignature =
+ "(Ljava.lang.String;)V";
+
+ boolean foundIntOverload = false;
+ boolean foundStringOverload = false;
+
+ for (final Iterator it = bean.getTypeDescriptor().getMethods().iterator();
+ it.hasNext();)
+ {
+ final IBeanMethodSymbol method = (IBeanMethodSymbol) it.next();
+ if (overloadedMethodName.equals(method.getName()))
+ {
+ final String typeSignature = method.getSignature();
+
+ if (intMethodSignature.equals(typeSignature))
+ {
+ foundIntOverload = true;
+ }
+ else if (stringMethodSignature.equals(typeSignature))
+ {
+ foundStringOverload = true;
+ }
+ }
+ }
+
+ assertTrue(foundIntOverload && foundStringOverload);
+ }
+
+ /**
+ * Test method signature that is only in the sub-class, not in the parent
+ */
+ public void testMethodSubclassOnly()
+ {
+ assertNull(_beanMethods.get("validate"));
+
+ IBeanMethodSymbol method =
+ (IBeanMethodSymbol) _beanMethodsSubclass.get("validate");
+ assertNotNull(method);
+ assertEquals("(Lcom.test.TestBean2;)"+Signature.SIG_VOID,
+ method.getSignature());
+ }
+
+/* ------ test acquisition of super-classes and interfaces -----------------------*/
+ /**
+ * Test correct super class acquistion
+ */
+ public void testSuperClassAcquisition()
+ {
+ // TestBean1
+ List superSigs =
+ _testBean1Symbol.getTypeDescriptor().getSuperTypeSignatures();
+
+ // should only have java.lang.Object as a super
+ assertEquals(superSigs.size(), 1);
+ assertEquals("Ljava.lang.Object;", (String)superSigs.get(0));
+
+ // TestBean1Subclass
+ superSigs =
+ _testBean1SubclassSymbol.getTypeDescriptor().getSuperTypeSignatures();
+
+ // should have Object and TestBean1 as parents
+ assertEquals(superSigs.size(), 2);
+ assertTrue(superSigs.contains("Ljava.lang.Object;"));
+ assertTrue(superSigs.contains("Lcom.test.TestBean1;"));
+
+ // TestBean2
+ superSigs =
+ _testBean2Symbol.getTypeDescriptor().getSuperTypeSignatures();
+
+ // should only have java.lang.Object as a super
+ assertEquals(superSigs.size(), 1);
+ assertEquals("Ljava.lang.Object;", (String)superSigs.get(0));
+
+ // TestBean2Subclass
+ superSigs =
+ _testBean2SubclassSymbol.getTypeDescriptor().getSuperTypeSignatures();
+ // should have Object and TestBean2 as parents
+ assertEquals(superSigs.size(), 2);
+ assertTrue(superSigs.contains("Ljava.lang.Object;"));
+ assertTrue(superSigs.contains("Lcom.test.TestBean2;"));
+
+ }
+
+ /**
+ * Test the acquisition of the interface implemented on TestBean2 and its subclass
+ */
+ public void testInterfaceAcquisition()
+ {
+ // TestBean2
+ List superSigs =
+ _testBean2Symbol.getTypeDescriptor().getInterfaceTypeSignatures();
+
+ // should only have ITestBean2
+ assertEquals(superSigs.size(), 1);
+ assertEquals("Lcom.test.ITestBean2;", (String)superSigs.get(0));
+
+ // TestBean2Subclass
+ superSigs =
+ _testBean2SubclassSymbol.getTypeDescriptor().getInterfaceTypeSignatures();
+ // should only have ITestBean2
+ assertEquals(superSigs.size(), 1);
+ assertEquals("Lcom.test.ITestBean2;", (String)superSigs.get(0));
+ }
+
+// coverage of EObject generated methods
+
+ /**
+ * Cover isSet
+ */
+ public void testIsESet()
+ {
+ IType testBean1Type = null;
+
+ try
+ {
+ testBean1Type =
+ _jdtTestEnvironment.getJavaProject().
+ findType(packageName1+"."+testBeanName1);
+ }
+ catch (JavaModelException jme)
+ {
+ fail(jme.getLocalizedMessage());
+ }
+
+ assertNotNull(testBean1Type);
+
+ IJavaTypeDescriptor2 desc =
+ SymbolFactory.eINSTANCE.createIJavaTypeDescriptor2();
+
+ // there are methods and one property on TestBean2
+ assertFalse(desc.eIsSet(SymbolPackage.eINSTANCE.getIJavaTypeDescriptor2_BeanProperties()));
+ assertFalse(desc.eIsSet(SymbolPackage.eINSTANCE.getIJavaTypeDescriptor2_BeanMethods()));
+ assertFalse(desc.eIsSet(SymbolPackage.eINSTANCE.getIBeanInstanceSymbol_JavaTypeDescriptor()));
+
+ desc.eSet(SymbolPackage.eINSTANCE.getIJavaTypeDescriptor2_BeanProperties(),
+ _testBean2Symbol.getJavaTypeDescriptor().getBeanProperties());
+ desc.eSet(SymbolPackage.eINSTANCE.getIJavaTypeDescriptor2_BeanMethods(),
+ _testBean2Symbol.getJavaTypeDescriptor().getBeanMethods());
+ desc.eSet(SymbolPackage.eINSTANCE.getIJavaTypeDescriptor2_Type(),
+ testBean1Type);
+
+ assertFalse(((List)desc.eGet(SymbolPackage.eINSTANCE.getIJavaTypeDescriptor2_BeanProperties())).size()
+ == 0);
+ assertFalse(((List)desc.eGet(SymbolPackage.eINSTANCE.getIJavaTypeDescriptor2_BeanMethods())).size()
+ == 0);
+ assertEquals(desc.eGet(SymbolPackage.eINSTANCE.getIJavaTypeDescriptor2_Type()),
+ testBean1Type);
+
+ assertTrue(desc.eIsSet(SymbolPackage.eINSTANCE.getIJavaTypeDescriptor2_BeanProperties()));
+ assertTrue(desc.eIsSet(SymbolPackage.eINSTANCE.getIJavaTypeDescriptor2_BeanMethods()));
+ assertTrue(desc.eIsSet(SymbolPackage.eINSTANCE.getIJavaTypeDescriptor2_Type()));
+
+ desc.eUnset(SymbolPackage.eINSTANCE.getIJavaTypeDescriptor2_BeanProperties());
+ desc.eUnset(SymbolPackage.eINSTANCE.getIJavaTypeDescriptor2_BeanMethods());
+ desc.eUnset(SymbolPackage.eINSTANCE.getIJavaTypeDescriptor2_Type());
+
+ // there are methods and one property on TestBean2
+ assertFalse(desc.eIsSet(SymbolPackage.eINSTANCE.getIJavaTypeDescriptor2_BeanProperties()));
+ assertFalse(desc.eIsSet(SymbolPackage.eINSTANCE.getIJavaTypeDescriptor2_BeanMethods()));
+ assertFalse(desc.eIsSet(SymbolPackage.eINSTANCE.getIJavaTypeDescriptor2_Type()));
+ }
+
+ /**
+ * Cover the toString
+ */
+ public void testToString()
+ {
+ _testBean2Symbol.getTypeDescriptor().toString();
+ }
+}
diff --git a/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/testdata/ITestBean2.java.data b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/testdata/ITestBean2.java.data
new file mode 100644
index 0000000..e837d65
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/testdata/ITestBean2.java.data
@@ -0,0 +1,5 @@
+package com.test;
+
+public interface ITestBean2
+{
+}
\ No newline at end of file
diff --git a/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/testdata/TestBean2.java.data b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/testdata/TestBean2.java.data
new file mode 100644
index 0000000..34d25e9
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/testdata/TestBean2.java.data
@@ -0,0 +1,37 @@
+package com.test
+
+public class TestBean2 implements ITestBean2
+{
+ public boolean aBooleanMethodWithNoArgs()
+ {
+ return false;
+ }
+
+ public String aStringMethodWithNoArgs()
+ {
+ return true;
+ }
+
+ public boolean isAnIsAccessor()
+ {
+ return false;
+ }
+
+ public int aIntegerMethodThatTakesAString(String arg)
+ {
+ return -1;
+ }
+
+ public int aIntegerMethodThatTakesAStringAndLong(String arg1, Long arg2)
+ {
+ return -1;
+ }
+
+ public void overloadedMethod(int a)
+ {
+ }
+
+ public void overloadedMethod(String a)
+ {
+ }
+}
\ No newline at end of file
diff --git a/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/testdata/TestBean2Subclass.java.data b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/testdata/TestBean2Subclass.java.data
new file mode 100644
index 0000000..cbe2224
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/testdata/TestBean2Subclass.java.data
@@ -0,0 +1,8 @@
+package com.test
+
+public class TestBean2Subclass extends TestBean2
+{
+ public void validate(TestBean2 parentBean)
+ {
+ }
+}
\ No newline at end of file