mas01mj@732: package asunit.framework { mas01mj@732: import asunit.errors.AbstractError; mas01mj@732: mas01mj@732: import flash.errors.IllegalOperationError; mas01mj@732: import flash.events.*; mas01mj@732: import flash.net.URLLoader; mas01mj@732: import flash.utils.getTimer; mas01mj@732: mas01mj@732: import mx.rpc.AsyncToken; mas01mj@732: import mx.rpc.Responder; mas01mj@732: import mx.rpc.events.FaultEvent; mas01mj@732: mas01mj@732: /** mas01mj@732: * Extend this class if you have a TestCase that requires the mas01mj@732: * asynchronous load of external data. mas01mj@732: */ mas01mj@732: public class AsynchronousHTTPServiceTestCase extends AsynchronousTestCase implements Test { mas01mj@732: mas01mj@732: public function AsynchronousHTTPServiceTestCase(testMethod:String = null) { mas01mj@732: super(testMethod); mas01mj@732: } mas01mj@732: mas01mj@732: // use this method in overriding run() if you are using an HTTPService: mas01mj@732: protected function configureResponder(token:AsyncToken):void { mas01mj@732: token.addResponder(new Responder(resultFunc, faultFunc)); mas01mj@732: } mas01mj@732: mas01mj@732: protected function resultFunc(event:Object):void { mas01mj@732: completeHandler(event as Event); mas01mj@732: } mas01mj@732: mas01mj@732: protected function faultFunc(event:Object):void { mas01mj@732: var faultEvent:FaultEvent = event as FaultEvent; mas01mj@732: if (faultEvent == null) { mas01mj@732: return; mas01mj@732: } mas01mj@732: var cause:Object = faultEvent.fault.rootCause; mas01mj@732: var ioErrorEvent:IOErrorEvent = cause as IOErrorEvent; mas01mj@732: if (ioErrorEvent) { mas01mj@732: ioErrorHandler(ioErrorEvent); mas01mj@732: return; mas01mj@732: } mas01mj@732: var securityErrorEvent:SecurityErrorEvent = cause as SecurityErrorEvent; mas01mj@732: if (securityErrorEvent) { mas01mj@732: securityErrorHandler(securityErrorEvent); mas01mj@732: } mas01mj@732: } mas01mj@732: mas01mj@732: } mas01mj@732: mas01mj@732: }