Author: keith
Date: Mon Dec 10 23:52:35 2007
New Revision: 10892

Log:

Adding test case for WSRequest hostObject HTTPBinding properties



Modified:
   
trunk/mashup/java/modules/integration/test-resources/scripts/hostObjectTest.js

Modified: 
trunk/mashup/java/modules/integration/test-resources/scripts/hostObjectTest.js
==============================================================================
--- 
trunk/mashup/java/modules/integration/test-resources/scripts/hostObjectTest.js  
    (original)
+++ 
trunk/mashup/java/modules/integration/test-resources/scripts/hostObjectTest.js  
    Mon Dec 10 23:52:35 2007
@@ -286,4 +286,68 @@
             file.write(wsReq.responseXML);
         }
     }
+}
+
+//tests HTTPProperties
+wsRequestHTTPPropertiesTest.inputTypes = "none";
+wsRequestHTTPPropertiesTest.outputType = "string";
+function wsRequestHTTPPropertiesTest(){
+    var req = new WSRequest();
+    var options = new Array();
+    options["useSOAP"] = "false";
+    options["HTTPMethod"] = "POST";
+    options["HTTPLocation"] = "weather/{city}";
+    options["HTTPInputSerialization"] = "application/xml";
+    req.open(options,"http://127.0.0.1:11001/services/RESTSample",false);
+    var payload = 
"<POSTWeather><city>colombo</city><weatherDetails>35</weatherDetails></POSTWeather>";
+    req.send(payload);
+    var result = (req.responseE4X["return"]).text();
+    if(result != "colombo"){
+       throw ("POST did not return expected result. Expected colombo, received 
" + result);
+    }
+
+    options["HTTPMethod"] = "GET";
+    options["HTTPInputSerialization"] = "application/x-www-form-urlencoded";
+    req = new WSRequest();
+    req.open(options,"http://127.0.0.1:11001/services/RESTSample",false);
+    payload = "<GETWeather><city>colombo</city></GETWeather>";
+    req.send(payload);
+    result = (req.responseE4X["return"]).text();
+    if(result != "35"){
+       throw ("GET did not return expected result. Expected 35, received " + 
result);
+    }
+
+    req = new WSRequest();
+    options["HTTPMethod"] = "PUT";
+    options["HTTPInputSerialization"] = "application/xml";
+    req.open(options,"http://127.0.0.1:11001/services/RESTSample",false);
+    payload = 
"<PUTWeather><city>colombo</city><weatherDetails>30</weatherDetails></PUTWeather>";
+    req.send(payload);
+    result = (req.responseE4X["return"]).text();
+    if(result != "colombo"){
+       throw ("PUT did not return expected result. Expected colombo, received 
" + result);
+    }
+
+    options["HTTPMethod"] = "GET";
+    options["HTTPInputSerialization"] = "application/x-www-form-urlencoded";
+    req = new WSRequest();
+    req.open(options,"http://127.0.0.1:11001/services/RESTSample",false);
+    payload = "<GETWeather><city>colombo</city></GETWeather>";
+    req.send(payload);
+    result = (req.responseE4X["return"]).text();
+    if(result != "30"){
+       throw ("GET did not return expected result. Expected 30, received " + 
result);
+    }
+
+    options["HTTPMethod"] = "DELETE";
+    options["HTTPInputSerialization"] = "application/x-www-form-urlencoded";
+    req = new WSRequest();
+    req.open(options,"http://127.0.0.1:11001/services/RESTSample",false);
+    payload = "<GETWeather><city>colombo</city></GETWeather>";
+    req.send(payload);
+    result = (req.responseE4X["return"]).text();
+    if(result != "colombo"){
+       throw ("DELETE did not return expected result. Expected colombo, 
received " + result);
+    }
+    return "succesfull";
 }
\ No newline at end of file

_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to