blob: 919b68f18f1d9d5b6436aae49f25b98fd4cac46c [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
David Reiss771f8c72008-02-27 01:55:25 +000024namespace java thrift.test
David Reiss9a08dc62008-02-27 01:55:17 +000025namespace cpp thrift.test
David Reiss6a4b82c2008-03-27 21:42:16 +000026namespace rb Thrift.Test
David Reiss07ef3a92008-03-27 21:42:39 +000027namespace perl ThriftTest
David Reiss9d65bf02008-03-27 21:41:37 +000028namespace csharp Thrift.Test
T Jake Luciani322caa22010-02-15 03:24:55 +000029namespace js ThriftTest
Marc Slemko17859852006-08-15 00:21:31 +000030
Bryan Duxbury9af23d92009-11-19 17:26:38 +000031/**
32 * Docstring!
33 */
Mark Sleee8540632006-05-30 09:24:40 +000034enum Numberz
35{
36 ONE = 1,
37 TWO,
38 THREE,
39 FIVE = 5,
40 SIX,
41 EIGHT = 8
42}
43
Mark Slee6e536442006-06-30 18:28:50 +000044typedef i64 UserId
Mark Sleee8540632006-05-30 09:24:40 +000045
Mark Sleee129a2d2007-02-21 05:17:48 +000046struct Bonk
47{
48 1: string message,
49 2: i32 type
50}
51
Kevin Clark9a863ee2009-03-24 16:04:36 +000052struct Bools {
53 1: bool im_true,
54 2: bool im_false,
55}
56
Mark Sleee8540632006-05-30 09:24:40 +000057struct Xtruct
58{
Mark Sleea3302652006-10-25 19:03:32 +000059 1: string string_thing,
60 4: byte byte_thing,
61 9: i32 i32_thing,
62 11: i64 i64_thing
Mark Sleee8540632006-05-30 09:24:40 +000063}
64
65struct Xtruct2
66{
Mark Sleea3302652006-10-25 19:03:32 +000067 1: byte byte_thing,
68 2: Xtruct struct_thing,
69 3: i32 i32_thing
Mark Sleee8540632006-05-30 09:24:40 +000070}
71
David Reiss233ace52009-03-30 20:46:47 +000072struct Xtruct3
73{
74 1: string string_thing,
75 4: i32 changed,
76 9: i32 i32_thing,
77 11: i64 i64_thing
78}
79
80
Mark Sleee8540632006-05-30 09:24:40 +000081struct Insanity
82{
Mark Sleea3302652006-10-25 19:03:32 +000083 1: map<Numberz, UserId> userMap,
84 2: list<Xtruct> xtructs
Mark Sleee8540632006-05-30 09:24:40 +000085}
86
Bryan Duxbury986d7052009-01-29 01:51:08 +000087struct CrazyNesting {
88 1: string string_field,
89 2: optional set<Insanity> set_field,
90 3: required list< map<set<i32>,map<i32,set<list<map<Insanity,string>>>>>> list_field
91}
92
Marc Slemkobf4fd192006-08-15 21:29:39 +000093exception Xception {
Mark Sleea3302652006-10-25 19:03:32 +000094 1: i32 errorCode,
95 2: string message
Marc Slemkod8b10512006-08-14 23:30:37 +000096}
97
Marc Slemkobf4fd192006-08-15 21:29:39 +000098exception Xception2 {
Mark Sleea3302652006-10-25 19:03:32 +000099 1: i32 errorCode,
100 2: Xtruct struct_thing
Marc Slemkod8b10512006-08-14 23:30:37 +0000101}
Mark Slee27ed6ec2007-08-16 01:26:31 +0000102
Mark Sleed3d733a2006-09-01 22:19:06 +0000103struct EmptyStruct {}
104
Marc Slemkod8b10512006-08-14 23:30:37 +0000105struct OneField {
Mark Sleea3302652006-10-25 19:03:32 +0000106 1: EmptyStruct field
Marc Slemkod8b10512006-08-14 23:30:37 +0000107}
Marc Slemko5b126d62006-08-11 23:03:42 +0000108
Mark Sleee8540632006-05-30 09:24:40 +0000109service ThriftTest
110{
Marc Slemkod8b10512006-08-14 23:30:37 +0000111 void testVoid(),
Mark Sleea3302652006-10-25 19:03:32 +0000112 string testString(1: string thing),
113 byte testByte(1: byte thing),
114 i32 testI32(1: i32 thing),
115 i64 testI64(1: i64 thing),
116 double testDouble(1: double thing),
117 Xtruct testStruct(1: Xtruct thing),
118 Xtruct2 testNest(1: Xtruct2 thing),
119 map<i32,i32> testMap(1: map<i32,i32> thing),
120 set<i32> testSet(1: set<i32> thing),
121 list<i32> testList(1: list<i32> thing),
122 Numberz testEnum(1: Numberz thing),
123 UserId testTypedef(1: UserId thing),
Mark Sleee8540632006-05-30 09:24:40 +0000124
Mark Sleea3302652006-10-25 19:03:32 +0000125 map<i32,map<i32,i32>> testMapMap(1: i32 hello),
Mark Sleee8540632006-05-30 09:24:40 +0000126
127 /* So you think you've got this all worked, out eh? */
Mark Sleea3302652006-10-25 19:03:32 +0000128 map<UserId, map<Numberz,Insanity>> testInsanity(1: Insanity argument),
Marc Slemkod8b10512006-08-14 23:30:37 +0000129
130 /* Multiple parameters */
David Reiss689c9ad2009-04-02 19:24:02 +0000131 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 +0000132
133 /* Exception specifier */
134
David Reiss689c9ad2009-04-02 19:24:02 +0000135 void testException(1: string arg) throws(1: Xception err1),
Marc Slemkod8b10512006-08-14 23:30:37 +0000136
137 /* Multiple exceptions specifier */
138
David Reiss689c9ad2009-04-02 19:24:02 +0000139 Xtruct testMultiException(1: string arg0, 2: string arg1) throws(1: Xception err1, 2: Xception2 err2)
David Reiss2ab6fe82008-02-18 02:11:44 +0000140
David Reissc51986f2009-03-24 20:01:25 +0000141 /* Test oneway void */
David Reisscecbed82009-03-24 20:02:22 +0000142 oneway void testOneway(1:i32 secondsToSleep)
Mark Sleee8540632006-05-30 09:24:40 +0000143}
Mark Sleedafa3cf2006-09-02 23:56:49 +0000144
145service SecondService
146{
147 void blahBlah()
148}
David Reiss9ff3b9d2008-02-15 01:10:23 +0000149
150struct VersioningTestV1 {
151 1: i32 begin_in_both,
David Reissa528f542009-03-24 22:48:40 +0000152 3: string old_string,
David Reiss9ff3b9d2008-02-15 01:10:23 +0000153 12: i32 end_in_both
154}
155
156struct VersioningTestV2 {
157 1: i32 begin_in_both,
158
159 2: i32 newint,
160 3: byte newbyte,
161 4: i16 newshort,
162 5: i64 newlong,
163 6: double newdouble
164 7: Bonk newstruct,
165 8: list<i32> newlist,
166 9: set<i32> newset,
167 10: map<i32, i32> newmap,
168 11: string newstring,
169 12: i32 end_in_both
David Reiss9a08dc62008-02-27 01:55:17 +0000170}
David Reiss2a4bfd62008-04-07 23:45:00 +0000171
172struct ListTypeVersioningV1 {
173 1: list<i32> myints;
174 2: string hello;
175}
176
177struct ListTypeVersioningV2 {
178 1: list<string> strings;
179 2: string hello;
Bryan Duxbury986d7052009-01-29 01:51:08 +0000180}