annotate bindings/as3/ext/asunit/framework/AsynchronousHTTPServiceTestCase.as @ 770:c54bc2ffbf92 tip

update tags
author convert-repo
date Fri, 16 Dec 2011 11:34:01 +0000
parents 3a0b9700b3d2
children
rev   line source
mas01mj@732 1 package asunit.framework {
mas01mj@732 2 import asunit.errors.AbstractError;
mas01mj@732 3
mas01mj@732 4 import flash.errors.IllegalOperationError;
mas01mj@732 5 import flash.events.*;
mas01mj@732 6 import flash.net.URLLoader;
mas01mj@732 7 import flash.utils.getTimer;
mas01mj@732 8
mas01mj@732 9 import mx.rpc.AsyncToken;
mas01mj@732 10 import mx.rpc.Responder;
mas01mj@732 11 import mx.rpc.events.FaultEvent;
mas01mj@732 12
mas01mj@732 13 /**
mas01mj@732 14 * Extend this class if you have a TestCase that requires the
mas01mj@732 15 * asynchronous load of external data.
mas01mj@732 16 */
mas01mj@732 17 public class AsynchronousHTTPServiceTestCase extends AsynchronousTestCase implements Test {
mas01mj@732 18
mas01mj@732 19 public function AsynchronousHTTPServiceTestCase(testMethod:String = null) {
mas01mj@732 20 super(testMethod);
mas01mj@732 21 }
mas01mj@732 22
mas01mj@732 23 // use this method in overriding run() if you are using an HTTPService:
mas01mj@732 24 protected function configureResponder(token:AsyncToken):void {
mas01mj@732 25 token.addResponder(new Responder(resultFunc, faultFunc));
mas01mj@732 26 }
mas01mj@732 27
mas01mj@732 28 protected function resultFunc(event:Object):void {
mas01mj@732 29 completeHandler(event as Event);
mas01mj@732 30 }
mas01mj@732 31
mas01mj@732 32 protected function faultFunc(event:Object):void {
mas01mj@732 33 var faultEvent:FaultEvent = event as FaultEvent;
mas01mj@732 34 if (faultEvent == null) {
mas01mj@732 35 return;
mas01mj@732 36 }
mas01mj@732 37 var cause:Object = faultEvent.fault.rootCause;
mas01mj@732 38 var ioErrorEvent:IOErrorEvent = cause as IOErrorEvent;
mas01mj@732 39 if (ioErrorEvent) {
mas01mj@732 40 ioErrorHandler(ioErrorEvent);
mas01mj@732 41 return;
mas01mj@732 42 }
mas01mj@732 43 var securityErrorEvent:SecurityErrorEvent = cause as SecurityErrorEvent;
mas01mj@732 44 if (securityErrorEvent) {
mas01mj@732 45 securityErrorHandler(securityErrorEvent);
mas01mj@732 46 }
mas01mj@732 47 }
mas01mj@732 48
mas01mj@732 49 }
mas01mj@732 50
mas01mj@732 51 }