forked from HTTP-RPC/Kilo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
102 lines (81 loc) · 3.23 KB
/
index.html
File metadata and controls
102 lines (81 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<!--
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
<head>
<title>HTTP-RPC Test</title>
<script src="httprpc.js"></script>
<script>
function testService() {
var serviceProxy = new WebServiceProxy("/httprpc-server-test/test");
// Add
serviceProxy.invokeWithArguments("add", {a:4, b:2}, function(result, error) {
validate(error == null && result == 6);
});
// Add values
serviceProxy.invokeWithArguments("addValues", {values:[1, 2, 3, 4]}, function(result, error) {
validate(error == null && result == 10);
});
// Invert value
serviceProxy.invokeWithArguments("invertValue", {value:true}, function(result, error) {
validate(error == null && result == false);
});
// Get characters
serviceProxy.invokeWithArguments("getCharacters", {text:"Hello, World!"}, function(result, error) {
validate(JSON.stringify(result) == JSON.stringify(["H", "e", "l", "l", "o", ",", " ", "W", "o", "r", "l", "d", "!"]));
});
// Get selection
serviceProxy.invokeWithArguments("getSelection", {items:["a", "b", "c", "d"]}, function(result, error) {
validate(error == null && result == "a, b, c, d");
});
// Get map
var map = {"a":123, "b":456, "c":789};
serviceProxy.invokeWithArguments("getMap", {"map":map}, function(result, error) {
validate(error == null && JSON.stringify(result) == JSON.stringify(map));
});
// Get statistics
serviceProxy.invokeWithArguments("getStatistics", {values:[1, 3, 5]}, function(result, error) {
validate(error == null && result.count == 3 && result.average == 3 && result.sum == 9);
});
// Get test data
serviceProxy.invoke("getTestData", function(result, error) {
validate(JSON.stringify(result) == JSON.stringify([{a:"hello", b:1, c:2}, {a:"goodbye", b:2, c:4}]));
});
// Get void
serviceProxy.invoke("getVoid", function(result, error) {
validate(error == null && result == null);
});
// Get null
serviceProxy.invoke("getNull", function(result, error) {
validate(error == null && result == null);
});
// Get locale code
serviceProxy.invoke("getLocaleCode", function(result, error) {
validate(error == null && result != null);
document.writeln(result + "<br/>");
});
// Get user name
serviceProxy.invoke("getUserName", function(result, error) {
validate(error == null && result == "tomcat");
});
// Is user in role
serviceProxy.invokeWithArguments("isUserInRole", {role:"tomcat"}, function(result, error) {
validate(error == null && result == true);
});
}
function validate(condition) {
document.writeln((condition ? "OK" : "FAIL") + "<br/>");
}
</script>
</head>
<body onload="testService()">
</body>
</html>