summaryrefslogtreecommitdiff
path: root/includes/js/dojox/rpc/tests/Service.js
diff options
context:
space:
mode:
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-13 09:49:11 +0000
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-13 09:49:11 +0000
commite44a7e37b6c7b5961adaffc62b9042b8d442938e (patch)
tree95b67c356e93163467db2451f2b8cce84ed5d582 /includes/js/dojox/rpc/tests/Service.js
parenta62b9742ee5e28bcec6872d88f50f25b820914f6 (diff)
downloadsemanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.gz
semanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.bz2
New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'includes/js/dojox/rpc/tests/Service.js')
-rw-r--r--includes/js/dojox/rpc/tests/Service.js702
1 files changed, 702 insertions, 0 deletions
diff --git a/includes/js/dojox/rpc/tests/Service.js b/includes/js/dojox/rpc/tests/Service.js
new file mode 100644
index 0000000..353519e
--- /dev/null
+++ b/includes/js/dojox/rpc/tests/Service.js
@@ -0,0 +1,702 @@
+if(!dojo._hasResource["dojox.rpc.tests.Service"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.rpc.tests.Service"] = true;
+dojo.provide("dojox.rpc.tests.Service");
+dojo.require("dojo.io.script");
+dojo.require("dojox.rpc.Service");
+dojo.require("dojox.rpc.JsonRPC");
+dojo.require("dojox.rpc.Rest");
+//this is a copy of our smd in js form, so we can just share it easily
+//dojo.require("dojox.rpc.tests.resources.testSmd");
+
+
+dojox.rpc.tests.service = new dojox.rpc.Service(dojo.moduleUrl("dojox.rpc.tests.resources", "test.smd"));
+
+doh.register("dojox.rpc.tests.echo",
+ [
+ {
+ name: "#1 POST,URL,Named Parameters",
+ timeout: 4000,
+ setUp: function(){
+ //this.svc = new dojox.rpc.Service(dojox.rpc.tests.resources.testSmd);
+ this.svc = dojox.rpc.tests.service;
+ },
+ runTest: function(){
+ var d = new doh.Deferred();
+
+ if (window.location.protocol=="file:") {
+ var err= new Error("This Test requires a webserver and will fail intentionally if loaded from file://");
+ d.errback(err);
+ return d;
+ }
+ //test when given named params
+ var td = this.svc.postEcho({message: this.name,foo:2});
+ td.addCallback(this, function(result){
+ if (result==this.name){
+ d.callback(true);
+ }else{
+ d.errback(new Error("Unexpected Return Value: ", result));
+ }
+ });
+
+ return d;
+ }
+ },
+ {
+ name: "#2 POST,URL,Ordered Parameters",
+ timeout: 4000,
+ setUp: function(){
+ //this.svc = new dojox.rpc.Service(dojox.rpc.tests.resources.testSmd);
+ this.svc = dojox.rpc.tests.service;
+
+ },
+ runTest: function(){
+ var d = new doh.Deferred();
+
+ if (window.location.protocol=="file:") {
+ var err= new Error("This Test requires a webserver and will fail intentionally if loaded from file://");
+ d.errback(err);
+ return d;
+ }
+
+ //test when given named params
+ var td = this.svc.postEcho(this.name,2);
+ td.addCallback(this, function(result){
+ if (result==this.name){
+ d.callback(true);
+ }else{
+ d.errback(new Error("Unexpected Return Value: ", result));
+ }
+ });
+
+ return d;
+ }
+ },
+ {
+ name: "#3 GET,URL,Named Parameters",
+ timeout: 4000,
+ setUp: function(){
+ //this.svc = new dojox.rpc.Service(dojox.rpc.tests.resources.testSmd);
+ this.svc = dojox.rpc.tests.service;
+ },
+ runTest: function(){
+ var d = new doh.Deferred();
+
+ if (window.location.protocol=="file:") {
+ var err= new Error("This Test requires a webserver and will fail intentionally if loaded from file://");
+ d.errback(err);
+ return d;
+ }
+
+ //test when given named params
+ var td = this.svc.getEcho({message: this.name});
+ td.addCallback(this, function(result){
+ if (result==this.name){
+ d.callback(true);
+ }else{
+ d.errback(new Error("Unexpected Return Value: ", result));
+ }
+ });
+
+ return d;
+ }
+ },
+
+ {
+ name: "#3.1 REST PUT,Named Parameters",
+ timeout: 4000,
+ setUp: function(){
+ //this.svc = new dojox.rpc.Service(dojox.rpc.tests.resources.testSmd);
+ this.svc = dojox.rpc.tests.service;
+ },
+ runTest: function(){
+ var d = new doh.Deferred();
+
+ if (window.location.protocol=="file:") {
+ var err= new Error("This Test requires a webserver and will fail intentionally if loaded from file://");
+ d.errback(err);
+ return d;
+ }
+
+ res = this.name + Math.random();
+ //test when given named params
+ var td = this.svc.restStore.put({location: "res"},res);
+ td.addCallback(this, function(result){
+ var td = this.svc.restStore({location: "res"});
+ td.addCallback(this, function(result){
+ if (result==res){
+ d.callback(true);
+ }else{
+ d.errback(new Error("Unexpected Return Value: ", result));
+ }
+ });
+
+ });
+
+ return d;
+ }
+ },
+ {
+ name: "#3.2 REST POST,Named Parameters",
+ timeout: 4000,
+ setUp: function(){
+ //this.svc = new dojox.rpc.Service(dojox.rpc.tests.resources.testSmd);
+ this.svc = dojox.rpc.tests.service;
+ },
+ runTest: function(){
+ var d = new doh.Deferred();
+
+ if (window.location.protocol=="file:") {
+ var err= new Error("This Test requires a webserver and will fail intentionally if loaded from file://");
+ d.errback(err);
+ return d;
+ }
+ var newRes = this.name + Math.random();
+ res += newRes;
+ //test when given named params
+ var td = this.svc.restStore.post({location: "res"},newRes);
+ td.addCallback(this, function(result){
+ var td = this.svc.restStore({location: "res"});
+ td.addCallback(this, function(result){
+ if (result==res){
+ d.callback(true);
+ }else{
+ d.errback(new Error("Unexpected Return Value: ", result));
+ }
+ });
+
+ });
+
+ return d;
+ }
+ },
+ {
+ name: "#3.3 REST DELETE,Named Parameters",
+ timeout: 4000,
+ setUp: function(){
+ //this.svc = new dojox.rpc.Service(dojox.rpc.tests.resources.testSmd);
+ this.svc = dojox.rpc.tests.service;
+ },
+ runTest: function(){
+ var d = new doh.Deferred();
+
+ if (window.location.protocol=="file:") {
+ var err= new Error("This Test requires a webserver and will fail intentionally if loaded from file://");
+ d.errback(err);
+ return d;
+ }
+
+ //test when given named params
+ var td = this.svc.restStore['delete']({location: "res"});
+ td.addCallback(this, function(result){
+ var td = this.svc.restStore({location: "res"});
+ td.addCallback(this, function(result){
+ if (result=="deleted"){
+ d.callback(true);
+ }else{
+ d.errback(new Error("Unexpected Return Value: ", result));
+ }
+ });
+
+ });
+
+ return d;
+ }
+ },
+ {
+ name: "#3.4 GET,URL,Named Parameters, Returning Json",
+ timeout: 4000,
+ setUp: function(){
+ //this.svc = new dojox.rpc.Service(dojox.rpc.tests.resources.testSmd);
+ this.svc = dojox.rpc.tests.service;
+ },
+ runTest: function(){
+ var d = new doh.Deferred();
+
+ if (window.location.protocol=="file:") {
+ var err= new Error("This Test requires a webserver and will fail intentionally if loaded from file://");
+ d.errback(err);
+ return d;
+ }
+
+ //test when given named params
+ var td = this.svc.getEchoJson({message:'{"foo":"bar"}'});
+ td.addCallback(this, function(result){
+ if (result.foo=='bar'){
+ d.callback(true);
+ }else{
+ d.errback(new Error("Unexpected Return Value: ", result));
+ }
+ });
+
+ return d;
+ }
+ },
+ {
+ name: "#3.5 GET,PATH,Named Parameters",
+ timeout: 4000,
+ setUp: function(){
+ //this.svc = new dojox.rpc.Service(dojox.rpc.tests.resources.testSmd);
+ this.svc = dojox.rpc.tests.service;
+ },
+ runTest: function(){
+ var d = new doh.Deferred();
+
+ if (window.location.protocol=="file:") {
+ var err= new Error("This Test requires a webserver and will fail intentionally if loaded from file://");
+ d.errback(err);
+ return d;
+ }
+
+ //test when given named params
+ var td = this.svc.getPathEcho({path: "pathname"});
+ td.addCallback(this, function(result){
+ if (result=="/path/pathname"){
+ d.callback(true);
+ }else{
+ d.errback(new Error("Unexpected Return Value: ", result));
+ }
+ });
+
+ return d;
+ }
+ },
+
+ {
+ name: "#4 GET,URL,Ordered Parameters",
+ timeout: 4000,
+ setUp: function(){
+ //this.svc = new dojox.rpc.Service(dojox.rpc.tests.resources.testSmd);
+ this.svc = dojox.rpc.tests.service;
+ },
+ runTest: function(){
+ var d = new doh.Deferred();
+
+ if (window.location.protocol=="file:") {
+ var err= new Error("This Test requires a webserver and will fail intentionally if loaded from file://");
+ d.errback(err);
+ return d;
+ }
+
+ //test when given named params
+ var td = this.svc.getEcho(this.name);
+ td.addCallback(this, function(result){
+ if (result==this.name){
+ d.callback(true);
+ }else{
+ d.errback(new Error("Unexpected Return Value: ", result));
+ }
+ });
+
+ return d;
+ }
+ },
+
+ {
+ name: "#5 POST,URL,Named Parameters",
+ timeout: 4000,
+ setUp: function(){
+ //this.svc = new dojox.rpc.Service(dojox.rpc.tests.resources.testSmd);
+ this.svc = dojox.rpc.tests.service;
+ },
+ runTest: function(){
+ var d = new doh.Deferred();
+
+ if (window.location.protocol=="file:") {
+ var err= new Error("This Test requires a webserver and will fail intentionally if loaded from file://");
+ d.errback(err);
+ return d;
+ }
+
+ //test when given named params
+ var td = this.svc.postJsonEcho({message: this.name});
+ td.addCallback(this, function(res){
+ var result = dojo.fromJson(res);
+ if (result && result.message && result.message==this.name){
+ d.callback(true);
+ }else{
+ d.errback(new Error("Unexpected Return Value: ", result));
+ }
+ });
+
+ return d;
+ }
+ },
+
+ {
+ name: "#6 POST,JSON,Ordered Parameters",
+ timeout: 4000,
+ setUp: function(){
+ //this.svc = new dojox.rpc.Service(dojox.rpc.tests.resources.testSmd);
+ this.svc = dojox.rpc.tests.service;
+ },
+ runTest: function(){
+ var d = new doh.Deferred();
+
+ if (window.location.protocol=="file:") {
+ var err= new Error("This Test requires a webserver and will fail intentionally if loaded from file://");
+ d.errback(err);
+ return d;
+ }
+
+ //test when given named params
+ var td = this.svc.postJsonEcho(this.name);
+ td.addCallback(this, function(res){
+ var result = dojo.fromJson(res);
+ if (result && result.message && result.message==this.name){
+ d.callback(true);
+ }else{
+ d.errback(new Error("Unexpected Return Value: ", result));
+ }
+ });
+
+ return d;
+ }
+ },
+ {
+ name: "#7 JSONP,URL,Named Parameters",
+ timeout: 4000,
+ setUp: function(){
+ //this.svc = new dojox.rpc.Service(dojox.rpc.tests.resources.testSmd);
+ this.svc = dojox.rpc.tests.service;
+ },
+ runTest: function(){
+ var d = new doh.Deferred();
+
+ if (window.location.protocol=="file:") {
+ var err= new Error("This Test requires a webserver and will fail intentionally if loaded from file://");
+ d.errback(err);
+ return d;
+ }
+
+ //test when given named params
+ var td = this.svc.jsonpEcho({message: this.name});
+ td.addCallback(this, function(result){
+ if (result==this.name){
+ d.callback(true);
+ }else{
+ d.errback(new Error("Unexpected Return Value: ", result));
+ }
+ });
+
+ return d;
+ }
+ },
+ {
+ name: "#8 JSONP,URL, Ordered Parameters",
+ timeout: 4000,
+ setUp: function(){
+ //this.svc = new dojox.rpc.Service(dojox.rpc.tests.resources.testSmd);
+ this.svc = dojox.rpc.tests.service;
+ },
+ runTest: function(){
+ var d = new doh.Deferred();
+
+ if (window.location.protocol=="file:") {
+ var err= new Error("This Test requires a webserver and will fail intentionally if loaded from file://");
+ d.errback(err);
+ return d;
+ }
+
+ //test when given named params
+ var td = this.svc.jsonpEcho(this.name);
+ td.addCallback(this, function(result){
+ if (result==this.name){
+ d.callback(true);
+ }else{
+ d.errback(new Error("Unexpected Return Value: ", result));
+ }
+ });
+
+ return d;
+ }
+ },
+ {
+ name: "#9 POST,JSON-RPC-1.0,Ordered Parameters",
+ timeout: 4000,
+ setUp: function(){
+ //this.svc = new dojox.rpc.Service(dojox.rpc.tests.resources.testSmd);
+ this.svc = dojox.rpc.tests.service;
+ },
+ runTest: function(){
+ var d = new doh.Deferred();
+
+ if (window.location.protocol=="file:") {
+ var err= new Error("This Test requires a webserver and will fail intentionally if loaded from file://");
+ d.errback(err);
+ return d;
+ }
+
+ //test when given named params
+ var td = this.svc.postJsonRpc10Echo(this.name);
+ td.addCallback(this, function(result){
+ if (result==this.name){
+ d.callback(true);
+ }else{
+ d.errback(new Error("Unexpected Return Value: ", result));
+ }
+ });
+
+ return d;
+ }
+ },
+ {
+ name: "#10 POST,JSON-RPC-1.0,Named Parameters",
+ timeout: 4000,
+ setUp: function(){
+ //this.svc = new dojox.rpc.Service(dojox.rpc.tests.resources.testSmd);
+ this.svc = dojox.rpc.tests.service;
+ },
+ runTest: function(){
+ var d = new doh.Deferred();
+
+ if (window.location.protocol=="file:") {
+ var err= new Error("This Test requires a webserver and will fail intentionally if loaded from file://");
+ d.errback(err);
+ return d;
+ }
+
+ //test when given named params
+ var td = this.svc.postJsonRpc10EchoNamed(this.name);
+ td.addCallback(this, function(result){
+ if (result==this.name){
+ d.callback(true);
+ }else{
+ d.errback(new Error("Unexpected Return Value: ", result));
+ }
+ });
+
+ return d;
+ }
+ },
+ {
+ name: "#11 POST,JSON-RPC 1.2, Ordered Parameters",
+ timeout: 4000,
+ setUp: function(){
+ //this.svc = new dojox.rpc.Service(dojox.rpc.tests.resources.testSmd);
+ this.svc = dojox.rpc.tests.service;
+ },
+ runTest: function(){
+ var d = new doh.Deferred();
+
+ if (window.location.protocol=="file:") {
+ var err= new Error("This Test requires a webserver and will fail intentionally if loaded from file://");
+ d.errback(err);
+ return d;
+ }
+
+ //test when given named params
+ var td = this.svc.postJsonRpc12Echo(this.name);
+ td.addCallback(this, function(result){
+ if (result==this.name){
+ d.callback(true);
+ }else{
+ d.errback(new Error("Unexpected Return Value: ", result));
+ }
+ });
+
+ return d;
+ }
+ },
+ {
+ name: "#12 POST,JSON-RPC 1.2, Named Parameters",
+ timeout: 4000,
+ setUp: function(){
+ //this.svc = new dojox.rpc.Service(dojox.rpc.tests.resources.testSmd);
+ this.svc = dojox.rpc.tests.service;
+ },
+ runTest: function(){
+ var d = new doh.Deferred();
+
+ if (window.location.protocol=="file:") {
+ var err= new Error("This Test requires a webserver and will fail intentionally if loaded from file://");
+ d.errback(err);
+ return d;
+ }
+
+ //test when given named params
+ var td = this.svc.postJsonRpc12Echo({message: this.name});
+ td.addCallback(this, function(result){
+ if (result==this.name){
+ d.callback(true);
+ }else{
+ d.errback(new Error("Unexpected Return Value: ", result));
+ }
+ });
+
+ return d;
+ }
+ }
+ /*
+ ,{
+ name: "#13 GET,JSON-RPC 1.2, Ordered Parameters",
+ timeout: 4000,
+ setUp: function(){
+ //this.svc = new dojox.rpc.Service(dojox.rpc.tests.resources.testSmd);
+ this.svc = dojox.rpc.tests.service;
+ },
+ runTest: function(){
+ var d = new doh.Deferred();
+
+ if (window.location.protocol=="file:") {
+ var err= new Error("This Test requires a webserver and will fail intentionally if loaded from file://");
+ d.errback(err);
+ return d;
+ }
+
+ //test when given named params
+ var td = this.svc.getJsonRpc12Echo(this.name);
+ td.addCallback(this, function(result){
+ if (result==this.name){
+ d.callback(true);
+ }else{
+ d.errback(new Error("Unexpected Return Value: ", result));
+ }
+ });
+
+ return d;
+ }
+ },
+ {
+ name: "#14 GET,JSON-RPC 1.2, Named Parameters",
+ timeout: 4000,
+ setUp: function(){
+ //this.svc = new dojox.rpc.Service(dojox.rpc.tests.resources.testSmd);
+ this.svc = dojox.rpc.tests.service;
+ },
+ runTest: function(){
+ var d = new doh.Deferred();
+
+ if (window.location.protocol=="file:") {
+ var err= new Error("This Test requires a webserver and will fail intentionally if loaded from file://");
+ d.errback(err);
+ return d;
+ }
+
+ //test when given named params
+ var td = this.svc.getJsonRpc12EchoNamed({message: this.name});
+ td.addCallback(this, function(result){
+ if (result==this.name){
+ d.callback(true);
+ }else{
+ d.errback(new Error("Unexpected Return Value: ", result));
+ }
+ });
+
+ return d;
+ }
+ },
+ ,{
+ name: "#15 JSONP,JSON-RPC 1.2, Ordered Parameters",
+ timeout: 4000,
+ setUp: function(){
+ //this.svc = new dojox.rpc.Service(dojox.rpc.tests.resources.testSmd);
+ this.svc = dojox.rpc.tests.service;
+ },
+ runTest: function(){
+ var d = new doh.Deferred();
+
+ if (window.location.protocol=="file:") {
+ var err= new Error("This Test requires a webserver and will fail intentionally if loaded from file://");
+ d.errback(err);
+ return d;
+ }
+
+ //test when given named params
+ var td = this.svc.jsonpJsonRpc12Echo(this.name);
+ td.addCallback(this, function(result){
+ if (result==this.name){
+ d.callback(true);
+ }else{
+ d.errback(new Error("Unexpected Return Value: ", result));
+ }
+ });
+
+ return d;
+ }
+ }
+ */
+ ]
+);
+
+doh.register("dojox.rpc.tests.jsonRpcForcedError", [
+ {
+ name: "POST,JSON-RPC 1.0, Ordered Parameters",
+ timeout: 4000,
+ setUp: function(){
+ //this.svc = new dojox.rpc.Service(dojox.rpc.tests.resources.testSmd);
+ this.svc = dojox.rpc.tests.service;
+ },
+ runTest: function(){
+ var d = new doh.Deferred();
+
+ if (window.location.protocol=="file:") {
+ var err= new Error("This Test requires a webserver and will fail intentionally if loaded from file://");
+ d.errback(err);
+ return d;
+ }
+
+ //test when given named params
+ var td = this.svc.postJsonRpc10ForcedError(this.name);
+
+ td.addErrback(this, function(error){
+ d.callback(true);
+ });
+
+ return d;
+ }
+ },
+ {
+ name: "POST,JSON-RPC 1.2, Ordered Parameters",
+ timeout: 4000,
+ setUp: function(){
+ //this.svc = new dojox.rpc.Service(dojox.rpc.tests.resources.testSmd);
+ this.svc = dojox.rpc.tests.service;
+ },
+ runTest: function(){
+ var d = new doh.Deferred();
+
+ if (window.location.protocol=="file:") {
+ var err= new Error("This Test requires a webserver and will fail intentionally if loaded from file://");
+ d.errback(err);
+ return d;
+ }
+
+ //test when given named params
+ var td = this.svc.postJsonRpc12ForcedError(this.name);
+
+ td.addErrback(this, function(error){
+ d.callback(true);
+ });
+
+ return d;
+ }
+ },
+ {
+ name: "POST,JSON-RPC 1.2, Named Parameters",
+ timeout: 4000,
+ setUp: function(){
+ //this.svc = new dojox.rpc.Service(dojox.rpc.tests.resources.testSmd);
+ this.svc = dojox.rpc.tests.service;
+ },
+ runTest: function(){
+ var d = new doh.Deferred();
+
+ if (window.location.protocol=="file:") {
+ var err= new Error("This Test requires a webserver and will fail intentionally if loaded from file://");
+ d.errback(err);
+ return d;
+ }
+
+ //test when given named params
+ var td = this.svc.postJsonRpc12ForcedError({message: this.name});
+
+ td.addErrback(this, function(error){
+ d.callback(true);
+ });
+
+ return d;
+ }
+ }
+]);
+
+}