| 30 |
ashish |
1 |
(*
|
|
|
2 |
Licensed to the Apache Software Foundation (ASF) under one
|
|
|
3 |
or more contributor license agreements. See the NOTICE file
|
|
|
4 |
distributed with this work for additional information
|
|
|
5 |
regarding copyright ownership. The ASF licenses this file
|
|
|
6 |
to you under the Apache License, Version 2.0 (the
|
|
|
7 |
"License"); you may not use this file except in compliance
|
|
|
8 |
with the License. You may obtain a copy of the License at
|
|
|
9 |
|
|
|
10 |
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
11 |
|
|
|
12 |
Unless required by applicable law or agreed to in writing,
|
|
|
13 |
software distributed under the License is distributed on an
|
|
|
14 |
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
15 |
KIND, either express or implied. See the License for the
|
|
|
16 |
specific language governing permissions and limitations
|
|
|
17 |
under the License.
|
|
|
18 |
*)
|
|
|
19 |
|
|
|
20 |
open Thrift;;
|
|
|
21 |
open ThriftTest_types;;
|
|
|
22 |
|
|
|
23 |
let s = new TSocket.t "127.0.0.1" 9090;;
|
|
|
24 |
let p = new TBinaryProtocol.t s;;
|
|
|
25 |
let c = new ThriftTest.client p p;;
|
|
|
26 |
let sod = function
|
|
|
27 |
Some v -> v
|
|
|
28 |
| None -> raise Thrift_error;;
|
|
|
29 |
|
|
|
30 |
s#opn;
|
|
|
31 |
print_string (c#testString "bya");
|
|
|
32 |
print_char '\n';
|
|
|
33 |
print_int (c#testByte 8);
|
|
|
34 |
print_char '\n';
|
|
|
35 |
print_int (c#testByte (-8));
|
|
|
36 |
print_char '\n';
|
|
|
37 |
print_int (c#testI32 32);
|
|
|
38 |
print_char '\n';
|
|
|
39 |
print_string (Int64.to_string (c#testI64 64L));
|
|
|
40 |
print_char '\n';
|
|
|
41 |
print_float (c#testDouble 3.14);
|
|
|
42 |
print_char '\n';
|
|
|
43 |
|
|
|
44 |
let l = [1;2;3;4] in
|
|
|
45 |
if l = (c#testList l) then print_string "list ok\n" else print_string "list fail\n";;
|
|
|
46 |
let h = Hashtbl.create 5 in
|
|
|
47 |
let a = Hashtbl.add h in
|
|
|
48 |
for i=1 to 10 do
|
|
|
49 |
a i (10*i)
|
|
|
50 |
done;
|
|
|
51 |
let r = c#testMap h in
|
|
|
52 |
for i=1 to 10 do
|
|
|
53 |
try
|
|
|
54 |
let g = Hashtbl.find r i in
|
|
|
55 |
print_int i;
|
|
|
56 |
print_char ' ';
|
|
|
57 |
print_int g;
|
|
|
58 |
print_char '\n'
|
|
|
59 |
with Not_found -> print_string ("Can't find "^(string_of_int i)^"\n")
|
|
|
60 |
done;;
|
|
|
61 |
|
|
|
62 |
let s = Hashtbl.create 5 in
|
|
|
63 |
let a = Hashtbl.add s in
|
|
|
64 |
for i = 1 to 10 do
|
|
|
65 |
a i true
|
|
|
66 |
done;
|
|
|
67 |
let r = c#testSet s in
|
|
|
68 |
for i = 1 to 10 do
|
|
|
69 |
try
|
|
|
70 |
let g = Hashtbl.find r i in
|
|
|
71 |
print_int i;
|
|
|
72 |
print_char '\n'
|
|
|
73 |
with Not_found -> print_string ("Can't find "^(string_of_int i)^"\n")
|
|
|
74 |
done;;
|
|
|
75 |
try
|
|
|
76 |
c#testException "Xception"
|
|
|
77 |
with Xception _ -> print_string "testException ok\n";;
|
|
|
78 |
try
|
|
|
79 |
ignore(c#testMultiException "Xception" "bya")
|
|
|
80 |
with Xception e -> Printf.printf "%d %s\n" (sod e#get_errorCode) (sod e#get_message);;
|
|
|
81 |
|
|
|
82 |
|