package tests { import flash.net.ObjectEncoding; import flash.net.Responder; import asunit.framework.RemotingTestCase; /** * RemotingTestCaseExample * @author Jens Krause [www.websector.de] * @date 11/29/97 */ public class RemotingTestCaseExample extends RemotingTestCase { private var _result: Object; private var _userVO: UserVO; /** * Constructor * @param testMethod String Name of the test case * */ public function RemotingTestCaseExample(testMethod: String = null) { super(testMethod); } /** * After a test is executed the tearDown method is called * and removed all references to test objects * */ override protected function tearDown():void { _userVO = null; } /** * Before a test is executed the setUp method is called * which instantiate all necessary test objects * */ override protected function setUp(): void { _userVO = _result as UserVO; } /** * Runs the test * */ public override function run():void { UserVO.register(); _result = new Object(); var gateway: String = "http://localhost:8080/mappingExample/gateway"; var encoding: uint = ObjectEncoding.AMF0; var method: String = "de.websector.blog.openamf.mapping.services.UserServices.getUserByName"; var responder:Responder = new Responder(onResult, onFault); super.connect(gateway, encoding); super.call(method, responder, "Luke Skywalker"); } /** * Callback handler for receiving a fault * @param $result Object * */ private function onFault($result: Object):void { result.addError(this, new Error($result.toString())); // call super.run() to execute test methods super.run(); } /** * Callback handler for receiving a result * @param $result Object * */ private function onResult($result: Object):void { _result = $result; super.disposeConnection(); // call super.run() to execute test methods super.run(); } /** * Tests the userVO */ public function testUserVO():void { assertTrue("result is instance of ", _result is UserVO); } /** * Tests the userName */ public function testUserName():void { assertEquals("UserName Luke Skywalker", _userVO.userName, "Luke Skywalker"); } /** * Tests the registerDate */ public function testRegisterDate():void { assertTrue("Register date ", _userVO.registerDate is Date); } // // /** // * Test that is born to lose. // */ // public function testFail():void // { // assertFalse("failing test", true); // } } }