blob: b776e29f479e84533205528e9e90dfa3f10dfdac [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.
18 */
19
David Reiss771f8c72008-02-27 01:55:25 +000020namespace java thrift.test
David Reiss9a08dc62008-02-27 01:55:17 +000021namespace cpp thrift.test
David Reiss6a4b82c2008-03-27 21:42:16 +000022namespace rb Thrift.Test
David Reiss07ef3a92008-03-27 21:42:39 +000023namespace perl ThriftTest
David Reiss9d65bf02008-03-27 21:41:37 +000024namespace csharp Thrift.Test
Marc Slemko17859852006-08-15 00:21:31 +000025
Mark Sleee8540632006-05-30 09:24:40 +000026enum Numberz
27{
28 ONE = 1,
29 TWO,
30 THREE,
31 FIVE = 5,
32 SIX,
33 EIGHT = 8
34}
35
Mark Slee6e536442006-06-30 18:28:50 +000036typedef i64 UserId
Mark Sleee8540632006-05-30 09:24:40 +000037
Mark Sleee129a2d2007-02-21 05:17:48 +000038struct Bonk
39{
40 1: string message,
41 2: i32 type
42}
43
Kevin Clark9a863ee2009-03-24 16:04:36 +000044struct Bools {
45 1: bool im_true,
46 2: bool im_false,
47}
48
Mark Sleee8540632006-05-30 09:24:40 +000049struct Xtruct
50{
Mark Sleea3302652006-10-25 19:03:32 +000051 1: string string_thing,
52 4: byte byte_thing,
53 9: i32 i32_thing,
54 11: i64 i64_thing
Mark Sleee8540632006-05-30 09:24:40 +000055}
56
57struct Xtruct2
58{
Mark Sleea3302652006-10-25 19:03:32 +000059 1: byte byte_thing,
60 2: Xtruct struct_thing,
61 3: i32 i32_thing
Mark Sleee8540632006-05-30 09:24:40 +000062}
63
David Reiss233ace52009-03-30 20:46:47 +000064struct Xtruct3
65{
66 1: string string_thing,
67 4: i32 changed,
68 9: i32 i32_thing,
69 11: i64 i64_thing
70}
71
72
Mark Sleee8540632006-05-30 09:24:40 +000073struct Insanity
74{
Mark Sleea3302652006-10-25 19:03:32 +000075 1: map<Numberz, UserId> userMap,
76 2: list<Xtruct> xtructs
Mark Sleee8540632006-05-30 09:24:40 +000077}
78
Bryan Duxbury986d7052009-01-29 01:51:08 +000079struct CrazyNesting {
80 1: string string_field,
81 2: optional set<Insanity> set_field,
82 3: required list< map<set<i32>,map<i32,set<list<map<Insanity,string>>>>>> list_field
83}
84
Marc Slemkobf4fd192006-08-15 21:29:39 +000085exception Xception {
Mark Sleea3302652006-10-25 19:03:32 +000086 1: i32 errorCode,
87 2: string message
Marc Slemkod8b10512006-08-14 23:30:37 +000088}
89
Marc Slemkobf4fd192006-08-15 21:29:39 +000090exception Xception2 {
Mark Sleea3302652006-10-25 19:03:32 +000091 1: i32 errorCode,
92 2: Xtruct struct_thing
Marc Slemkod8b10512006-08-14 23:30:37 +000093}
Mark Slee27ed6ec2007-08-16 01:26:31 +000094
Mark Sleed3d733a2006-09-01 22:19:06 +000095struct EmptyStruct {}
96
Marc Slemkod8b10512006-08-14 23:30:37 +000097struct OneField {
Mark Sleea3302652006-10-25 19:03:32 +000098 1: EmptyStruct field
Marc Slemkod8b10512006-08-14 23:30:37 +000099}
Marc Slemko5b126d62006-08-11 23:03:42 +0000100
Mark Sleee8540632006-05-30 09:24:40 +0000101service ThriftTest
102{
Marc Slemkod8b10512006-08-14 23:30:37 +0000103 void testVoid(),
Mark Sleea3302652006-10-25 19:03:32 +0000104 string testString(1: string thing),
105 byte testByte(1: byte thing),
106 i32 testI32(1: i32 thing),
107 i64 testI64(1: i64 thing),
108 double testDouble(1: double thing),
109 Xtruct testStruct(1: Xtruct thing),
110 Xtruct2 testNest(1: Xtruct2 thing),
111 map<i32,i32> testMap(1: map<i32,i32> thing),
112 set<i32> testSet(1: set<i32> thing),
113 list<i32> testList(1: list<i32> thing),
114 Numberz testEnum(1: Numberz thing),
115 UserId testTypedef(1: UserId thing),
Mark Sleee8540632006-05-30 09:24:40 +0000116
Mark Sleea3302652006-10-25 19:03:32 +0000117 map<i32,map<i32,i32>> testMapMap(1: i32 hello),
Mark Sleee8540632006-05-30 09:24:40 +0000118
119 /* So you think you've got this all worked, out eh? */
Mark Sleea3302652006-10-25 19:03:32 +0000120 map<UserId, map<Numberz,Insanity>> testInsanity(1: Insanity argument),
Marc Slemkod8b10512006-08-14 23:30:37 +0000121
122 /* Multiple parameters */
Mark Slee27ed6ec2007-08-16 01:26:31 +0000123 Xtruct testMulti(byte arg0, i32 arg1, i64 arg2, map<i16, string> arg3, Numberz arg4, UserId arg5),
Marc Slemkod8b10512006-08-14 23:30:37 +0000124
125 /* Exception specifier */
126
Marc Slemkobf4fd192006-08-15 21:29:39 +0000127 void testException(string arg) throws(Xception err1),
Marc Slemkod8b10512006-08-14 23:30:37 +0000128
129 /* Multiple exceptions specifier */
130
Mark Sleea3302652006-10-25 19:03:32 +0000131 Xtruct testMultiException(string arg0, string arg1) throws(Xception err1, Xception2 err2)
David Reiss2ab6fe82008-02-18 02:11:44 +0000132
David Reissc51986f2009-03-24 20:01:25 +0000133 /* Test oneway void */
David Reisscecbed82009-03-24 20:02:22 +0000134 oneway void testOneway(1:i32 secondsToSleep)
Mark Sleee8540632006-05-30 09:24:40 +0000135}
Mark Sleedafa3cf2006-09-02 23:56:49 +0000136
137service SecondService
138{
139 void blahBlah()
140}
David Reiss9ff3b9d2008-02-15 01:10:23 +0000141
142struct VersioningTestV1 {
143 1: i32 begin_in_both,
David Reissa528f542009-03-24 22:48:40 +0000144 3: string old_string,
David Reiss9ff3b9d2008-02-15 01:10:23 +0000145 12: i32 end_in_both
146}
147
148struct VersioningTestV2 {
149 1: i32 begin_in_both,
150
151 2: i32 newint,
152 3: byte newbyte,
153 4: i16 newshort,
154 5: i64 newlong,
155 6: double newdouble
156 7: Bonk newstruct,
157 8: list<i32> newlist,
158 9: set<i32> newset,
159 10: map<i32, i32> newmap,
160 11: string newstring,
161 12: i32 end_in_both
David Reiss9a08dc62008-02-27 01:55:17 +0000162}
David Reiss2a4bfd62008-04-07 23:45:00 +0000163
164struct ListTypeVersioningV1 {
165 1: list<i32> myints;
166 2: string hello;
167}
168
169struct ListTypeVersioningV2 {
170 1: list<string> strings;
171 2: string hello;
Bryan Duxbury986d7052009-01-29 01:51:08 +0000172}