r19142: ensure no race conditions during installation by having same name in source...
[Samba/bb.git] / services / qooxdoo / test.esp
blobe8686dcc255129b1a0cab49468fead7c7c91ca1c
1 <%
2 /*
3  * Copyright:
4  *   (C) 2006 by Derrell Lipman
5  *       All rights reserved
6  *
7  * License:
8  *   LGPL 2.1: http://creativecommons.org/licenses/LGPL/2.1/
9  */
12  * This is the standard qooxdoo test class.  There are tests for each of the
13  * primitive types here, along with standard named tests "echo", "sink" and
14  * "sleep".
15  */
17 /**
18  * Echo the (one and only) parameter.
19  *
20  * @param params
21  *   An array containing the parameters to this method
22  *
23  * @param error
24  *   An object of class JsonRpcError.
25  *
26  * @return
27  *   Success: The object containing the result of the method;
28  *   Failure: null
29  */
30 function _echo(params, error)
32     if (params.length != 1)
33     {
34         error.setError(JsonRpcError_ParameterMismatch,
35                        "Expected 1 parameter; got " + params.length);
36         return error;
37     }
38     return "Client said: [" + params[0] + "]";
40 jsonrpc.method.echo = _echo;
42 /**
43  * Sink all data and never return.
44  *
45  * @param params
46  *   An array containing the parameters to this method (none expected)
47  *
48  * @param error
49  *   An object of class JsonRpcError.
50  *
51  * @return
52  *   "Never"
53  */
54 function _sink(params, error)
56     /* We're never supposed to return.  Just sleep for a very long time. */
57     sleep(240);
59 jsonrpc.method.sink = _sink;
61 /**
62  * Sleep for the number of seconds specified by the parameter.
63  *
64  * @param params
65  *   An array containing the parameters to this method (one expected)
66  *
67  * @param error
68  *   An object of class JsonRpcError.
69  *
70  * @return
71  *   Success: The object containing the result of the method;
72  *   Failure: null
73  */
74 function _sleep(params, error)
76     if (params.length != 1)
77     {
78         error.setError(JsonRpcError_ParameterMismatch,
79                        "Expected 1 parameter; got " + params.length);
80         return error;
81     }
82     
83     sleep(params[0]);
84     return params[0];
86 jsonrpc.method.sleep = _sleep;
88 /*************************************************************************/
91  * The remainder of the functions test each individual primitive type, and
92  * test echoing arbitrary types.  Hopefully the name is self-explanatory.
93  */
95 function _getInteger(params, error)
97     return 1;
99 jsonrpc.method.getInteger = _getInteger;
101 function _getFloat(params, error)
103     return 1/3;
105 jsonrpc.method.getFloat = _getFloat;
107 function _getString(params, error)
109     return "Hello world";
111 jsonrpc.method.getString = _getString;
113 function _getBadString(params, error)
115     return "<!DOCTYPE HTML \"-//IETF//DTD HTML 2.0//EN\">";
117 jsonrpc.method.getBadString = _getBadString;
119 function _getArrayInteger(params, error)
121     return new Array(1, 2, 3, 4);
123 jsonrpc.method.getArrayInteger = _getArrayInteger;
125 function _getArrayString(params, error)
127     return new Array("one", "two", "three", "four");
129 jsonrpc.method.getArrayString = _getArrayString;
131 function _getObject(params, error)
133     o = new Object(); // some arbitrary object
134     o.something = 23;
135     o.garbage = 'lkasjdff;lajsdfkl;sadf';
136     return o;    
138 jsonrpc.method.getObject = _getObject;
140 function _getTrue(params, error)
142     return true;
144 jsonrpc.method.getTrue = _getTrue;
146 function _getFalse(params, error)
148     return false;
150 jsonrpc.method.getFalse = _getFalse;
152 function _getNull(params, error)
154     return null;
156 jsonrpc.method.getNull = _getNull;
158 function _isInteger(params, error)
160     var type = nativeTypeOf(params[0]);
161     return type == "integer" || type == "integer64";
163 jsonrpc.method.isInteger = _isInteger;
165 function _isFloat(params, error)
167     return nativeTypeOf(params[0]) == "float";
169 jsonrpc.method.isFloat = _isFloat;
171 function _isString(params, error)
173     return nativeTypeOf(params[0]) == "string";
175 jsonrpc.method.isString = _isString;
177 function _isBoolean(params, error)
179     return nativeTypeOf(params[0]) == "boolean";
181 jsonrpc.method.isBoolean = _isBoolean;
183 function _isArray(params, error)
185     return nativeTypeOf(params[0]) == "object" && params.length != undefined;
187 jsonrpc.method.isArray = _isArray;
189 function _isObject(params, error)
191     return nativeTypeOf(params[0]) == "object";
193 jsonrpc.method.isObject = _isObject;
195 function _isNull(params, error)
197     return nativeTypeOf(params[0]) == "null";
199 jsonrpc.method.isNull = _isNull;
201 function _getParams(params, error)
203     return params;
204 }       
205 jsonrpc.method.getParams = _getParams;
207 function _getParam(params, error)
209     return params[0];
210 }       
211 jsonrpc.method.getParam = _getParam;
213 function _getCurrentTimestamp()
215     now = gettimeofday();
216     obj = new Object();
217     obj.now = now.sec;
218     obj.json = JSON_Date.create(now);
219     return obj;
221 jsonrpc.method.getCurrentTimestamp = _getCurrentTimestamp;
223 function _getError(params, error)
225     error.setError(23, "This is an application-provided error");
226     return error;
227 }       
228 jsonrpc.method.getError = _getError;
232  * Local Variables:
233  * mode: c
234  * End:
235  */