| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Adobe BlazeDS
Revision: 2989
Author: bsahlas@adobe.com
Date: 25 Aug 2008 16:39:18
Changes:this should do it -- more cleanup RPC services - all non-proxy tests have now moved to SDK branch
Files:| ... | ...@@ -0,0 +1,77 @@ | |
| 1 | <?xml version="1.0" ?> | |
| 2 | <!-- | |
| 3 | * | |
| 4 | * ADOBE CONFIDENTIAL | |
| 5 | * ___________________ | |
| 6 | * | |
| 7 | * Copyright 2008 Adobe Systems Incorporated | |
| 8 | * All Rights Reserved. | |
| 9 | * | |
| 10 | * NOTICE: All information contained herein is, and remains | |
| 11 | * the property of Adobe Systems Incorporated and its suppliers, | |
| 12 | * if any. The intellectual and technical concepts contained | |
| 13 | * herein are proprietary to Adobe Systems Incorporated and its | |
| 14 | * suppliers and may be covered by U.S. and Foreign Patents, | |
| 15 | * patents in process, and are protected by trade secret or copyright law. | |
| 16 | * Dissemination of this information or reproduction of this material | |
| 17 | * is strictly forbidden unless prior written permission is obtained | |
| 18 | * from Adobe Systems Incorporated. | |
| 19 | --> | |
| 20 | ||
| 21 | <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:qa="http://www.adobe.com/2006/flexqa" creationComplete="run()"> | |
| 22 | ||
| 23 | <mx:HTTPService id="hs" destination="basic.xml_amf" method="get" useProxy="true" result="onServiceResult(event)" fault="onServiceFault(event)"/> | |
| 24 | <mx:HTTPService id="hsFault" useProxy="true" destination="bogus" fault="onServiceFaultTest(event)" /> | |
| 25 | ||
| 26 | <mx:Script> | |
| 27 | <![CDATA[ | |
| 28 | /**************************************************** | |
| 29 | * simple HttpService test | |
| 30 | * **************************************************/ | |
| 31 | ||
| 32 | import qa.mxunit.*; | |
| 33 | import mx.rpc.events.*; | |
| 34 | ||
| 35 | public var result:Object; | |
| 36 | public var type : String; | |
| 37 | public var faultType : String; | |
| 38 | ||
| 39 | public function onServiceResult(event:ResultEvent):void { | |
| 40 | type = event.type; | |
| 41 | result = event.result; | |
| 42 | } | |
| 43 | ||
| 44 | public function onServiceFault(event:FaultEvent):void { | |
| 45 | trace("http service fault: " + event.fault.faultString); | |
| 46 | } | |
| 47 | ||
| 48 | public function onServiceFaultTest(event:FaultEvent):void { | |
| 49 | faultType = event.type; | |
| 50 | } | |
| 51 | ||
| 52 | public function run():void { | |
| 53 | hs.send(); | |
| 54 | hsFault.send() | |
| 55 | ||
| 56 | MXUnitManager.delay = 6000; | |
| 57 | MXUnitManager.addTests(this,["Test_attributes","Test_result","Test_fault"],10000); | |
| 58 | } | |
| 59 | ||
| 60 | public function Test_attributes():void { | |
| 61 | ||
| 62 | Assert.isTrue(hs.useProxy == true, "useProxy should be true"); | |
| 63 | Assert.isTrue(hs.method == "get", "method should be get"); | |
| 64 | Assert.isTrue(hs.lastResult == result, "hs.lastResult should be event.result"); | |
| 65 | } | |
| 66 | ||
| 67 | public function Test_result():void { | |
| 68 | Assert.isTrue(type == "result", "should result in a Result"); | |
| 69 | } | |
| 70 | ||
| 71 | public function Test_fault():void { | |
| 72 | Assert.isTrue(faultType == "fault", "should result in a Fault"); | |
| 73 | } | |
| 74 | ||
| 75 | ]]> | |
| 76 | </mx:Script> | |
| 77 | </mx:Application> | |
| 0 | 78 | \ No newline at end of file |
| ... | ...@@ -0,0 +1,84 @@ | |
| 1 | <?xml version="1.0" ?> | |
| 2 | <!-- | |
| 3 | * | |
| 4 | * ADOBE CONFIDENTIAL | |
| 5 | * ___________________ | |
| 6 | * | |
| 7 | * Copyright 2008 Adobe Systems Incorporated | |
| 8 | * All Rights Reserved. | |
| 9 | * | |
| 10 | * NOTICE: All information contained herein is, and remains | |
| 11 | * the property of Adobe Systems Incorporated and its suppliers, | |
| 12 | * if any. The intellectual and technical concepts contained | |
| 13 | * herein are proprietary to Adobe Systems Incorporated and its | |
| 14 | * suppliers and may be covered by U.S. and Foreign Patents, | |
| 15 | * patents in process, and are protected by trade secret or copyright law. | |
| 16 | * Dissemination of this information or reproduction of this material | |
| 17 | * is strictly forbidden unless prior written permission is obtained | |
| 18 | * from Adobe Systems Incorporated. | |
| 19 | --> | |
| 20 | ||
| 21 | <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:qa="http://www.adobe.com/2006/flexqa" creationComplete="run()"> | |
| 22 | ||
| 23 | <!-- method = get --> | |
| 24 | <mx:HTTPService id="hsGet" useProxy="true" destination="echoParamsExtraOnUrl_amf" resultFormat = "flashvars" method = "get" result="onServiceResultGet(event)" > | |
| 25 | <mx:request> | |
| 26 | <mx:value>value</mx:value> | |
| 27 | </mx:request> | |
| 28 | </mx:HTTPService> | |
| 29 | ||
| 30 | <!-- method = post --> | |
| 31 | <mx:HTTPService id="hsPost" useProxy="true" destination="echoParamsExtraOnUrl_amf" resultFormat = "flashvars" method = "post" result="onServiceResultPost(event)" > | |
| 32 | <mx:request> | |
| 33 | <mx:value>value</mx:value> | |
| 34 | </mx:request> | |
| 35 | </mx:HTTPService> | |
| 36 | ||
| 37 | <mx:Script> | |
| 38 | <![CDATA[ | |
| 39 | /**************************************************** | |
| 40 | * HttpService GET/POST method test | |
| 41 | * **************************************************/ | |
| 42 | ||
| 43 | import qa.mxunit.*; | |
| 44 | import mx.rpc.events.*; | |
| 45 | ||
| 46 | public var fault:Object; | |
| 47 | public var resultGet:Object; | |
| 48 | public var resultPost:Object; | |
| 49 | public var events:Array; | |
| 50 | ||
| 51 | public function onServiceResultGet(event:ResultEvent):void { | |
| 52 | resultGet = event.result; | |
| 53 | } | |
| 54 | ||
| 55 | public function onServiceResultPost(event:ResultEvent):void { | |
| 56 | resultPost = event.result; | |
| 57 | } | |
| 58 | ||
| 59 | public function onServiceFault(event:FaultEvent):void { | |
| 60 | trace("event.fault.faultString: " + event.fault.faultString); | |
| 61 | events.push("service fault"); | |
| 62 | } | |
| 63 | ||
| 64 | public function run():void { | |
| 65 | events = new Array(); | |
| 66 | hsGet.send(); | |
| 67 | hsPost.send(); | |
| 68 | ||
| 69 | MXUnitManager.delay = 6000; | |
| 70 | MXUnitManager.addTests(this,["Test_get","Test_post"],10000); | |
| 71 | } | |
| 72 | ||
| 73 | public function Test_get():void { | |
| 74 | Assert.isTrue(resultGet.value == "value", "result.value should be 'value'"); | |
| 75 | Assert.isTrue(resultGet.extra == "extra", "result.extra should be 'extra'"); | |
| 76 | } | |
| 77 | ||
| 78 | public function Test_post():void { | |
| 79 | Assert.isTrue(resultPost.value == "value", "result.value should be 'value'"); | |
| 80 | Assert.isTrue(resultPost.extra == "extra", "result.extra should be 'extra'"); | |
| 81 | } | |
| 82 | ]]> | |
| 83 | </mx:Script> | |
| 84 | </mx:Application> | |
| 0 | 85 | \ No newline at end of file |
| ... | ...@@ -0,0 +1,217 @@ | |
| 1 | <?xml version="1.0" ?> | |
| 2 | <!-- | |
| 3 | * | |
| 4 | * ADOBE CONFIDENTIAL | |
| 5 | * ___________________ | |
| 6 | * | |
| 7 | * Copyright 2008 Adobe Systems Incorporated | |
| 8 | * All Rights Reserved. | |
| 9 | * | |
| 10 | * NOTICE: All information contained herein is, and remains | |
| 11 | * the property of Adobe Systems Incorporated and its suppliers, | |
| 12 | * if any. The intellectual and technical concepts contained | |
| 13 | * herein are proprietary to Adobe Systems Incorporated and its | |
| 14 | * suppliers and may be covered by U.S. and Foreign Patents, | |
| 15 | * patents in process, and are protected by trade secret or copyright law. | |
| 16 | * Dissemination of this information or reproduction of this material | |
| 17 | * is strictly forbidden unless prior written permission is obtained | |
| 18 | * from Adobe Systems Incorporated. | |
| 19 | --> | |
| 20 | ||
| 21 | <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:qa="http://www.adobe.com/2006/flexqa" creationComplete="run()"> | |
| 22 | ||
| 23 | <!-- resultFormat = e4x --> | |
| 24 | <mx:HTTPService | |
| 25 | id="hsE4X" | |
| 26 | useProxy="true" | |
| 27 | destination="basic.xml_amf" | |
| 28 | resultFormat = "e4x" | |
| 29 | result="onServiceResult_e4x(event)" | |
| 30 | fault="onServiceFault(event)" > | |
| 31 | </mx:HTTPService> | |
| 32 | ||
| 33 | <!--resultFormat = flashvars --> | |
| 34 | <mx:HTTPService | |
| 35 | id="hsFlashVars" | |
| 36 | useProxy="true" | |
| 37 | destination="echoParamsAsFlashvars_amf" | |
| 38 | resultFormat = "flashvars" | |
| 39 | method = "POST" | |
| 40 | result="onServiceResult_flashvars(event)" | |
| 41 | fault="onServiceFault(event)" > | |
| 42 | ||
| 43 | <mx:request> | |
| 44 | <mx:foo>foo</mx:foo> | |
| 45 | <mx:bar>bar</mx:bar> | |
| 46 | </mx:request> | |
| 47 | </mx:HTTPService> | |
| 48 | ||
| 49 | <!--resultFormat = object --> | |
| 50 | <mx:HTTPService | |
| 51 | id="hsObject" | |
| 52 | useProxy="true" | |
| 53 | destination="basic.xml_amf" | |
| 54 | resultFormat = "object" | |
| 55 | result="onServiceResult_object(event)" | |
| 56 | fault="onServiceFault(event)" | |
| 57 | makeObjectsBindable="false" /> | |
| 58 | ||
| 59 | <!--resultFormat = array --> | |
| 60 | <mx:HTTPService | |
| 61 | id="hsArray" | |
| 62 | useProxy="true" | |
| 63 | destination="basic.xml_amf" | |
| 64 | resultFormat = "array" | |
| 65 | result="onServiceResult_array(event)" | |
| 66 | fault="onServiceFault(event)" | |
| 67 | makeObjectsBindable="false" /> | |
| 68 | ||
| 69 | <!-- resultFormat = text --> | |
| 70 | <mx:HTTPService | |
| 71 | id="hsText" | |
| 72 | useProxy="true" | |
| 73 | destination="echoParamsAsFlashvars_amf" | |
| 74 | resultFormat = "text" | |
| 75 | method = "POST" | |
| 76 | result="onServiceResult_text(event)" | |
| 77 | fault="onServiceFault(event)" > | |
| 78 | ||
| 79 | <mx:request> | |
| 80 | <mx:foo>foo</mx:foo> | |
| 81 | <mx:bar>bar</mx:bar> | |
| 82 | </mx:request> | |
| 83 | </mx:HTTPService> | |
| 84 | ||
| 85 | <!-- resultFormat = xml --> | |
| 86 | <mx:HTTPService | |
| 87 | id="hsXML" | |
| 88 | useProxy="true" | |
| 89 | destination="basic.xml_amf" | |
| 90 | resultFormat = "xml" | |
| 91 | result="onServiceResult_xml(event)" | |
| 92 | fault="onServiceFault(event)" /> | |
| 93 | ||
| 94 | <mx:Script> | |
| 95 | <![CDATA[ | |
| 96 | /**************************************************** | |
| 97 | * HttpService resultFormat test | |
| 98 | * **************************************************/ | |
| 99 | ||
| 100 | import qa.mxunit.*; | |
| 101 | import mx.rpc.events.*; | |
| 102 | import mx.utils.*; | |
| 103 | ||
| 104 | public var resultE4X:Object; | |
| 105 | public var resultFlashVars:Object; | |
| 106 | public var resultObject:Object; | |
| 107 | public var resultArray:Array; | |
| 108 | public var resultArrayObject:Object; | |
| 109 | public var resultText:Object; | |
| 110 | public var resultXML:Object; | |
| 111 | ||
| 112 | ||
| 113 | public var expected : XML = new XML("<basic><string>string</string><integer>123</integer><float>123.123</float>"+"<boolean>true</boolean><array>1</array><array>2</array><array>3</array><object><property>value</property></object></basic>"); | |
| 114 | ||
| 115 | public var expectedXML : XMLDocument = new XMLDocument(); | |
| 116 | ||
| 117 | ||
| 118 | public function onServiceFault(event:FaultEvent):void { | |
| 119 | trace("service fault: " + event.fault.faultString); | |
| 120 | } | |
| 121 | ||
| 122 | public function onServiceResult_e4x(event:ResultEvent):void { | |
| 123 | resultE4X = event.result; | |
| 124 | } | |
| 125 | ||
| 126 | public function onServiceResult_flashvars(event:ResultEvent):void { | |
| 127 | resultFlashVars = event.result; | |
| 128 | } | |
| 129 | ||
| 130 | public function onServiceResult_object(event:ResultEvent):void { | |
| 131 | resultObject = event.result; | |
| 132 | } | |
| 133 | ||
| 134 | public function onServiceResult_array(event:ResultEvent):void { | |
| 135 | resultArray = event.result as Array; | |
| 136 | resultArrayObject = event.result; | |
| 137 | } | |
| 138 | ||
| 139 | public function onServiceResult_text(event:ResultEvent):void { | |
| 140 | resultText = StringUtil.trim(String(event.result)); | |
| 141 | } | |
| 142 | ||
| 143 | public function onServiceResult_xml(event:ResultEvent):void { | |
| 144 | resultXML = event.result; | |
| 145 | } | |
| 146 | ||
| 147 | public function run():void { | |
| 148 | expectedXML.ignoreWhite = true; | |
| 149 | expectedXML.parseXML("<basic><string>string</string><integer>123</integer><float>123.123</float>"+"<boolean>true</boolean><array>1</array><array>2</array><array>3</array><object><property>value</property></object></basic>"); | |
| 150 | ||
| 151 | hsE4X.send(); | |
| 152 | hsFlashVars.send(); | |
| 153 | hsObject.send(); | |
| 154 | hsArray.send(); | |
| 155 | hsText.send(); | |
| 156 | hsXML.send(); | |
| 157 | ||
| 158 | MXUnitManager.delay = 6000; | |
| 159 | MXUnitManager.addTests(this,["Test_e4x","Test_flashvars","Test_object","Test_array","Test_text","Test_xml"],10000); | |
| 160 | } | |
| 161 | ||
| 162 | public function Test_e4x():void { | |
| 163 | Assert.isTrue(resultE4X.toString() == expected.toString(), ""); | |
| 164 | } | |
| 165 | ||
| 166 | public function Test_flashvars():void { | |
| 167 | Assert.isTrue(resultFlashVars.bar == "bar", " result.bar should be 'bar'"); | |
| 168 | Assert.isTrue(resultFlashVars.foo == "foo", "result.foo should be 'foo'"); | |
| 169 | } | |
| 170 | ||
| 171 | public function Test_object():void { | |
| 172 | Assert.isTrue(resultObject.basic != null, "first property should be not be null"); | |
| 173 | Assert.isTrue(resultObject.basic.string == "string", "result.basic.string should be string"); | |
| 174 | Assert.isTrue(resultObject.basic.string is String, "result.basic.string is String = true"); | |
| 175 | Assert.isTrue(resultObject.basic.integer == 123, "result.basic.integer should be 123"); | |
| 176 | Assert.isTrue(resultObject.basic.integer is int, "result.basic.integer is int = true"); | |
| 177 | Assert.isTrue(resultObject.basic.float == 123.123, "result.basic.float should be 123.123"); | |
| 178 | Assert.isTrue(resultObject.basic.float is Number, "result.basic.float is Number = true"); | |
| 179 | Assert.isTrue(resultObject.basic.boolean == true, "result.basic.boolean should be true"); | |
| 180 | Assert.isTrue(resultObject.basic.boolean is Boolean, "result.basic.boolean is Boolean = true"); | |
| 181 | Assert.isTrue(resultObject.basic.array.length == 3, "result.basic.array.lenght should be 3"); | |
| 182 | Assert.isTrue(resultObject.basic.array is Array, "result.basic.array is Array = true"); | |
| 183 | Assert.isTrue(resultObject.basic.array[0] == 1, "result.basic.array[0] should be 1"); | |
| 184 | Assert.isTrue(resultObject.basic.array[1] == 2, "result.basic.array[1] should be 2"); | |
| 185 | Assert.isTrue(resultObject.basic.array[2] == 3, "result.basic.array[2] should be 3"); | |
| 186 | } | |
| 187 | ||
| 188 | public function Test_array():void { | |
| 189 | Assert.isTrue(resultArrayObject is Array,"result should be an array"); | |
| 190 | Assert.isTrue(resultArray[0].basic != null, "first property should be not be null"); | |
| 191 | Assert.isTrue(resultArray[0].basic.string == "string", "result.basic.string should be string"); | |
| 192 | Assert.isTrue(resultArray[0].basic.string is String, "result.basic.string is String = true"); | |
| 193 | Assert.isTrue(resultArray[0].basic.integer == 123, "result.basic.integer should be 123"); | |
| 194 | Assert.isTrue(resultArray[0].basic.integer is int, "result.basic.integer is int = true"); | |
| 195 | Assert.isTrue(resultArray[0].basic.float == 123.123, "result.basic.float should be 123.123"); | |
| 196 | Assert.isTrue(resultArray[0].basic.float is Number, "result.basic.float is Number = true"); | |
| 197 | Assert.isTrue(resultArray[0].basic.boolean == true, "result.basic.boolean should be true"); | |
| 198 | Assert.isTrue(resultArray[0].basic.boolean is Boolean, "result.basic.boolean is Boolean = true"); | |
| 199 | Assert.isTrue(resultArray[0].basic.array.length == 3, "result.basic.array.lenght should be 3"); | |
| 200 | Assert.isTrue(resultArray[0].basic.array is Array, "result.basic.array is Array = true"); | |
| 201 | Assert.isTrue(resultArray[0].basic.array[0] == 1, "result.basic.array[0] should be 1"); | |
| 202 | Assert.isTrue(resultArray[0].basic.array[1] == 2, "result.basic.array[1] should be 2"); | |
| 203 | Assert.isTrue(resultArray[0].basic.array[2] == 3, "result.basic.array[2] should be 3"); | |
| 204 | } | |
| 205 | ||
| 206 | ||
| 207 | public function Test_text():void { | |
| 208 | Assert.isTrue(resultText == "bar=bar&foo=foo", "result should be 'foo=foo&bar=bar'"); | |
| 209 | } | |
| 210 | ||
| 211 | public function Test_xml():void { | |
| 212 | Assert.isTrue(resultXML == expectedXML.toString(), ""); | |
| 213 | } | |
| 214 | ||
| 215 | ]]> | |
| 216 | </mx:Script> | |
| 217 | </mx:Application> | |
| 0 | 218 | \ No newline at end of file |
| ... | ...@@ -0,0 +1,96 @@ | |
| 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <!-- | |
| 3 | * | |
| 4 | * ADOBE CONFIDENTIAL | |
| 5 | * ___________________ | |
| 6 | * | |
| 7 | * Copyright 2008 Adobe Systems Incorporated | |
| 8 | * All Rights Reserved. | |
| 9 | * | |
| 10 | * NOTICE: All information contained herein is, and remains | |
| 11 | * the property of Adobe Systems Incorporated and its suppliers, | |
| 12 | * if any. The intellectual and technical concepts contained | |
| 13 | * herein are proprietary to Adobe Systems Incorporated and its | |
| 14 | * suppliers and may be covered by U.S. and Foreign Patents, | |
| 15 | * patents in process, and are protected by trade secret or copyright law. | |
| 16 | * Dissemination of this information or reproduction of this material | |
| 17 | * is strictly forbidden unless prior written permission is obtained | |
| 18 | * from Adobe Systems Incorporated. | |
| 19 | --> | |
| 20 | ||
| 21 | <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="run()"> | |
| 22 | ||
| 23 | <mx:TextArea id="output" x="95" y="368" width="432" height="293"/> | |
| 24 | ||
| 25 | <mx:HTTPService id="myService" url="http://localhost:81/" | |
| 26 | resultFormat = "object" | |
| 27 | result="onServiceResult(event)" | |
| 28 | fault="onServiceFault(event)" | |
| 29 | makeObjectsBindable="false" | |
| 30 | contentType="application/x-www-form-urlencoded" | |
| 31 | method="GET"/> | |
| 32 | ||
| 33 | <mx:Script> | |
| 34 | <![CDATA[ | |
| 35 | /**************************************************** | |
| 36 | * HTTPService test for bug 203212 | |
| 37 | * **************************************************/ | |
| 38 | ||
| 39 | import TestCase203212; | |
| 40 | import mx.utils.ObjectUtil; | |
| 41 | import qa.mxunit.*; | |
| 42 | import mx.rpc.events.*; | |
| 43 | ||
| 44 | public var dynProps:Object = {name:"Adobe"}; | |
| 45 | public var testCase203212:TestCase203212 = new TestCase203212(dynProps, "dynamic property"); | |
| 46 | public var request:Object; | |
| 47 | public var result:Object; | |
| 48 | public var dynamicProp:String = ""; | |
| 49 | ||
| 50 | public function run():void | |
| 51 | { | |
| 52 | dump(testCase203212); | |
| 53 | myService.addEventListener(InvokeEvent.INVOKE, handleInvokeEvent); | |
| 54 | myService.send(testCase203212); | |
| 55 | MXUnitManager.delay = 5000; | |
| 56 | MXUnitManager.addTests(this,["Test_concreteVars", "Test_dynamicVars"],1000); | |
| 57 | } | |
| 58 | private function dump(obj:Object):void | |
| 59 | { | |
| 60 | this.output.text += "-----------------------------------------\n"; | |
| 61 | this.output.text += "dump --> " + ObjectUtil.toString(obj) + "\n"; | |
| 62 | this.output.text += "-----------------------------------------\n"; | |
| 63 | } | |
| 64 | private function handleInvokeEvent(event:InvokeEvent):void | |
| 65 | { | |
| 66 | // here we can have a look at the actual soap message being created before its sent | |
| 67 | // check for the values | |
| 68 | request = event.message.body["lastName"]; | |
| 69 | dynamicProp = event.message.body["anotherProp"]; | |
| 70 | dump("Actual Request " + request); | |
| 71 | } | |
| 72 | private function onServiceFault(event:FaultEvent):void | |
| 73 | { | |
| 74 | result = event.fault.faultString; | |
| 75 | } | |
| 76 | ||
| 77 | private function onServiceResult(event:ResultEvent):void | |
| 78 | { | |
| 79 | result = event.result; | |
| 80 | } | |
| 81 | ||
| 82 | public function Test_concreteVars():void | |
| 83 | { | |
| 84 | dump("service result: " + result); | |
| 85 | Assert.isTrue(request == "Anonymous", "not true"); | |
| 86 | } | |
| 87 | ||
| 88 | public function Test_dynamicVars():void | |
| 89 | { | |
| 90 | Assert.isTrue(dynamicProp == "dynamic property", "not true"); | |
| 91 | } | |
| 92 | ]]> | |
| 93 | </mx:Script> | |
| 94 | ||
| 95 | ||
| 96 | </mx:Application> |
| ... | ...@@ -0,0 +1,153 @@ | |
| 1 | <?xml version="1.0" ?> | |
| 2 | <!-- | |
| 3 | * | |
| 4 | * ADOBE CONFIDENTIAL | |
| 5 | * ___________________ | |
| 6 | * | |
| 7 | * Copyright 2008 Adobe Systems Incorporated | |
| 8 | * All Rights Reserved. | |
| 9 | * | |
| 10 | * NOTICE: All information contained herein is, and remains | |
| 11 | * the property of Adobe Systems Incorporated and its suppliers, | |
| 12 | * if any. The intellectual and technical concepts contained | |
| 13 | * herein are proprietary to Adobe Systems Incorporated and its | |
| 14 | * suppliers and may be covered by U.S. and Foreign Patents, | |
| 15 | * patents in process, and are protected by trade secret or copyright law. | |
| 16 | * Dissemination of this information or reproduction of this material | |
| 17 | * is strictly forbidden unless prior written permission is obtained | |
| 18 | * from Adobe Systems Incorporated. | |
| 19 | --> | |
| 20 | ||
| 21 | <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:qa="http://www.adobe.com/2006/flexqa" creationComplete="run()"> | |
| 22 | ||
| 23 | <mx:HTTPService | |
| 24 | id="hsNoParamsGet" | |
| 25 | destination="echoParams_amf" | |
| 26 | method="get" | |
| 27 | useProxy="true" | |
| 28 | result="onServiceResultNoParamsGet(event)" | |
| 29 | fault="onServiceFaultNoParamsGet(event)" | |
| 30 | > | |
| 31 | <mx:request> | |
| 32 | <mx:value>value</mx:value> | |
| 33 | </mx:request> | |
| 34 | </mx:HTTPService> | |
| 35 | ||
| 36 | <mx:HTTPService | |
| 37 | id="hsNoParamsPost" | |
| 38 | destination="echoParams_amf" | |
| 39 | method="post" | |
| 40 | useProxy="true" | |
| 41 | result="onServiceResultNoParamsPost(event)" | |
| 42 | fault="onServiceFaultNoParamsPost(event)" | |
| 43 | > | |
| 44 | <mx:request> | |
| 45 | <mx:value>value</mx:value> | |
| 46 | </mx:request> | |
| 47 | </mx:HTTPService> | |
| 48 | ||
| 49 | <mx:HTTPService | |
| 50 | id="hsWithParamsGet" | |
| 51 | destination="echoParams_amf" | |
| 52 | method="get" | |
| 53 | useProxy="true" | |
| 54 | result="onServiceResultWithParamsGet(event)" | |
| 55 | fault="onServiceFaultWithParams(event)" | |
| 56 | > | |
| 57 | <mx:request> | |
| 58 | <mx:value>value</mx:value> | |
| 59 | </mx:request> | |
| 60 | </mx:HTTPService> | |
| 61 | ||
| 62 | <mx:HTTPService | |
| 63 | id="hsWithParamsPost" | |
| 64 | destination="echoParams_amf" | |
| 65 | method="post" | |
| 66 | useProxy="true" | |
| 67 | result="onServiceResultWithParamsPost(event)" | |
| 68 | fault="onServiceFaultWithParams(event)" | |
| 69 | > | |
| 70 | <mx:request> | |
| 71 | <mx:value>value</mx:value> | |
| 72 | </mx:request> | |
| 73 | </mx:HTTPService> | |
| 74 | ||
| 75 | <mx:Script> | |
| 76 | <![CDATA[ | |
| 77 | /**************************************************** | |
| 78 | * HttpService request test | |
| 79 | * **************************************************/ | |
| 80 | ||
| 81 | import qa.mxunit.*; | |
| 82 | import mx.rpc.events.*; | |
| 83 | ||
| 84 | public var bPassNoParamsGet : Boolean = true; | |
| 85 | public var bPassNoParamsPost : Boolean = true; | |
| 86 | public var resultWithParamsGet : Object; | |
| 87 | public var resultWithParamsPost : Object; | |
| 88 | ||
| 89 | public function onServiceFaultNoParamsGet(event:FaultEvent):void { | |
| 90 | bPassNoParamsGet = false; | |
| 91 | } | |
| 92 | ||
| 93 | public function onServiceFaultNoParamsPost(event:FaultEvent):void { | |
| 94 | bPassNoParamsPost = false; | |
| 95 | } | |
| 96 | ||
| 97 | public function onServiceFaultWithParams(event:FaultEvent):void { | |
| 98 | trace("service fault: " + event.fault.faultString); | |
| 99 | } | |
| 100 | ||
| 101 | public function onServiceResultNoParamsGet(event:ResultEvent):void { | |
| 102 | for (var i : String in event.result) | |
| 103 | { | |
| 104 | if (i != "parameters") | |
| 105 | bPassNoParamsGet = false; | |
| 106 | } | |
| 107 | } | |
| 108 | ||
| 109 | public function onServiceResultNoParamsPost(event:ResultEvent):void { | |
| 110 | for (var i : String in event.result) | |
| 111 | { | |
| 112 | if (i != "parameters") | |
| 113 | bPassNoParamsPost = false; | |
| 114 | } | |
| 115 | } | |
| 116 | ||
| 117 | public function onServiceResultWithParamsGet(event:ResultEvent):void { | |
| 118 | resultWithParamsGet = event.result; | |
| 119 | } | |
| 120 | ||
| 121 | public function onServiceResultWithParamsPost(event:ResultEvent):void { | |
| 122 | resultWithParamsPost = event.result; | |
| 123 | } | |
| 124 | ||
| 125 | public function run():void { | |
| 126 | hsNoParamsGet.send(); | |
| 127 | hsNoParamsPost.send(); | |
| 128 | hsWithParamsGet.send({value: 'value'}); | |
| 129 | hsWithParamsPost.send({value: 'value'}); | |
| 130 | ||
| 131 | MXUnitManager.delay = 6000; | |
| 132 | MXUnitManager.addTests(this,["Test_NoParamsGet","Test_NoParamsPost","Test_WithParamsGet","Test_WithParamsPost"],10000); | |
| 133 | } | |
| 134 | ||
| 135 | public function Test_NoParamsGet():void { | |
| 136 | Assert.isTrue(bPassNoParamsGet, ""); | |
| 137 | } | |
| 138 | ||
| 139 | public function Test_NoParamsPost():void { | |
| 140 | Assert.isTrue(bPassNoParamsPost, ""); | |
| 141 | } | |
| 142 | ||
| 143 | public function Test_WithParamsGet():void { | |
| 144 | Assert.isTrue(resultWithParamsGet.parameters.value == "value", "result.parameters.value should be value"); | |
| 145 | } | |
| 146 | ||
| 147 | public function Test_WithParamsPost():void { | |
| 148 | Assert.isTrue(resultWithParamsPost.parameters.value == "value", "result.parameters.value should be value"); | |
| 149 | } | |
| 150 | ||
| 151 | ]]> | |
| 152 | </mx:Script> | |
| 153 | </mx:Application> | |
| 0 | 154 | \ No newline at end of file |
| ... | ...@@ -0,0 +1,102 @@ | |
| 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp()"> | |
| 3 | <mx:TextArea id="output" height="200" percentWidth="80" x="38" y="353"/> | |
| 4 | <mx:TraceTarget level="8"/> | |
| 5 | ||
| 6 | <mx:Script> | |
| 7 | <![CDATA[ | |
| 8 | import mx.rpc.AbstractService; | |
| 9 | import mx.rpc.AsyncToken; | |
| 10 | import mx.rpc.AbstractOperation; | |
| 11 | import mx.controls.Alert; | |
| 12 | import mx.utils.ObjectUtil; | |
| 13 | ||
| 14 | import flash.events.*; | |
| 15 | import mx.rpc.events.*; | |
| 16 | import mx.rpc.soap.*; | |
| 17 | import qa.mxunit.*; | |
| 18 | import mx.rpc.events.*; | |
| 19 | ||
| 20 | // class borrowed from finder.mxml sdk app | |
| 21 | ||
| 22 | private static var WebServicePointer:AbstractService; | |
| 23 | private var ws:AbstractService ; | |
| 24 | private var result:Object; | |
| 25 | private var type:String; | |
| 26 | private var faultType:String; | |
| 27 | private var obj:Object = new Object(); | |
| 28 | private var actualSOAPRequest:XML; | |
| 29 | private var expectedSOAPResponse:String = "java.lang.NumberFormatException: For input string: \"A1\""; | |
| 30 | private var actualSOAPResponse:Object; | |
| 31 | ||
| 32 | private static function getWebService():AbstractService | |
| 33 | { | |
| 34 | if (WebServicePointer == null) { | |
| 35 | var ws:WebService = new WebService(); | |
| 36 | ws.wsdl="http://localhost:8400/qa-regress/axis/services/echo?wsdl"; | |
| 37 | //ws.wsdl="echo.wsdl"; // use real web service, not mock-call by pointing the soap:address to the expected response | |
| 38 | // NOTICE: This setting is necessary for proper error message handling | |
| 39 | // due to player bug #99307 | |
| 40 | ws.useProxy = true; | |
| 41 | trace(" call getWebService() "); | |
| 42 | ws.loadWSDL(); | |
| 43 | WebServicePointer = ws; | |
| 44 | } | |
| 45 | return WebServicePointer; | |
| 46 | } | |
| 47 | ||
| 48 | private function initApp():void{ | |
| 49 | ws = getWebService(); | |
| 50 | ws.addEventListener("fault", onServiceFault); | |
| 51 | ws.addEventListener("load", onServiceLoad); | |
| 52 | } | |
| 53 | private function onServiceLoad(event:Event):void { | |
| 54 | output.text += "-> Service load.\n"; | |
| 55 | var o:Object = {inputInteger:'A1'}; | |
| 56 | ops(o); | |
| 57 | MXUnitManager.delay = 6000; | |
| 58 | MXUnitManager.addTests(this,["Test_ValueOf_actualSOAPResponse"],10000); | |
| 59 | } | |
| 60 | private function onServiceFault(event:FaultEvent):void { | |
| 61 | trace("web service fault: " + event.fault.faultString); | |
| 62 | output.text += "-> Service fault: " + event.fault.faultCode + " - " + event.fault.faultString + ".\n"; | |
| 63 | } | |
| 64 | private function onFault(event:FaultEvent):void { | |
| 65 | trace("operation fault: " + event.fault.faultString); | |
| 66 | output.text += "FaultEvent: faultCode " + event.fault.faultCode + " faultString " + event.fault.faultString + ".\n\n\n\n"; | |
| 67 | actualSOAPResponse = event.fault.faultString; | |
| 68 | output.text += "actualSOAPResponse " + actualSOAPResponse + "\n\n"; | |
| 69 | } | |
| 70 | private function onResult(event:ResultEvent):void { | |
| 71 | ||
| 72 | trace("result: " + event.result); | |
| 73 | output.text += "event.result.varString " + event.result + "\n"; | |
| 74 | ||
| 75 | output.text += "-> Result: " + ObjectUtil.toString(event.result) + ".\n"; | |
| 76 | if(event.result != null){ | |
| 77 | output.text += "-> Passed \n"; | |
| 78 | }else{ | |
| 79 | output.text += "-> shound't be null " + event.result + ".\n"; | |
| 80 | } | |
| 81 | actualSOAPResponse = event.result; | |
| 82 | } | |
| 83 | private function ops(input:Object):void{ | |
| 84 | var lOperation:AbstractOperation= ws.getOperation("echoInteger"); | |
| 85 | lOperation.arguments.inputInteger = input.inputInteger; | |
| 86 | lOperation.addEventListener(ResultEvent.RESULT,onResult); | |
| 87 | lOperation.addEventListener(FaultEvent.FAULT, onFault); | |
| 88 | var op:Operation = lOperation as Operation; | |
| 89 | op.resultFormat = "object"; | |
| 90 | var lCall:AsyncToken = ws.echoInteger(); | |
| 91 | } | |
| 92 | // public test function | |
| 93 | public function Test_ValueOf_actualSOAPResponse():void { | |
| 94 | if(actualSOAPResponse != null){ | |
| 95 | Assert.isTrue(actualSOAPResponse == expectedSOAPResponse.toString() , expectedSOAPResponse.toString()); | |
| 96 | }else{ | |
| 97 | Assert.fail("not null"); | |
| 98 | } | |
| 99 | } | |
| 100 | ]]> | |
| 101 | </mx:Script> | |
| 102 | </mx:Application> |
| ... | ...@@ -0,0 +1,97 @@ | |
| 1 | <?xml version="1.0" ?> | |
| 2 | <!-- | |
| 3 | * | |
| 4 | * ADOBE CONFIDENTIAL | |
| 5 | * ___________________ | |
| 6 | * | |
| 7 | * Copyright 2008 Adobe Systems Incorporated | |
| 8 | * All Rights Reserved. | |
| 9 | * | |
| 10 | * NOTICE: All information contained herein is, and remains | |
| 11 | * the property of Adobe Systems Incorporated and its suppliers, | |
| 12 | * if any. The intellectual and technical concepts contained | |
| 13 | * herein are proprietary to Adobe Systems Incorporated and its | |
| 14 | * suppliers and may be covered by U.S. and Foreign Patents, | |
| 15 |