Author: jsong
Date: Wed Oct  6 18:07:48 2004
New Revision: 53926

Modified:
   
incubator/beehive/trunk/controls/test/src/drivers/org/apache/beehive/controls/test/driver/contextevent/DriveBeanRecorder.java
   
incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/contextevent/LifeCycleTest.java
Log:
Update drivers and tests for control lifecycle event test.


Modified: 
incubator/beehive/trunk/controls/test/src/drivers/org/apache/beehive/controls/test/driver/contextevent/DriveBeanRecorder.java
==============================================================================
--- 
incubator/beehive/trunk/controls/test/src/drivers/org/apache/beehive/controls/test/driver/contextevent/DriveBeanRecorder.java
       (original)
+++ 
incubator/beehive/trunk/controls/test/src/drivers/org/apache/beehive/controls/test/driver/contextevent/DriveBeanRecorder.java
       Wed Oct  6 18:07:48 2004
@@ -1,5 +1,6 @@
 package org.apache.beehive.controls.test.driver.contextevent;
 
+import  org.apache.beehive.controls.api.context.ControlBeanContext;
 import org.apache.beehive.test.tools.milton.common.Report;
 import org.apache.beehive.controls.test.controls.contextevent.RecorderBean;
 
@@ -28,24 +29,48 @@
                        report.setMessage("the custom control is NULL");
                }
                else{
-                       /**Bug: CR199168
+                       //There is only one method onCreate() in 
ControlBeanContext.LifeCycle
 
-                       ControlBeanContext peerContext = 
myRecorder.getPeerContext();
-                       PeerContext.addCallbackListener( new 
ControlBeanContext.LifeCycle()
+                       ControlBeanContext peerContext = 
myControl.getControlBeanContext();
+                       peerContext.addLifeCycleListener( new 
ControlBeanContext.LifeCycle()
                                {
-                                       public void onCreate() { 
onCreateReceived=true;};
+                                       public void onCreate() {
 
-                                   //public void onAcquire() { //do recording};
-                                   //public void onRelease() { //do recording 
};
-                               });
-                       */
 
-                       /* Before CR199168 is fixed, just simply fail this 
test*/
+                                               onCreateReceived=true; };
+                                       /*
+                                       public void onAcquire() { //do 
recording};
+                                       public void onRelease() { //do 
recording};
+                                       */
+                                       });
 
+                       report.setStatus(Report.PASS);
+               }
+
+               return report;
+       }
+
+    /*
+     * Listens to control life cycle events by adding listener to control bean 
class.
+     */
+       public Report getResult(){
+
+               Report report=new Report();
+
+               if (myControl==null){
                        report.setStatus(Report.FAIL);
-                       report.setMessage("Failed by CR190273. Please check the 
latest development");
+                       report.setMessage("the custom control is NULL");
+               }
+               else{
+                       if (onCreateReceived)
+                               report.setStatus(Report.PASS);
+                       else{
+                               report.setStatus(Report.FAIL);
+                               report.setMessage("onCreate is not received.");
+                       }
                }
 
                return report;
        }
+
 }

Modified: 
incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/contextevent/LifeCycleTest.java
==============================================================================
--- 
incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/contextevent/LifeCycleTest.java
       (original)
+++ 
incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/contextevent/LifeCycleTest.java
       Wed Oct  6 18:07:48 2004
@@ -6,8 +6,10 @@
 import org.apache.beehive.controls.api.bean.Control;
 import org.apache.beehive.controls.api.bean.ControlBean;
 import org.apache.beehive.controls.test.controls.contextevent.RecorderBean;
+import org.apache.beehive.controls.test.driver.contextevent.DriveBeanRecorder;
 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;
 
 /**
  * A TestCase that tests control's context event by listening to and recording 
controls'
@@ -56,20 +58,24 @@
 
     /**
      * Tests listening to control's lifecycle events by registering a listener
+     * It seems we can't grab onCreate event in this way.
      */
-       @Freq("detailed")
+       @Freq("checkin")
        @Status("inactive")
     public void testRecordFromBeanInstance() throws Exception
     {
-               /**Bug: CR190273
-
-               ControlBeanContext peerContext = myRecorder.getPeerContext();
-               PeerContext.addCallbackListener( new 
ControlBeanContext.Callback()
-                       { public void onCreate() { //do recording };
-                        public void onAcquire() { //do recording};
-                       public void onRelease() { //do recording }; });
-               */
-
+               DriveBeanRecorder driver=new DriveBeanRecorder();
+               RecorderBean recorderbean=(RecorderBean)Beans.instantiate(
+                       Thread.currentThread().getContextClassLoader(),
+                       
"org.apache.beehive.controls.test.controls.contextevent.RecorderBean");
+               driver.setControl(recorderbean);
+               Report report1=driver.doTest();
+               Assert.assertEquals(Report.PASS,report1.getStatus());
+               try{
+                       Thread.currentThread().sleep(500);
+               }
+               catch(Exception e){}
+               Report report2=driver.getResult();
+               Assert.assertEquals(Report.PASS,report2.getStatus());
     }
-
 }

Reply via email to