You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by js...@apache.org on 2005/01/25 21:40:51 UTC

svn commit: r126421 - /incubator/beehive/trunk/controls/test/src/drivers/org/apache/beehive/controls/test/driver/packaging/DrivePropertyInfo.java /incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/packaging/PropertyInfoTest.java

Author: jsong
Date: Tue Jan 25 12:40:49 2005
New Revision: 126421

URL: http://svn.apache.org/viewcvs?view=rev&rev=126421
Log:
Add tests for controls packaging.

Added:
   incubator/beehive/trunk/controls/test/src/drivers/org/apache/beehive/controls/test/driver/packaging/DrivePropertyInfo.java
   incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/packaging/PropertyInfoTest.java

Added: incubator/beehive/trunk/controls/test/src/drivers/org/apache/beehive/controls/test/driver/packaging/DrivePropertyInfo.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/src/drivers/org/apache/beehive/controls/test/driver/packaging/DrivePropertyInfo.java?view=auto&rev=126421
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/controls/test/src/drivers/org/apache/beehive/controls/test/driver/packaging/DrivePropertyInfo.java	Tue Jan 25 12:40:49 2005
@@ -0,0 +1,144 @@
+package org.apache.beehive.controls.test.driver.packaging;
+
+import java.lang.Class;
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import org.apache.beehive.controls.test.controls.property.BoundPropertyControlBean;
+import org.apache.beehive.test.tools.milton.common.Report;
+
+/* This class contains the logic to test PropertyInfo annotation of control packaging.
+ *
+ * PropertyInfo annotations on control interface shall be written into control beaninfo
+ * class during control packaging process.
+ * The tests in this class will get feature info from control beaninfo class in
+ * order to make sure this part of packaging process works fine.
+ */
+
+public class DrivePropertyInfo
+{
+
+	/*Gets class level feature info from BoundPropertyBeanBeanInfo class*/
+	public Report doGetPropertyInfo(){
+
+		Report report=new Report();
+		report.setStatus(Report.PASS);
+
+		try{
+			BeanInfo beanInfo=Introspector.getBeanInfo(Class.forName(
+				"org.apache.beehive.controls.test.controls.property.BoundPropertyControlBean"));
+			PropertyDescriptor[] descriptors=beanInfo.getPropertyDescriptors();
+
+			//Find and inspect property descriptor for each property.
+			PropertyDescriptor descriptor=findProperty(descriptors,"Brand");
+
+			if (descriptor==null){
+				report.setStatus(Report.FAIL);
+				report.setMessage("Could not find property descriptor for 'Brand'.");
+			}
+			else{
+				if (!descriptor.isBound()){
+					report.setStatus(Report.FAIL);
+					report.setMessage("'Brand' is not bound.");
+				}
+				else if	(descriptor.isConstrained()){
+					report.setStatus(Report.FAIL);
+					report.setMessage("'Brand' is constrained.");
+				}
+
+			}
+
+			if (report.getStatus().equals(Report.PASS)){
+				descriptor=findProperty(descriptors,"Material");
+				if (descriptor==null){
+					report.setStatus(Report.FAIL);
+					report.setMessage("Could not find property descriptor for 'Material'.");
+				}
+				else{
+					if (descriptor.isBound()){
+						report.setStatus(Report.FAIL);
+						report.setMessage("'Material' is bound.");
+					}
+					else if	(!descriptor.isConstrained()){
+						report.setStatus(Report.FAIL);
+						report.setMessage("'Material' is not constrained.");
+					}
+				}
+			}
+
+			if (report.getStatus().equals(Report.PASS)){
+				descriptor=findProperty(descriptors,"Quality");
+				if (descriptor==null){
+					report.setStatus(Report.FAIL);
+					report.setMessage("Could not find property descriptor for 'Quality'.");
+				}
+				else{
+					if (!descriptor.isBound()){
+						report.setStatus(Report.FAIL);
+						report.setMessage("'Quality' is not bound.");
+					}
+					else if	(!descriptor.isConstrained()){
+						report.setStatus(Report.FAIL);
+						report.setMessage("'Quality' is not constrained.");
+					}
+				}
+
+			}
+
+			if (report.getStatus().equals(Report.PASS)){
+				descriptor=findProperty(descriptors,"age");
+				if (descriptor==null){
+					report.setStatus(Report.FAIL);
+					report.setMessage("Could not find property descriptor for 'age'.");
+				}
+				else{
+					if (!descriptor.isBound()){
+						report.setStatus(Report.FAIL);
+						report.setMessage("'age' is not bound.");
+					}
+					else if	(descriptor.isConstrained()){
+						report.setStatus(Report.FAIL);
+						report.setMessage("'age' is constrained.");
+					}
+				}
+			}
+			if (report.getStatus().equals(Report.PASS)){
+				descriptor=findProperty(descriptors,"height");
+				if (descriptor==null){
+					report.setStatus(Report.FAIL);
+					report.setMessage("Could not find property descriptor for 'height'.");
+				}
+				else{
+					if (descriptor.isBound()){
+						report.setStatus(Report.FAIL);
+						report.setMessage("'hight' is bound.");
+					}
+					else if	(!descriptor.isConstrained()){
+						report.setStatus(Report.FAIL);
+						report.setMessage("'hight' is not constrained.");
+					}
+				}
+			}
+
+		}
+		catch(Exception e){
+			report.setStatus(Report.FAIL);
+			report.setExceptionStack(e);
+		}
+
+		return report;
+
+	}
+	private PropertyDescriptor findProperty(PropertyDescriptor[] array,String propertyname){
+
+		PropertyDescriptor result=null;
+		for(int i=0;i<array.length;i++){
+			result=array[i];
+			if (result.getName().equals(propertyname))
+				break;
+		}
+		return result;
+	}
+
+}

Added: incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/packaging/PropertyInfoTest.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/packaging/PropertyInfoTest.java?view=auto&rev=126421
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/packaging/PropertyInfoTest.java	Tue Jan 25 12:40:49 2005
@@ -0,0 +1,40 @@
+package org.apache.beehive.controls.test.java.packaging;
+
+import junit.framework.TestCase;
+import org.apache.beehive.controls.test.driver.packaging.DrivePropertyInfo;
+import org.apache.beehive.test.tools.milton.common.Report;
+import org.apache.beehive.test.tools.mantis.annotations.tch.Freq;
+
+
+/**
+ * A TestCase that tests controls PropertyInfo
+ *
+ * PropertyInfo annotation on control interface is saved into controlBeanInfo class
+ * when the control is packaged.
+ *
+ * The tests in this class get property info from controlBeanInfo class after the
+ * control is packaged into jar, in order to verify this part of control packaging
+ * process.
+ */
+@Freq("detailed")
+public class PropertyInfoTest extends TestCase
+{
+    public PropertyInfoTest( String s ) { super( s ); }
+
+    public void setUp() { }
+
+	/*Test getting FeatureInfo from ControlBeanInfo class*/
+	@Freq("detailed")
+    public void testGetPropertyInfo() throws Exception
+    {
+		DrivePropertyInfo driver=new DrivePropertyInfo();
+
+		Report report=driver.doGetPropertyInfo();
+
+		String result=report.getStatus();
+
+		if (result.equals(Report.FAIL))
+			fail(report.getMessage());
+
+    }
+}