blob: 2eaf6c60906f79d0fdeb5cab2d851a2ea8e7106e [file] [log] [blame]
T Jake Luciani322caa22010-02-15 03:24:55 +00001package test;
2
3import java.util.HashMap;
4import java.util.List;
5import java.util.Map;
6import java.util.Set;
7
8import org.apache.thrift.TException;
9
10import thrift.test.Insanity;
11import thrift.test.ThriftTest;
12import thrift.test.Xception;
13import thrift.test.Xception2;
14import thrift.test.Xtruct;
15import thrift.test.Xtruct2;
16import thrift.test.Numberz;
17
18public class TestHandler implements ThriftTest.Iface {
19
20 public byte testByte(byte thing) throws TException {
21 return thing;
22 }
23
24 public double testDouble(double thing) throws TException {
25 return thing;
26 }
27
28 public Numberz testEnum(Numberz thing) throws TException {
29 return thing;
30 }
31
32 public void testException(String arg) throws Xception, TException {
33 throw new Xception(1,"server test exception");
34 }
35
36 public int testI32(int thing) throws TException {
37 return thing;
38 }
39
40 public long testI64(long thing) throws TException {
41 return thing;
42 }
43
44 public Map<Long, Map<Numberz, Insanity>> testInsanity(Insanity argument) throws TException {
45 Map<Long, Map<Numberz, Insanity>> result = new HashMap<Long, Map<Numberz,Insanity>>();
46
47 result.put(Long.valueOf(1), new HashMap<Numberz,Insanity>());
48 result.get(Long.valueOf(1)).put(Numberz.ONE, argument);
49
50 result.put(Long.valueOf(2), new HashMap<Numberz,Insanity>());
51 result.get(Long.valueOf(2)).put(Numberz.ONE, argument);
52
53 return result;
54 }
55
56 public List<Integer> testList(List<Integer> thing) throws TException {
57 return thing;
58 }
59
60 public Map<Integer, Integer> testMap(Map<Integer, Integer> thing) throws TException {
61 return thing;
62 }
63
64 public Map<Integer, Map<Integer, Integer>> testMapMap(int hello) throws TException {
65 Map<Integer, Map<Integer,Integer>> result = new HashMap<Integer, Map<Integer,Integer>>();
66
67 result.put(Integer.valueOf(1), new HashMap<Integer,Integer>());
68 result.get(Integer.valueOf(1)).put(Integer.valueOf(1), Integer.valueOf(1));
69 result.get(Integer.valueOf(1)).put(Integer.valueOf(2), Integer.valueOf(2));
70 result.get(Integer.valueOf(2)).put(Integer.valueOf(1), Integer.valueOf(1));
71
72 return result;
73 }
74
75 public Xtruct testMulti(byte arg0, int arg1, long arg2, Map<Short, String> arg3, Numberz arg4, long arg5) throws TException {
76 Xtruct xtr = new Xtruct();
77
78 xtr.byte_thing = arg0;
79 xtr.i32_thing = arg1;
80 xtr.i64_thing = arg2;
81 xtr.string_thing = "server string";
82
83 return xtr;
84 }
85
86 public Xtruct testMultiException(String arg0, String arg1) throws Xception, Xception2, TException {
87 Xtruct xtr = new Xtruct();
88 xtr.setString_thing(arg0);
89 throw new Xception2(1,xtr);
90 }
91
92 public Xtruct2 testNest(Xtruct2 thing) throws TException {
93 return thing;
94 }
95
96 public void testOneway(int secondsToSleep) throws TException {
97 try{
98 Thread.sleep(secondsToSleep * 1000);
99 }catch(InterruptedException e){
100
101 }
102 }
103
104 public Set<Integer> testSet(Set<Integer> thing) throws TException {
105 return thing;
106 }
107
108 public String testString(String thing) throws TException {
109 return thing;
110 }
111
112 public Xtruct testStruct(Xtruct thing) throws TException {
113 return thing;
114 }
115
116 public long testTypedef(long thing) throws TException {
117 return thing;
118 }
119
120 public void testVoid() throws TException {
121
122 }
123}