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