package tests { import mx.rpc.remoting.RemoteObject; import mx.controls.Alert; import mx.rpc.events.ResultEvent import mx.rpc.events.FaultEvent public class DatabaseTest { private var summaryObj:Array; private var remoteObject:RemoteObject; private var application:Object; public function DatabaseTest(application:Object) { this.summaryObj = new Array(); this.application = application; remoteObject = new RemoteObject(); remoteObject.destination = "DatabaseTestMySql"; remoteObject.addEventListener("fault", onFault); remoteObject.getCustomers.addEventListener("result", getCustomers_result); remoteObject.getCustomers.addEventListener("fault", getCustomers_fault); } public function onFault (event:FaultEvent):void { Alert.show(event.fault.faultString, 'Error'); } private function getCustomers_result( event:ResultEvent ):void { var resultArray:Array = event.result as Array; if( resultArray.length > 0 ) summaryObj.push( "success: data access test - getCustomers" ); else summaryObj.push( "failure: data access test - getCustomers" ); application.setSummary(summaryObj); application.setDataOutput(resultArray); } public function getCustomers_fault(event:FaultEvent):void { summaryObj.push( "failure: server reported an error: " + event.fault.faultString ); summaryObj.push( "run northwind.sql from /Services/weborb/tests/ to set up the database" ); application.setSummary(summaryObj); } public function runTests():void { this.summaryObj = new Array(); remoteObject.getCustomers(10); } } }