blob: 69185848116734272e51344e70895a79efd2311a [file] [log] [blame]
David Reissea2cba82009-03-30 21:35:00 +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.
Todd Lipcon53ae9f32009-12-07 00:42:38 +000018 *
19 * Contains some contributions under the Thrift Software License.
20 * Please see doc/old-thrift-license.txt in the Thrift distribution for
21 * details.
David Reissea2cba82009-03-30 21:35:00 +000022 */
23
Roger Meier213a6642010-10-27 12:30:11 +000024namespace c_glib TTest
David Reiss771f8c72008-02-27 01:55:25 +000025namespace java thrift.test
David Reiss9a08dc62008-02-27 01:55:17 +000026namespace cpp thrift.test
David Reiss6a4b82c2008-03-27 21:42:16 +000027namespace rb Thrift.Test
David Reiss07ef3a92008-03-27 21:42:39 +000028namespace perl ThriftTest
David Reiss9d65bf02008-03-27 21:41:37 +000029namespace csharp Thrift.Test
T Jake Luciani322caa22010-02-15 03:24:55 +000030namespace js ThriftTest
Bryan Duxbury4d8a9cd2010-08-30 17:09:58 +000031namespace st ThriftTest
Anthony F. Molinaro0b4936d2010-09-27 04:43:39 +000032namespace py ThriftTest
Roger Meier50e43492010-10-08 17:46:06 +000033namespace py.twisted ThriftTest
Christian Lavoieafc6d8f2011-02-20 02:39:19 +000034namespace go ThriftTest
Bryan Duxbury1d373bc2011-03-02 18:13:30 +000035namespace php ThriftTest
Jake Farrell7ae13e12011-10-18 14:35:26 +000036namespace delphi Thrift.Test
David Reissfb790d72010-09-02 16:41:45 +000037namespace * thrift.test
Marc Slemko17859852006-08-15 00:21:31 +000038
Bryan Duxbury9af23d92009-11-19 17:26:38 +000039/**
40 * Docstring!
41 */
Mark Sleee8540632006-05-30 09:24:40 +000042enum Numberz
43{
44 ONE = 1,
45 TWO,
46 THREE,
47 FIVE = 5,
48 SIX,
49 EIGHT = 8
50}
51
Bryan Duxbury9f0a7862010-09-12 14:38:36 +000052const Numberz myNumberz = Numberz.ONE;
53// the following is expected to fail:
54// const Numberz urNumberz = ONE;
55
Mark Slee6e536442006-06-30 18:28:50 +000056typedef i64 UserId
Mark Sleee8540632006-05-30 09:24:40 +000057
Mark Sleee129a2d2007-02-21 05:17:48 +000058struct Bonk
59{
60 1: string message,
61 2: i32 type
62}
63
Kevin Clark9a863ee2009-03-24 16:04:36 +000064struct Bools {
65 1: bool im_true,
66 2: bool im_false,
67}
68
Mark Sleee8540632006-05-30 09:24:40 +000069struct Xtruct
70{
Mark Sleea3302652006-10-25 19:03:32 +000071 1: string string_thing,
72 4: byte byte_thing,
73 9: i32 i32_thing,
74 11: i64 i64_thing
Mark Sleee8540632006-05-30 09:24:40 +000075}
76
77struct Xtruct2
78{
Mark Sleea3302652006-10-25 19:03:32 +000079 1: byte byte_thing,
80 2: Xtruct struct_thing,
81 3: i32 i32_thing
Mark Sleee8540632006-05-30 09:24:40 +000082}
83
David Reiss233ace52009-03-30 20:46:47 +000084struct Xtruct3
85{
86 1: string string_thing,
87 4: i32 changed,
88 9: i32 i32_thing,
89 11: i64 i64_thing
90}
91
92
Mark Sleee8540632006-05-30 09:24:40 +000093struct Insanity
94{
Mark Sleea3302652006-10-25 19:03:32 +000095 1: map<Numberz, UserId> userMap,
96 2: list<Xtruct> xtructs
Mark Sleee8540632006-05-30 09:24:40 +000097}
98
Bryan Duxbury986d7052009-01-29 01:51:08 +000099struct CrazyNesting {
100 1: string string_field,
101 2: optional set<Insanity> set_field,
Bryan Duxburyb3d0aa02010-10-06 20:00:03 +0000102 3: required list< map<set<i32>,map<i32,set<list<map<Insanity,string>>>>>> list_field,
103 4: binary binary_field
Bryan Duxbury986d7052009-01-29 01:51:08 +0000104}
105
Marc Slemkobf4fd192006-08-15 21:29:39 +0000106exception Xception {
Mark Sleea3302652006-10-25 19:03:32 +0000107 1: i32 errorCode,
108 2: string message
Marc Slemkod8b10512006-08-14 23:30:37 +0000109}
110
Marc Slemkobf4fd192006-08-15 21:29:39 +0000111exception Xception2 {
Mark Sleea3302652006-10-25 19:03:32 +0000112 1: i32 errorCode,
113 2: Xtruct struct_thing
Marc Slemkod8b10512006-08-14 23:30:37 +0000114}
Mark Slee27ed6ec2007-08-16 01:26:31 +0000115
Mark Sleed3d733a2006-09-01 22:19:06 +0000116struct EmptyStruct {}
117
Marc Slemkod8b10512006-08-14 23:30:37 +0000118struct OneField {
Mark Sleea3302652006-10-25 19:03:32 +0000119 1: EmptyStruct field
Marc Slemkod8b10512006-08-14 23:30:37 +0000120}
Marc Slemko5b126d62006-08-11 23:03:42 +0000121
Mark Sleee8540632006-05-30 09:24:40 +0000122service ThriftTest
123{
Marc Slemkod8b10512006-08-14 23:30:37 +0000124 void testVoid(),
Mark Sleea3302652006-10-25 19:03:32 +0000125 string testString(1: string thing),
126 byte testByte(1: byte thing),
127 i32 testI32(1: i32 thing),
128 i64 testI64(1: i64 thing),
129 double testDouble(1: double thing),
130 Xtruct testStruct(1: Xtruct thing),
131 Xtruct2 testNest(1: Xtruct2 thing),
132 map<i32,i32> testMap(1: map<i32,i32> thing),
Roger Meier9d8e8f82011-06-14 19:38:27 +0000133 map<string,string> testStringMap(1: map<string,string> thing),
Mark Sleea3302652006-10-25 19:03:32 +0000134 set<i32> testSet(1: set<i32> thing),
135 list<i32> testList(1: list<i32> thing),
136 Numberz testEnum(1: Numberz thing),
137 UserId testTypedef(1: UserId thing),
Mark Sleee8540632006-05-30 09:24:40 +0000138
Mark Sleea3302652006-10-25 19:03:32 +0000139 map<i32,map<i32,i32>> testMapMap(1: i32 hello),
Mark Sleee8540632006-05-30 09:24:40 +0000140
141 /* So you think you've got this all worked, out eh? */
Mark Sleea3302652006-10-25 19:03:32 +0000142 map<UserId, map<Numberz,Insanity>> testInsanity(1: Insanity argument),
Marc Slemkod8b10512006-08-14 23:30:37 +0000143
144 /* Multiple parameters */
David Reiss689c9ad2009-04-02 19:24:02 +0000145 Xtruct testMulti(1: byte arg0, 2: i32 arg1, 3: i64 arg2, 4: map<i16, string> arg3, 5: Numberz arg4, 6: UserId arg5),
Marc Slemkod8b10512006-08-14 23:30:37 +0000146
147 /* Exception specifier */
148
David Reiss689c9ad2009-04-02 19:24:02 +0000149 void testException(1: string arg) throws(1: Xception err1),
Marc Slemkod8b10512006-08-14 23:30:37 +0000150
151 /* Multiple exceptions specifier */
152
David Reiss689c9ad2009-04-02 19:24:02 +0000153 Xtruct testMultiException(1: string arg0, 2: string arg1) throws(1: Xception err1, 2: Xception2 err2)
David Reiss2ab6fe82008-02-18 02:11:44 +0000154
David Reissc51986f2009-03-24 20:01:25 +0000155 /* Test oneway void */
David Reisscecbed82009-03-24 20:02:22 +0000156 oneway void testOneway(1:i32 secondsToSleep)
Mark Sleee8540632006-05-30 09:24:40 +0000157}
Mark Sleedafa3cf2006-09-02 23:56:49 +0000158
159service SecondService
160{
161 void blahBlah()
162}
David Reiss9ff3b9d2008-02-15 01:10:23 +0000163
164struct VersioningTestV1 {
165 1: i32 begin_in_both,
David Reissa528f542009-03-24 22:48:40 +0000166 3: string old_string,
David Reiss9ff3b9d2008-02-15 01:10:23 +0000167 12: i32 end_in_both
168}
169
170struct VersioningTestV2 {
171 1: i32 begin_in_both,
172
173 2: i32 newint,
174 3: byte newbyte,
175 4: i16 newshort,
176 5: i64 newlong,
177 6: double newdouble
178 7: Bonk newstruct,
179 8: list<i32> newlist,
180 9: set<i32> newset,
181 10: map<i32, i32> newmap,
182 11: string newstring,
183 12: i32 end_in_both
David Reiss9a08dc62008-02-27 01:55:17 +0000184}
David Reiss2a4bfd62008-04-07 23:45:00 +0000185
186struct ListTypeVersioningV1 {
187 1: list<i32> myints;
188 2: string hello;
189}
190
191struct ListTypeVersioningV2 {
192 1: list<string> strings;
193 2: string hello;
Bryan Duxbury986d7052009-01-29 01:51:08 +0000194}
Bryan Duxbury206c0dc2010-10-19 23:00:27 +0000195
196struct GuessProtocolStruct {
197 7: map<string,string> map_field,
198}
Bryan Duxburydf4cffd2011-03-15 17:16:09 +0000199
200struct LargeDeltas {
201 1: Bools b1,
202 10: Bools b10,
203 100: Bools b100,
204 500: bool check_true,
205 1000: Bools b1000,
206 1500: bool check_false,
207 2000: VersioningTestV2 vertwo2000,
208 2500: set<string> a_set2500,
209 3000: VersioningTestV2 vertwo3000,
210 4000: list<i32> big_numbers
211}
Roger Meierf4eec7a2011-09-11 18:16:21 +0000212
213struct NestedListsI32x2 {
214 1: list<list<i32>> integerlist
215}
216struct NestedListsI32x3 {
217 1: list<list<list<i32>>> integerlist
218}
219struct NestedMixedx2 {
220 1: list<set<i32>> int_set_list
221 2: map<i32,set<string>> map_int_strset
222 3: list<map<i32,set<string>>> map_int_strset_list
223}
224struct ListBonks {
225 1: list<Bonk> bonk
226}
227struct NestedListsBonk {
228 1: list<list<list<Bonk>>> bonk
229}
Bryan Duxbury6c928f32011-10-13 21:32:52 +0000230
231struct BoolTest {
232 1: optional bool b = true;
233 2: optional string s = "true";
234}