diff options
author | Derrell Lipman <derrell@samba.org> | 2006-12-31 20:12:12 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:35:23 -0500 |
commit | d1e09e2e6f9db62bbab84abb53e23ee73764178a (patch) | |
tree | 18e57f756611c9d3e10fb41bf7c09eeb795028dd /swat.obsolete/apps/qooxdoo-examples/test/RPC_4.html | |
parent | 710dfce70ca9024d2f026518638bb193e914f4a0 (diff) | |
download | samba-d1e09e2e6f9db62bbab84abb53e23ee73764178a.tar.gz samba-d1e09e2e6f9db62bbab84abb53e23ee73764178a.tar.bz2 samba-d1e09e2e6f9db62bbab84abb53e23ee73764178a.zip |
r20446: rename swat directory to swat.obsolete; keeping it around since there is lots of useful info in it.
(This used to be commit 5f9f72a9cfab80561b23284001b67c4ea961757b)
Diffstat (limited to 'swat.obsolete/apps/qooxdoo-examples/test/RPC_4.html')
-rw-r--r-- | swat.obsolete/apps/qooxdoo-examples/test/RPC_4.html | 470 |
1 files changed, 470 insertions, 0 deletions
diff --git a/swat.obsolete/apps/qooxdoo-examples/test/RPC_4.html b/swat.obsolete/apps/qooxdoo-examples/test/RPC_4.html new file mode 100644 index 0000000000..52a6f4674e --- /dev/null +++ b/swat.obsolete/apps/qooxdoo-examples/test/RPC_4.html @@ -0,0 +1,470 @@ +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <title>qooxdoo » Demo</title> + <link type="text/css" rel="stylesheet" href="../../resource/css/layout.css"/> + <!--[if IE]> + <link type="text/css" rel="stylesheet" href="../../resource/css/layout_ie.css"/> + <![endif]--> + <script type="text/javascript" src="../../script/qx.js"></script> + <script type="text/javascript" src=".qxrpc"></script> + <!-- With the above script, the service URL for a J2EE application can be + automatically determined, no matter on what path it's deployed. --> +</head> +<body> + <script type="text/javascript" src="../../script/layout.js"></script> + + <div id="demoDescription"> + <p>Test for RPC functionality.</p> + <p> + This test calls a whole set of functions to test each of the primitive + data types. The comparison results should all end with ": true", and + the last test generates an Application Error (#1000). No other test + generates that error, so receiving it means the complete set of tests + was run. + </p> + <p> + These functions all use the asynchronous interface. This is the + interface that your applications should use. See the warning in + RPC_3.html regarding use of the synchronous interface. + </p> + </div> + + <script type="text/javascript"> +// qx.Settings.setCustomOfClass("qx.io.remote.RemoteExchange", "enableDebug", true); + qx.Settings.setCustomOfClass("qx.io.Json", "enableDebug", true); + + qx.core.Init.getInstance().defineMain(function() { + var layout1 = new qx.ui.layout.VerticalBoxLayout(); + layout1.setTop(40); + layout1.setLeft(20); + layout1.setSpacing(4); + + var crossDomain = new qx.ui.form.CheckBox("Cross Domain"); + layout1.add(crossDomain); + + layout1.add(new qx.ui.basic.Label("URL:")); + var defaultURL = qx.io.remote.Rpc.makeServerURL(); + if (defaultURL == null) { + defaultURL = "/services/"; + } + var url = new qx.ui.form.TextField(defaultURL); + layout1.add(url); + + layout1.add(new qx.ui.basic.Label("Service path:")); + var service = new qx.ui.form.TextField("qooxdoo.test"); + layout1.add(service); + + var start = new qx.ui.form.Button("Start test"); + layout1.add(start); + + var mycall = null; + var test; + var testNum; + + start.addEventListener("execute", function() { + var obj; + var date; + var dataArray; + + /* + * Create an array of each of the tests. Each array element is itself + * an array of two function: the first to issue the test request, and + * the second to validate the result. + */ + var tests = + [ + [ + function() + { + test = "getCurrentTimestamp"; + layout1.warn("Calling '" + test + "'"); + mycall = rpc.callAsync(handler, test); + }, + + function(result) + { + layout1.warn("result: now=" + result.now); + layout1.warn("result: jsonDate=" + result.json.toString()); + } + ], + + [ + function() + { + test = "getInteger"; + layout1.warn("Calling '" + test + "'"); + mycall = rpc.callAsync(handler, test); + }, + + function(result) + { + layout1.warn("result: {" + result + "}"); + layout1.warn("Returns a number, got " + typeof(result) + ": " + (typeof(result) == "number" && isFinite(result) ? "true" : "false")); + } + ], + + [ + function() + { + test = "isInteger"; + layout1.warn("Calling '" + test + "'"); + mycall = rpc.callAsync(handler, test, 1); + }, + + function(result) + { + layout1.warn("result: {" + result + "}"); + layout1.warn("Returns an integer: " + result); + } + ], + + [ + function() + { + test = "getString"; + layout1.warn("Calling '" + test + "'"); + mycall = rpc.callAsync(handler, test); + }, + + function(result) + { + layout1.warn("result: {" + result + "}"); + layout1.warn("Returns a string: " + (typeof(result) == "string")); + } + ], + + [ + function() + { + test = "isString"; + layout1.warn("Calling '" + test + "'"); + mycall = rpc.callAsync(handler, test, "Hello World"); + }, + + function(result) + { + layout1.warn("result: {" + result + "}"); + layout1.warn("Returns a string: " + result); + } + ], + + [ + function() + { + test = "getNull"; + layout1.warn("Calling '" + test + "'"); + var mycall = rpc.callAsync(handler, test); + }, + + function(result) + { + layout1.warn("result: {" + result + "}"); + layout1.warn("Returns null: " + (typeof(result) == "object" && mycall === null ? "true" : "false")); + } + ], + + [ + function() + { + test = "isNull"; + layout1.warn("Calling '" + test + "'"); + mycall = rpc.callAsync(handler, test, null); + }, + + function(result) + { + layout1.warn("result: {" + result + "}"); + layout1.warn("Returns null: " + result); + } + ], + + [ + function() + { + test = "getArrayInteger"; + layout1.warn("Calling '" + test + "'"); + mycall = rpc.callAsync(handler, test); + }, + + function(result) + { + layout1.warn("result: {" + result + "}"); + layout1.warn("Returns an array: " + ((typeof(result) == "object") && (result instanceof Array))); + } + ], + + [ + function() + { + test = "getArrayString"; + layout1.warn("Calling '" + test + "'"); + mycall = rpc.callAsync(handler, test); + }, + + function(result) + { + layout1.warn("result: {" + result + "}"); + layout1.warn("Returns an array: " + ((typeof(result) == "object") && (result instanceof Array))); + } + ], + + [ + function() + { + dataArray = new Array(5); + + for (i=0; i<5; i++) + { + dataArray[i] = i; + }; + + test = "isArray"; + layout1.warn("Calling '" + test + "'"); + mycall = rpc.callAsync(handler, test, dataArray); + }, + + function(result) + { + layout1.warn("result: {" + result + "}"); + layout1.warn("Returns an array: " + result); + } + ], + + [ + function() + { + dataArray = new Array(5); + + for (i=0; i<5; i++) + { + dataArray[i] = "Element " + i; + }; + + test = "isArray"; + layout1.warn("Calling '" + test + "'"); + mycall = rpc.callAsync(handler, test, dataArray); + }, + + function(result) + { + layout1.warn("result: {" + result + "}"); + layout1.warn("Returns an array: " + result); + } + ], + + [ + function() + { + test = "getFloat"; + layout1.warn("Calling '" + test + "'"); + mycall = rpc.callAsync(handler, test); + }, + + function(result) + { + layout1.warn("result: {" + result + "}"); + layout1.warn("Returns a float: " + (typeof(result) == "number")); + } + ], + + [ + function() + { + test = "getObject"; + layout1.warn("Calling '" + test + "'"); + mycall = rpc.callAsync(handler, test); + }, + + function(result) + { + layout1.warn("result: {" + result + "}"); + layout1.warn("Returns an object: " + (typeof(result) == "object")); + } + ], + + [ + function() + { + test = "isObject"; + layout1.warn("Calling '" + test + "'"); + obj = new Object(); + obj.s = "Hi there."; + obj.n = 23; + obj.o = new Object(); + obj.o.s = "This is a test."; + mycall = rpc.callAsync(handler, test, obj); + }, + + function(result) + { + layout1.warn("result: {" + result.toString() + "}"); + layout1.warn("Returns an object: " + result); + } + ], + + [ + function() + { + test = "isBoolean"; + layout1.warn("Calling '" + test + "'"); + mycall = rpc.callAsync(handler, test, false); + }, + + function(result) + { + layout1.warn("result: {" + result.toString() + "}"); + layout1.warn("Returns a boolean: " + result); + } + ], + + [ + function() + { + test = "isBoolean"; + layout1.warn("Calling '" + test + "'"); + mycall = rpc.callAsync(handler, test, true); + }, + + function(result) + { + layout1.warn("result: {" + result.toString() + "}"); + layout1.warn("Returns a boolean: " + result); + } + ], + + [ + function() + { + test = "getTrue"; + layout1.warn("Calling '" + test + "'"); + mycall = rpc.callAsync(handler, test); + }, + + function(result) + { + layout1.warn("result: {" + result.toString() + "}"); + layout1.warn("Returns a boolean = true: " + (typeof(result) == "boolean")); + } + ], + + [ + function() + { + test = "getFalse"; + layout1.warn("Calling '" + test + "'"); + mycall = rpc.callAsync(handler, test); + }, + + function(result) + { + layout1.warn("result: {" + result.toString() + "}"); + layout1.warn("Returns a boolean = false: " + (typeof(result) == "boolean")); + } + ], + + [ + function() + { + Date.prototype.classname = "Date"; + date = new Date(); + test = "getParam"; + layout1.warn("Calling '" + test + "'"); + mycall = rpc.callAsync(handler, test, date); + }, + + function(result) + { + layout1.warn("result: {" + result + "}"); + layout1.warn("Returns a date object, got " + (result.classname == date.classname)); + layout1.warn("Returns matching time " + date.getTime() + " = " + result.getTime() + " :" + (result.getTime() == date.getTime())); + } + ], + + [ + function() + { + dataArray = new Array(); + dataArray[0] = true; + dataArray[1] = false; + dataArray[2] = 1; + dataArray[3] = 1.1; + dataArray[4] = "Hello World"; + dataArray[5] = new Array(5); + dataArray[6] = new Object(); + dataArray[7] = new Date(); + + test = "getParams"; + layout1.warn("Calling '" + test + "'"); + mycall = rpc.callAsync(handler, test, dataArray[0], dataArray[1], dataArray[2], dataArray[3], dataArray[4], dataArray[5], dataArray[6], dataArray[7]); + }, + + function(result) + { + layout1.warn("result: {" + result + "}"); + + for (i=0; i< dataArray.length; i++) + { + layout1.warn("Returned parameter (" + i + ") value '" + result[i] + "' matches '" + dataArray[i] + "': " + (result[i].toString() == dataArray[i].toString())); + layout1.warn("Returned parameter (" + i + ") type '" + typeof(result[i]) + "' matches '" + typeof(dataArray[i]) + "': " + (typeof(result[i]) == typeof(dataArray[i]))); + }; + } + ], + + [ + function() + { + test = "getError"; + layout1.warn("Calling '" + test + "'"); + mycall = rpc.callAsync(handler, test); + }, + + function(result) + { + // should never get here; we should receive an exception + layout1.warn("ERROR: Should have received an exception! Got: " + result); + } + ] + ]; + + /* + * This is the generic handler, used by each of the tests. It + * ascertains whether an exception occured and alert()s with the + * exception if so; otherwise it calls the result validation function + * and then starts the next test. + */ + handler = function(result, ex, id) { + mycall = null; + if (ex !== null) { + alert("Async(" + id + ") exception: " + ex); + } else { + // display results of the completed test + tests[testNum][1](result); // [][1] = validate response + + // start the next test + ++testNum; + + // Are we done? + if (testNum < tests.length) { + // Nope. Run the next test. + tests[testNum][0](); + } + } + } + + // Determine which transport to use + rpc = new qx.io.remote.Rpc(url.getValue(), service.getValue()); + rpc.setTimeout(10000); + rpc.setCrossDomain(crossDomain.isChecked()); + + // start the first test + testNum = 0; + tests[testNum][0](); // [][0] = request + }); + + var d = qx.ui.core.ClientDocument.getInstance(); + d.add(layout1); + }); + </script> +</body> +</html> |