Author: jsong Date: Thu Dec 16 11:20:37 2004 New Revision: 122570 URL: http://svn.apache.org/viewcvs?view=rev&rev=122570 Log: Add/activate more detailed tests on instantiating control using Controls api.
Added: incubator/beehive/trunk/controls/test/src/drivers/org/apache/beehive/controls/test/driver/instantiate/DriveBoundProperty.java Modified: incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/instantiate/TestInstantiate.java incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/jpf/instantiate/TestInstantiate.java incubator/beehive/trunk/controls/test/webapps/controlsWeb/WEB-INF/src/jws/Instantiate.jws incubator/beehive/trunk/controls/test/webapps/controlsWeb/instantiate/programwithproperty/Controller.jpf Added: incubator/beehive/trunk/controls/test/src/drivers/org/apache/beehive/controls/test/driver/instantiate/DriveBoundProperty.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/src/drivers/org/apache/beehive/controls/test/driver/instantiate/DriveBoundProperty.java?view=auto&rev=122570 ============================================================================== --- (empty file) +++ incubator/beehive/trunk/controls/test/src/drivers/org/apache/beehive/controls/test/driver/instantiate/DriveBoundProperty.java Thu Dec 16 11:20:37 2004 @@ -0,0 +1,42 @@ +package org.apache.beehive.controls.test.driver.instantiate; + +import org.apache.beehive.test.tools.milton.common.Report; +import org.apache.beehive.controls.test.controls.property.BoundPropertyControlBean; + +/* This class contains the logic to test instantiating controls with an external propertSet. + * A Report object is generated for test result. + */ + +public class DriveBoundProperty +{ + + /* A control with a externally declared propertySet*/ + private BoundPropertyControlBean myControl; + + public void setControl(BoundPropertyControlBean aControl){ + + myControl=aControl; + } + + /* Verifies if the property value is same as expected*/ + public Report doTestReconfiguredExtProperty(int expected){ + + Report report=new Report(); + + if (myControl==null) + report.setStatus(Report.FAIL); + else + { + int age=myControl.getAge(); + if (age==expected) + report.setStatus(Report.PASS); + else{ + report.setStatus(Report.FAIL); + report.setMessage("The age is wrong:"+age); + } + + } + return report; + } + +} \ No newline at end of file Modified: incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/instantiate/TestInstantiate.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/instantiate/TestInstantiate.java?view=diff&rev=122570&p1=incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/instantiate/TestInstantiate.java&r1=122569&p2=incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/instantiate/TestInstantiate.java&r2=122570 ============================================================================== --- incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/instantiate/TestInstantiate.java (original) +++ incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/instantiate/TestInstantiate.java Thu Dec 16 11:20:37 2004 @@ -3,13 +3,18 @@ import junit.framework.TestCase; import java.beans.Beans; import org.apache.beehive.controls.api.bean.Control; +import org.apache.beehive.controls.api.bean.Controls; import org.apache.beehive.controls.api.bean.ControlBean; import org.apache.beehive.controls.api.properties.PropertyMap; +import org.apache.beehive.controls.api.properties.BeanPropertyMap; import org.apache.beehive.controls.test.controls.instantiate.HelloControlBean; +import org.apache.beehive.controls.test.controls.property.BoundExtPropertySet; import org.apache.beehive.controls.test.controls.property.SingleProperty; import org.apache.beehive.controls.test.controls.property.SinglePropertyBean; +import org.apache.beehive.controls.test.controls.property.BoundPropertyControlBean; import org.apache.beehive.controls.test.driver.instantiate.DriveHelloControl; import org.apache.beehive.controls.test.driver.instantiate.DriveSingleProperty; +import org.apache.beehive.controls.test.driver.instantiate.DriveBoundProperty; import org.apache.beehive.test.tools.mantis.annotations.tch.Freq; import org.apache.beehive.test.tools.mantis.annotations.tch.Status; import org.apache.beehive.test.tools.milton.common.Report; @@ -93,22 +98,20 @@ } /** - * Tests programmically instantiating a custom control with propertySet + * Tests programmically instantiating a control with propertySet */ @Freq("detailed") - @Status("inactive") + @Status("active") public void testProgramWithProperty() throws Exception { - /* - We still can not do this because of JIRA-BEEHIVE-137 Report report=new Report(); - PropertyMap greetAttr = new PropertyMap(SingleProperty.Greeting.class); - greetAttr.setProperty("GreetWord","Good afternoon!"); + BeanPropertyMap greetAttr = new BeanPropertyMap(SingleProperty.Greeting.class); + greetAttr.setProperty(SinglePropertyBean.GreetWordKey,"Good afternoon!"); SinglePropertyBean spbean = (SinglePropertyBean)Controls.instantiate( - cl, - "org.apache.beehive.controls.test.controls.properties.SinglePropertyBean", + Thread.currentThread().getContextClassLoader(), + "org.apache.beehive.controls.test.controls.property.SinglePropertyBean", greetAttr); DriveSingleProperty driver=new DriveSingleProperty(); @@ -117,6 +120,37 @@ String result=report.getStatus(); if (!result.equals(Report.PASS)) fail(report.getMessage()); + } + + /** + * Tests programmically instantiating a control with an external declared propertySet + */ + @Freq("detailed") + @Status("inactive") + public void testProgramWithExtProperty() throws Exception + { + + /* + We hit another problem here: reset primitive value property using Controls + Right now, BeanPropertyMap.setProperty does not allow resetting primitive value. + + + Report report=new Report(); + + BeanPropertyMap greetAttr = new BeanPropertyMap(BoundExtPropertySet.class); + greetAttr.setProperty(BoundPropertyControlBean.AgeKey,10); + BoundPropertyControlBean bbean = (BoundPropertyControlBean)Controls.instantiate( + Thread.currentThread().getContextClassLoader(), + "org.apache.beehive.controls.test.controls.property.BoundPropertyControlBean", + greetAttr); + + DriveBoundProperty driver=new DriveBoundProperty(); + driver.setControl(bbean); + report=driver.doTestReconfiguredExtProperty(10); + String result=report.getStatus(); + if (!result.equals(Report.PASS)) + fail(report.getMessage()); */ } + } Modified: incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/jpf/instantiate/TestInstantiate.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/jpf/instantiate/TestInstantiate.java?view=diff&rev=122570&p1=incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/jpf/instantiate/TestInstantiate.java&r1=122569&p2=incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/jpf/instantiate/TestInstantiate.java&r2=122570 ============================================================================== --- incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/jpf/instantiate/TestInstantiate.java (original) +++ incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/jpf/instantiate/TestInstantiate.java Thu Dec 16 11:20:37 2004 @@ -44,18 +44,9 @@ * Tests programmically instantiating a custom control with propertySet */ @Freq("detailed") - @Status("inactive") + @Status("active") public void testProgrammWithProperty() throws Exception { - /*BUG:CR190302 - - PropertyMap greetAttr = new (PropertyMap(SingleProperty.Greeting.class); - greetAttr.setProperty("GreetWord","Good afternoon!"); - SinglePropertyBean spbean = (SinglePropertyBean)Controls.instantiate( - cl, - "org.apache.beehive.controls.test.controls.properties.SinglePropertyBean", - greetAttr); - */ assertReport("/controlsWeb/instantiate/programwithproperty/Controller.jpf"); } } Modified: incubator/beehive/trunk/controls/test/webapps/controlsWeb/WEB-INF/src/jws/Instantiate.jws Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/webapps/controlsWeb/WEB-INF/src/jws/Instantiate.jws?view=diff&rev=122570&p1=incubator/beehive/trunk/controls/test/webapps/controlsWeb/WEB-INF/src/jws/Instantiate.jws&r1=122569&p2=incubator/beehive/trunk/controls/test/webapps/controlsWeb/WEB-INF/src/jws/Instantiate.jws&r2=122570 ============================================================================== --- incubator/beehive/trunk/controls/test/webapps/controlsWeb/WEB-INF/src/jws/Instantiate.jws (original) +++ incubator/beehive/trunk/controls/test/webapps/controlsWeb/WEB-INF/src/jws/Instantiate.jws Thu Dec 16 11:20:37 2004 @@ -24,7 +24,9 @@ import javax.jws.WebMethod; import javax.jws.WebService; import org.apache.beehive.controls.api.bean.Control; +import org.apache.beehive.controls.api.bean.Controls; import org.apache.beehive.controls.api.bean.ControlBean; +import org.apache.beehive.controls.api.properties.BeanPropertyMap; import org.apache.beehive.controls.test.controls.instantiate.HelloControlBean; import org.apache.beehive.controls.test.controls.property.SingleProperty; import org.apache.beehive.controls.test.controls.property.SinglePropertyBean; @@ -85,18 +87,25 @@ @WebMethod public Report testProgrammaticInstantiateWithProperty() { - /*BUG:CR190302 - - PropertyMap greetAttr = new (PropertyMap(SingleProperty.Greeting.class); - greetAttr.setProperty("GreetWord","Good afternoon!"); - SinglePropertyBean spbean = (SinglePropertyBean) - Controls.instantiate(cl, "org.apache.beehive.controls.test.controls.properties.SinglePropertyBean", greetAttr); - - Before CR190302 is fixed, this test just simply fails. - */ Report report=new Report(); - report.setStatus(Report.FAIL); - report.setMessage("Missing API: Controls. JIRA-BEEHIVE-113"); + + try{ + BeanPropertyMap greetAttr = new BeanPropertyMap(SingleProperty.Greeting.class); + greetAttr.setProperty(SinglePropertyBean.GreetWordKey,"Good afternoon!"); + SinglePropertyBean spbean = (SinglePropertyBean)Controls.instantiate( + Thread.currentThread().getContextClassLoader(), + "org.apache.beehive.controls.test.controls.property.SinglePropertyBean", + greetAttr); + + DriveSingleProperty driver=new DriveSingleProperty(); + driver.setControl(spbean); + report=driver.doTestReconfiguredProperty("Good afternoon!"); + } + catch(Exception e){ + report.setStatus(Report.FAIL); + report.setExceptionStack(e); + } + return report; } Modified: incubator/beehive/trunk/controls/test/webapps/controlsWeb/instantiate/programwithproperty/Controller.jpf Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/webapps/controlsWeb/instantiate/programwithproperty/Controller.jpf?view=diff&rev=122570&p1=incubator/beehive/trunk/controls/test/webapps/controlsWeb/instantiate/programwithproperty/Controller.jpf&r1=122569&p2=incubator/beehive/trunk/controls/test/webapps/controlsWeb/instantiate/programwithproperty/Controller.jpf&r2=122570 ============================================================================== --- incubator/beehive/trunk/controls/test/webapps/controlsWeb/instantiate/programwithproperty/Controller.jpf (original) +++ incubator/beehive/trunk/controls/test/webapps/controlsWeb/instantiate/programwithproperty/Controller.jpf Thu Dec 16 11:20:37 2004 @@ -23,7 +23,10 @@ import org.apache.beehive.netui.pageflow.annotations.Jpf; import org.apache.beehive.controls.api.bean.Control; +import org.apache.beehive.controls.api.bean.Controls; import org.apache.beehive.controls.api.bean.ControlBean; +import org.apache.beehive.controls.api.properties.BeanPropertyMap; +import org.apache.beehive.controls.test.controls.property.SingleProperty; import org.apache.beehive.controls.test.controls.property.SinglePropertyBean; import org.apache.beehive.controls.test.driver.instantiate.DriveSingleProperty; import org.apache.beehive.test.tools.milton.common.Report; @@ -44,17 +47,23 @@ ) protected Forward begin(){ - /*BUG:CR190302 + Report report=new Report(); + try{ + BeanPropertyMap greetAttr = new BeanPropertyMap(SingleProperty.Greeting.class); + greetAttr.setProperty(SinglePropertyBean.GreetWordKey,"Good afternoon!"); + SinglePropertyBean spbean = (SinglePropertyBean)Controls.instantiate( + Thread.currentThread().getContextClassLoader(), + "org.apache.beehive.controls.test.controls.property.SinglePropertyBean", + greetAttr); - PropertyMap greetAttr = new (PropertyMap(SingleProperty.Greeting.class); - greetAttr.setProperty("GreetWord","Good afternoon!"); - SinglePropertyBean spbean = (SinglePropertyBean) - Controls.instantiate(cl, "org.apache.beehive.controls.test.controls.properties.SinglePropertyBean", greetAttr); - - Before CR190302 is fixed, this test just simply fails. - */ - Report report=new Report(); - report.setStatus(Report.FAIL); + DriveSingleProperty driver=new DriveSingleProperty(); + driver.setControl(spbean); + report=driver.doTestReconfiguredProperty("Good afternoon!"); + } + catch(Exception e){ + report.setStatus(Report.FAIL); + report.setExceptionStack(e); + } return new Forward(Report.RESULTS, Report.KEY, report); }
