David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame^] | 1 | /* |
| 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 Reiss | 771f8c7 | 2008-02-27 01:55:25 +0000 | [diff] [blame] | 20 | namespace java thrift.test |
David Reiss | 9a08dc6 | 2008-02-27 01:55:17 +0000 | [diff] [blame] | 21 | namespace cpp thrift.test |
David Reiss | 6a4b82c | 2008-03-27 21:42:16 +0000 | [diff] [blame] | 22 | namespace rb Thrift.Test |
David Reiss | 07ef3a9 | 2008-03-27 21:42:39 +0000 | [diff] [blame] | 23 | namespace perl ThriftTest |
David Reiss | 9d65bf0 | 2008-03-27 21:41:37 +0000 | [diff] [blame] | 24 | namespace csharp Thrift.Test |
Marc Slemko | 1785985 | 2006-08-15 00:21:31 +0000 | [diff] [blame] | 25 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 26 | enum Numberz |
| 27 | { |
| 28 | ONE = 1, |
| 29 | TWO, |
| 30 | THREE, |
| 31 | FIVE = 5, |
| 32 | SIX, |
| 33 | EIGHT = 8 |
| 34 | } |
| 35 | |
Mark Slee | 6e53644 | 2006-06-30 18:28:50 +0000 | [diff] [blame] | 36 | typedef i64 UserId |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 37 | |
Mark Slee | e129a2d | 2007-02-21 05:17:48 +0000 | [diff] [blame] | 38 | struct Bonk |
| 39 | { |
| 40 | 1: string message, |
| 41 | 2: i32 type |
| 42 | } |
| 43 | |
Kevin Clark | 9a863ee | 2009-03-24 16:04:36 +0000 | [diff] [blame] | 44 | struct Bools { |
| 45 | 1: bool im_true, |
| 46 | 2: bool im_false, |
| 47 | } |
| 48 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 49 | struct Xtruct |
| 50 | { |
Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 51 | 1: string string_thing, |
| 52 | 4: byte byte_thing, |
| 53 | 9: i32 i32_thing, |
| 54 | 11: i64 i64_thing |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | struct Xtruct2 |
| 58 | { |
Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 59 | 1: byte byte_thing, |
| 60 | 2: Xtruct struct_thing, |
| 61 | 3: i32 i32_thing |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 62 | } |
| 63 | |
David Reiss | 233ace5 | 2009-03-30 20:46:47 +0000 | [diff] [blame] | 64 | struct 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 Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 73 | struct Insanity |
| 74 | { |
Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 75 | 1: map<Numberz, UserId> userMap, |
| 76 | 2: list<Xtruct> xtructs |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 77 | } |
| 78 | |
Bryan Duxbury | 986d705 | 2009-01-29 01:51:08 +0000 | [diff] [blame] | 79 | struct 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 Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 85 | exception Xception { |
Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 86 | 1: i32 errorCode, |
| 87 | 2: string message |
Marc Slemko | d8b1051 | 2006-08-14 23:30:37 +0000 | [diff] [blame] | 88 | } |
| 89 | |
Marc Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 90 | exception Xception2 { |
Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 91 | 1: i32 errorCode, |
| 92 | 2: Xtruct struct_thing |
Marc Slemko | d8b1051 | 2006-08-14 23:30:37 +0000 | [diff] [blame] | 93 | } |
Mark Slee | 27ed6ec | 2007-08-16 01:26:31 +0000 | [diff] [blame] | 94 | |
Mark Slee | d3d733a | 2006-09-01 22:19:06 +0000 | [diff] [blame] | 95 | struct EmptyStruct {} |
| 96 | |
Marc Slemko | d8b1051 | 2006-08-14 23:30:37 +0000 | [diff] [blame] | 97 | struct OneField { |
Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 98 | 1: EmptyStruct field |
Marc Slemko | d8b1051 | 2006-08-14 23:30:37 +0000 | [diff] [blame] | 99 | } |
Marc Slemko | 5b126d6 | 2006-08-11 23:03:42 +0000 | [diff] [blame] | 100 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 101 | service ThriftTest |
| 102 | { |
Marc Slemko | d8b1051 | 2006-08-14 23:30:37 +0000 | [diff] [blame] | 103 | void testVoid(), |
Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 104 | 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 Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 116 | |
Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 117 | map<i32,map<i32,i32>> testMapMap(1: i32 hello), |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 118 | |
| 119 | /* So you think you've got this all worked, out eh? */ |
Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 120 | map<UserId, map<Numberz,Insanity>> testInsanity(1: Insanity argument), |
Marc Slemko | d8b1051 | 2006-08-14 23:30:37 +0000 | [diff] [blame] | 121 | |
| 122 | /* Multiple parameters */ |
Mark Slee | 27ed6ec | 2007-08-16 01:26:31 +0000 | [diff] [blame] | 123 | Xtruct testMulti(byte arg0, i32 arg1, i64 arg2, map<i16, string> arg3, Numberz arg4, UserId arg5), |
Marc Slemko | d8b1051 | 2006-08-14 23:30:37 +0000 | [diff] [blame] | 124 | |
| 125 | /* Exception specifier */ |
| 126 | |
Marc Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 127 | void testException(string arg) throws(Xception err1), |
Marc Slemko | d8b1051 | 2006-08-14 23:30:37 +0000 | [diff] [blame] | 128 | |
| 129 | /* Multiple exceptions specifier */ |
| 130 | |
Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 131 | Xtruct testMultiException(string arg0, string arg1) throws(Xception err1, Xception2 err2) |
David Reiss | 2ab6fe8 | 2008-02-18 02:11:44 +0000 | [diff] [blame] | 132 | |
David Reiss | c51986f | 2009-03-24 20:01:25 +0000 | [diff] [blame] | 133 | /* Test oneway void */ |
David Reiss | cecbed8 | 2009-03-24 20:02:22 +0000 | [diff] [blame] | 134 | oneway void testOneway(1:i32 secondsToSleep) |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 135 | } |
Mark Slee | dafa3cf | 2006-09-02 23:56:49 +0000 | [diff] [blame] | 136 | |
| 137 | service SecondService |
| 138 | { |
| 139 | void blahBlah() |
| 140 | } |
David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 141 | |
| 142 | struct VersioningTestV1 { |
| 143 | 1: i32 begin_in_both, |
David Reiss | a528f54 | 2009-03-24 22:48:40 +0000 | [diff] [blame] | 144 | 3: string old_string, |
David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 145 | 12: i32 end_in_both |
| 146 | } |
| 147 | |
| 148 | struct 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 Reiss | 9a08dc6 | 2008-02-27 01:55:17 +0000 | [diff] [blame] | 162 | } |
David Reiss | 2a4bfd6 | 2008-04-07 23:45:00 +0000 | [diff] [blame] | 163 | |
| 164 | struct ListTypeVersioningV1 { |
| 165 | 1: list<i32> myints; |
| 166 | 2: string hello; |
| 167 | } |
| 168 | |
| 169 | struct ListTypeVersioningV2 { |
| 170 | 1: list<string> strings; |
| 171 | 2: string hello; |
Bryan Duxbury | 986d705 | 2009-01-29 01:51:08 +0000 | [diff] [blame] | 172 | } |