Moving from govendor to dep, updated dependencies (#48)

* Moving from govendor to dep.

* Making the pull request template more friendly.

* Fixing akward space in PR template.

* goimports run on whole project using ` goimports -w $(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./gen-go/*")`

source of command: https://gist.github.com/bgentry/fd1ffef7dbde01857f66
This commit is contained in:
Renan DelValle 2018-01-07 13:13:47 -08:00 committed by GitHub
parent 9631aa3aab
commit 8d445c1c77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2186 changed files with 400410 additions and 352 deletions

View file

@ -0,0 +1,63 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
typedef list<i32> ( cpp.template = "std::list" ) int_linked_list
struct foo {
1: i32 bar ( presence = "required" );
2: i32 baz ( presence = "manual", cpp.use_pointer = "", );
3: i32 qux;
4: i32 bop;
} (
cpp.type = "DenseFoo",
python.type = "DenseFoo",
java.final = "",
annotation.without.value,
)
exception foo_error {
1: i32 error_code ( foo="bar" )
2: string error_msg
} (foo = "bar")
typedef string ( unicode.encoding = "UTF-16" ) non_latin_string (foo="bar")
typedef list< double ( cpp.fixed_point = "16" ) > tiny_float_list
enum weekdays {
SUNDAY ( weekend = "yes" ),
MONDAY,
TUESDAY,
WEDNESDAY,
THURSDAY,
FRIDAY,
SATURDAY ( weekend = "yes" )
} (foo.bar="baz")
/* Note that annotations on senum values are not supported. */
senum seasons {
"Spring",
"Summer",
"Fall",
"Winter"
} ( foo = "bar" )
service foo_service {
void foo() ( foo = "bar" )
} (a.b="c")

View file

@ -0,0 +1,25 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
const i64 myint = 68719476736
const i64 broken = 9876543210987654321 // A little over 2^63
enum foo {
bar = 68719476736
}

View file

@ -0,0 +1,74 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
namespace cpp yozone
struct thing {
1: i32 hello,
2: i32 goodbye
}
enum enumconstants {
ONE = 1,
TWO = 2
}
// struct thing2 {
// /** standard docstring */
// 1: enumconstants val = TWO
// }
typedef i32 myIntType
const myIntType myInt = 3
//const map<enumconstants,string> GEN_ENUM_NAMES = {ONE : "HOWDY", TWO: "PARTNER"}
const i32 hex_const = 0x0001F
const i32 negative_hex_constant = -0x0001F
const i32 GEN_ME = -3523553
const double GEn_DUB = 325.532
const double GEn_DU = 085.2355
const string GEN_STRING = "asldkjasfd"
const double e10 = 1e10 // fails with 0.9.3 and earlier
const double e11 = -1e10
const map<i32,i32> GEN_MAP = { 35532 : 233, 43523 : 853 }
const list<i32> GEN_LIST = [ 235235, 23598352, 3253523 ]
const map<i32, map<i32, i32>> GEN_MAPMAP = { 235 : { 532 : 53255, 235:235}}
const map<string,i32> GEN_MAP2 = { "hello" : 233, "lkj98d" : 853, 'lkjsdf' : 098325 }
const thing GEN_THING = { 'hello' : 325, 'goodbye' : 325352 }
const map<i32,thing> GEN_WHAT = { 35 : { 'hello' : 325, 'goodbye' : 325352 } }
const set<i32> GEN_SET = [ 235, 235, 53235 ]
exception Blah {
1: i32 bing }
exception Gak {}
service yowza {
void blingity(),
i32 blangity() throws (1: Blah hoot )
}

View file

@ -0,0 +1,378 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
namespace c_glib TTest
namespace cpp thrift.test.debug
namespace java thrift.test
namespace rb thrift.test
struct Doubles {
1: double nan,
2: double inf,
3: double neginf,
4: double repeating,
5: double big,
6: double tiny,
7: double zero,
8: double negzero,
}
struct OneOfEach {
1: bool im_true,
2: bool im_false,
3: i8 a_bite = 0x7f,
4: i16 integer16 = 0x7fff,
5: i32 integer32,
6: i64 integer64 = 10000000000,
7: double double_precision,
8: string some_characters,
9: string zomg_unicode,
10: bool what_who,
11: binary base64,
12: list<i8> byte_list = [1, 2, 3],
13: list<i16> i16_list = [1,2,3],
14: list<i64> i64_list = [1,2,3]
}
struct Bonk {
1: i32 type,
2: string message,
}
struct Nesting {
1: Bonk my_bonk,
2: OneOfEach my_ooe,
}
struct HolyMoley {
1: list<OneOfEach> big,
2: set<list<string> (python.immutable = "")> contain,
3: map<string,list<Bonk>> bonks,
}
struct Backwards {
2: i32 first_tag2,
1: i32 second_tag1,
}
struct Empty {
} (
python.immutable = "",
)
struct Wrapper {
1: Empty foo
} (
python.immutable = "",
)
struct RandomStuff {
1: i32 a,
2: i32 b,
3: i32 c,
4: i32 d,
5: list<i32> myintlist,
6: map<i32,Wrapper> maps,
7: i64 bigint,
8: double triple,
}
struct Base64 {
1: i32 a,
2: binary b1,
3: binary b2,
4: binary b3,
5: binary b4,
6: binary b5,
7: binary b6,
}
struct CompactProtoTestStruct {
// primitive fields
1: i8 a_byte;
2: i16 a_i16;
3: i32 a_i32;
4: i64 a_i64;
5: double a_double;
6: string a_string;
7: binary a_binary;
8: bool true_field;
9: bool false_field;
10: Empty empty_struct_field;
// primitives in lists
11: list<i8> byte_list;
12: list<i16> i16_list;
13: list<i32> i32_list;
14: list<i64> i64_list;
15: list<double> double_list;
16: list<string> string_list;
17: list<binary> binary_list;
18: list<bool> boolean_list;
19: list<Empty> struct_list;
// primitives in sets
20: set<i8> byte_set;
21: set<i16> i16_set;
22: set<i32> i32_set;
23: set<i64> i64_set;
24: set<double> double_set;
25: set<string> string_set;
26: set<binary> binary_set;
27: set<bool> boolean_set;
28: set<Empty> struct_set;
// maps
// primitives as keys
29: map<i8, i8> byte_byte_map;
30: map<i16, i8> i16_byte_map;
31: map<i32, i8> i32_byte_map;
32: map<i64, i8> i64_byte_map;
33: map<double, i8> double_byte_map;
34: map<string, i8> string_byte_map;
35: map<binary, i8> binary_byte_map;
36: map<bool, i8> boolean_byte_map;
// primitives as values
37: map<i8, i16> byte_i16_map;
38: map<i8, i32> byte_i32_map;
39: map<i8, i64> byte_i64_map;
40: map<i8, double> byte_double_map;
41: map<i8, string> byte_string_map;
42: map<i8, binary> byte_binary_map;
43: map<i8, bool> byte_boolean_map;
// collections as keys
44: map<list<i8> (python.immutable = ""), i8> list_byte_map;
45: map<set<i8> (python.immutable = ""), i8> set_byte_map;
46: map<map<i8,i8> (python.immutable = ""), i8> map_byte_map;
// collections as values
47: map<i8, map<i8,i8>> byte_map_map;
48: map<i8, set<i8>> byte_set_map;
49: map<i8, list<i8>> byte_list_map;
}
// To be used to test the serialization of an empty map
struct SingleMapTestStruct {
1: required map<i32, i32> i32_map;
}
const CompactProtoTestStruct COMPACT_TEST = {
'a_byte' : 127,
'a_i16' : 32000,
'a_i32' : 1000000000,
'a_i64' : 0xffffffffff,
'a_double' : 5.6789,
'a_string' : "my string",
//'a_binary,'
'true_field' : 1,
'false_field' : 0,
'empty_struct_field' : {},
'byte_list' : [-127, -1, 0, 1, 127],
'i16_list' : [-1, 0, 1, 0x7fff],
'i32_list' : [-1, 0, 0xff, 0xffff, 0xffffff, 0x7fffffff],
'i64_list' : [-1, 0, 0xff, 0xffff, 0xffffff, 0xffffffff, 0xffffffffff, 0xffffffffffff, 0xffffffffffffff, 0x7fffffffffffffff],
'double_list' : [0.1, 0.2, 0.3],
'string_list' : ["first", "second", "third"],
//'binary_list,'
'boolean_list' : [1, 1, 1, 0, 0, 0],
'struct_list' : [{}, {}],
'byte_set' : [-127, -1, 0, 1, 127],
'i16_set' : [-1, 0, 1, 0x7fff],
'i32_set' : [1, 2, 3],
'i64_set' : [-1, 0, 0xff, 0xffff, 0xffffff, 0xffffffff, 0xffffffffff, 0xffffffffffff, 0xffffffffffffff, 0x7fffffffffffffff],
'double_set' : [0.1, 0.2, 0.3],
'string_set' : ["first", "second", "third"],
//'binary_set,'
'boolean_set' : [1, 0],
'struct_set' : [{}],
'byte_byte_map' : {1 : 2},
'i16_byte_map' : {1 : 1, -1 : 1, 0x7fff : 1},
'i32_byte_map' : {1 : 1, -1 : 1, 0x7fffffff : 1},
'i64_byte_map' : {0 : 1, 1 : 1, -1 : 1, 0x7fffffffffffffff : 1},
'double_byte_map' : {-1.1 : 1, 1.1 : 1},
'string_byte_map' : {"first" : 1, "second" : 2, "third" : 3, "" : 0},
//'binary_byte_map,'
'boolean_byte_map' : {1 : 1, 0 : 0},
'byte_i16_map' : {1 : 1, 2 : -1, 3 : 0x7fff},
'byte_i32_map' : {1 : 1, 2 : -1, 3 : 0x7fffffff},
'byte_i64_map' : {1 : 1, 2 : -1, 3 : 0x7fffffffffffffff},
'byte_double_map' : {1 : 0.1, 2 : -0.1, 3 : 1000000.1},
'byte_string_map' : {1 : "", 2 : "blah", 3 : "loooooooooooooong string"},
//'byte_binary_map,'
'byte_boolean_map' : {1 : 1, 2 : 0},
'list_byte_map' : {[1, 2, 3] : 1, [0, 1] : 2, [] : 0},
'set_byte_map' : {[1, 2, 3] : 1, [0, 1] : 2, [] : 0},
'map_byte_map' : {{1 : 1} : 1, {2 : 2} : 2, {} : 0},
'byte_map_map' : {0 : {}, 1 : {1 : 1}, 2 : {1 : 1, 2 : 2}},
'byte_set_map' : {0 : [], 1 : [1], 2 : [1, 2]},
'byte_list_map' : {0 : [], 1 : [1], 2 : [1, 2]},
}
const i32 MYCONST = 2
exception ExceptionWithAMap {
1: string blah;
2: map<string, string> map_field;
}
service ServiceForExceptionWithAMap {
void methodThatThrowsAnException() throws (1: ExceptionWithAMap xwamap);
}
service Srv {
i32 Janky(1: i32 arg);
// return type only methods
void voidMethod();
i32 primitiveMethod();
CompactProtoTestStruct structMethod();
void methodWithDefaultArgs(1: i32 something = MYCONST);
oneway void onewayMethod();
bool declaredExceptionMethod(1: bool shouldThrow) throws (1: ExceptionWithAMap xwamap);
}
service Inherited extends Srv {
i32 identity(1: i32 arg)
}
service EmptyService {}
// The only purpose of this thing is to increase the size of the generated code
// so that ZlibTest has more highly compressible data to play with.
struct BlowUp {
1: map<list<i32>(python.immutable = ""),set<map<i32,string> (python.immutable = "")>> b1;
2: map<list<i32>(python.immutable = ""),set<map<i32,string> (python.immutable = "")>> b2;
3: map<list<i32>(python.immutable = ""),set<map<i32,string> (python.immutable = "")>> b3;
4: map<list<i32>(python.immutable = ""),set<map<i32,string> (python.immutable = "")>> b4;
}
struct ReverseOrderStruct {
4: string first;
3: i16 second;
2: i32 third;
1: i64 fourth;
}
service ReverseOrderService {
void myMethod(4: string first, 3: i16 second, 2: i32 third, 1: i64 fourth);
}
enum SomeEnum {
ONE = 1
TWO = 2
}
/** This is a docstring on a constant! */
const SomeEnum MY_SOME_ENUM = SomeEnum.ONE
const SomeEnum MY_SOME_ENUM_1 = 1
/*const SomeEnum MY_SOME_ENUM_2 = 7*/
const map<SomeEnum,SomeEnum> MY_ENUM_MAP = {
SomeEnum.ONE : SomeEnum.TWO
}
struct StructWithSomeEnum {
1: SomeEnum blah;
}
const map<SomeEnum,StructWithSomeEnum> EXTRA_CRAZY_MAP = {
SomeEnum.ONE : {"blah" : SomeEnum.TWO}
}
union TestUnion {
/**
* A doc string
*/
1: string string_field;
2: i32 i32_field;
3: OneOfEach struct_field;
4: list<RandomStuff> struct_list;
5: i32 other_i32_field;
6: SomeEnum enum_field;
7: set<i32> i32_set;
8: map<i32, i32> i32_map;
}
union TestUnionMinusStringField {
2: i32 i32_field;
3: OneOfEach struct_field;
4: list<RandomStuff> struct_list;
5: i32 other_i32_field;
6: SomeEnum enum_field;
7: set<i32> i32_set;
8: map<i32, i32> i32_map;
}
union ComparableUnion {
1: string string_field;
2: binary binary_field;
}
struct StructWithAUnion {
1: TestUnion test_union;
}
struct PrimitiveThenStruct {
1: i32 blah;
2: i32 blah2;
3: Backwards bw;
}
typedef map<i32,i32> SomeMap
struct StructWithASomemap {
1: required SomeMap somemap_field;
}
struct BigFieldIdStruct {
1: string field1;
45: string field2;
}
struct BreaksRubyCompactProtocol {
1: string field1;
2: BigFieldIdStruct field2;
3: i32 field3;
}
struct TupleProtocolTestStruct {
optional i32 field1;
optional i32 field2;
optional i32 field3;
optional i32 field4;
optional i32 field5;
optional i32 field6;
optional i32 field7;
optional i32 field8;
optional i32 field9;
optional i32 field10;
optional i32 field11;
optional i32 field12;
}
struct ListDoublePerf {
1: list<double> field;
}

View file

@ -0,0 +1,98 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/*
../compiler/cpp/thrift -gen cpp:dense DebugProtoTest.thrift
../compiler/cpp/thrift -gen cpp:dense DenseLinkingTest.thrift
g++ -Wall -g -I../lib/cpp/src -I/usr/local/include/boost-1_33_1 \
DebugProtoTest.cpp gen-cpp/DebugProtoTest_types.cpp \
gen-cpp/DenseLinkingTest_types.cpp \
../lib/cpp/.libs/libthrift.a -o DebugProtoTest
./DebugProtoTest
*/
/*
The idea of this test is that everything is structurally identical to DebugProtoTest.
If I messed up the naming of the reflection local typespecs,
then compiling this should give errors because of doubly defined symbols.
*/
namespace cpp thrift.test
namespace java thrift.test
struct OneOfEachZZ {
1: bool im_true,
2: bool im_false,
3: byte a_bite,
4: i16 integer16,
5: i32 integer32,
6: i64 integer64,
7: double double_precision,
8: string some_characters,
9: string zomg_unicode,
10: bool what_who,
}
struct BonkZZ {
1: i32 type,
2: string message,
}
struct NestingZZ {
1: BonkZZ my_bonk,
2: OneOfEachZZ my_ooe,
}
struct HolyMoleyZZ {
1: list<OneOfEachZZ> big,
2: set<list<string>> contain,
3: map<string,list<BonkZZ>> bonks,
}
struct BackwardsZZ {
2: i32 first_tag2,
1: i32 second_tag1,
}
struct EmptyZZ {
}
struct WrapperZZ {
1: EmptyZZ foo
}
struct RandomStuffZZ {
1: i32 a,
2: i32 b,
3: i32 c,
4: i32 d,
5: list<i32> myintlist,
6: map<i32,WrapperZZ> maps,
7: i64 bigint,
8: double triple,
}
service Srv {
i32 Janky(1: i32 arg)
}
service UnderscoreSrv {
i64 some_rpc_call(1: string message)
}

287
vendor/git.apache.org/thrift.git/test/DocTest.thrift generated vendored Normal file
View file

@ -0,0 +1,287 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Program doctext.
*
* Seriously, this is the documentation for this whole program.
*/
namespace java thrift.test
namespace cpp thrift.test
// C++ comment
/* c style comment */
# the new unix comment
/** Some doc text goes here. Wow I am [nesting these] (no more nesting.) */
enum Numberz
{
/** This is how to document a parameter */
ONE = 1,
/** And this is a doc for a parameter that has no specific value assigned */
TWO,
THREE,
FIVE = 5,
SIX,
EIGHT = 8
}
/** This is how you would do a typedef doc */
typedef i64 UserId
/** And this is where you would document a struct */
struct Xtruct
{
/** And the members of a struct */
1: string string_thing
/** doct text goes before a comma */
4: i8 byte_thing,
9: i32 i32_thing,
11: i64 i64_thing
}
/**
* You can document constants now too. Yeehaw!
*/
const i32 INT32CONSTANT = 9853
const i16 INT16CONSTANT = 1616
/** Everyone get in on the docu-action! */
const map<string,string> MAPCONSTANT = {'hello':'world', 'goodnight':'moon'}
struct Xtruct2
{
1: i8 byte_thing,
2: Xtruct struct_thing,
3: i32 i32_thing
}
/** Struct insanity */
struct Insanity
{
/** This is doc for field 1 */
1: map<Numberz, UserId> userMap,
/** And this is doc for field 2 */
2: list<Xtruct> xtructs
}
exception Xception {
1: i32 errorCode,
2: string message
}
exception Xception2 {
1: i32 errorCode,
2: Xtruct struct_thing
}
/* C1 */
/** Doc */
/* C2 */
/* C3 */
struct EmptyStruct {}
struct OneField {
1: EmptyStruct field
}
/** This is where you would document a Service */
service ThriftTest
{
/** And this is how you would document functions in a service */
void testVoid(),
string testString(1: string thing),
i8 testByte(1: byte thing),
i32 testI32(1: i32 thing),
/** Like this one */
i64 testI64(1: i64 thing),
double testDouble(1: double thing),
Xtruct testStruct(1: Xtruct thing),
Xtruct2 testNest(1: Xtruct2 thing),
map<i32,i32> testMap(1: map<i32,i32> thing),
set<i32> testSet(1: set<i32> thing),
list<i32> testList(1: list<i32> thing),
/** This is an example of a function with params documented */
Numberz testEnum(
/** This param is a thing */
1: Numberz thing
),
UserId testTypedef(1: UserId thing),
map<i32,map<i32,i32>> testMapMap(1: i32 hello),
/* So you think you've got this all worked, out eh? */
map<UserId, map<Numberz,Insanity>> testInsanity(1: Insanity argument),
}
/// This style of Doxy-comment doesn't work.
typedef i32 SorryNoGo
/**
* This is a trivial example of a multiline docstring.
*/
typedef i32 TrivialMultiLine
/**
* This is the canonical example
* of a multiline docstring.
*/
typedef i32 StandardMultiLine
/**
* The last line is non-blank.
* I said non-blank! */
typedef i32 LastLine
/** Both the first line
* are non blank. ;-)
* and the last line */
typedef i32 FirstAndLastLine
/**
* INDENTED TITLE
* The text is less indented.
*/
typedef i32 IndentedTitle
/** First line indented.
* Unfortunately, this does not get indented.
*/
typedef i32 FirstLineIndent
/**
* void code_in_comment() {
* printf("hooray code!");
* }
*/
typedef i32 CodeInComment
/**
* Indented Docstring.
* This whole docstring is indented.
* This line is indented further.
*/
typedef i32 IndentedDocstring
/** Irregular docstring.
* We will have to punt
* on this thing */
typedef i32 Irregular1
/**
* note the space
* before these lines
* but not this
* one
*/
typedef i32 Irregular2
/**
* Flush against
* the left.
*/
typedef i32 Flush
/**
No stars in this one.
It should still work fine, though.
Including indenting.
*/
typedef i32 NoStars
/** Trailing whitespace
Sloppy trailing whitespace
is truncated. */
typedef i32 TrailingWhitespace
/**
* This is a big one.
*
* We'll have some blank lines in it.
*
* void as_well_as(some code) {
* puts("YEEHAW!");
* }
*/
typedef i32 BigDog
/**
*
*
*/
typedef i32 TotallyDegenerate
/**no room for newline here*/
/* * / */
typedef i32 TestFor3501a
/**
* /
*/
typedef i32 TestFor3501b
/* Comment-end tokens can of course have more than one asterisk */
struct TestFor3709_00 { /* ? */ 1: i32 foo }
/* Comment-end tokens can of course have more than one asterisk **/
struct TestFor3709_01 { /* ? */ 1: i32 foo }
/* Comment-end tokens can of course have more than one asterisk ***/
struct TestFor3709_02 { /* ? */ 1: i32 foo }
/** Comment-end tokens can of course have more than one asterisk */
struct TestFor3709_03 { /* ? */ 1: i32 foo }
/** Comment-end tokens can of course have more than one asterisk **/
struct TestFor3709_04 { /* ? */ 1: i32 foo }
/** Comment-end tokens can of course have more than one asterisk ***/
struct TestFor3709_05 { /* ? */ 1: i32 foo }
/*** Comment-end tokens can of course have more than one asterisk */
struct TestFor3709_06 { /* ? */ 1: i32 foo }
/*** Comment-end tokens can of course have more than one asterisk **/
struct TestFor3709_07 { /* ? */ 1: i32 foo }
/*** Comment-end tokens can of course have more than one asterisk ***/
struct TestFor3709_08 { /* ? */ 1: i32 foo }
struct TestFor3709 {
/** This is a comment */
1: required string id,
/** This is also a comment **/
2: required string typeId,
/** Yet another comment! */
3: required i32 endTimestamp
}
/* THE END */

114
vendor/git.apache.org/thrift.git/test/EnumTest.thrift generated vendored Normal file
View file

@ -0,0 +1,114 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* Contains some contributions under the Thrift Software License.
* Please see doc/old-thrift-license.txt in the Thrift distribution for
* details.
*/
namespace c_glib TTest
enum MyEnum1 {
ME1_0 = 0,
ME1_1 = 1,
ME1_2,
ME1_3,
ME1_5 = 5,
ME1_6,
}
enum MyEnum2 {
ME2_0,
ME2_1,
ME2_2,
}
enum MyEnum2_again {
// enum value identifiers may appear again in another enum type
ME0_1,
ME1_1,
ME2_1,
ME3_1,
}
enum MyEnum3 {
ME3_0,
ME3_1,
ME3_N2 = -2,
ME3_N1,
ME3_D0,
ME3_D1,
ME3_9 = 9,
ME3_10,
}
enum MyEnum4 {
ME4_A = 0x7ffffffd
ME4_B
ME4_C
// attempting to define another enum value here fails
// with an overflow error, as we overflow values that can be
// represented with an i32.
}
enum MyEnum5 {
e1 // fails with 0.9.3 and earlier
e2 = 42 // fails with 0.9.3 and earlier
}
struct MyStruct {
1: MyEnum2 me2_2 = MyEnum1.ME2_2
2: MyEnum3 me3_n2 = MyEnum3.ME3_N2
3: MyEnum3 me3_d1 = MyEnum3.ME3_D1
}
struct EnumTestStruct {
1: MyEnum3 a_enum;
2: list<MyEnum3> enum_list;
3: set<MyEnum3> enum_set;
4: map<MyEnum3, MyEnum3> enum_enum_map;
// collections as keys
44: map<list<MyEnum3> (python.immutable = ""), MyEnum3> list_enum_map;
45: map<set<MyEnum3> (python.immutable = ""), MyEnum3> set_enum_map;
46: map<map<MyEnum3,MyEnum3> (python.immutable = ""), MyEnum3> map_enum_map;
// collections as values
47: map<MyEnum3, map<MyEnum3, MyEnum3>> enum_map_map;
48: map<MyEnum3, set<MyEnum3>> enum_set_map;
49: map<MyEnum3, list<MyEnum3>> enum_list_map;
}
const EnumTestStruct ENUM_TEST = {
'a_enum': MyEnum3.ME3_D1,
'enum_list': [MyEnum3.ME3_D1, MyEnum3.ME3_0, MyEnum3.ME3_N2],
'enum_set': [MyEnum3.ME3_D1, MyEnum3.ME3_N1],
'enum_enum_map': {MyEnum3.ME3_D1: MyEnum3.ME3_0, MyEnum3.ME3_0: MyEnum3.ME3_D1},
'list_enum_map': {[MyEnum3.ME3_D1, MyEnum3.ME3_0]: MyEnum3.ME3_0, [MyEnum3.ME3_D1]: MyEnum3.ME3_0, [MyEnum3.ME3_0]: MyEnum3.ME3_D1},
'set_enum_map': {[MyEnum3.ME3_D1, MyEnum3.ME3_0]: MyEnum3.ME3_0, [MyEnum3.ME3_D1]: MyEnum3.ME3_0},
'map_enum_map': {{MyEnum3.ME3_N1: MyEnum3.ME3_10}: MyEnum3.ME3_1},
'enum_map_map': {MyEnum3.ME3_N1: {MyEnum3.ME3_D1: MyEnum3.ME3_D1}},
'enum_set_map': {MyEnum3.ME3_N2: [MyEnum3.ME3_D1, MyEnum3.ME3_N1], MyEnum3.ME3_10: [MyEnum3.ME3_D1, MyEnum3.ME3_N1]},
'enum_list_map': {MyEnum3.ME3_D1: [MyEnum3.ME3_10], MyEnum3.ME3_0: [MyEnum3.ME3_9, MyEnum3.ME3_10]},
}
service EnumTestService {
MyEnum3 testEnum(1: MyEnum3 enum1),
list<MyEnum3> testEnumList(1: list<MyEnum3> enum1),
set<MyEnum3> testEnumSet(1: set<MyEnum3> enum1),
map<MyEnum3, MyEnum3> testEnumMap(1: map<MyEnum3, MyEnum3> enum1),
EnumTestStruct testEnumStruct(1: EnumTestStruct enum1),
}

View file

@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
namespace java thrift.test.fullcamel
struct OneOfEachZZ {
1: bool im_true,
2: bool im_false,
3: byte a_bite,
4: i16 integer16,
5: i32 integer32,
6: i64 integer64,
7: double double_precision,
8: string some_characters,
9: string zomg_unicode,
10: bool what_who,
}
service UnderscoreSrv {
i64 some_rpc_call(1: string message)
}

24
vendor/git.apache.org/thrift.git/test/Include.thrift generated vendored Normal file
View file

@ -0,0 +1,24 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
include "ThriftTest.thrift"
struct IncludeTest {
1: required ThriftTest.Bools bools
}

View file

@ -0,0 +1,39 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
namespace java thrift.test
struct OneOfEachBeans {
1: bool boolean_field,
2: byte a_bite,
3: i16 integer16,
4: i32 integer32,
5: i64 integer64,
6: double double_precision,
7: string some_characters,
8: binary base64,
9: list<byte> byte_list,
10: list<i16> i16_list,
11: list<i64> i64_list
}
service Service {
i64 mymethod(i64 blah);
}

98
vendor/git.apache.org/thrift.git/test/JavaTypes.thrift generated vendored Normal file
View file

@ -0,0 +1,98 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
namespace java thrift.test
struct Integer {
1: i32 val
}
struct String {
1: string val
}
struct Boolean {
1: bool val
}
struct Double {
1: double val
}
struct Long {
1: i64 val
}
struct Byte {
1: byte val
}
struct Float {
1: double val
}
struct List {
1: list<string> vals
}
struct ArrayList {
1: list<string> vals
}
struct SortedMap {
1: map<string, string> vals
}
struct TreeMap {
1: map<string, string> vals
}
struct HashMap {
1: map<string, String> vals
}
struct Map {
1: map<double, Double> vals
}
struct Object {
1: Integer integer,
2: String str,
3: Boolean boolean_field,
4: Double dbl,
5: Byte bite,
6: map<i32, Integer> intmap,
7: Map somemap,
}
exception Exception {
1: string msg
}
service AsyncNonblockingService {
Object mymethod(
1: Integer integer,
2: String str,
3: Boolean boolean_field,
4: Double dbl,
5: Byte bite,
6: map<i32, Integer> intmap,
7: Map somemap,
) throws (1:Exception ex);
}

View file

@ -0,0 +1,18 @@
struct Simple {
1: string value
}
struct Complex {
1: Simple struct_field
2: list<Simple> struct_list_field
3: set<Simple> struct_set_field
4: map<string,Simple> struct_map_field
5: list<set<map<string,list<Simple>>>> struct_nested_containers_field
6: map<string, list<map<string,Simple>> > struct_nested_containers_field2
7: list<list<string>> list_of_list_field
8: list<list<list<string>>> list_of_list_of_list_field
}
struct ComplexList {
1: list<Complex> struct_list_field;
}

150
vendor/git.apache.org/thrift.git/test/Makefile.am generated vendored Executable file
View file

@ -0,0 +1,150 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
SUBDIRS = features
PRECROSS_TARGET =
if WITH_C_GLIB
SUBDIRS += c_glib
PRECROSS_TARGET += precross-c_glib
endif
if WITH_MONO
SUBDIRS += csharp
PRECROSS_TARGET += precross-csharp
endif
if WITH_CPP
SUBDIRS += cpp
PRECROSS_TARGET += precross-cpp
endif
if WITH_PERL
SUBDIRS += perl
PRECROSS_TARGET += precross-perl
endif
if WITH_PHP
SUBDIRS += php
PRECROSS_TARGET += precross-php
endif
if WITH_DART
SUBDIRS += dart
PRECROSS_TARGET += precross-dart
endif
if WITH_PYTHON
SUBDIRS += py
PRECROSS_TARGET += precross-py
SUBDIRS += py.tornado
if WITH_TWISTED_TEST
SUBDIRS += py.twisted
endif
endif
if WITH_RUBY
SUBDIRS += rb
PRECROSS_TARGET += precross-rb
endif
if WITH_HASKELL
SUBDIRS += hs
endif
if WITH_HAXE
SUBDIRS += haxe
endif
if WITH_GO
SUBDIRS += go
PRECROSS_TARGET += precross-go
endif
if WITH_ERLANG
SUBDIRS += erl
PRECROSS_TARGET += precross-erl
endif
if WITH_LUA
SUBDIRS += lua
PRECROSS_TARGET += precross-lua
endif
#
# generate html for ThriftTest.thrift
#
check-local:
$(top_builddir)/compiler/cpp/thrift --gen html -r $(top_srcdir)/test/ThriftTest.thrift
clean-local:
rm -rf $(top_srcdir)/test/gen-html
EXTRA_DIST = \
audit \
crossrunner \
keys \
c_glib \
cpp \
dart \
erl \
hs \
lua \
ocaml \
perl \
php \
py \
py.twisted \
py.tornado \
rb \
threads \
AnnotationTest.thrift \
BrokenConstants.thrift \
ConstantsDemo.thrift \
DebugProtoTest.thrift \
DenseLinkingTest.thrift \
DocTest.thrift \
EnumTest.thrift \
FullCamelTest.thrift \
Include.thrift \
JavaBeansTest.thrift \
JavaTypes.thrift \
JsDeepConstructorTest.thrift \
ManyOptionals.thrift \
ManyTypedefs.thrift \
NameConflictTest.thrift \
OptionalRequiredTest.thrift \
Recursive.thrift \
ReuseObjects.thrift \
SmallTest.thrift \
StressTest.thrift \
ThriftTest.thrift \
TypedefTest.thrift \
known_failures_Linux.json \
test.py \
tests.json \
rebuild_known_failures.sh \
result.js \
index.html \
README.md \
valgrind.suppress
precross-%:
$(MAKE) -C $* precross
precross: $(PRECROSS_TARGET)

View file

@ -0,0 +1,231 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// The java codegenerator has a few different codepaths depending
// on how many optionals the struct has; this attempts to exercise
// them.
namespace java thrift.test
struct Opt4 {
1: i32 def1;
2: i32 def2;
3: i32 def3;
4: i32 def4;
}
struct Opt13 {
1: i32 def1;
2: i32 def2;
3: i32 def3;
4: i32 def4;
5: i32 def5;
6: i32 def6;
7: i32 def7;
8: i32 def8;
9: i32 def9;
10: i32 def10;
11: i32 def11;
12: i32 def12;
13: i32 def13;
}
struct Opt30 {
1: i32 def1;
2: i32 def2;
3: i32 def3;
4: i32 def4;
5: i32 def5;
6: i32 def6;
7: i32 def7;
8: i32 def8;
9: i32 def9;
10: i32 def10;
11: i32 def11;
12: i32 def12;
13: i32 def13;
14: i32 def14;
15: i32 def15;
16: i32 def16;
17: i32 def17;
18: i32 def18;
19: i32 def19;
20: i32 def20;
21: i32 def21;
22: i32 def22;
23: i32 def23;
24: i32 def24;
25: i32 def25;
26: i32 def26;
27: i32 def27;
28: i32 def28;
29: i32 def29;
30: i32 def30;
}
struct Opt64 {
1: i32 def1;
2: i32 def2;
3: i32 def3;
4: i32 def4;
5: i32 def5;
6: i32 def6;
7: i32 def7;
8: i32 def8;
9: i32 def9;
10: i32 def10;
11: i32 def11;
12: i32 def12;
13: i32 def13;
14: i32 def14;
15: i32 def15;
16: i32 def16;
17: i32 def17;
18: i32 def18;
19: i32 def19;
20: i32 def20;
21: i32 def21;
22: i32 def22;
23: i32 def23;
24: i32 def24;
25: i32 def25;
26: i32 def26;
27: i32 def27;
28: i32 def28;
29: i32 def29;
30: i32 def30;
31: i32 def31;
32: i32 def32;
33: i32 def33;
34: i32 def34;
35: i32 def35;
36: i32 def36;
37: i32 def37;
38: i32 def38;
39: i32 def39;
40: i32 def40;
41: i32 def41;
42: i32 def42;
43: i32 def43;
44: i32 def44;
45: i32 def45;
46: i32 def46;
47: i32 def47;
48: i32 def48;
49: i32 def49;
50: i32 def50;
51: i32 def51;
52: i32 def52;
53: i32 def53;
54: i32 def54;
55: i32 def55;
56: i32 def56;
57: i32 def57;
58: i32 def58;
59: i32 def59;
60: i32 def60;
61: i32 def61;
62: i32 def62;
63: i32 def63;
64: i32 def64;
}
struct Opt80 {
1: i32 def1;
2: i32 def2;
3: i32 def3;
4: i32 def4;
5: i32 def5;
6: i32 def6;
7: i32 def7;
8: i32 def8;
9: i32 def9;
10: i32 def10;
11: i32 def11;
12: i32 def12;
13: i32 def13;
14: i32 def14;
15: i32 def15;
16: i32 def16;
17: i32 def17;
18: i32 def18;
19: i32 def19;
20: i32 def20;
21: i32 def21;
22: i32 def22;
23: i32 def23;
24: i32 def24;
25: i32 def25;
26: i32 def26;
27: i32 def27;
28: i32 def28;
29: i32 def29;
30: i32 def30;
31: i32 def31;
32: i32 def32;
33: i32 def33;
34: i32 def34;
35: i32 def35;
36: i32 def36;
37: i32 def37;
38: i32 def38;
39: i32 def39;
40: i32 def40;
41: i32 def41;
42: i32 def42;
43: i32 def43;
44: i32 def44;
45: i32 def45;
46: i32 def46;
47: i32 def47;
48: i32 def48;
49: i32 def49;
50: i32 def50;
51: i32 def51;
52: i32 def52;
53: i32 def53;
54: i32 def54;
55: i32 def55;
56: i32 def56;
57: i32 def57;
58: i32 def58;
59: i32 def59;
60: i32 def60;
61: i32 def61;
62: i32 def62;
63: i32 def63;
64: i32 def64;
65: i32 def65;
66: i32 def66;
67: i32 def67;
68: i32 def68;
69: i32 def69;
70: i32 def70;
71: i32 def71;
72: i32 def72;
73: i32 def73;
74: i32 def74;
75: i32 def75;
76: i32 def76;
77: i32 def77;
78: i32 def78;
79: i32 def79;
80: i32 def80;
}

View file

@ -0,0 +1,50 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// This is to make sure you don't mess something up when you change typedef code.
// Generate it with the old and new thrift and make sure they are the same.
/*
rm -rf gen-* orig-*
mkdir old new
thrift --gen cpp --gen java --gen php --gen phpi --gen py --gen rb --gen xsd --gen perl --gen ocaml --gen erl --gen hs --strict ManyTypedefs.thrift
mv gen-* old
../compiler/cpp/thrift --gen cpp --gen java --gen php --gen phpi --gen py --gen rb --gen xsd --gen perl --gen ocaml --gen erl --gen hs --strict ManyTypedefs.thrift
mv gen-* new
diff -ur old new
rm -rf old new
# There should be no output.
*/
typedef i32 int32
typedef list<map<int32, string>> biglist
struct struct1 {
1: int32 myint;
2: biglist mylist;
}
exception exception1 {
1: biglist alist;
2: struct1 mystruct;
}
service AService {
struct1 method1(1: int32 myint) throws (1: exception1 exn);
biglist method2();
}

View file

@ -0,0 +1,110 @@
// Naming testcases, sepcifically for these tickets (but not limited to them)
// THRIFT-2508 Uncompileable C# code due to language keywords in IDL
// THRIFT-2557 error CS0542 member names cannot be the same as their enclosing type
struct using {
1: double single
2: double integer
}
struct delegate {
1: string partial
2: delegate delegate
}
struct get {
1: bool sbyte
}
struct partial {
1: using using
2: bool read
3: bool write
}
enum Maybe {
JUST = 1,
TRUE = 2,
FALSE = 3
}
enum Either {
LEFT = 1,
RIGHT = 2
}
struct foldr {
1: string id
}
struct of {
1: string let
2: string where
}
struct ofOf {
1: of Of
}
struct ClassAndProp {
1: bool ClassAndProp
2: bool ClassAndProp_
3: bool ClassAndProp__
4: bool ClassAndProper
}
struct second_chance {
1: bool SECOND_CHANCE
2: bool SECOND_CHANCE_
3: bool SECOND_CHANCE__
4: bool SECOND_CHANCES
}
struct NOW_EAT_THIS {
1: bool now_eat_this
2: bool now_eat_this_
3: bool now_eat_this__
4: bool now_eat_this_and_this
}
struct TheEdgeCase {
1: bool theEdgeCase
2: bool theEdgeCase_
3: bool theEdgeCase__
4: bool TheEdgeCase
5: bool TheEdgeCase_
6: bool TheEdgeCase__
}
struct Tricky_ {
1: bool tricky
2: bool Tricky
}
struct Nested {
1: ClassAndProp ClassAndProp
2: second_chance second_chance
3: NOW_EAT_THIS NOW_EAT_THIS
4: TheEdgeCase TheEdgeCase
5: Tricky_ Tricky_
6: Nested Nested
}
exception Problem_ {
1: bool problem
2: bool Problem
}
service extern {
delegate event(1: partial get)
void Foo(1: Nested Foo_args) throws (1: Problem_ Foo_result)
}
service qualified {
Maybe maybe(1: Maybe foldr)
Either either(1: foldr of)
}
// eof

View file

@ -0,0 +1,88 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* Contains some contributions under the Thrift Software License.
* Please see doc/old-thrift-license.txt in the Thrift distribution for
* details.
*/
namespace c_glib TTest
namespace cpp thrift.test
namespace java thrift.test
struct OldSchool {
1: i16 im_int;
2: string im_str;
3: list<map<i32,string>> im_big;
}
struct Simple {
1: /* :) */ i16 im_default;
2: required i16 im_required;
3: optional i16 im_optional;
}
struct Tricky1 {
1: /* :) */ i16 im_default;
}
struct Tricky2 {
1: optional i16 im_optional;
}
struct Tricky3 {
1: required i16 im_required;
}
struct OptionalDefault {
1: optional i16 opt_int = 1234;
2: optional string opt_str = "default";
}
struct Complex {
1: i16 cp_default;
2: required i16 cp_required;
3: optional i16 cp_optional;
4: map<i16,Simple> the_map;
5: required Simple req_simp;
6: optional Simple opt_simp;
}
struct ManyOpt {
1: optional i32 opt1;
2: optional i32 opt2;
3: optional i32 opt3;
4: i32 def4;
5: optional i32 opt5;
6: optional i32 opt6;
}
struct JavaTestHelper {
1: required i32 req_int;
2: optional i32 opt_int;
3: required string req_obj;
4: optional string opt_obj;
5: required binary req_bin;
6: optional binary opt_bin;
}
struct Binaries {
4: binary bin;
5: required binary req_bin;
6: optional binary opt_bin;
}

185
vendor/git.apache.org/thrift.git/test/README.md generated vendored Executable file
View file

@ -0,0 +1,185 @@
# Apache Thrift - integration test suite
This is the cross everything integration test suite for Apache Thrift.
## Run
### A. Using Make
The test can be executed by:
make cross
This starts the [test.py](test.py) script which does the real cross test with
different transports, protocols and languages.
Note that this skips any language that is not built locally. It also skips
tests that are known to be failing. If you need more control over which tests
to run, read following section.
### B. Using test script directly
Alternatively, you can invoke [test.py](test.py) directly. You need to run`make
precross` once before executing it for the first time.
For example, if you changed something in `nodejs` library and need to verify
the patch, you can skip everything except `nodejs` itself and some reference
implementation (currently `cpp` and `java` are recommended) like this:
./configure --without-c_glib -without-csharp --without-erlang --without-lua ...
make precross -j8
test/test.py --server cpp,java --client nodejs
test/test.py --server nodejs --client cpp,java
Another useful flag is --regex. For example, to run all tests that involve
Java TBinaryProtocol:
test/test.py --regex "java.*binary"
## Test case definition file
The cross test cases are defined in [tests.json](tests.json).
The root element is collection of test target definitions.
Each test target definition looks like this:
{
"name": "somelib",
"client": {
"command": ["somelib_client_executable"],
"workdir": "somelib/bin",
"protocols": ["binary"],
"transports": ["buffered"],
"sockets": ["ip"],
},
"server": {
"command": ["somelib_server_executable"],
"workdir": "somelib/bin",
"protocols": ["binary"],
"transports": ["buffered"],
"sockets": ["ip", "ip-ssl"],
}
}
Either client or server definition or both should be present.
Parameters that are common to both `client` and `server` can be put to target
definition root:
{
"name": "somelib",
"workdir": "somelib/bin",
"protocols": ["binary"],
"transports": ["buffered"],
"sockets": ["ip"],
"client": { "command": ["somelib_client_executable"] },
"server": {
"command": ["somelib_server_executable"],
"sockets": ["ip-ssl"]
}
}
For the complete list of supported keys and their effect, see source code
comment at the opt of [crossrunner/collect.py](crossrunner/collect.py).
## List of known failures
Since many cross tests currently fail (mainly due to partial incompatibility
around exception handling), the test script specifically report for "not known
before" failures.
For this purpose, test cases known to (occasionally) fail are listed in
`known_failures_<platform>.json` where `<platform>` matches with python
`platform.system()` string.
Currently, only Linux version is included.
FYI, the file is initially generated by
test/test.py --update-expected-failures=overwrite
after a full test run, then repeatedly
test/test.py --skip-known-failures
test/test.py --update-expected-failures=merge
to update the known failures, run
make fail
## Test executable specification
### Command line parameters
Unit tests for languages are usually located under lib/<lang>/test/
cross language tests according to [ThriftTest.thrift](ThriftTest.thrift) shall be
provided for every language including executables with the following command
line interface:
**Server command line interface:**
$ ./cpp/TestServer -h
Allowed options:
-h [ --help ] produce help message
--port arg (=9090) Port number to listen
--domain-socket arg Unix Domain Socket (e.g. /tmp/ThriftTest.thrift)
--named-pipe arg Windows Named Pipe (e.g. MyThriftPipe)
--server-type arg (=simple) type of server, "simple", "thread-pool",
"threaded", or "nonblocking"
--transport arg (=buffered) transport: buffered, framed, http, anonpipe
--protocol arg (=binary) protocol: binary, compact, json
--ssl Encrypted Transport using SSL
--processor-events processor-events
-n [ --workers ] arg (=4) Number of thread pools workers. Only valid for
thread-pool server type
**Client command line interface:**
$ ./cpp/TestClient -h
Allowed options:
-h [ --help ] produce help message
--host arg (=localhost) Host to connect
--port arg (=9090) Port number to connect
--domain-socket arg Domain Socket (e.g. /tmp/ThriftTest.thrift),
instead of host and port
--named-pipe arg Windows Named Pipe (e.g. MyThriftPipe)
--anon-pipes hRead hWrite Windows Anonymous Pipes pair (handles)
--transport arg (=buffered) Transport: buffered, framed, http, evhttp
--protocol arg (=binary) Protocol: binary, compact, json
--ssl Encrypted Transport using SSL
-n [ --testloops ] arg (=1) Number of Tests
-t [ --threads ] arg (=1) Number of Test threads
If you have executed the **make check** or **make cross** then you will be able to browse
[gen-html/ThriftTest.html](gen-html/ThriftTest.html) with the test documentation.
### Return code
The return code (exit code) shall be 0 on success, or an integer in the range 1 - 255 on errors.
In order to signal failed tests, the return code shall be composed from these bits to indicate
failing tests:
#define TEST_BASETYPES 1 // 0000 0001
#define TEST_STRUCTS 2 // 0000 0010
#define TEST_CONTAINERS 4 // 0000 0100
#define TEST_EXCEPTIONS 8 // 0000 1000
#define TEST_UNKNOWN 64 // 0100 0000 (Failed to prepare environemt etc.)
#define TEST_TIMEOUT 128 // 1000 0000
#define TEST_NOTUSED 48 // 0011 0000 (reserved bits)
Tests that have not been executed at all count as errors.
**Example:**
During tests, the test client notices that some of the Struct tests fail.
Furthermore, due to some other problem none of the Exception tests is executed.
Therefore, the test client returns the code `10 = 2 | 8`, indicating the failure
of both test 2 (TEST_STRUCTS) and test 8 (TEST_EXCEPTIONS).
## SSL
Test Keys and Certificates are provided in multiple formats under the following
directory [test/keys](keys)

47
vendor/git.apache.org/thrift.git/test/Recursive.thrift generated vendored Normal file
View file

@ -0,0 +1,47 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
struct RecTree {
1: list<RecTree> children
2: i16 item
}
struct RecList {
1: RecList & nextitem
3: i16 item
}
struct CoRec {
1: CoRec2 & other
}
struct CoRec2 {
1: CoRec other
}
struct VectorTest {
1: list<RecList> lister;
}
service TestService
{
RecTree echoTree(1:RecTree tree)
RecList echoList(1:RecList lst)
CoRec echoCoRec(1:CoRec item)
}

View file

@ -0,0 +1,30 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// The java codegenerator has option to reuse objects for deserialization
namespace java thrift.test
include "ThriftTest.thrift"
struct Reuse {
1: i32 val1;
2: set<string> val2;
}

60
vendor/git.apache.org/thrift.git/test/SmallTest.thrift generated vendored Normal file
View file

@ -0,0 +1,60 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
namespace rb TestNamespace
struct Goodbyez {
1: i32 val = 325;
}
senum Thinger {
"ASDFKJ",
"r32)*F#@",
"ASDFLJASDF"
}
struct BoolPasser {
1: bool value = 1
}
struct Hello {
1: i32 simple = 53,
2: map<i32,i32> complex = {23:532, 6243:632, 2355:532},
3: map<i32, map<i32,i32>> complexer,
4: string words = "words",
5: Goodbyez thinz = {'val' : 36632}
}
const map<i32,map<i32,i32>> CMAP = { 235: {235:235}, 53:{53:53} }
const i32 CINT = 325;
const Hello WHOA = {'simple' : 532}
exception Goodbye {
1: i32 simple,
2: map<i32,i32> complex,
3: map<i32, map<i32,i32>> complexer,
}
service SmallService {
Thinger testThinger(1:Thinger bootz),
Hello testMe(1:i32 hello=64, 2: Hello wonk) throws (1: Goodbye g),
void testVoid() throws (1: Goodbye g),
i32 testI32(1:i32 boo)
}

View file

@ -0,0 +1,35 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
namespace cpp test.stress
namespace d thrift.test.stress
namespace go stress
service Service {
void echoVoid(),
i8 echoByte(1: i8 arg),
i32 echoI32(1: i32 arg),
i64 echoI64(1: i64 arg),
string echoString(1: string arg),
list<i8> echoList(1: list<i8> arg),
set<i8> echoSet(1: set<i8> arg),
map<i8, i8> echoMap(1: map<i8, i8> arg),
}

411
vendor/git.apache.org/thrift.git/test/ThriftTest.thrift generated vendored Normal file
View file

@ -0,0 +1,411 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* Contains some contributions under the Thrift Software License.
* Please see doc/old-thrift-license.txt in the Thrift distribution for
* details.
*/
namespace c_glib TTest
namespace java thrift.test
namespace cpp thrift.test
namespace rb Thrift.Test
namespace perl ThriftTest
namespace csharp Thrift.Test
namespace js ThriftTest
namespace st ThriftTest
namespace py ThriftTest
namespace py.twisted ThriftTest
namespace go thrifttest
namespace php ThriftTest
namespace delphi Thrift.Test
namespace cocoa ThriftTest
namespace lua ThriftTest
namespace xsd test (uri = 'http://thrift.apache.org/ns/ThriftTest')
// Presence of namespaces and sub-namespaces for which there is
// no generator should compile with warnings only
namespace noexist ThriftTest
namespace cpp.noexist ThriftTest
namespace * thrift.test
/**
* Docstring!
*/
enum Numberz
{
ONE = 1,
TWO,
THREE,
FIVE = 5,
SIX,
EIGHT = 8
}
const Numberz myNumberz = Numberz.ONE;
// the following is expected to fail:
// const Numberz urNumberz = ONE;
typedef i64 UserId
struct Bonk
{
1: string message,
2: i32 type
}
typedef map<string,Bonk> MapType
struct Bools {
1: bool im_true,
2: bool im_false,
}
struct Xtruct
{
1: string string_thing,
4: i8 byte_thing,
9: i32 i32_thing,
11: i64 i64_thing
}
struct Xtruct2
{
1: i8 byte_thing, // used to be byte, hence the name
2: Xtruct struct_thing,
3: i32 i32_thing
}
struct Xtruct3
{
1: string string_thing,
4: i32 changed,
9: i32 i32_thing,
11: i64 i64_thing
}
struct Insanity
{
1: map<Numberz, UserId> userMap,
2: list<Xtruct> xtructs
} (python.immutable= "")
struct CrazyNesting {
1: string string_field,
2: optional set<Insanity> set_field,
// Do not insert line break as test/go/Makefile.am is removing this line with pattern match
3: required list<map<set<i32> (python.immutable = ""), map<i32,set<list<map<Insanity,string>(python.immutable = "")> (python.immutable = "")>>>> list_field,
4: binary binary_field
}
union SomeUnion {
1: map<Numberz, UserId> map_thing,
2: string string_thing,
3: i32 i32_thing,
4: Xtruct3 xtruct_thing,
5: Insanity insanity_thing
}
exception Xception {
1: i32 errorCode,
2: string message
}
exception Xception2 {
1: i32 errorCode,
2: Xtruct struct_thing
}
struct EmptyStruct {}
struct OneField {
1: EmptyStruct field
}
service ThriftTest
{
/**
* Prints "testVoid()" and returns nothing.
*/
void testVoid(),
/**
* Prints 'testString("%s")' with thing as '%s'
* @param string thing - the string to print
* @return string - returns the string 'thing'
*/
string testString(1: string thing),
/**
* Prints 'testBool("%s")' where '%s' with thing as 'true' or 'false'
* @param bool thing - the bool data to print
* @return bool - returns the bool 'thing'
*/
bool testBool(1: bool thing),
/**
* Prints 'testByte("%d")' with thing as '%d'
* The types i8 and byte are synonyms, use of i8 is encouraged, byte still exists for the sake of compatibility.
* @param byte thing - the i8/byte to print
* @return i8 - returns the i8/byte 'thing'
*/
i8 testByte(1: i8 thing),
/**
* Prints 'testI32("%d")' with thing as '%d'
* @param i32 thing - the i32 to print
* @return i32 - returns the i32 'thing'
*/
i32 testI32(1: i32 thing),
/**
* Prints 'testI64("%d")' with thing as '%d'
* @param i64 thing - the i64 to print
* @return i64 - returns the i64 'thing'
*/
i64 testI64(1: i64 thing),
/**
* Prints 'testDouble("%f")' with thing as '%f'
* @param double thing - the double to print
* @return double - returns the double 'thing'
*/
double testDouble(1: double thing),
/**
* Prints 'testBinary("%s")' where '%s' is a hex-formatted string of thing's data
* @param binary thing - the binary data to print
* @return binary - returns the binary 'thing'
*/
binary testBinary(1: binary thing),
/**
* Prints 'testStruct("{%s}")' where thing has been formatted into a string of comma separated values
* @param Xtruct thing - the Xtruct to print
* @return Xtruct - returns the Xtruct 'thing'
*/
Xtruct testStruct(1: Xtruct thing),
/**
* Prints 'testNest("{%s}")' where thing has been formatted into a string of the nested struct
* @param Xtruct2 thing - the Xtruct2 to print
* @return Xtruct2 - returns the Xtruct2 'thing'
*/
Xtruct2 testNest(1: Xtruct2 thing),
/**
* Prints 'testMap("{%s")' where thing has been formatted into a string of 'key => value' pairs
* separated by commas and new lines
* @param map<i32,i32> thing - the map<i32,i32> to print
* @return map<i32,i32> - returns the map<i32,i32> 'thing'
*/
map<i32,i32> testMap(1: map<i32,i32> thing),
/**
* Prints 'testStringMap("{%s}")' where thing has been formatted into a string of 'key => value' pairs
* separated by commas and new lines
* @param map<string,string> thing - the map<string,string> to print
* @return map<string,string> - returns the map<string,string> 'thing'
*/
map<string,string> testStringMap(1: map<string,string> thing),
/**
* Prints 'testSet("{%s}")' where thing has been formatted into a string of values
* separated by commas and new lines
* @param set<i32> thing - the set<i32> to print
* @return set<i32> - returns the set<i32> 'thing'
*/
set<i32> testSet(1: set<i32> thing),
/**
* Prints 'testList("{%s}")' where thing has been formatted into a string of values
* separated by commas and new lines
* @param list<i32> thing - the list<i32> to print
* @return list<i32> - returns the list<i32> 'thing'
*/
list<i32> testList(1: list<i32> thing),
/**
* Prints 'testEnum("%d")' where thing has been formatted into it's numeric value
* @param Numberz thing - the Numberz to print
* @return Numberz - returns the Numberz 'thing'
*/
Numberz testEnum(1: Numberz thing),
/**
* Prints 'testTypedef("%d")' with thing as '%d'
* @param UserId thing - the UserId to print
* @return UserId - returns the UserId 'thing'
*/
UserId testTypedef(1: UserId thing),
/**
* Prints 'testMapMap("%d")' with hello as '%d'
* @param i32 hello - the i32 to print
* @return map<i32,map<i32,i32>> - returns a dictionary with these values:
* {-4 => {-4 => -4, -3 => -3, -2 => -2, -1 => -1, }, 4 => {1 => 1, 2 => 2, 3 => 3, 4 => 4, }, }
*/
map<i32,map<i32,i32>> testMapMap(1: i32 hello),
/**
* So you think you've got this all worked, out eh?
*
* Creates a the returned map with these values and prints it out:
* { 1 => { 2 => argument,
* 3 => argument,
* },
* 2 => { 6 => <empty Insanity struct>, },
* }
* @return map<UserId, map<Numberz,Insanity>> - a map with the above values
*/
map<UserId, map<Numberz,Insanity>> testInsanity(1: Insanity argument),
/**
* Prints 'testMulti()'
* @param i8 arg0 -
* @param i32 arg1 -
* @param i64 arg2 -
* @param map<i16, string> arg3 -
* @param Numberz arg4 -
* @param UserId arg5 -
* @return Xtruct - returns an Xtruct with string_thing = "Hello2, byte_thing = arg0, i32_thing = arg1
* and i64_thing = arg2
*/
Xtruct testMulti(1: i8 arg0, 2: i32 arg1, 3: i64 arg2, 4: map<i16, string> arg3, 5: Numberz arg4, 6: UserId arg5),
/**
* Print 'testException(%s)' with arg as '%s'
* @param string arg - a string indication what type of exception to throw
* if arg == "Xception" throw Xception with errorCode = 1001 and message = arg
* elsen if arg == "TException" throw TException
* else do not throw anything
*/
void testException(1: string arg) throws(1: Xception err1),
/**
* Print 'testMultiException(%s, %s)' with arg0 as '%s' and arg1 as '%s'
* @param string arg - a string indication what type of exception to throw
* if arg0 == "Xception" throw Xception with errorCode = 1001 and message = "This is an Xception"
* elsen if arg0 == "Xception2" throw Xception2 with errorCode = 2002 and struct_thing.string_thing = "This is an Xception2"
* else do not throw anything
* @return Xtruct - an Xtruct with string_thing = arg1
*/
Xtruct testMultiException(1: string arg0, 2: string arg1) throws(1: Xception err1, 2: Xception2 err2)
/**
* Print 'testOneway(%d): Sleeping...' with secondsToSleep as '%d'
* sleep 'secondsToSleep'
* Print 'testOneway(%d): done sleeping!' with secondsToSleep as '%d'
* @param i32 secondsToSleep - the number of seconds to sleep
*/
oneway void testOneway(1:i32 secondsToSleep)
}
service SecondService
{
void blahBlah()
/**
* Prints 'testString("%s")' with thing as '%s'
* @param string thing - the string to print
* @return string - returns the string 'thing'
*/
string secondtestString(1: string thing),
}
struct VersioningTestV1 {
1: i32 begin_in_both,
3: string old_string,
12: i32 end_in_both
}
struct VersioningTestV2 {
1: i32 begin_in_both,
2: i32 newint,
3: i8 newbyte,
4: i16 newshort,
5: i64 newlong,
6: double newdouble
7: Bonk newstruct,
8: list<i32> newlist,
9: set<i32> newset,
10: map<i32, i32> newmap,
11: string newstring,
12: i32 end_in_both
}
struct ListTypeVersioningV1 {
1: list<i32> myints;
2: string hello;
}
struct ListTypeVersioningV2 {
1: list<string> strings;
2: string hello;
}
struct GuessProtocolStruct {
7: map<string,string> map_field,
}
struct LargeDeltas {
1: Bools b1,
10: Bools b10,
100: Bools b100,
500: bool check_true,
1000: Bools b1000,
1500: bool check_false,
2000: VersioningTestV2 vertwo2000,
2500: set<string> a_set2500,
3000: VersioningTestV2 vertwo3000,
4000: list<i32> big_numbers
}
struct NestedListsI32x2 {
1: list<list<i32>> integerlist
}
struct NestedListsI32x3 {
1: list<list<list<i32>>> integerlist
}
struct NestedMixedx2 {
1: list<set<i32>> int_set_list
2: map<i32,set<string>> map_int_strset
3: list<map<i32,set<string>>> map_int_strset_list
}
struct ListBonks {
1: list<Bonk> bonk
}
struct NestedListsBonk {
1: list<list<list<Bonk>>> bonk
}
struct BoolTest {
1: optional bool b = true;
2: optional string s = "true";
}
struct StructA {
1: required string s;
}
struct StructB {
1: optional StructA aa;
2: required StructA ab;
}

View file

@ -0,0 +1,36 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* Contains some contributions under the Thrift Software License.
* Please see doc/old-thrift-license.txt in the Thrift distribution for
* details.
*/
namespace cpp thrift.test
typedef i32 MyInt32
typedef string MyString;
struct TypedefTestStruct {
1: MyInt32 field_MyInt32;
2: MyString field_MyString;
3: i32 field_Int32;
4: string field_String;
}
typedef TypedefTestStruct MyStruct,

40
vendor/git.apache.org/thrift.git/test/audit/README.md generated vendored Normal file
View file

@ -0,0 +1,40 @@
Typical usage
=============
```
thrift.exe --audit <oldFile> <newFile>
```
Example run
===========
```
> thrift.exe --audit test.thrift break1.thrift
[Thrift Audit Failure:break1.thrift] New Thrift File has missing function base_function3
[Thrift Audit Warning:break1.thrift] Constant const3 has different value
```
Problems that the audit tool can catch
======================================
Errors
* Removing an enum value
* Changing the type of a struct field
* Changing the required-ness of a struct field
* Removing a struct field
* Adding a required struct field
* Adding a struct field 'in the middle'. This usually indicates an old ID has been recycled
* Struct removed
* Oneway-ness change
* Return type change
* Missing function
* Missing service
* Change in service inheritance
Warnings
* Removing a language namespace declaration
* Changing a namespace
* Changing an enum value's name
* Removing an enum class
* Default value changed
* Struct field name change
* Removed constant
* Type of constant changed
* Value of constant changed

View file

@ -0,0 +1,188 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//Thrift Method removed from service base.
namespace cpp test
//constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3= [23, 32],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,190 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//break10 - Struct field removed from struct2 id =1
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,190 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//break11 - Struct field removed from struct3 id =7
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,191 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// derived1_function1 return type changed from enum1 to enum2
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum2 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,191 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// derived1_function6 return type changed from struct1 to struct2
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct2 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,190 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// derived1_function6 return type changed from string to double
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
double derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,190 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// break15 - derived2_function1 return type changed from list<i32> to list<i16>
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i16> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,191 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// break 16 - derived2_function5 return type changed from map<test_enum1, test_enum2> to map<test_enum3, test_enum2>
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum3, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,191 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//break17 - derived2_function6 return type changed from map<struct1,struct2> to map<struct1, struct3>
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct3> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,191 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//break18- oneway removed from base_oneway
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,191 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//break19 - oneway added to base_function1
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
oneway void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,190 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//Struct field changed in test_struct1
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i32 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,190 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// break 20 - first enum value removed from enum1
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,190 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//break21- last enum value removed from enum2
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,190 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//break22 - in-between enum value removed from enum1
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,192 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//break23 - required struct field added to struct4
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2,
3: required i64 struct4_member3
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,191 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//break24 - removed inheritance from derived1.
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,191 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//Changed inheritance of derived2
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends derived1 {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,191 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//break26 - Field type changed in base_function1 argument id=3
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: double function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,190 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// break27 - argument changed base_function2 list<enum1> to list<enum3> id =8
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum3> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,190 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//break28- derived1_function5 arguement type changed map<i64, double> to list<i64>
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: list<i64> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,191 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//break29 - base_function2 arguemnt type changed list<string> to string
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: string function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,191 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//break3 - Struct field changed in test_struct1(enum1 to enum2)
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum2 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,190 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// break30- derived1_function6 argument changed struct1 to map<struct1,struct1>
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
map<test_struct1,test_struct1> derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,191 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//break31 - Exception removed to base_function2
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,191 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//break32- Exception1 field type changed for id =1
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i64 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,191 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//break33 - derived1_function1 exception type changed.
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception1 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,192 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//break34 - Field added to struct with Field ID being in between two existing field IDs
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
6: map<test_enum1, test_enum2> struct3_member6,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,190 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//Field type changed in test_struct1(bool to string)
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: string struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 =[23, 32],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,190 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// member field type changed in test_struct1(bool to list<bool>)
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: list<bool> struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,191 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Field type changed in test_struct2 (list<double> to list<i16>)
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<i16> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,190 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//break7 - requiredness removed in struct6
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,191 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//break8 - requiredness addedd in struct5
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: required string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,190 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//break9 - Struct field removed from struct1
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

189
vendor/git.apache.org/thrift.git/test/audit/test.thrift generated vendored Normal file
View file

@ -0,0 +1,189 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.3;
const map<string,string> const3 = {"hello":"world", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.5,
5: string struct1_member5 = "Audit test",
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 struct1_member9
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> struct2_member2,
3: list<i64> struct2_member3 = [23, 32 ],
4: list<double> struct2_member4,
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:2, 3:4},
2: map<i64, double> struct3_member2 = {10:1.1, 20:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1,
2: string struct5_member2 = "Thrift Audit Test"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base {
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

View file

@ -0,0 +1,261 @@
#!/usr/bin/perl -w
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#break1 - Thrift method removed from service base
#break2 - Struct field changed in test_struct1(i16 to i32)
#break3 - Struct field changed in test_struct1(enum1 to enum2)
#break4 - Field type changed in test_struct1(bool to string)
#break5- member field type changed in test_struct1(bool to list<bool>)
#break6- Field type changed in test_struct2 (list<double> to list<i16>)
#break7 - requiredness removed in struct6
#break8 - requiredness addedd in struct5
#break9 - Struct field removed from struct1
#break10 - Struct field removed from struct2 id = 1
#break11 - Struct field removed from struct3 last id
#break12 - derived1_function1 return type changed from enum1 to enum2
#break13 - derived1_function6 return type changed from struct1 to struct2
#break14 - derived1_function4 return type changed from string to double
#break15 - derived2_function1 return type changed from list<i32> to list<i16>
#break16 - derived2_function5 return type changed from map<test_enum1,test_enum2> to map<test_enum3, test_enum2>
#break17 - derived2_function6 return type changed from map<struct1,struct2> to map<struct1, struct3>
#break18- oneway removed from base_oneway
#break19 - oneway added to base_function1
#break20 - first enum value removed from enum1
#break21- last enum value removed from enum2
#break22 - in-between enum value removed from enum1
#break23 - required struct field added to struct4
#break24 - removed inheritance of derived1.
#break25 - changed inheritance of derived2.
#break26 - Field type changed in base_function1 argument id=3
#break27 - argument changed base_function2 list<enum1> to list<enum3> id =8
#break28- derived1_function5 arguement type changed map<i64, double> to list<i64>
#break29 - base_function2 arguemnt type changed list<string> to string
#break30- derived1_function6 argument changed struct1 to map<struct1,struct1>
#break31 - Exception removed to base_function2
#break32- Exception1 field type changed for id =1
#break33 - derived1_function1 exception type changed.
#break34 - Field added to struct with Field ID being in between two existing field IDs
#warning.thrift
#Changing defaults
#Id=1 struct5
#id=2 struct5
#id=4 struct2(list<double>)
#id=3 struct2(list<i64> default values removed)
#id 4 struct1 change in double value
#id 5 struct1 (default string value removed)
#id=1 struct3 (change in map values)
#id2 struct3 (change in map keys)
#change in inheritance for derived1 and derived2
#change in struct field names
#id9 struct1
#id2 struct2
use strict;
use warnings;
use Getopt::Std;
# globals
my $gArguments = ""; # arguments that will be passed to AuditTool
my $gAuditToolPath = "";
my $gPreviousThriftPath; # previous thrift path
my $gCurrentThriftPath; # current thrift path
my $gThriftFileFolder;
my $gBreakingFilesCount =34;
my $gVerbose = 0;
#functions
sub auditBreakingChanges;
sub auditNonBreakingChanges;
main();
sub main
{
parseOptions();
auditBreakingChanges();
auditNonBreakingChanges();
}
sub parseOptions
{
my %options = ();
if ( getopts ('vf:o:t:',\%options) )
{
# current (new) thrift folder
if ($options{'f'})
{
$gThriftFileFolder = $options{'f'};
$gPreviousThriftPath = $gThriftFileFolder."/test.thrift";
}
else
{
die "Missing Folder containing thrift files\n";
}
if($options{'t'})
{
$gAuditToolPath = $options{'t'};
}
else
{
die "Audit Tool Path required \n";
}
if ($options{'v'})
{
$gVerbose = 1;
}
}
}
sub auditBreakingChanges
{
my $breakingFileBaseName = $gThriftFileFolder."/break";
my $newThriftFile;
for(my $i=1; $i <= $gBreakingFilesCount; $i++)
{
$newThriftFile = $breakingFileBaseName."$i.thrift";
my $arguments = $gPreviousThriftPath." ".$newThriftFile;
my ($exitCode, $output) = callThriftAuditTool($arguments);
print $output if $gVerbose eq 1;
if($exitCode == 1)
{
# thrift_audit returns 1 when it is not able to find files or other non-audit failures
print "exiting with exit code =1 i = ".$i."\n";
print $output;
exit $exitCode;
}
if($exitCode != 2)
{
# thrift-audit return 2 for audit failures. So for Breaking changes we should get 2 as return value.
print $output;
die "\nTEST FAILURE: Breaking Change not detected for thrift file $newThriftFile, code=$exitCode \n";
}
if(index($output,getMessageSubString("break$i")) == -1)
{
#Audit tool detected failure, but not the expected one. The change in breaking thrift file does not match getMessageSubString()
print $output;
die "\nTest FAILURE: Audit tool detected failure, but not the expected one!\n";
}
else
{
#Thrift audit tool has detected audit failure and has returned exited to status code 2
print "Test Pass: Audit Failure detected for thrift file break$i.thrift \n";
}
}
}
sub auditNonBreakingChanges
{
my $breakingFileBaseName = $gThriftFileFolder."/warning";
my $newThriftFile;
$newThriftFile = $breakingFileBaseName.".thrift";
my $arguments = $gPreviousThriftPath." ".$newThriftFile;
my ($exitCode, $output) = callThriftAuditTool($arguments);
print $output if $gVerbose eq 1;
if($exitCode == 1)
{
# thrift_audit returns 1 when it is not able to find files or other non-audit failures
print "exiting with exit code = 1 for file warning.thrift\n";
exit $exitCode;
}
elsif($exitCode != 0)
{
# thrift-audit return 0 if there are no audit failures.
die "\nTEST FAILURE: Non Breaking changes returned failure for thrift file $newThriftFile \n";
}
else
{
#Thrift audit tool has exited with status 0.
print "Test Pass: Audit tool exits with success for warnings \n";
}
}
# -----------------------------------------------------------------------------------------------------
# call thriftAuditTool script
sub callThriftAuditTool ( $ )
{
my $args = shift;
my $command = "$gAuditToolPath --audit $args";
my $output = `$command 2>&1`;
my $exitCode = $? >> 8;
return ($exitCode,$output);
}
sub getMessageSubString( $ )
{
my $fileName = shift;
my %lookupTable = (
"break1" => "base_function3",
"break2" => "test_struct1",
"break3" => "test_struct1",
"break4" => "test_struct1",
"break5" => "test_struct1",
"break6" => "test_struct2",
"break7" => "test_struct6",
"break8" => "test_struct5",
"break9" => "test_struct1",
"break10" => "test_struct2",
"break11" => "test_struct3",
"break12" => "derived1_function1",
"break13" => "derived1_function6",
"break14" => "derived1_function4",
"break15" => "derived2_function1",
"break16" => "derived2_function5",
"break17" => "derived2_function6",
"break18" => "base_oneway",
"break19" => "base_function1",
"break20" => "test_enum1",
"break21" => "test_enum2",
"break22" => "test_enum1",
"break23" => "test_struct4",
"break24" => "derived1",
"break25" => "derived2",
"break26" => "base_function1",
"break27" => "base_function2_args",
"break28" => "derived1_function5_args",
"break29" => "base_function2_args",
"break30" => "derived1_function6",
"break31" => "base_function2_exception",
"break32" => "test_exception1",
"break33" => "derived1_function1_exception",
"break34" => "test_struct3",
);
if (not exists $lookupTable{ $fileName })
{
print "in the null case\n";
return "NULL";
}
my $retval = $lookupTable{ $fileName };
print "$fileName => $retval\n";
return $lookupTable{ $fileName };
}

View file

@ -0,0 +1,190 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
namespace cpp test
//Constants
const i32 const1 = 123;
const double const2 = 23.2;
const map<string,string> const3 = {"hello":"class", "thrift":"audit"};
//Exception
exception test_exception1 {
1: i32 code;
2: string json;
}
exception test_exception2 {
1: i32 code;
2: string json;
}
//Enums
enum test_enum1 {
enum1_value0 = 0,
enum1_value1 = 1,
enum1_value2 = 2,
enum1_value5 = 5,
enum1_value7 = 7,
enum1_value8 = 8
}
enum test_enum2 {
enum2_value0 = 0,
enum2_value1 = 1,
enum2_value2 = 2,
enum2_value3 = 3
}
enum test_enum3 {
enum3_value1 = 0,
enum3_value2 = 1
}
struct test_struct1 {
1: i16 struct1_member1,
2: i32 struct1_member2,
3: i64 struct1_member3,
4: double struct1_member4 = 2.4,
5: string struct1_member5,
6: bool struct1_member6,
7: byte struct1_member7,
8: binary struct1_member8,
9: test_enum1 changed19
}
struct test_struct2 {
1: list<i16> struct2_member1,
2: list<i32> changed22,
3: list<i64> struct2_member3,
4: list<double> struct2_member4 =[1.0, 2.1],
5: list<string> struct2_member5,
6: list<bool> struct2_member6,
7: list<byte> struct2_member7,
8: list<binary> struct2_member8,
9: list<test_enum1> struct2_member9
}
struct test_struct3 {
1: map<i16, i32> struct3_member1 = {1:10, 2:20},
2: map<i64, double> struct3_member2 = {1:1.1, 2:2.1},
3: map<string, bool> struct3_member3,
4: map<byte, test_enum1> struct3_member4,
5: map<test_enum2, test_enum3 > struct3_member5,
7: map<double, string> struct3_member7
}
struct test_struct4 {
1: i32 struct4_member1,
2: optional i32 struct4_member2
}
struct test_struct5{
1: double struct5_member1 = 1.1,
2: string struct5_member2 = "Thrift Audit Tess"
}
struct test_struct6 {
1: i32 struct6_member1,
2: required i32 struct6_member2
}
service base {
oneway void base_oneway(
1: i32 arg1),
void base_function1(
1: i16 function1_arg1,
2: i32 function1_arg2,
3: i64 function1_arg3,
4: double function1_arg4,
5: string function1_arg5,
6: bool function1_arg6,
7: test_enum1 function1_arg7,
8: test_struct1 function1_arg8),
void base_function2(
1: list<i16> function2_arg1,
2: list<i32> function2_arg2,
3: list<i64> function2_arg3,
4: list<double> function2_arg4,
5: list<string> function2_arg5,
6: list<bool> function2_arg6,
7: list<byte> function2_arg7,
8: list<test_enum1> function2_arg8,
9: list<test_struct1> function2_arg9) throws (1:test_exception2 e),
void base_function3(),
}
service derived1 extends base{
test_enum1 derived1_function1(
1: i64 function1_arg1,
2: double function1_arg2,
3: test_enum1 function1_arg3) throws (1:test_exception2 e),
i64 derived1_function2(
1: list<i64> function2_arg1,
2: list<double> function2_arg2,
3: list<string> function2_arg3,
4: list<byte> function2_arg4,
5: list<test_enum1> function2_arg5) throws (1:test_exception2 e),
double derived1_function3(
1: string function3_arg1,
2: bool function3_arg2) throws (1:test_exception2 e),
string derived1_function4(
1: string function4_arg1,
2: bool function4_arg2) throws (1:test_exception2 e),
bool derived1_function5(
1: map<i64, double> function5_arg1,
2: map<string, bool> function5_arg2,
3: map<test_enum1, test_enum2> function5_arg3) throws (1:test_exception2 e),
test_struct1 derived1_function6(
1: double function6_arg1) throws (1:test_exception2 e),
}
service derived2 extends base {
list<i32> derived2_function1(
1: i32 function1_arg1) throws (1:test_exception2 e),
list<test_enum1> derived2_function2(
1:i64 function2_arg2) throws (1:test_exception2 e),
list<test_struct1> derived2_function3(
1:double function3_arg1) throws(1:test_exception2 e),
map<double, string> derived2_function4(
1:string function4_arg1) throws(1:test_exception2 e),
map<test_enum1, test_enum2> derived2_function5(
1:bool function5_arg1) throws(1:test_exception2 e),
map<test_struct1, test_struct2> derived2_function6(
1:bool function6_arg1) throws(1:test_exception2 e),
}

74
vendor/git.apache.org/thrift.git/test/c_glib/Makefile.am generated vendored Executable file
View file

@ -0,0 +1,74 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
AUTOMAKE_OPTIONS = subdir-objects serial-tests
noinst_LTLIBRARIES = libtestcglib.la
nodist_libtestcglib_la_SOURCES = \
gen-c_glib/t_test_second_service.c \
gen-c_glib/t_test_second_service.h \
gen-c_glib/t_test_thrift_test.c \
gen-c_glib/t_test_thrift_test.h \
gen-c_glib/t_test_thrift_test_types.c \
gen-c_glib/t_test_thrift_test_types.h
libtestcglib_la_LIBADD = $(top_builddir)/lib/c_glib/libthrift_c_glib.la
precross: libtestcglib.la test_client test_server
check_PROGRAMS = \
test_client \
test_server
test_client_SOURCES = \
src/test_client.c
test_client_LDADD = \
libtestcglib.la \
$(top_builddir)/lib/c_glib/libthrift_c_glib.la
test_server_SOURCES = \
src/thrift_test_handler.c \
src/thrift_test_handler.h \
src/test_server.c
test_server_LDADD = \
libtestcglib.la \
$(top_builddir)/lib/c_glib/libthrift_c_glib.la
#
# Common thrift code generation rules
#
THRIFT = $(top_builddir)/compiler/cpp/thrift
gen-c_glib/t_test_second_service.c gen-c_glib/t_test_second_service.h gen-c_glib/t_test_thrift_test.c gen-c_glib/t_test_thrift_test.h gen-c_glib/t_test_thrift_test_types.c gen-c_glib/t_test_thrift_test_types.h: $(top_srcdir)/test/ThriftTest.thrift $(THRIFT)
$(THRIFT) --gen c_glib -r $<
AM_CFLAGS = -g -Wall -Wextra $(GLIB_CFLAGS) $(GOBJECT_CFLAGS)
AM_CXXFLAGS = $(AM_CFLAGS)
AM_CPPFLAGS = -I$(top_srcdir)/lib/c_glib/src -Igen-c_glib
AM_LDFLAGS = $(GLIB_LIBS) $(GOBJECT_LIBS) @GCOV_LDFLAGS@
clean-local:
$(RM) gen-c_glib/*
EXTRA_DIST = \
src/test_client.c \
src/thrift_test_handler.c \
src/thrift_test_handler.h \
src/test_server.c

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,227 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#include <glib-object.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <thrift/c_glib/thrift.h>
#include <thrift/c_glib/protocol/thrift_binary_protocol_factory.h>
#include <thrift/c_glib/protocol/thrift_compact_protocol_factory.h>
#include <thrift/c_glib/server/thrift_server.h>
#include <thrift/c_glib/server/thrift_simple_server.h>
#include <thrift/c_glib/transport/thrift_buffered_transport.h>
#include <thrift/c_glib/transport/thrift_buffered_transport_factory.h>
#include <thrift/c_glib/transport/thrift_framed_transport.h>
#include <thrift/c_glib/transport/thrift_framed_transport_factory.h>
#include <thrift/c_glib/transport/thrift_server_socket.h>
#include <thrift/c_glib/transport/thrift_server_transport.h>
#include <thrift/c_glib/transport/thrift_transport.h>
#include <thrift/c_glib/transport/thrift_transport_factory.h>
#include "../gen-c_glib/t_test_thrift_test.h"
#include "thrift_test_handler.h"
/* Our server object, declared globally so it is accessible within the SIGINT
signal handler */
ThriftServer *server = NULL;
/* A flag that indicates whether the server was interrupted with SIGINT
(i.e. Ctrl-C) so we can tell whether its termination was abnormal */
gboolean sigint_received = FALSE;
/* Handle SIGINT ("Ctrl-C") signals by gracefully stopping the server */
static void
sigint_handler (int signal_number)
{
THRIFT_UNUSED_VAR (signal_number);
/* Take note we were called */
sigint_received = TRUE;
/* Shut down the server gracefully */
if (server != NULL)
thrift_server_stop (server);
}
int
main (int argc, char **argv)
{
static gint port = 9090;
static gchar *server_type_option = NULL;
static gchar *transport_option = NULL;
static gchar *protocol_option = NULL;
static gint string_limit = 0;
static gint container_limit = 0;
static
GOptionEntry option_entries[] = {
{ "port", 0, 0, G_OPTION_ARG_INT, &port,
"Port number to connect (=9090)", NULL },
{ "server-type", 0, 0, G_OPTION_ARG_STRING, &server_type_option,
"Type of server: simple (=simple)", NULL },
{ "transport", 0, 0, G_OPTION_ARG_STRING, &transport_option,
"Transport: buffered, framed (=buffered)", NULL },
{ "protocol", 0, 0, G_OPTION_ARG_STRING, &protocol_option,
"Protocol: binary, compact (=binary)", NULL },
{ "string-limit", 0, 0, G_OPTION_ARG_INT, &string_limit,
"Max string length (=none)", NULL },
{ "container-limit", 0, 0, G_OPTION_ARG_INT, &container_limit,
"Max container length (=none)", NULL },
{ NULL }
};
gchar *server_name = "simple";
gchar *transport_name = "buffered";
GType transport_factory_type = THRIFT_TYPE_BUFFERED_TRANSPORT_FACTORY;
gchar *protocol_name = "binary";
GType protocol_factory_type = THRIFT_TYPE_BINARY_PROTOCOL_FACTORY;
TTestThriftTestHandler *handler;
ThriftProcessor *processor;
ThriftServerTransport *server_transport;
ThriftTransportFactory *transport_factory;
ThriftProtocolFactory *protocol_factory;
struct sigaction sigint_action;
GOptionContext *option_context;
gboolean options_valid = TRUE;
GError *error = NULL;
#if (!GLIB_CHECK_VERSION (2, 36, 0))
g_type_init ();
#endif
/* Configure and parse our command-line options */
option_context = g_option_context_new (NULL);
g_option_context_add_main_entries (option_context,
option_entries,
NULL);
if (g_option_context_parse (option_context,
&argc,
&argv,
&error) == FALSE) {
fprintf (stderr, "%s\n", error->message);
return 255;
}
g_option_context_free (option_context);
/* Validate the parsed options */
if (server_type_option != NULL &&
strncmp (server_type_option, "simple", 7) != 0) {
fprintf (stderr, "Unknown server type %s\n", protocol_option);
options_valid = FALSE;
}
if (protocol_option != NULL) {
if (strncmp (protocol_option, "compact", 8) == 0) {
protocol_factory_type = THRIFT_TYPE_COMPACT_PROTOCOL_FACTORY;
protocol_name = "compact";
}
else if (strncmp (protocol_option, "binary", 7) != 0) {
fprintf (stderr, "Unknown protocol type %s\n", protocol_option);
options_valid = FALSE;
}
}
if (transport_option != NULL) {
if (strncmp (transport_option, "framed", 7) == 0) {
transport_factory_type = THRIFT_TYPE_FRAMED_TRANSPORT_FACTORY;
transport_name = "framed";
}
else if (strncmp (transport_option, "buffered", 9) != 0) {
fprintf (stderr, "Unknown transport type %s\n", transport_option);
options_valid = FALSE;
}
}
if (!options_valid)
return 254;
/* Establish all our connection objects */
handler = g_object_new (TYPE_THRIFT_TEST_HANDLER,
NULL);
processor = g_object_new (T_TEST_TYPE_THRIFT_TEST_PROCESSOR,
"handler", handler,
NULL);
server_transport = g_object_new (THRIFT_TYPE_SERVER_SOCKET,
"port", port,
NULL);
transport_factory = g_object_new (transport_factory_type,
NULL);
if (strncmp (protocol_name, "compact", 8) == 0) {
protocol_factory = g_object_new (protocol_factory_type,
"string_limit", string_limit,
"container_limit", container_limit,
NULL);
} else {
protocol_factory = g_object_new (protocol_factory_type,
NULL);
}
server = g_object_new (THRIFT_TYPE_SIMPLE_SERVER,
"processor", processor,
"server_transport", server_transport,
"input_transport_factory", transport_factory,
"output_transport_factory", transport_factory,
"input_protocol_factory", protocol_factory,
"output_protocol_factory", protocol_factory,
NULL);
/* Install our SIGINT handler, which handles Ctrl-C being pressed by stopping
the server gracefully */
memset (&sigint_action, 0, sizeof (sigint_action));
sigint_action.sa_handler = sigint_handler;
sigint_action.sa_flags = SA_RESETHAND;
sigaction (SIGINT, &sigint_action, NULL);
printf ("Starting \"%s\" server (%s/%s) listen on: %d\n",
server_name,
transport_name,
protocol_name,
port);
fflush (stdout);
/* Serve clients until SIGINT is received (Ctrl-C is pressed) */
thrift_server_serve (server, &error);
/* If the server stopped for any reason other than being interrupted by the
user, report the error */
if (!sigint_received) {
g_message ("thrift_server_serve: %s",
error != NULL ? error->message : "(null)");
g_clear_error (&error);
}
puts ("done.");
g_object_unref (server);
g_object_unref (protocol_factory);
g_object_unref (transport_factory);
g_object_unref (server_transport);
g_object_unref (processor);
g_object_unref (handler);
return 0;
}

View file

@ -0,0 +1,837 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#include <inttypes.h>
#include <string.h>
#include <unistd.h>
#include <thrift/c_glib/thrift.h>
#include <thrift/c_glib/thrift_application_exception.h>
#include "thrift_test_handler.h"
/* A handler that implements the TTestThriftTestIf interface */
G_DEFINE_TYPE (ThriftTestHandler,
thrift_test_handler,
T_TEST_TYPE_THRIFT_TEST_HANDLER);
gboolean
thrift_test_handler_test_void (TTestThriftTestIf *iface,
GError **error)
{
THRIFT_UNUSED_VAR (iface);
THRIFT_UNUSED_VAR (error);
printf ("testVoid()\n");
return TRUE;
}
gboolean
thrift_test_handler_test_string (TTestThriftTestIf *iface,
gchar **_return,
const gchar *thing,
GError **error)
{
THRIFT_UNUSED_VAR (iface);
THRIFT_UNUSED_VAR (error);
printf ("testString(\"%s\")\n", thing);
*_return = g_strdup (thing);
return TRUE;
}
gboolean
thrift_test_handler_test_bool (TTestThriftTestIf *iface,
gboolean *_return,
const gboolean thing,
GError **error)
{
THRIFT_UNUSED_VAR (iface);
THRIFT_UNUSED_VAR (error);
printf ("testBool(%s)\n", thing ? "true" : "false");
*_return = thing;
return TRUE;
}
gboolean
thrift_test_handler_test_byte (TTestThriftTestIf *iface,
gint8 *_return,
const gint8 thing,
GError **error)
{
THRIFT_UNUSED_VAR (iface);
THRIFT_UNUSED_VAR (error);
printf ("testByte(%d)\n", (gint)thing);
*_return = thing;
return TRUE;
}
gboolean
thrift_test_handler_test_i32 (TTestThriftTestIf *iface,
gint32 *_return,
const gint32 thing,
GError **error)
{
THRIFT_UNUSED_VAR (iface);
THRIFT_UNUSED_VAR (error);
printf ("testI32(%d)\n", thing);
*_return = thing;
return TRUE;
}
gboolean
thrift_test_handler_test_i64 (TTestThriftTestIf *iface,
gint64 *_return,
const gint64 thing,
GError **error)
{
THRIFT_UNUSED_VAR (iface);
THRIFT_UNUSED_VAR (error);
printf ("testI64(%" PRId64 ")\n", thing);
*_return = thing;
return TRUE;
}
gboolean
thrift_test_handler_test_double (TTestThriftTestIf *iface,
gdouble *_return,
const gdouble thing,
GError **error)
{
THRIFT_UNUSED_VAR (iface);
THRIFT_UNUSED_VAR (error);
printf ("testDouble(%f)\n", thing);
*_return = thing;
return TRUE;
}
gboolean
thrift_test_handler_test_binary (TTestThriftTestIf *iface,
GByteArray ** _return,
const GByteArray * thing,
GError **error)
{
THRIFT_UNUSED_VAR (iface);
THRIFT_UNUSED_VAR (error);
printf ("testBinary()\n"); // TODO: hex output
g_byte_array_ref((GByteArray *)thing);
*_return = (GByteArray *)thing;
return TRUE;
}
gboolean
thrift_test_handler_test_struct (TTestThriftTestIf *iface,
TTestXtruct **_return,
const TTestXtruct *thing,
GError **error)
{
gchar *string_thing = NULL;
gint byte_thing;
gint i32_thing;
gint64 i64_thing;
THRIFT_UNUSED_VAR (iface);
THRIFT_UNUSED_VAR (error);
g_object_get ((TTestXtruct *)thing,
"string_thing", &string_thing,
"byte_thing", &byte_thing,
"i32_thing", &i32_thing,
"i64_thing", &i64_thing,
NULL);
printf ("testStruct({\"%s\", %d, %d, %" PRId64 "})\n",
string_thing,
(gint)byte_thing,
i32_thing,
i64_thing);
g_object_set (*_return,
"string_thing", string_thing,
"byte_thing", byte_thing,
"i32_thing", i32_thing,
"i64_thing", i64_thing,
NULL);
if (string_thing != NULL)
g_free (string_thing);
return TRUE;
}
gboolean
thrift_test_handler_test_nest (TTestThriftTestIf *iface,
TTestXtruct2 **_return,
const TTestXtruct2 *thing,
GError **error)
{
gchar *inner_string_thing = NULL;
gint byte_thing, inner_byte_thing;
gint i32_thing, inner_i32_thing;
gint64 inner_i64_thing;
TTestXtruct *struct_thing;
THRIFT_UNUSED_VAR (iface);
THRIFT_UNUSED_VAR (error);
g_object_get ((TTestXtruct2 *)thing,
"byte_thing", &byte_thing,
"struct_thing", &struct_thing,
"i32_thing", &i32_thing,
NULL);
g_object_get (struct_thing,
"string_thing", &inner_string_thing,
"byte_thing", &inner_byte_thing,
"i32_thing", &inner_i32_thing,
"i64_thing", &inner_i64_thing,
NULL);
printf ("testNest({%d, {\"%s\", %d, %d, %" PRId64 "}, %d})\n",
byte_thing,
inner_string_thing,
inner_byte_thing,
inner_i32_thing,
inner_i64_thing,
i32_thing);
g_object_set (*_return,
"byte_thing", byte_thing,
"struct_thing", struct_thing,
"i32_thing", i32_thing,
NULL);
if (inner_string_thing != NULL)
g_free (inner_string_thing);
g_object_unref (struct_thing);
return TRUE;
}
gboolean
thrift_test_handler_test_map (TTestThriftTestIf *iface,
GHashTable **_return,
const GHashTable *thing,
GError **error)
{
GHashTableIter hash_table_iter;
gpointer key;
gpointer value;
gboolean first = TRUE;
THRIFT_UNUSED_VAR (iface);
THRIFT_UNUSED_VAR (error);
printf ("testMap({");
g_hash_table_iter_init (&hash_table_iter, (GHashTable *)thing);
while (g_hash_table_iter_next (&hash_table_iter,
&key,
&value)) {
gint32 *new_key;
gint32 *new_value;
if (first)
first = FALSE;
else
printf (", ");
printf ("%d => %d", *(gint32 *)key, *(gint32 *)value);
new_key = g_malloc (sizeof *new_key);
*new_key = *(gint32 *)key;
new_value = g_malloc (sizeof *new_value);
*new_value = *(gint32 *)value;
g_hash_table_insert (*_return, new_key, new_value);
}
printf ("})\n");
return TRUE;
}
gboolean
thrift_test_handler_test_string_map (TTestThriftTestIf *iface,
GHashTable **_return,
const GHashTable *thing,
GError **error)
{
GHashTableIter hash_table_iter;
gpointer key;
gpointer value;
gboolean first = TRUE;
THRIFT_UNUSED_VAR (iface);
THRIFT_UNUSED_VAR (error);
printf ("testStringMap({");
g_hash_table_iter_init (&hash_table_iter, (GHashTable *)thing);
while (g_hash_table_iter_next (&hash_table_iter,
&key,
&value)) {
gchar *new_key;
gchar *new_value;
if (first)
first = FALSE;
else
printf (", ");
printf ("%s => %s", (gchar *)key, (gchar *)value);
new_key = g_strdup ((gchar *)key);
new_value = g_strdup ((gchar *)value);
g_hash_table_insert (*_return, new_key, new_value);
}
printf ("})\n");
return TRUE;
}
gboolean
thrift_test_handler_test_set (TTestThriftTestIf *iface,
GHashTable **_return,
const GHashTable *thing,
GError **error)
{
GHashTableIter hash_table_iter;
gpointer key;
gboolean first = TRUE;
THRIFT_UNUSED_VAR (iface);
THRIFT_UNUSED_VAR (error);
printf ("testSet({");
g_hash_table_iter_init (&hash_table_iter, (GHashTable *)thing);
while (g_hash_table_iter_next (&hash_table_iter,
&key,
NULL)) {
gint32 *new_key;
if (first)
first = FALSE;
else
printf (", ");
printf ("%d", *(gint32 *)key);
new_key = g_malloc (sizeof *new_key);
*new_key = *(gint32 *)key;
g_hash_table_insert (*_return, new_key, NULL);
}
printf ("})\n");
return TRUE;
}
gboolean
thrift_test_handler_test_list (TTestThriftTestIf *iface,
GArray **_return,
const GArray *thing,
GError **error)
{
guint i;
gboolean first = TRUE;
THRIFT_UNUSED_VAR (iface);
THRIFT_UNUSED_VAR (error);
printf ("testList({");
for (i = 0; i < thing->len; i += 1) {
gint32 value;
gint32 *new_value;
if (first)
first = FALSE;
else
printf (", ");
value = g_array_index (thing, gint32, i);
printf ("%d", value);
new_value = g_malloc (sizeof *new_value);
*new_value = value;
g_array_append_val (*_return, *new_value);
}
printf ("})\n");
return TRUE;
}
gboolean
thrift_test_handler_test_enum (TTestThriftTestIf *iface,
TTestNumberz *_return,
const TTestNumberz thing,
GError **error)
{
THRIFT_UNUSED_VAR (iface);
THRIFT_UNUSED_VAR (error);
printf ("testEnum(%d)\n", thing);
*_return = thing;
return TRUE;
}
gboolean
thrift_test_handler_test_typedef (TTestThriftTestIf *iface,
TTestUserId *_return,
const TTestUserId thing,
GError **error)
{
THRIFT_UNUSED_VAR (iface);
THRIFT_UNUSED_VAR (error);
printf ("testTypedef(%" PRId64 ")\n", thing);
*_return = thing;
return TRUE;
}
gboolean
thrift_test_handler_test_map_map (TTestThriftTestIf *iface,
GHashTable **_return,
const gint32 hello,
GError **error)
{
GHashTable *positive;
GHashTable *negative;
gint32 *key;
gint32 *value;
guint i;
THRIFT_UNUSED_VAR (iface);
THRIFT_UNUSED_VAR (error);
printf ("testMapMap(%d)\n", hello);
positive = g_hash_table_new_full (g_int_hash,
g_int_equal,
g_free,
g_free);
negative = g_hash_table_new_full (g_int_hash,
g_int_equal,
g_free,
g_free);
for (i = 1; i < 5; i += 1) {
key = g_malloc (sizeof *key);
value = g_malloc (sizeof *value);
*key = i;
*value = i;
g_hash_table_insert (positive, key, value);
key = g_malloc (sizeof *key);
value = g_malloc (sizeof *value);
*key = -i;
*value = -i;
g_hash_table_insert (negative, key, value);
}
key = g_malloc (sizeof *key);
*key = 4;
g_hash_table_insert (*_return, key, positive);
key = g_malloc (sizeof *key);
*key = -4;
g_hash_table_insert (*_return, key, negative);
return TRUE;
}
gboolean
thrift_test_handler_test_insanity (TTestThriftTestIf *iface,
GHashTable **_return,
const TTestInsanity *argument,
GError **error)
{
TTestXtruct *xtruct_in;
gchar *string_thing = NULL;
gint byte_thing;
gint i32_thing;
gint64 i64_thing;
GPtrArray *xtructs;
TTestInsanity *looney;
GHashTable *user_map;
GHashTable *first_map;
GHashTable *second_map;
GHashTableIter hash_table_iter;
GHashTableIter inner_hash_table_iter;
GHashTableIter user_map_iter;
gpointer key;
gpointer value;
TTestUserId *user_id;
guint i;
THRIFT_UNUSED_VAR (iface);
THRIFT_UNUSED_VAR (error);
printf ("testInsanity()\n");
first_map = g_hash_table_new_full (g_direct_hash,
g_direct_equal,
NULL,
g_object_unref);
second_map = g_hash_table_new_full (g_direct_hash,
g_direct_equal,
NULL,
g_object_unref);
g_hash_table_insert (first_map,
GINT_TO_POINTER (T_TEST_NUMBERZ_TWO),
(gpointer)argument);
g_hash_table_insert (first_map,
GINT_TO_POINTER (T_TEST_NUMBERZ_THREE),
(gpointer)argument);
/* Increment argument's ref count by two because first_map now holds
two references to it and the caller is not aware we have made any
additional references to argument. (That is, caller owns argument
and will unref it explicitly in addition to unref-ing *_return.)
We do this instead of creating a copy of argument in order to mimic
the C++ implementation (and since, frankly, the world needs less
argument, not more). */
g_object_ref ((gpointer)argument);
g_object_ref ((gpointer)argument);
looney = g_object_new (T_TEST_TYPE_INSANITY, NULL);
g_hash_table_insert (second_map,
GINT_TO_POINTER (T_TEST_NUMBERZ_SIX),
looney);
user_id = g_malloc (sizeof *user_id);
*user_id = 1;
g_hash_table_insert (*_return, user_id, first_map);
user_id = g_malloc (sizeof *user_id);
*user_id = 2;
g_hash_table_insert (*_return, user_id, second_map);
printf ("return");
printf (" = {");
g_hash_table_iter_init (&hash_table_iter, *_return);
while (g_hash_table_iter_next (&hash_table_iter,
&key,
&value)) {
printf ("%" PRId64 " => {", *(TTestUserId *)key);
g_hash_table_iter_init (&inner_hash_table_iter,
(GHashTable *)value);
while (g_hash_table_iter_next (&inner_hash_table_iter,
&key,
&value)) {
printf ("%d => {", (TTestNumberz)key);
g_object_get ((TTestInsanity *)value,
"userMap", &user_map,
"xtructs", &xtructs,
NULL);
printf ("{");
g_hash_table_iter_init (&user_map_iter, user_map);
while (g_hash_table_iter_next (&user_map_iter,
&key,
&value)) {
printf ("%d => %" PRId64 ", ",
(TTestNumberz)key,
*(TTestUserId *)value);
}
printf ("}, ");
g_hash_table_unref (user_map);
printf ("{");
for (i = 0; i < xtructs->len; ++i) {
xtruct_in = g_ptr_array_index (xtructs, i);
g_object_get (xtruct_in,
"string_thing", &string_thing,
"byte_thing", &byte_thing,
"i32_thing", &i32_thing,
"i64_thing", &i64_thing,
NULL);
printf ("{\"%s\", %d, %d, %" PRId64 "}, ",
string_thing,
byte_thing,
i32_thing,
i64_thing);
}
printf ("}");
g_ptr_array_unref (xtructs);
printf ("}, ");
}
printf ("}, ");
}
printf ("}\n");
return TRUE;
}
gboolean
thrift_test_handler_test_multi (TTestThriftTestIf *iface,
TTestXtruct **_return,
const gint8 arg0,
const gint32 arg1,
const gint64 arg2,
const GHashTable *arg3,
const TTestNumberz arg4,
const TTestUserId arg5,
GError **error)
{
THRIFT_UNUSED_VAR (iface);
THRIFT_UNUSED_VAR (error);
THRIFT_UNUSED_VAR (arg3);
THRIFT_UNUSED_VAR (arg4);
THRIFT_UNUSED_VAR (arg5);
printf ("testMulti()\n");
g_object_set (*_return,
"string_thing", g_strdup ("Hello2"),
"byte_thing", arg0,
"i32_thing", arg1,
"i64_thing", arg2,
NULL);
return TRUE;
}
gboolean
thrift_test_handler_test_exception (TTestThriftTestIf *iface,
const gchar *arg,
TTestXception **err1,
GError **error)
{
THRIFT_UNUSED_VAR (iface);
TTestXtruct *xtruct;
gboolean result;
printf ("testException(%s)\n", arg);
/* Unlike argument objects, exception objects are not pre-created */
g_assert (*err1 == NULL);
if (strncmp (arg, "Xception", 9) == 0) {
/* "Throw" a custom exception: Set the corresponding exception
argument, set *error to NULL and return FALSE */
*err1 = g_object_new (T_TEST_TYPE_XCEPTION,
"errorCode", 1001,
"message", g_strdup (arg),
NULL);
*error = NULL;
result = FALSE;
}
else if (strncmp (arg, "TException", 11) == 0) {
/* "Throw" a generic TException (ThriftApplicationException): Set
all exception arguments to NULL, set *error and return FALSE */
*err1 = NULL;
g_set_error (error,
thrift_application_exception_error_quark (),
THRIFT_APPLICATION_EXCEPTION_ERROR_UNKNOWN,
"Default TException.");
result = FALSE;
}
else {
*err1 = NULL;
*error = NULL;
/* This code is duplicated from the C++ test suite, though it
appears to serve no purpose */
xtruct = g_object_new (T_TEST_TYPE_XTRUCT,
"string_thing", g_strdup (arg),
NULL);
g_object_unref (xtruct);
result = TRUE;
}
return result;
}
gboolean
thrift_test_handler_test_multi_exception (TTestThriftTestIf *iface,
TTestXtruct **_return,
const gchar *arg0,
const gchar *arg1,
TTestXception **err1,
TTestXception2 **err2,
GError **error)
{
THRIFT_UNUSED_VAR (iface);
THRIFT_UNUSED_VAR (error);
TTestXtruct *struct_thing;
gboolean result;
printf ("testMultiException(%s, %s)\n", arg0, arg1);
g_assert (*err1 == NULL);
g_assert (*err2 == NULL);
if (strncmp (arg0, "Xception", 8) == 0 && strlen(arg0) == 8) {
*err1 = g_object_new (T_TEST_TYPE_XCEPTION,
"errorCode", 1001,
"message", g_strdup ("This is an Xception"),
NULL);
result = FALSE;
}
else if (strncmp (arg0, "Xception2", 9) == 0) {
*err2 = g_object_new (T_TEST_TYPE_XCEPTION2,
"errorCode", 2002,
NULL);
g_object_get (*err2,
"struct_thing", &struct_thing,
NULL);
g_object_set (struct_thing,
"string_thing", g_strdup ("This is an Xception2"),
NULL);
g_object_set (*err2,
"struct_thing", struct_thing,
NULL);
g_object_unref (struct_thing);
result = FALSE;
}
else {
g_object_set (*_return,
"string_thing", g_strdup (arg1),
NULL);
result = TRUE;
}
return result;
}
gboolean
thrift_test_handler_test_oneway (TTestThriftTestIf *iface,
const gint32 secondsToSleep,
GError **error)
{
THRIFT_UNUSED_VAR (iface);
THRIFT_UNUSED_VAR (error);
printf ("testOneway(%d): Sleeping...\n", secondsToSleep);
sleep (secondsToSleep);
printf ("testOneway(%d): done sleeping!\n", secondsToSleep);
return TRUE;
}
static void
thrift_test_handler_init (ThriftTestHandler *self)
{
THRIFT_UNUSED_VAR (self);
}
static void
thrift_test_handler_class_init (ThriftTestHandlerClass *klass)
{
TTestThriftTestHandlerClass *base_class =
T_TEST_THRIFT_TEST_HANDLER_CLASS (klass);
base_class->test_void =
klass->test_void =
thrift_test_handler_test_void;
base_class->test_string =
klass->test_string =
thrift_test_handler_test_string;
base_class->test_bool =
klass->test_bool =
thrift_test_handler_test_bool;
base_class->test_byte =
klass->test_byte =
thrift_test_handler_test_byte;
base_class->test_i32 =
klass->test_i32 =
thrift_test_handler_test_i32;
base_class->test_i64 =
klass->test_i64 =
thrift_test_handler_test_i64;
base_class->test_double =
klass->test_double =
thrift_test_handler_test_double;
base_class->test_binary =
klass->test_binary =
thrift_test_handler_test_binary;
base_class->test_struct =
klass->test_struct =
thrift_test_handler_test_struct;
base_class->test_nest =
klass->test_nest =
thrift_test_handler_test_nest;
base_class->test_map =
klass->test_map =
thrift_test_handler_test_map;
base_class->test_string_map =
klass->test_string_map =
thrift_test_handler_test_string_map;
base_class->test_set =
klass->test_set =
thrift_test_handler_test_set;
base_class->test_list =
klass->test_list =
thrift_test_handler_test_list;
base_class->test_enum =
klass->test_enum =
thrift_test_handler_test_enum;
base_class->test_typedef =
klass->test_typedef =
thrift_test_handler_test_typedef;
base_class->test_map_map =
klass->test_map_map =
thrift_test_handler_test_map_map;
base_class->test_insanity =
klass->test_insanity =
thrift_test_handler_test_insanity;
base_class->test_multi =
klass->test_multi =
thrift_test_handler_test_multi;
base_class->test_exception =
klass->test_exception =
thrift_test_handler_test_exception;
base_class->test_multi_exception =
klass->test_multi_exception =
thrift_test_handler_test_multi_exception;
base_class->test_oneway =
klass->test_oneway =
thrift_test_handler_test_oneway;
}

View file

@ -0,0 +1,245 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#ifndef _THRIFT_TEST_HANDLER_H
#define _THRIFT_TEST_HANDLER_H
#include <glib-object.h>
#include <stdio.h>
#include "../gen-c_glib/t_test_thrift_test.h"
G_BEGIN_DECLS
/* A handler that implements the TTestThriftTestIf interface */
#define TYPE_THRIFT_TEST_HANDLER (thrift_test_handler_get_type ())
#define THRIFT_TEST_HANDLER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
TYPE_THRIFT_TEST_HANDLER, \
ThriftTestHandler))
#define IS_THRIFT_TEST_HANDLER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
TYPE_THRIFT_TEST_HANDLER))
#define THRIFT_TEST_HANDLER_CLASS(c) \
(G_TYPE_CHECK_CLASS_CAST ((c), \
TYPE_THRIFT_TEST_HANDLER, \
ThriftTestHandlerClass))
#define IS_THRIFT_TEST_HANDLER_CLASS(c) \
(G_TYPE_CHECK_CLASS_TYPE ((c), \
TYPE_THRIFT_TEST_HANDLER))
#define THRIFT_TEST_HANDLER_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
TYPE_THRIFT_TEST_HANDLER, \
ThriftTestHandlerClass))
typedef struct _ThriftTestHandler ThriftTestHandler;
typedef struct _ThriftTestHandlerClass ThriftTestHandlerClass;
struct _ThriftTestHandler {
TTestThriftTestHandler parent;
};
struct _ThriftTestHandlerClass {
TTestThriftTestHandlerClass parent;
gboolean (*test_void) (TTestThriftTestIf *iface,
GError **error);
gboolean (*test_string) (TTestThriftTestIf *iface,
gchar **_return,
const gchar *thing,
GError **error);
gboolean (*test_bool) (TTestThriftTestIf *iface,
gboolean*_return,
const gboolean thing,
GError **error);
gboolean (*test_byte) (TTestThriftTestIf *iface,
gint8*_return,
const gint8 thing,
GError **error);
gboolean (*test_i32) (TTestThriftTestIf *iface,
gint32*_return,
const gint32 thing,
GError **error);
gboolean (*test_i64) (TTestThriftTestIf *iface,
gint64*_return,
const gint64 thing,
GError **error);
gboolean (*test_double) (TTestThriftTestIf *iface,
gdouble*_return,
const gdouble thing,
GError **error);
gboolean (*test_binary) (TTestThriftTestIf *iface,
GByteArray **_return,
const GByteArray *thing,
GError **error);
gboolean (*test_struct) (TTestThriftTestIf *iface,
TTestXtruct **_return,
const TTestXtruct *thing,
GError **error);
gboolean (*test_nest) (TTestThriftTestIf *iface,
TTestXtruct2 **_return,
const TTestXtruct2 *thing,
GError **error);
gboolean (*test_map) (TTestThriftTestIf *iface,
GHashTable **_return,
const GHashTable *thing,
GError **error);
gboolean (*test_string_map) (TTestThriftTestIf *iface,
GHashTable **_return,
const GHashTable *thing,
GError **error);
gboolean (*test_set) (TTestThriftTestIf *iface,
GHashTable **_return,
const GHashTable *thing,
GError **error);
gboolean (*test_list) (TTestThriftTestIf *iface,
GArray **_return,
const GArray *thing,
GError **error);
gboolean (*test_enum) (TTestThriftTestIf *iface,
TTestNumberz*_return,
const TTestNumberz thing,
GError **error);
gboolean (*test_typedef) (TTestThriftTestIf *iface,
TTestUserId*_return,
const TTestUserId thing,
GError **error);
gboolean (*test_map_map) (TTestThriftTestIf *iface,
GHashTable **_return,
const gint32 hello,
GError **error);
gboolean (*test_insanity) (TTestThriftTestIf *iface,
GHashTable **_return,
const TTestInsanity *argument,
GError **error);
gboolean (*test_multi) (TTestThriftTestIf *iface,
TTestXtruct **_return,
const gint8 arg0,
const gint32 arg1,
const gint64 arg2,
const GHashTable *arg3,
const TTestNumberz arg4,
const TTestUserId arg5,
GError **error);
gboolean (*test_exception) (TTestThriftTestIf *iface,
const gchar *arg,
TTestXception **err1,
GError **error);
gboolean (*test_multi_exception) (TTestThriftTestIf *iface,
TTestXtruct **_return,
const gchar *arg0,
const gchar *arg1,
TTestXception **err1,
TTestXception2 **err2,
GError **error);
gboolean (*test_oneway) (TTestThriftTestIf *iface,
const gint32 secondsToSleep,
GError **error);
};
/* Used by THRIFT_TEST_HANDLER_GET_TYPE */
GType thrift_test_handler_get_type (void);
gboolean thrift_test_handler_test_void (TTestThriftTestIf *iface,
GError **error);
gboolean thrift_test_handler_test_string (TTestThriftTestIf *iface,
gchar **_return,
const gchar *thing,
GError **error);
gboolean thrift_test_handler_test_byte (TTestThriftTestIf *iface,
gint8*_return,
const gint8 thing,
GError **error);
gboolean t_test_thrift_test_if_test_i32 (TTestThriftTestIf *iface,
gint32*_return,
const gint32 thing,
GError **error);
gboolean thrift_test_handler_test_i64 (TTestThriftTestIf *iface,
gint64*_return,
const gint64 thing,
GError **error);
gboolean thrift_test_handler_test_double (TTestThriftTestIf *iface,
gdouble*_return,
const gdouble thing,
GError **error);
gboolean thrift_test_handler_test_struct (TTestThriftTestIf *iface,
TTestXtruct **_return,
const TTestXtruct *thing,
GError **error);
gboolean thrift_test_handler_test_nest (TTestThriftTestIf *iface,
TTestXtruct2 **_return,
const TTestXtruct2 *thing,
GError **error);
gboolean thrift_test_handler_test_map (TTestThriftTestIf *iface,
GHashTable **_return,
const GHashTable *thing,
GError **error);
gboolean thrift_test_handler_test_string_map (TTestThriftTestIf *iface,
GHashTable **_return,
const GHashTable *thing,
GError **error);
gboolean thrift_test_handler_test_set (TTestThriftTestIf *iface,
GHashTable **_return,
const GHashTable *thing,
GError **error);
gboolean thrift_test_handler_test_list (TTestThriftTestIf *iface,
GArray **_return,
const GArray *thing,
GError **error);
gboolean thrift_test_handler_test_typedef (TTestThriftTestIf *iface,
TTestUserId*_return,
const TTestUserId thing,
GError **error);
gboolean thrift_test_handler_test_map_map (TTestThriftTestIf *iface,
GHashTable **_return,
const gint32 hello,
GError **error);
gboolean thrift_test_handler_test_insanity (TTestThriftTestIf *iface,
GHashTable **_return,
const TTestInsanity *argument,
GError **error);
gboolean thrift_test_handler_test_multi (TTestThriftTestIf *iface,
TTestXtruct **_return,
const gint8 arg0,
const gint32 arg1,
const gint64 arg2,
const GHashTable *arg3,
const TTestNumberz arg4,
const TTestUserId arg5,
GError **error);
gboolean thrift_test_handler_test_exception (TTestThriftTestIf *iface,
const gchar *arg,
TTestXception **err1,
GError **error);
gboolean thrift_test_handler_test_multi_exception (TTestThriftTestIf *iface,
TTestXtruct **_return,
const gchar *arg0,
const gchar *arg1,
TTestXception **err1,
TTestXception2 **err2,
GError **error);
gboolean thrift_test_handler_test_oneway (TTestThriftTestIf *iface,
const gint32 secondsToSleep,
GError **error);
G_END_DECLS
#endif /* _THRIFT_TEST_HANDLER_H */

89
vendor/git.apache.org/thrift.git/test/cpp/CMakeLists.txt generated vendored Executable file
View file

@ -0,0 +1,89 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# Contains the thrift specific LINK_AGAINST_THRIFT_LIBRARY
include(ThriftMacros)
include_directories(SYSTEM "${Boost_INCLUDE_DIRS}")
find_package(OpenSSL REQUIRED)
include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
find_package(Libevent REQUIRED) # Libevent comes with CMake support from upstream
include_directories(SYSTEM ${LIBEVENT_INCLUDE_DIRS})
#Make sure gen-cpp files can be included
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
include_directories("${CMAKE_CURRENT_BINARY_DIR}/gen-cpp")
include_directories("${PROJECT_SOURCE_DIR}/lib/cpp/src")
set(crosstestgencpp_SOURCES
gen-cpp/ThriftTest.cpp
gen-cpp/ThriftTest_types.cpp
gen-cpp/ThriftTest_constants.cpp
src/ThriftTest_extras.cpp
)
add_library(crosstestgencpp STATIC ${crosstestgencpp_SOURCES})
LINK_AGAINST_THRIFT_LIBRARY(crosstestgencpp thrift)
set(crossstressgencpp_SOURCES
gen-cpp/Service.cpp
#gen-cpp/StressTest_types.cpp #basically empty, so omitting
gen-cpp/StressTest_constants.cpp
)
add_library(crossstressgencpp STATIC ${crossstressgencpp_SOURCES})
LINK_AGAINST_THRIFT_LIBRARY(crossstressgencpp thrift)
add_executable(TestServer src/TestServer.cpp)
target_link_libraries(TestServer crosstestgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
LINK_AGAINST_THRIFT_LIBRARY(TestServer thrift)
LINK_AGAINST_THRIFT_LIBRARY(TestServer thriftnb)
LINK_AGAINST_THRIFT_LIBRARY(TestServer thriftz)
add_executable(TestClient src/TestClient.cpp)
target_link_libraries(TestClient crosstestgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
LINK_AGAINST_THRIFT_LIBRARY(TestClient thrift)
LINK_AGAINST_THRIFT_LIBRARY(TestClient thriftnb)
LINK_AGAINST_THRIFT_LIBRARY(TestClient thriftz)
add_executable(StressTest src/StressTest.cpp)
target_link_libraries(StressTest crossstressgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
LINK_AGAINST_THRIFT_LIBRARY(StressTest thrift)
LINK_AGAINST_THRIFT_LIBRARY(StressTest thriftnb)
add_test(NAME StressTest COMMAND StressTest)
add_executable(StressTestNonBlocking src/StressTestNonBlocking.cpp)
target_link_libraries(StressTestNonBlocking crossstressgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
LINK_AGAINST_THRIFT_LIBRARY(StressTestNonBlocking thrift)
LINK_AGAINST_THRIFT_LIBRARY(StressTestNonBlocking thriftnb)
LINK_AGAINST_THRIFT_LIBRARY(StressTestNonBlocking thriftz)
add_test(NAME StressTestNonBlocking COMMAND StressTestNonBlocking)
#
# Common thrift code generation rules
#
add_custom_command(OUTPUT gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest_types.cpp gen-cpp/ThriftTest_constants.cpp
COMMAND ${THRIFT_COMPILER} --gen cpp:templates,cob_style -r ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift
)
add_custom_command(OUTPUT gen-cpp/StressTest_types.cpp gen-cpp/StressTest_constants.cpp gen-cpp/Service.cpp
COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/StressTest.thrift
)

125
vendor/git.apache.org/thrift.git/test/cpp/Makefile.am generated vendored Executable file
View file

@ -0,0 +1,125 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
AUTOMAKE_OPTIONS = subdir-objects serial-tests
BUILT_SOURCES = gen-cpp/ThriftTest.cpp \
gen-cpp/ThriftTest_types.cpp \
gen-cpp/ThriftTest_constants.cpp \
gen-cpp/StressTest_types.cpp \
gen-cpp/StressTest_constants.cpp \
gen-cpp/Service.cpp
noinst_LTLIBRARIES = libtestgencpp.la libstresstestgencpp.la
nodist_libtestgencpp_la_SOURCES = \
gen-cpp/ThriftTest_constants.cpp \
gen-cpp/ThriftTest_constants.h \
gen-cpp/ThriftTest_types.cpp \
gen-cpp/ThriftTest_types.h \
gen-cpp/ThriftTest_types.tcc \
gen-cpp/ThriftTest.cpp \
gen-cpp/ThriftTest.h \
gen-cpp/ThriftTest.tcc \
src/ThriftTest_extras.cpp
libtestgencpp_la_LIBADD = $(top_builddir)/lib/cpp/libthrift.la
nodist_libstresstestgencpp_la_SOURCES = \
gen-cpp/StressTest_constants.cpp \
gen-cpp/StressTest_types.cpp \
gen-cpp/StressTest_constants.h \
gen-cpp/StressTest_types.h \
gen-cpp/Service.cpp \
gen-cpp/Service.h
libstresstestgencpp_la_LIBADD = $(top_builddir)/lib/cpp/libthrift.la
precross: TestServer TestClient
check_PROGRAMS = \
TestServer \
TestClient \
StressTest \
StressTestNonBlocking
# we currently do not run the testsuite, stop c++ server issue
# TESTS = \
# $(check_PROGRAMS)
TestServer_SOURCES = \
src/TestServer.cpp
TestServer_LDADD = \
libtestgencpp.la \
$(top_builddir)/lib/cpp/libthrift.la \
$(top_builddir)/lib/cpp/libthriftz.la \
$(top_builddir)/lib/cpp/libthriftnb.la \
-levent -lboost_program_options -lboost_system -lboost_filesystem $(ZLIB_LIBS)
TestClient_SOURCES = \
src/TestClient.cpp
TestClient_LDADD = \
libtestgencpp.la \
$(top_builddir)/lib/cpp/libthrift.la \
$(top_builddir)/lib/cpp/libthriftz.la \
$(top_builddir)/lib/cpp/libthriftnb.la \
-levent -lboost_program_options -lboost_system -lboost_filesystem $(ZLIB_LIBS)
StressTest_SOURCES = \
src/StressTest.cpp
StressTest_LDADD = \
libstresstestgencpp.la \
$(top_builddir)/lib/cpp/libthrift.la
StressTestNonBlocking_SOURCES = \
src/StressTestNonBlocking.cpp
StressTestNonBlocking_LDADD = \
libstresstestgencpp.la \
$(top_builddir)/lib/cpp/libthriftnb.la \
-levent
#
# Common thrift code generation rules
#
THRIFT = $(top_builddir)/compiler/cpp/thrift
gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest_types.cpp gen-cpp/ThriftTest_constants.cpp: $(top_srcdir)/test/ThriftTest.thrift $(THRIFT)
$(THRIFT) --gen cpp:templates,cob_style -r $<
gen-cpp/StressTest_types.cpp gen-cpp/StressTest_constants.cpp gen-cpp/Service.cpp: $(top_srcdir)/test/StressTest.thrift $(THRIFT)
$(THRIFT) --gen cpp $<
AM_CPPFLAGS = $(BOOST_CPPFLAGS) $(LIBEVENT_CPPFLAGS) -I$(top_srcdir)/lib/cpp/src -Igen-cpp
AM_CXXFLAGS = -Wall -Wextra -pedantic
AM_LDFLAGS = $(BOOST_LDFLAGS) $(LIBEVENT_LDFLAGS) $(ZLIB_LIBS)
clean-local:
$(RM) gen-cpp/*
style-local:
$(CPPSTYLE_CMD)
EXTRA_DIST = \
src/TestClient.cpp \
src/TestServer.cpp \
src/StressTest.cpp \
src/StressTestNonBlocking.cpp \
realloc/realloc_test.c \
realloc/Makefile

View file

@ -0,0 +1,107 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <dlfcn.h>
int copies;
int non_copies;
void *realloc(void *ptr, size_t size) {
static void *(*real_realloc)(void*, size_t) = NULL;
if (real_realloc == NULL) {
real_realloc = (void* (*) (void*, size_t)) dlsym(RTLD_NEXT, "realloc");
}
void *ret_ptr = (*real_realloc)(ptr, size);
if (ret_ptr == ptr) {
non_copies++;
} else {
copies++;
}
return ret_ptr;
}
struct TMemoryBuffer {
void* ptr;
int size;
};
int main(int argc, char *argv[]) {
int num_buffers;
int init_size;
int max_size;
int doublings;
int iterations;
if (argc < 6 ||
argc > 7 ||
(num_buffers = atoi(argv[1])) == 0 ||
(init_size = atoi(argv[2])) == 0 ||
(max_size = atoi(argv[3])) == 0 ||
init_size > max_size ||
(iterations = atoi(argv[4])) == 0 ||
(doublings = atoi(argv[5])) == 0 ||
(argc == 7 && atoi(argv[6]) == 0)) {
fprintf(stderr, "usage: realloc_test <num_buffers> <init_size> <max_size> <doublings> <iterations> [seed]\n");
exit(EXIT_FAILURE);
}
for ( int i = 0 ; i < argc ; i++ ) {
printf("%s ", argv[i]);
}
printf("\n");
if (argc == 7) {
srand(atoi(argv[6]));
} else {
srand(time(NULL));
}
struct TMemoryBuffer* buffers = calloc(num_buffers, sizeof(*buffers));
if (buffers == NULL) abort();
for ( int i = 0 ; i < num_buffers ; i++ ) {
buffers[i].size = max_size;
}
while (iterations --> 0) {
for ( int i = 0 ; i < doublings * num_buffers ; i++ ) {
struct TMemoryBuffer* buf = &buffers[rand() % num_buffers];
buf->size *= 2;
if (buf->size <= max_size) {
buf->ptr = realloc(buf->ptr, buf->size);
} else {
free(buf->ptr);
buf->size = init_size;
buf->ptr = malloc(buf->size);
}
if (buf->ptr == NULL) abort();
}
}
printf("Non-copied %d/%d (%.2f%%)\n", non_copies, copies + non_copies, 100.0 * non_copies / (copies + non_copies));
return 0;
}

View file

@ -0,0 +1,605 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#include <thrift/concurrency/ThreadManager.h>
#include <thrift/concurrency/PlatformThreadFactory.h>
#include <thrift/concurrency/Monitor.h>
#include <thrift/concurrency/Util.h>
#include <thrift/concurrency/Mutex.h>
#include <thrift/protocol/TBinaryProtocol.h>
#include <thrift/server/TSimpleServer.h>
#include <thrift/server/TThreadPoolServer.h>
#include <thrift/server/TThreadedServer.h>
#include <thrift/transport/TServerSocket.h>
#include <thrift/transport/TSocket.h>
#include <thrift/transport/TTransportUtils.h>
#include <thrift/transport/TFileTransport.h>
#include <thrift/TLogging.h>
#include "Service.h"
#include <iostream>
#include <set>
#include <stdexcept>
#include <sstream>
#include <map>
#if _WIN32
#include <thrift/windows/TWinsockSingleton.h>
#endif
using namespace std;
using namespace apache::thrift;
using namespace apache::thrift::protocol;
using namespace apache::thrift::transport;
using namespace apache::thrift::server;
using namespace apache::thrift::concurrency;
using namespace test::stress;
struct eqstr {
bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) == 0; }
};
struct ltstr {
bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) < 0; }
};
// typedef hash_map<const char*, int, hash<const char*>, eqstr> count_map;
typedef map<const char*, int, ltstr> count_map;
class Server : public ServiceIf {
public:
Server() {}
void count(const char* method) {
Guard m(lock_);
int ct = counts_[method];
counts_[method] = ++ct;
}
void echoVoid() {
count("echoVoid");
return;
}
count_map getCount() {
Guard m(lock_);
return counts_;
}
int8_t echoByte(const int8_t arg) { return arg; }
int32_t echoI32(const int32_t arg) { return arg; }
int64_t echoI64(const int64_t arg) { return arg; }
void echoString(string& out, const string& arg) {
if (arg != "hello") {
T_ERROR_ABORT("WRONG STRING (%s)!!!!", arg.c_str());
}
out = arg;
}
void echoList(vector<int8_t>& out, const vector<int8_t>& arg) { out = arg; }
void echoSet(set<int8_t>& out, const set<int8_t>& arg) { out = arg; }
void echoMap(map<int8_t, int8_t>& out, const map<int8_t, int8_t>& arg) { out = arg; }
private:
count_map counts_;
Mutex lock_;
};
enum TransportOpenCloseBehavior {
OpenAndCloseTransportInThread,
DontOpenAndCloseTransportInThread
};
class ClientThread : public Runnable {
public:
ClientThread(boost::shared_ptr<TTransport> transport,
boost::shared_ptr<ServiceIf> client,
Monitor& monitor,
size_t& workerCount,
size_t loopCount,
TType loopType,
TransportOpenCloseBehavior behavior)
: _transport(transport),
_client(client),
_monitor(monitor),
_workerCount(workerCount),
_loopCount(loopCount),
_loopType(loopType),
_behavior(behavior) {}
void run() {
// Wait for all worker threads to start
{
Synchronized s(_monitor);
while (_workerCount == 0) {
_monitor.wait();
}
}
_startTime = Util::currentTime();
if(_behavior == OpenAndCloseTransportInThread) {
_transport->open();
}
switch (_loopType) {
case T_VOID:
loopEchoVoid();
break;
case T_BYTE:
loopEchoByte();
break;
case T_I32:
loopEchoI32();
break;
case T_I64:
loopEchoI64();
break;
case T_STRING:
loopEchoString();
break;
default:
cerr << "Unexpected loop type" << _loopType << endl;
break;
}
_endTime = Util::currentTime();
if(_behavior == OpenAndCloseTransportInThread) {
_transport->close();
}
_done = true;
{
Synchronized s(_monitor);
_workerCount--;
if (_workerCount == 0) {
_monitor.notify();
}
}
}
void loopEchoVoid() {
for (size_t ix = 0; ix < _loopCount; ix++) {
_client->echoVoid();
}
}
void loopEchoByte() {
for (size_t ix = 0; ix < _loopCount; ix++) {
int8_t arg = 1;
int8_t result;
result = _client->echoByte(arg);
(void)result;
assert(result == arg);
}
}
void loopEchoI32() {
for (size_t ix = 0; ix < _loopCount; ix++) {
int32_t arg = 1;
int32_t result;
result = _client->echoI32(arg);
(void)result;
assert(result == arg);
}
}
void loopEchoI64() {
for (size_t ix = 0; ix < _loopCount; ix++) {
int64_t arg = 1;
int64_t result;
result = _client->echoI64(arg);
(void)result;
assert(result == arg);
}
}
void loopEchoString() {
for (size_t ix = 0; ix < _loopCount; ix++) {
string arg = "hello";
string result;
_client->echoString(result, arg);
assert(result == arg);
}
}
boost::shared_ptr<TTransport> _transport;
boost::shared_ptr<ServiceIf> _client;
Monitor& _monitor;
size_t& _workerCount;
size_t _loopCount;
TType _loopType;
int64_t _startTime;
int64_t _endTime;
bool _done;
Monitor _sleep;
TransportOpenCloseBehavior _behavior;
};
class TStartObserver : public apache::thrift::server::TServerEventHandler {
public:
TStartObserver() : awake_(false) {}
virtual void preServe() {
apache::thrift::concurrency::Synchronized s(m_);
awake_ = true;
m_.notifyAll();
}
void waitForService() {
apache::thrift::concurrency::Synchronized s(m_);
while (!awake_)
m_.waitForever();
}
private:
apache::thrift::concurrency::Monitor m_;
bool awake_;
};
int main(int argc, char** argv) {
#if _WIN32
transport::TWinsockSingleton::create();
#endif
int port = 9091;
string clientType = "regular";
string serverType = "thread-pool";
string protocolType = "binary";
size_t workerCount = 4;
size_t clientCount = 20;
size_t loopCount = 50000;
TType loopType = T_VOID;
string callName = "echoVoid";
bool runServer = true;
bool logRequests = false;
string requestLogPath = "./requestlog.tlog";
bool replayRequests = false;
ostringstream usage;
usage << argv[0] << " [--port=<port number>] [--server] [--server-type=<server-type>] "
"[--protocol-type=<protocol-type>] [--workers=<worker-count>] "
"[--clients=<client-count>] [--loop=<loop-count>] "
"[--client-type=<client-type>]" << endl
<< "\tclients Number of client threads to create - 0 implies no clients, i.e. "
"server only. Default is " << clientCount << endl
<< "\thelp Prints this help text." << endl
<< "\tcall Service method to call. Default is " << callName << endl
<< "\tloop The number of remote thrift calls each client makes. Default is " << loopCount << endl
<< "\tport The port the server and clients should bind to "
"for thrift network connections. Default is " << port << endl
<< "\tserver Run the Thrift server in this process. Default is " << runServer << endl
<< "\tserver-type Type of server, \"simple\" or \"thread-pool\". Default is " << serverType << endl
<< "\tprotocol-type Type of protocol, \"binary\", \"ascii\", or \"xml\". Default is " << protocolType << endl
<< "\tlog-request Log all request to ./requestlog.tlog. Default is " << logRequests << endl
<< "\treplay-request Replay requests from log file (./requestlog.tlog) Default is " << replayRequests << endl
<< "\tworkers Number of thread pools workers. Only valid "
"for thread-pool server type. Default is " << workerCount << endl
<< "\tclient-type Type of client, \"regular\" or \"concurrent\". Default is " << clientType << endl
<< endl;
map<string, string> args;
for (int ix = 1; ix < argc; ix++) {
string arg(argv[ix]);
if (arg.compare(0, 2, "--") == 0) {
size_t end = arg.find_first_of("=", 2);
string key = string(arg, 2, end - 2);
if (end != string::npos) {
args[key] = string(arg, end + 1);
} else {
args[key] = "true";
}
} else {
throw invalid_argument("Unexcepted command line token: " + arg);
}
}
try {
if (!args["clients"].empty()) {
clientCount = atoi(args["clients"].c_str());
}
if (!args["help"].empty()) {
cerr << usage.str();
return 0;
}
if (!args["loop"].empty()) {
loopCount = atoi(args["loop"].c_str());
}
if (!args["call"].empty()) {
callName = args["call"];
}
if (!args["port"].empty()) {
port = atoi(args["port"].c_str());
}
if (!args["server"].empty()) {
runServer = args["server"] == "true";
}
if (!args["log-request"].empty()) {
logRequests = args["log-request"] == "true";
}
if (!args["replay-request"].empty()) {
replayRequests = args["replay-request"] == "true";
}
if (!args["server-type"].empty()) {
serverType = args["server-type"];
if (serverType == "simple") {
} else if (serverType == "thread-pool") {
} else if (serverType == "threaded") {
} else {
throw invalid_argument("Unknown server type " + serverType);
}
}
if (!args["client-type"].empty()) {
clientType = args["client-type"];
if (clientType == "regular") {
} else if (clientType == "concurrent") {
} else {
throw invalid_argument("Unknown client type " + clientType);
}
}
if (!args["workers"].empty()) {
workerCount = atoi(args["workers"].c_str());
}
} catch (std::exception& e) {
cerr << e.what() << endl;
cerr << usage.str();
}
boost::shared_ptr<PlatformThreadFactory> threadFactory
= boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
// Dispatcher
boost::shared_ptr<Server> serviceHandler(new Server());
if (replayRequests) {
boost::shared_ptr<Server> serviceHandler(new Server());
boost::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
// Transports
boost::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath));
fileTransport->setChunkSize(2 * 1024 * 1024);
fileTransport->setMaxEventSize(1024 * 16);
fileTransport->seekToEnd();
// Protocol Factory
boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
TFileProcessor fileProcessor(serviceProcessor, protocolFactory, fileTransport);
fileProcessor.process(0, true);
exit(0);
}
if (runServer) {
boost::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
// Transport
boost::shared_ptr<TServerSocket> serverSocket(new TServerSocket(port));
// Transport Factory
boost::shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());
// Protocol Factory
boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
if (logRequests) {
// initialize the log file
boost::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath));
fileTransport->setChunkSize(2 * 1024 * 1024);
fileTransport->setMaxEventSize(1024 * 16);
transportFactory
= boost::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport));
}
boost::shared_ptr<TServer> server;
if (serverType == "simple") {
server.reset(
new TSimpleServer(serviceProcessor, serverSocket, transportFactory, protocolFactory));
} else if (serverType == "threaded") {
server.reset(
new TThreadedServer(serviceProcessor, serverSocket, transportFactory, protocolFactory));
} else if (serverType == "thread-pool") {
boost::shared_ptr<ThreadManager> threadManager
= ThreadManager::newSimpleThreadManager(workerCount);
threadManager->threadFactory(threadFactory);
threadManager->start();
server.reset(new TThreadPoolServer(serviceProcessor,
serverSocket,
transportFactory,
protocolFactory,
threadManager));
}
boost::shared_ptr<TStartObserver> observer(new TStartObserver);
server->setServerEventHandler(observer);
boost::shared_ptr<Thread> serverThread = threadFactory->newThread(server);
cerr << "Starting the server on port " << port << endl;
serverThread->start();
observer->waitForService();
// If we aren't running clients, just wait forever for external clients
if (clientCount == 0) {
serverThread->join();
}
}
if (clientCount > 0) { //FIXME: start here for client type?
Monitor monitor;
size_t threadCount = 0;
set<boost::shared_ptr<Thread> > clientThreads;
if (callName == "echoVoid") {
loopType = T_VOID;
} else if (callName == "echoByte") {
loopType = T_BYTE;
} else if (callName == "echoI32") {
loopType = T_I32;
} else if (callName == "echoI64") {
loopType = T_I64;
} else if (callName == "echoString") {
loopType = T_STRING;
} else {
throw invalid_argument("Unknown service call " + callName);
}
if(clientType == "regular") {
for (size_t ix = 0; ix < clientCount; ix++) {
boost::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port));
boost::shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket, 2048));
boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(bufferedSocket));
boost::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol));
clientThreads.insert(threadFactory->newThread(boost::shared_ptr<ClientThread>(
new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType, OpenAndCloseTransportInThread))));
}
} else if(clientType == "concurrent") {
boost::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port));
boost::shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket, 2048));
boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(bufferedSocket));
//boost::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol));
boost::shared_ptr<ServiceConcurrentClient> serviceClient(new ServiceConcurrentClient(protocol));
socket->open();
for (size_t ix = 0; ix < clientCount; ix++) {
clientThreads.insert(threadFactory->newThread(boost::shared_ptr<ClientThread>(
new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType, DontOpenAndCloseTransportInThread))));
}
}
for (std::set<boost::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin();
thread != clientThreads.end();
thread++) {
(*thread)->start();
}
int64_t time00;
int64_t time01;
{
Synchronized s(monitor);
threadCount = clientCount;
cerr << "Launch " << clientCount << " " << clientType << " client threads" << endl;
time00 = Util::currentTime();
monitor.notifyAll();
while (threadCount > 0) {
monitor.wait();
}
time01 = Util::currentTime();
}
int64_t firstTime = 9223372036854775807LL;
int64_t lastTime = 0;
double averageTime = 0;
int64_t minTime = 9223372036854775807LL;
int64_t maxTime = 0;
for (set<boost::shared_ptr<Thread> >::iterator ix = clientThreads.begin();
ix != clientThreads.end();
ix++) {
boost::shared_ptr<ClientThread> client
= boost::dynamic_pointer_cast<ClientThread>((*ix)->runnable());
int64_t delta = client->_endTime - client->_startTime;
assert(delta > 0);
if (client->_startTime < firstTime) {
firstTime = client->_startTime;
}
if (client->_endTime > lastTime) {
lastTime = client->_endTime;
}
if (delta < minTime) {
minTime = delta;
}
if (delta > maxTime) {
maxTime = delta;
}
averageTime += delta;
}
averageTime /= clientCount;
cout << "workers :" << workerCount << ", client : " << clientCount << ", loops : " << loopCount
<< ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << endl;
count_map count = serviceHandler->getCount();
count_map::iterator iter;
for (iter = count.begin(); iter != count.end(); ++iter) {
printf("%s => %d\n", iter->first, iter->second);
}
cerr << "done." << endl;
}
return 0;
}

View file

@ -0,0 +1,538 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#include <thrift/concurrency/ThreadManager.h>
#include <thrift/concurrency/PlatformThreadFactory.h>
#include <thrift/concurrency/Monitor.h>
#include <thrift/concurrency/Util.h>
#include <thrift/concurrency/Mutex.h>
#include <thrift/protocol/TBinaryProtocol.h>
#include <thrift/server/TSimpleServer.h>
#include <thrift/server/TThreadPoolServer.h>
#include <thrift/server/TThreadedServer.h>
#include <thrift/server/TNonblockingServer.h>
#include <thrift/transport/TServerSocket.h>
#include <thrift/transport/TSocket.h>
#include <thrift/transport/TTransportUtils.h>
#include <thrift/transport/TFileTransport.h>
#include <thrift/TLogging.h>
#include "Service.h"
#include <boost/shared_ptr.hpp>
#include <iostream>
#include <set>
#include <stdexcept>
#include <sstream>
#include <map>
#if _WIN32
#include <thrift/windows/TWinsockSingleton.h>
#endif
using namespace std;
using namespace apache::thrift;
using namespace apache::thrift::protocol;
using namespace apache::thrift::transport;
using namespace apache::thrift::server;
using namespace apache::thrift::concurrency;
using namespace test::stress;
struct eqstr {
bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) == 0; }
};
struct ltstr {
bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) < 0; }
};
// typedef hash_map<const char*, int, hash<const char*>, eqstr> count_map;
typedef map<const char*, int, ltstr> count_map;
class Server : public ServiceIf {
public:
Server() {}
void count(const char* method) {
Guard m(lock_);
int ct = counts_[method];
counts_[method] = ++ct;
}
void echoVoid() {
count("echoVoid");
// Sleep to simulate work
THRIFT_SLEEP_USEC(1);
return;
}
count_map getCount() {
Guard m(lock_);
return counts_;
}
int8_t echoByte(const int8_t arg) { return arg; }
int32_t echoI32(const int32_t arg) { return arg; }
int64_t echoI64(const int64_t arg) { return arg; }
void echoString(string& out, const string& arg) {
if (arg != "hello") {
T_ERROR_ABORT("WRONG STRING (%s)!!!!", arg.c_str());
}
out = arg;
}
void echoList(vector<int8_t>& out, const vector<int8_t>& arg) { out = arg; }
void echoSet(set<int8_t>& out, const set<int8_t>& arg) { out = arg; }
void echoMap(map<int8_t, int8_t>& out, const map<int8_t, int8_t>& arg) { out = arg; }
private:
count_map counts_;
Mutex lock_;
};
class ClientThread : public Runnable {
public:
ClientThread(boost::shared_ptr<TTransport> transport,
boost::shared_ptr<ServiceClient> client,
Monitor& monitor,
size_t& workerCount,
size_t loopCount,
TType loopType)
: _transport(transport),
_client(client),
_monitor(monitor),
_workerCount(workerCount),
_loopCount(loopCount),
_loopType(loopType) {}
void run() {
// Wait for all worker threads to start
{
Synchronized s(_monitor);
while (_workerCount == 0) {
_monitor.wait();
}
}
_startTime = Util::currentTime();
_transport->open();
switch (_loopType) {
case T_VOID:
loopEchoVoid();
break;
case T_BYTE:
loopEchoByte();
break;
case T_I32:
loopEchoI32();
break;
case T_I64:
loopEchoI64();
break;
case T_STRING:
loopEchoString();
break;
default:
cerr << "Unexpected loop type" << _loopType << endl;
break;
}
_endTime = Util::currentTime();
_transport->close();
_done = true;
{
Synchronized s(_monitor);
_workerCount--;
if (_workerCount == 0) {
_monitor.notify();
}
}
}
void loopEchoVoid() {
for (size_t ix = 0; ix < _loopCount; ix++) {
_client->echoVoid();
}
}
void loopEchoByte() {
for (size_t ix = 0; ix < _loopCount; ix++) {
int8_t arg = 1;
int8_t result;
result = _client->echoByte(arg);
(void)result;
assert(result == arg);
}
}
void loopEchoI32() {
for (size_t ix = 0; ix < _loopCount; ix++) {
int32_t arg = 1;
int32_t result;
result = _client->echoI32(arg);
(void)result;
assert(result == arg);
}
}
void loopEchoI64() {
for (size_t ix = 0; ix < _loopCount; ix++) {
int64_t arg = 1;
int64_t result;
result = _client->echoI64(arg);
(void)result;
assert(result == arg);
}
}
void loopEchoString() {
for (size_t ix = 0; ix < _loopCount; ix++) {
string arg = "hello";
string result;
_client->echoString(result, arg);
assert(result == arg);
}
}
boost::shared_ptr<TTransport> _transport;
boost::shared_ptr<ServiceClient> _client;
Monitor& _monitor;
size_t& _workerCount;
size_t _loopCount;
TType _loopType;
int64_t _startTime;
int64_t _endTime;
bool _done;
Monitor _sleep;
};
int main(int argc, char** argv) {
#if _WIN32
transport::TWinsockSingleton::create();
#endif
int port = 9091;
string serverType = "simple";
string protocolType = "binary";
uint32_t workerCount = 4;
uint32_t clientCount = 20;
uint32_t loopCount = 1000;
TType loopType = T_VOID;
string callName = "echoVoid";
bool runServer = true;
bool logRequests = false;
string requestLogPath = "./requestlog.tlog";
bool replayRequests = false;
ostringstream usage;
usage << argv[0] << " [--port=<port number>] [--server] [--server-type=<server-type>] "
"[--protocol-type=<protocol-type>] [--workers=<worker-count>] "
"[--clients=<client-count>] [--loop=<loop-count>]" << endl
<< "\tclients Number of client threads to create - 0 implies no clients, i.e. "
"server only. Default is " << clientCount << endl
<< "\thelp Prints this help text." << endl
<< "\tcall Service method to call. Default is " << callName << endl
<< "\tloop The number of remote thrift calls each client makes. Default is "
<< loopCount << endl << "\tport The port the server and clients should bind to "
"for thrift network connections. Default is " << port << endl
<< "\tserver Run the Thrift server in this process. Default is " << runServer
<< endl << "\tserver-type Type of server, \"simple\" or \"thread-pool\". Default is "
<< serverType << endl
<< "\tprotocol-type Type of protocol, \"binary\", \"ascii\", or \"xml\". Default is "
<< protocolType << endl
<< "\tlog-request Log all request to ./requestlog.tlog. Default is " << logRequests
<< endl << "\treplay-request Replay requests from log file (./requestlog.tlog) Default is "
<< replayRequests << endl << "\tworkers Number of thread pools workers. Only valid "
"for thread-pool server type. Default is " << workerCount
<< endl;
map<string, string> args;
for (int ix = 1; ix < argc; ix++) {
string arg(argv[ix]);
if (arg.compare(0, 2, "--") == 0) {
size_t end = arg.find_first_of("=", 2);
string key = string(arg, 2, end - 2);
if (end != string::npos) {
args[key] = string(arg, end + 1);
} else {
args[key] = "true";
}
} else {
throw invalid_argument("Unexcepted command line token: " + arg);
}
}
try {
if (!args["clients"].empty()) {
clientCount = atoi(args["clients"].c_str());
}
if (!args["help"].empty()) {
cerr << usage.str();
return 0;
}
if (!args["loop"].empty()) {
loopCount = atoi(args["loop"].c_str());
}
if (!args["call"].empty()) {
callName = args["call"];
}
if (!args["port"].empty()) {
port = atoi(args["port"].c_str());
}
if (!args["server"].empty()) {
runServer = args["server"] == "true";
}
if (!args["log-request"].empty()) {
logRequests = args["log-request"] == "true";
}
if (!args["replay-request"].empty()) {
replayRequests = args["replay-request"] == "true";
}
if (!args["server-type"].empty()) {
serverType = args["server-type"];
}
if (!args["workers"].empty()) {
workerCount = atoi(args["workers"].c_str());
}
} catch (std::exception& e) {
cerr << e.what() << endl;
cerr << usage.str();
}
boost::shared_ptr<PlatformThreadFactory> threadFactory
= boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
// Dispatcher
boost::shared_ptr<Server> serviceHandler(new Server());
if (replayRequests) {
boost::shared_ptr<Server> serviceHandler(new Server());
boost::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
// Transports
boost::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath));
fileTransport->setChunkSize(2 * 1024 * 1024);
fileTransport->setMaxEventSize(1024 * 16);
fileTransport->seekToEnd();
// Protocol Factory
boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
TFileProcessor fileProcessor(serviceProcessor, protocolFactory, fileTransport);
fileProcessor.process(0, true);
exit(0);
}
if (runServer) {
boost::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
// Protocol Factory
boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
// Transport Factory
boost::shared_ptr<TTransportFactory> transportFactory;
if (logRequests) {
// initialize the log file
boost::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath));
fileTransport->setChunkSize(2 * 1024 * 1024);
fileTransport->setMaxEventSize(1024 * 16);
transportFactory
= boost::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport));
}
boost::shared_ptr<Thread> serverThread;
boost::shared_ptr<Thread> serverThread2;
if (serverType == "simple") {
serverThread = threadFactory->newThread(boost::shared_ptr<TServer>(
new TNonblockingServer(serviceProcessor, protocolFactory, port)));
serverThread2 = threadFactory->newThread(boost::shared_ptr<TServer>(
new TNonblockingServer(serviceProcessor, protocolFactory, port + 1)));
} else if (serverType == "thread-pool") {
boost::shared_ptr<ThreadManager> threadManager
= ThreadManager::newSimpleThreadManager(workerCount);
threadManager->threadFactory(threadFactory);
threadManager->start();
serverThread = threadFactory->newThread(boost::shared_ptr<TServer>(
new TNonblockingServer(serviceProcessor, protocolFactory, port, threadManager)));
serverThread2 = threadFactory->newThread(boost::shared_ptr<TServer>(
new TNonblockingServer(serviceProcessor, protocolFactory, port + 1, threadManager)));
}
cerr << "Starting the server on port " << port << " and " << (port + 1) << endl;
serverThread->start();
serverThread2->start();
// If we aren't running clients, just wait forever for external clients
if (clientCount == 0) {
serverThread->join();
serverThread2->join();
}
}
THRIFT_SLEEP_SEC(1);
if (clientCount > 0) {
Monitor monitor;
size_t threadCount = 0;
set<boost::shared_ptr<Thread> > clientThreads;
if (callName == "echoVoid") {
loopType = T_VOID;
} else if (callName == "echoByte") {
loopType = T_BYTE;
} else if (callName == "echoI32") {
loopType = T_I32;
} else if (callName == "echoI64") {
loopType = T_I64;
} else if (callName == "echoString") {
loopType = T_STRING;
} else {
throw invalid_argument("Unknown service call " + callName);
}
for (uint32_t ix = 0; ix < clientCount; ix++) {
boost::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port + (ix % 2)));
boost::shared_ptr<TFramedTransport> framedSocket(new TFramedTransport(socket));
boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(framedSocket));
boost::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol));
clientThreads.insert(threadFactory->newThread(boost::shared_ptr<ClientThread>(
new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType))));
}
for (std::set<boost::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin();
thread != clientThreads.end();
thread++) {
(*thread)->start();
}
int64_t time00;
int64_t time01;
{
Synchronized s(monitor);
threadCount = clientCount;
cerr << "Launch " << clientCount << " client threads" << endl;
time00 = Util::currentTime();
monitor.notifyAll();
while (threadCount > 0) {
monitor.wait();
}
time01 = Util::currentTime();
}
int64_t firstTime = 9223372036854775807LL;
int64_t lastTime = 0;
double averageTime = 0;
int64_t minTime = 9223372036854775807LL;
int64_t maxTime = 0;
for (set<boost::shared_ptr<Thread> >::iterator ix = clientThreads.begin();
ix != clientThreads.end();
ix++) {
boost::shared_ptr<ClientThread> client
= boost::dynamic_pointer_cast<ClientThread>((*ix)->runnable());
int64_t delta = client->_endTime - client->_startTime;
assert(delta > 0);
if (client->_startTime < firstTime) {
firstTime = client->_startTime;
}
if (client->_endTime > lastTime) {
lastTime = client->_endTime;
}
if (delta < minTime) {
minTime = delta;
}
if (delta > maxTime) {
maxTime = delta;
}
averageTime += delta;
}
averageTime /= clientCount;
cout << "workers :" << workerCount << ", client : " << clientCount << ", loops : " << loopCount
<< ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << endl;
count_map count = serviceHandler->getCount();
count_map::iterator iter;
for (iter = count.begin(); iter != count.end(); ++iter) {
printf("%s => %d\n", iter->first, iter->second);
}
cerr << "done." << endl;
}
return 0;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,775 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
#include <thrift/concurrency/ThreadManager.h>
#include <thrift/concurrency/PlatformThreadFactory.h>
#include <thrift/protocol/TBinaryProtocol.h>
#include <thrift/protocol/TCompactProtocol.h>
#include <thrift/protocol/THeaderProtocol.h>
#include <thrift/protocol/TJSONProtocol.h>
#include <thrift/server/TSimpleServer.h>
#include <thrift/server/TThreadedServer.h>
#include <thrift/server/TThreadPoolServer.h>
#include <thrift/async/TEvhttpServer.h>
#include <thrift/async/TAsyncBufferProcessor.h>
#include <thrift/async/TAsyncProtocolProcessor.h>
#include <thrift/server/TNonblockingServer.h>
#include <thrift/transport/TServerSocket.h>
#include <thrift/transport/TSSLServerSocket.h>
#include <thrift/transport/TSSLSocket.h>
#include <thrift/transport/THttpServer.h>
#include <thrift/transport/THttpTransport.h>
#include <thrift/transport/TTransportUtils.h>
#include "ThriftTest.h"
#include <iostream>
#include <stdexcept>
#include <sstream>
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
#include <thrift/cxxfunctional.h>
#include <signal.h>
#if _WIN32
#include <thrift/windows/TWinsockSingleton.h>
#endif
using namespace std;
using namespace apache::thrift;
using namespace apache::thrift::concurrency;
using namespace apache::thrift::protocol;
using namespace apache::thrift::transport;
using namespace apache::thrift::server;
using namespace apache::thrift::async;
using namespace thrift::test;
class TestHandler : public ThriftTestIf {
public:
TestHandler() {}
void testVoid() { printf("testVoid()\n"); }
void testString(string& out, const string& thing) {
printf("testString(\"%s\")\n", thing.c_str());
out = thing;
}
bool testBool(const bool thing) {
printf("testBool(%s)\n", thing ? "true" : "false");
return thing;
}
int8_t testByte(const int8_t thing) {
printf("testByte(%d)\n", (int)thing);
return thing;
}
int32_t testI32(const int32_t thing) {
printf("testI32(%d)\n", thing);
return thing;
}
int64_t testI64(const int64_t thing) {
printf("testI64(%" PRId64 ")\n", thing);
return thing;
}
double testDouble(const double thing) {
printf("testDouble(%f)\n", thing);
return thing;
}
void testBinary(std::string& _return, const std::string& thing) {
std::ostringstream hexstr;
hexstr << std::hex << thing;
printf("testBinary(%s)\n", hexstr.str().c_str());
_return = thing;
}
void testStruct(Xtruct& out, const Xtruct& thing) {
printf("testStruct({\"%s\", %d, %d, %" PRId64 "})\n",
thing.string_thing.c_str(),
(int)thing.byte_thing,
thing.i32_thing,
thing.i64_thing);
out = thing;
}
void testNest(Xtruct2& out, const Xtruct2& nest) {
const Xtruct& thing = nest.struct_thing;
printf("testNest({%d, {\"%s\", %d, %d, %" PRId64 "}, %d})\n",
(int)nest.byte_thing,
thing.string_thing.c_str(),
(int)thing.byte_thing,
thing.i32_thing,
thing.i64_thing,
nest.i32_thing);
out = nest;
}
void testMap(map<int32_t, int32_t>& out, const map<int32_t, int32_t>& thing) {
printf("testMap({");
map<int32_t, int32_t>::const_iterator m_iter;
bool first = true;
for (m_iter = thing.begin(); m_iter != thing.end(); ++m_iter) {
if (first) {
first = false;
} else {
printf(", ");
}
printf("%d => %d", m_iter->first, m_iter->second);
}
printf("})\n");
out = thing;
}
void testStringMap(map<std::string, std::string>& out,
const map<std::string, std::string>& thing) {
printf("testMap({");
map<std::string, std::string>::const_iterator m_iter;
bool first = true;
for (m_iter = thing.begin(); m_iter != thing.end(); ++m_iter) {
if (first) {
first = false;
} else {
printf(", ");
}
printf("%s => %s", (m_iter->first).c_str(), (m_iter->second).c_str());
}
printf("})\n");
out = thing;
}
void testSet(set<int32_t>& out, const set<int32_t>& thing) {
printf("testSet({");
set<int32_t>::const_iterator s_iter;
bool first = true;
for (s_iter = thing.begin(); s_iter != thing.end(); ++s_iter) {
if (first) {
first = false;
} else {
printf(", ");
}
printf("%d", *s_iter);
}
printf("})\n");
out = thing;
}
void testList(vector<int32_t>& out, const vector<int32_t>& thing) {
printf("testList({");
vector<int32_t>::const_iterator l_iter;
bool first = true;
for (l_iter = thing.begin(); l_iter != thing.end(); ++l_iter) {
if (first) {
first = false;
} else {
printf(", ");
}
printf("%d", *l_iter);
}
printf("})\n");
out = thing;
}
Numberz::type testEnum(const Numberz::type thing) {
printf("testEnum(%d)\n", thing);
return thing;
}
UserId testTypedef(const UserId thing) {
printf("testTypedef(%" PRId64 ")\n", thing);
return thing;
}
void testMapMap(map<int32_t, map<int32_t, int32_t> >& mapmap, const int32_t hello) {
printf("testMapMap(%d)\n", hello);
map<int32_t, int32_t> pos;
map<int32_t, int32_t> neg;
for (int i = 1; i < 5; i++) {
pos.insert(make_pair(i, i));
neg.insert(make_pair(-i, -i));
}
mapmap.insert(make_pair(4, pos));
mapmap.insert(make_pair(-4, neg));
}
void testInsanity(map<UserId, map<Numberz::type, Insanity> >& insane, const Insanity& argument) {
printf("testInsanity()\n");
Insanity looney;
map<Numberz::type, Insanity> first_map;
map<Numberz::type, Insanity> second_map;
first_map.insert(make_pair(Numberz::TWO, argument));
first_map.insert(make_pair(Numberz::THREE, argument));
second_map.insert(make_pair(Numberz::SIX, looney));
insane.insert(make_pair(1, first_map));
insane.insert(make_pair(2, second_map));
printf("return");
printf(" = {");
map<UserId, map<Numberz::type, Insanity> >::const_iterator i_iter;
for (i_iter = insane.begin(); i_iter != insane.end(); ++i_iter) {
printf("%" PRId64 " => {", i_iter->first);
map<Numberz::type, Insanity>::const_iterator i2_iter;
for (i2_iter = i_iter->second.begin(); i2_iter != i_iter->second.end(); ++i2_iter) {
printf("%d => {", i2_iter->first);
map<Numberz::type, UserId> userMap = i2_iter->second.userMap;
map<Numberz::type, UserId>::const_iterator um;
printf("{");
for (um = userMap.begin(); um != userMap.end(); ++um) {
printf("%d => %" PRId64 ", ", um->first, um->second);
}
printf("}, ");
vector<Xtruct> xtructs = i2_iter->second.xtructs;
vector<Xtruct>::const_iterator x;
printf("{");
for (x = xtructs.begin(); x != xtructs.end(); ++x) {
printf("{\"%s\", %d, %d, %" PRId64 "}, ",
x->string_thing.c_str(),
(int)x->byte_thing,
x->i32_thing,
x->i64_thing);
}
printf("}");
printf("}, ");
}
printf("}, ");
}
printf("}\n");
}
void testMulti(Xtruct& hello,
const int8_t arg0,
const int32_t arg1,
const int64_t arg2,
const std::map<int16_t, std::string>& arg3,
const Numberz::type arg4,
const UserId arg5) {
(void)arg3;
(void)arg4;
(void)arg5;
printf("testMulti()\n");
hello.string_thing = "Hello2";
hello.byte_thing = arg0;
hello.i32_thing = arg1;
hello.i64_thing = (int64_t)arg2;
}
void testException(const std::string& arg) {
printf("testException(%s)\n", arg.c_str());
if (arg.compare("Xception") == 0) {
Xception e;
e.errorCode = 1001;
e.message = arg;
throw e;
} else if (arg.compare("TException") == 0) {
apache::thrift::TException e;
throw e;
} else {
Xtruct result;
result.string_thing = arg;
return;
}
}
void testMultiException(Xtruct& result,
const std::string& arg0,
const std::string& arg1) {
printf("testMultiException(%s, %s)\n", arg0.c_str(), arg1.c_str());
if (arg0.compare("Xception") == 0) {
Xception e;
e.errorCode = 1001;
e.message = "This is an Xception";
throw e;
} else if (arg0.compare("Xception2") == 0) {
Xception2 e;
e.errorCode = 2002;
e.struct_thing.string_thing = "This is an Xception2";
throw e;
} else {
result.string_thing = arg1;
return;
}
}
void testOneway(const int32_t sleepFor) {
printf("testOneway(%d): Sleeping...\n", sleepFor);
THRIFT_SLEEP_SEC(sleepFor);
printf("testOneway(%d): done sleeping!\n", sleepFor);
}
};
class TestProcessorEventHandler : public TProcessorEventHandler {
virtual void* getContext(const char* fn_name, void* serverContext) {
(void)serverContext;
return new std::string(fn_name);
}
virtual void freeContext(void* ctx, const char* fn_name) {
(void)fn_name;
delete static_cast<std::string*>(ctx);
}
virtual void preRead(void* ctx, const char* fn_name) { communicate("preRead", ctx, fn_name); }
virtual void postRead(void* ctx, const char* fn_name, uint32_t bytes) {
(void)bytes;
communicate("postRead", ctx, fn_name);
}
virtual void preWrite(void* ctx, const char* fn_name) { communicate("preWrite", ctx, fn_name); }
virtual void postWrite(void* ctx, const char* fn_name, uint32_t bytes) {
(void)bytes;
communicate("postWrite", ctx, fn_name);
}
virtual void asyncComplete(void* ctx, const char* fn_name) {
communicate("asyncComplete", ctx, fn_name);
}
virtual void handlerError(void* ctx, const char* fn_name) {
communicate("handlerError", ctx, fn_name);
}
void communicate(const char* event, void* ctx, const char* fn_name) {
std::cout << event << ": " << *static_cast<std::string*>(ctx) << " = " << fn_name << std::endl;
}
};
class TestHandlerAsync : public ThriftTestCobSvIf {
public:
TestHandlerAsync(boost::shared_ptr<TestHandler>& handler) : _delegate(handler) {}
virtual ~TestHandlerAsync() {}
virtual void testVoid(tcxx::function<void()> cob) {
_delegate->testVoid();
cob();
}
virtual void testString(tcxx::function<void(std::string const& _return)> cob,
const std::string& thing) {
std::string res;
_delegate->testString(res, thing);
cob(res);
}
virtual void testBool(tcxx::function<void(bool const& _return)> cob, const bool thing) {
bool res = _delegate->testBool(thing);
cob(res);
}
virtual void testByte(tcxx::function<void(int8_t const& _return)> cob, const int8_t thing) {
int8_t res = _delegate->testByte(thing);
cob(res);
}
virtual void testI32(tcxx::function<void(int32_t const& _return)> cob, const int32_t thing) {
int32_t res = _delegate->testI32(thing);
cob(res);
}
virtual void testI64(tcxx::function<void(int64_t const& _return)> cob, const int64_t thing) {
int64_t res = _delegate->testI64(thing);
cob(res);
}
virtual void testDouble(tcxx::function<void(double const& _return)> cob, const double thing) {
double res = _delegate->testDouble(thing);
cob(res);
}
virtual void testBinary(tcxx::function<void(std::string const& _return)> cob,
const std::string& thing) {
std::string res;
_delegate->testBinary(res, thing);
cob(res);
}
virtual void testStruct(tcxx::function<void(Xtruct const& _return)> cob, const Xtruct& thing) {
Xtruct res;
_delegate->testStruct(res, thing);
cob(res);
}
virtual void testNest(tcxx::function<void(Xtruct2 const& _return)> cob, const Xtruct2& thing) {
Xtruct2 res;
_delegate->testNest(res, thing);
cob(res);
}
virtual void testMap(tcxx::function<void(std::map<int32_t, int32_t> const& _return)> cob,
const std::map<int32_t, int32_t>& thing) {
std::map<int32_t, int32_t> res;
_delegate->testMap(res, thing);
cob(res);
}
virtual void testStringMap(
tcxx::function<void(std::map<std::string, std::string> const& _return)> cob,
const std::map<std::string, std::string>& thing) {
std::map<std::string, std::string> res;
_delegate->testStringMap(res, thing);
cob(res);
}
virtual void testSet(tcxx::function<void(std::set<int32_t> const& _return)> cob,
const std::set<int32_t>& thing) {
std::set<int32_t> res;
_delegate->testSet(res, thing);
cob(res);
}
virtual void testList(tcxx::function<void(std::vector<int32_t> const& _return)> cob,
const std::vector<int32_t>& thing) {
std::vector<int32_t> res;
_delegate->testList(res, thing);
cob(res);
}
virtual void testEnum(tcxx::function<void(Numberz::type const& _return)> cob,
const Numberz::type thing) {
Numberz::type res = _delegate->testEnum(thing);
cob(res);
}
virtual void testTypedef(tcxx::function<void(UserId const& _return)> cob, const UserId thing) {
UserId res = _delegate->testTypedef(thing);
cob(res);
}
virtual void testMapMap(
tcxx::function<void(std::map<int32_t, std::map<int32_t, int32_t> > const& _return)> cob,
const int32_t hello) {
std::map<int32_t, std::map<int32_t, int32_t> > res;
_delegate->testMapMap(res, hello);
cob(res);
}
virtual void testInsanity(
tcxx::function<void(std::map<UserId, std::map<Numberz::type, Insanity> > const& _return)> cob,
const Insanity& argument) {
std::map<UserId, std::map<Numberz::type, Insanity> > res;
_delegate->testInsanity(res, argument);
cob(res);
}
virtual void testMulti(tcxx::function<void(Xtruct const& _return)> cob,
const int8_t arg0,
const int32_t arg1,
const int64_t arg2,
const std::map<int16_t, std::string>& arg3,
const Numberz::type arg4,
const UserId arg5) {
Xtruct res;
_delegate->testMulti(res, arg0, arg1, arg2, arg3, arg4, arg5);
cob(res);
}
virtual void testException(
tcxx::function<void()> cob,
tcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob,
const std::string& arg) {
try {
_delegate->testException(arg);
} catch (const apache::thrift::TException& e) {
exn_cob(apache::thrift::TDelayedException::delayException(e));
return;
}
cob();
}
virtual void testMultiException(
tcxx::function<void(Xtruct const& _return)> cob,
tcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob,
const std::string& arg0,
const std::string& arg1) {
Xtruct res;
try {
_delegate->testMultiException(res, arg0, arg1);
} catch (const apache::thrift::TException& e) {
exn_cob(apache::thrift::TDelayedException::delayException(e));
return;
}
cob(res);
}
virtual void testOneway(tcxx::function<void()> cob, const int32_t secondsToSleep) {
_delegate->testOneway(secondsToSleep);
cob();
}
protected:
boost::shared_ptr<TestHandler> _delegate;
};
namespace po = boost::program_options;
int main(int argc, char** argv) {
string testDir = boost::filesystem::system_complete(argv[0]).parent_path().parent_path().parent_path().string();
string certPath = testDir + "/keys/server.crt";
string keyPath = testDir + "/keys/server.key";
#if _WIN32
transport::TWinsockSingleton::create();
#endif
int port = 9090;
bool ssl = false;
string transport_type = "buffered";
string protocol_type = "binary";
string server_type = "simple";
string domain_socket = "";
bool abstract_namespace = false;
size_t workers = 4;
int string_limit = 0;
int container_limit = 0;
po::options_description desc("Allowed options");
desc.add_options()
("help,h", "produce help message")
("port", po::value<int>(&port)->default_value(port), "Port number to listen")
("domain-socket", po::value<string>(&domain_socket) ->default_value(domain_socket), "Unix Domain Socket (e.g. /tmp/ThriftTest.thrift)")
("abstract-namespace", "Create the domain socket in the Abstract Namespace (no connection with filesystem pathnames)")
("server-type", po::value<string>(&server_type)->default_value(server_type), "type of server, \"simple\", \"thread-pool\", \"threaded\", or \"nonblocking\"")
("transport", po::value<string>(&transport_type)->default_value(transport_type), "transport: buffered, framed, http")
("protocol", po::value<string>(&protocol_type)->default_value(protocol_type), "protocol: binary, compact, header, json")
("ssl", "Encrypted Transport using SSL")
("processor-events", "processor-events")
("workers,n", po::value<size_t>(&workers)->default_value(workers), "Number of thread pools workers. Only valid for thread-pool server type")
("string-limit", po::value<int>(&string_limit))
("container-limit", po::value<int>(&container_limit));
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
if (vm.count("help")) {
cout << desc << "\n";
return 1;
}
try {
if (!server_type.empty()) {
if (server_type == "simple") {
} else if (server_type == "thread-pool") {
} else if (server_type == "threaded") {
} else if (server_type == "nonblocking") {
} else {
throw invalid_argument("Unknown server type " + server_type);
}
}
if (!protocol_type.empty()) {
if (protocol_type == "binary") {
} else if (protocol_type == "compact") {
} else if (protocol_type == "json") {
} else if (protocol_type == "header") {
} else {
throw invalid_argument("Unknown protocol type " + protocol_type);
}
}
if (!transport_type.empty()) {
if (transport_type == "buffered") {
} else if (transport_type == "framed") {
} else if (transport_type == "http") {
} else {
throw invalid_argument("Unknown transport type " + transport_type);
}
}
} catch (std::exception& e) {
cerr << e.what() << endl;
cout << desc << "\n";
return 1;
}
if (vm.count("ssl")) {
ssl = true;
}
if (vm.count("abstract-namespace")) {
abstract_namespace = true;
}
// Dispatcher
boost::shared_ptr<TProtocolFactory> protocolFactory;
if (protocol_type == "json") {
boost::shared_ptr<TProtocolFactory> jsonProtocolFactory(new TJSONProtocolFactory());
protocolFactory = jsonProtocolFactory;
} else if (protocol_type == "compact") {
TCompactProtocolFactoryT<TBufferBase> *compactProtocolFactory = new TCompactProtocolFactoryT<TBufferBase>();
compactProtocolFactory->setContainerSizeLimit(container_limit);
compactProtocolFactory->setStringSizeLimit(string_limit);
protocolFactory.reset(compactProtocolFactory);
} else if (protocol_type == "header") {
boost::shared_ptr<TProtocolFactory> headerProtocolFactory(new THeaderProtocolFactory());
protocolFactory = headerProtocolFactory;
} else {
TBinaryProtocolFactoryT<TBufferBase>* binaryProtocolFactory = new TBinaryProtocolFactoryT<TBufferBase>();
binaryProtocolFactory->setContainerSizeLimit(container_limit);
binaryProtocolFactory->setStringSizeLimit(string_limit);
protocolFactory.reset(binaryProtocolFactory);
}
// Processor
boost::shared_ptr<TestHandler> testHandler(new TestHandler());
boost::shared_ptr<ThriftTestProcessor> testProcessor(new ThriftTestProcessor(testHandler));
if (vm.count("processor-events")) {
testProcessor->setEventHandler(
boost::shared_ptr<TProcessorEventHandler>(new TestProcessorEventHandler()));
}
// Transport
boost::shared_ptr<TSSLSocketFactory> sslSocketFactory;
boost::shared_ptr<TServerSocket> serverSocket;
if (ssl) {
sslSocketFactory = boost::shared_ptr<TSSLSocketFactory>(new TSSLSocketFactory());
sslSocketFactory->loadCertificate(certPath.c_str());
sslSocketFactory->loadPrivateKey(keyPath.c_str());
sslSocketFactory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
serverSocket = boost::shared_ptr<TServerSocket>(new TSSLServerSocket(port, sslSocketFactory));
} else {
if (domain_socket != "") {
if (abstract_namespace) {
std::string abstract_socket("\0", 1);
abstract_socket += domain_socket;
serverSocket = boost::shared_ptr<TServerSocket>(new TServerSocket(abstract_socket));
} else {
unlink(domain_socket.c_str());
serverSocket = boost::shared_ptr<TServerSocket>(new TServerSocket(domain_socket));
}
port = 0;
} else {
serverSocket = boost::shared_ptr<TServerSocket>(new TServerSocket(port));
}
}
// Factory
boost::shared_ptr<TTransportFactory> transportFactory;
if (transport_type == "http" && server_type != "nonblocking") {
boost::shared_ptr<TTransportFactory> httpTransportFactory(new THttpServerTransportFactory());
transportFactory = httpTransportFactory;
} else if (transport_type == "framed") {
boost::shared_ptr<TTransportFactory> framedTransportFactory(new TFramedTransportFactory());
transportFactory = framedTransportFactory;
} else {
boost::shared_ptr<TTransportFactory> bufferedTransportFactory(new TBufferedTransportFactory());
transportFactory = bufferedTransportFactory;
}
// Server Info
cout << "Starting \"" << server_type << "\" server (" << transport_type << "/" << protocol_type
<< ") listen on: ";
if (abstract_namespace) {
cout << '@';
}
cout << domain_socket;
if (port != 0) {
cout << port;
}
cout << endl;
// Server
boost::shared_ptr<apache::thrift::server::TServer> server;
if (server_type == "simple") {
server.reset(new TSimpleServer(testProcessor, serverSocket, transportFactory, protocolFactory));
} else if (server_type == "thread-pool") {
boost::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workers);
boost::shared_ptr<PlatformThreadFactory> threadFactory
= boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
threadManager->threadFactory(threadFactory);
threadManager->start();
server.reset(new TThreadPoolServer(testProcessor,
serverSocket,
transportFactory,
protocolFactory,
threadManager));
} else if (server_type == "threaded") {
server.reset(
new TThreadedServer(testProcessor, serverSocket, transportFactory, protocolFactory));
} else if (server_type == "nonblocking") {
if (transport_type == "http") {
boost::shared_ptr<TestHandlerAsync> testHandlerAsync(new TestHandlerAsync(testHandler));
boost::shared_ptr<TAsyncProcessor> testProcessorAsync(
new ThriftTestAsyncProcessor(testHandlerAsync));
boost::shared_ptr<TAsyncBufferProcessor> testBufferProcessor(
new TAsyncProtocolProcessor(testProcessorAsync, protocolFactory));
// not loading nonblockingServer into "server" because
// TEvhttpServer doesn't inherit from TServer, and doesn't
// provide a stop method.
TEvhttpServer nonblockingServer(testBufferProcessor, port);
nonblockingServer.serve();
} else {
server.reset(new TNonblockingServer(testProcessor, protocolFactory, port));
}
}
if (server.get() != NULL) {
if (protocol_type == "header") {
// Tell the server to use the same protocol for input / output
// if using header
server->setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>());
}
apache::thrift::concurrency::PlatformThreadFactory factory;
factory.setDetached(false);
boost::shared_ptr<apache::thrift::concurrency::Runnable> serverThreadRunner(server);
boost::shared_ptr<apache::thrift::concurrency::Thread> thread
= factory.newThread(serverThreadRunner);
thread->start();
// HACK: cross language test suite is unable to handle cin properly
// that's why we stay in a endless loop here
while (1) {
}
// FIXME: find another way to stop the server (e.g. a signal)
// cout<<"Press enter to stop the server."<<endl;
// cin.ignore(); //wait until a key is pressed
server->stop();
thread->join();
server.reset();
}
cout << "done." << endl;
return 0;
}

View file

@ -0,0 +1,33 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Extra functions required for ThriftTest_types to work
#include <thrift/protocol/TDebugProtocol.h>
#include "gen-cpp/ThriftTest_types.h"
namespace thrift {
namespace test {
bool Insanity::operator<(thrift::test::Insanity const& other) const {
using apache::thrift::ThriftDebugString;
return ThriftDebugString(*this) < ThriftDebugString(other);
}
}
}

View file

@ -0,0 +1,23 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
from .test import test_name # noqa
from .collect import collect_cross_tests, collect_feature_tests # noqa
from .run import TestDispatcher # noqa
from .report import generate_known_failures, load_known_failures # noqa

View file

@ -0,0 +1,162 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
import platform
import re
from itertools import product
from .util import merge_dict
from .test import TestEntry
# Those keys are passed to execution as is.
# Note that there are keys other than these, namely:
# delay: After server is started, client start is delayed for the value
# (seconds).
# timeout: Test timeout after client is started (seconds).
# platforms: Supported platforms. Should match platform.system() value.
# protocols: list of supported protocols
# transports: list of supported transports
# sockets: list of supported sockets
#
# protocols and transports entries can be colon separated "spec:impl" pair
# (e.g. binary:accel) where test is run for any matching "spec" while actual
# argument passed to test executable is "impl".
# Otherwise "spec" is equivalent to "spec:spec" pair.
# (e.g. "binary" is equivalent to "binary:binary" in tests.json)
#
VALID_JSON_KEYS = [
'name', # name of the library, typically a language name
'workdir', # work directory where command is executed
'command', # test command
'extra_args', # args appended to command after other args are appended
'remote_args', # args added to the other side of the program
'join_args', # whether args should be passed as single concatenated string
'env', # additional environmental variable
]
DEFAULT_MAX_DELAY = 5
DEFAULT_TIMEOUT = 5
def _collect_testlibs(config, server_match, client_match=[None]):
"""Collects server/client configurations from library configurations"""
def expand_libs(config):
for lib in config:
sv = lib.pop('server', None)
cl = lib.pop('client', None)
yield lib, sv, cl
def yield_testlibs(base_configs, configs, match):
for base, conf in zip(base_configs, configs):
if conf:
if not match or base['name'] in match:
platforms = conf.get('platforms') or base.get('platforms')
if not platforms or platform.system() in platforms:
yield merge_dict(base, conf)
libs, svs, cls = zip(*expand_libs(config))
servers = list(yield_testlibs(libs, svs, server_match))
clients = list(yield_testlibs(libs, cls, client_match))
return servers, clients
def collect_features(config, match):
res = list(map(re.compile, match))
return list(filter(lambda c: any(map(lambda r: r.search(c['name']), res)), config))
def _do_collect_tests(servers, clients):
def intersection(key, o1, o2):
"""intersection of two collections.
collections are replaced with sets the first time"""
def cached_set(o, key):
v = o[key]
if not isinstance(v, set):
v = set(v)
o[key] = v
return v
return cached_set(o1, key) & cached_set(o2, key)
def intersect_with_spec(key, o1, o2):
# store as set of (spec, impl) tuple
def cached_set(o):
def to_spec_impl_tuples(values):
for v in values:
spec, _, impl = v.partition(':')
yield spec, impl or spec
v = o[key]
if not isinstance(v, set):
v = set(to_spec_impl_tuples(set(v)))
o[key] = v
return v
for spec1, impl1 in cached_set(o1):
for spec2, impl2 in cached_set(o2):
if spec1 == spec2:
name = impl1 if impl1 == impl2 else '%s-%s' % (impl1, impl2)
yield name, impl1, impl2
def maybe_max(key, o1, o2, default):
"""maximum of two if present, otherwise defult value"""
v1 = o1.get(key)
v2 = o2.get(key)
return max(v1, v2) if v1 and v2 else v1 or v2 or default
def filter_with_validkeys(o):
ret = {}
for key in VALID_JSON_KEYS:
if key in o:
ret[key] = o[key]
return ret
def merge_metadata(o, **ret):
for key in VALID_JSON_KEYS:
if key in o:
ret[key] = o[key]
return ret
for sv, cl in product(servers, clients):
for proto, proto1, proto2 in intersect_with_spec('protocols', sv, cl):
for trans, trans1, trans2 in intersect_with_spec('transports', sv, cl):
for sock in intersection('sockets', sv, cl):
yield {
'server': merge_metadata(sv, **{'protocol': proto1, 'transport': trans1}),
'client': merge_metadata(cl, **{'protocol': proto2, 'transport': trans2}),
'delay': maybe_max('delay', sv, cl, DEFAULT_MAX_DELAY),
'timeout': maybe_max('timeout', sv, cl, DEFAULT_TIMEOUT),
'protocol': proto,
'transport': trans,
'socket': sock
}
def _filter_entries(tests, regex):
if regex:
return filter(lambda t: re.search(regex, TestEntry.get_name(**t)), tests)
return tests
def collect_cross_tests(tests_dict, server_match, client_match, regex):
sv, cl = _collect_testlibs(tests_dict, server_match, client_match)
return list(_filter_entries(_do_collect_tests(sv, cl), regex))
def collect_feature_tests(tests_dict, features_dict, server_match, feature_match, regex):
sv, _ = _collect_testlibs(tests_dict, server_match)
ft = collect_features(features_dict, feature_match)
return list(_filter_entries(_do_collect_tests(sv, ft), regex))

View file

@ -0,0 +1,24 @@
import os
import sys
if sys.version_info[0] == 2:
_ENCODE = sys.getfilesystemencoding()
def path_join(*args):
bin_args = map(lambda a: a.decode(_ENCODE), args)
return os.path.join(*bin_args).encode(_ENCODE)
def str_join(s, l):
bin_args = map(lambda a: a.decode(_ENCODE), l)
b = s.decode(_ENCODE)
return b.join(bin_args).encode(_ENCODE)
logfile_open = open
else:
path_join = os.path.join
str_join = str.join
def logfile_open(*args):
return open(*args, errors='replace')

View file

@ -0,0 +1,434 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
from __future__ import print_function
import datetime
import json
import multiprocessing
import os
import platform
import re
import subprocess
import sys
import time
import traceback
from .compat import logfile_open, path_join, str_join
from .test import TestEntry
LOG_DIR = 'log'
RESULT_HTML = 'index.html'
RESULT_JSON = 'results.json'
FAIL_JSON = 'known_failures_%s.json'
def generate_known_failures(testdir, overwrite, save, out):
def collect_failures(results):
success_index = 5
for r in results:
if not r[success_index]:
yield TestEntry.get_name(*r)
try:
with logfile_open(path_join(testdir, RESULT_JSON), 'r') as fp:
results = json.load(fp)
except IOError:
sys.stderr.write('Unable to load last result. Did you run tests ?\n')
return False
fails = collect_failures(results['results'])
if not overwrite:
known = load_known_failures(testdir)
known.extend(fails)
fails = known
fails_json = json.dumps(sorted(set(fails)), indent=2, separators=(',', ': '))
if save:
with logfile_open(os.path.join(testdir, FAIL_JSON % platform.system()), 'w+') as fp:
fp.write(fails_json)
sys.stdout.write('Successfully updated known failures.\n')
if out:
sys.stdout.write(fails_json)
sys.stdout.write('\n')
return True
def load_known_failures(testdir):
try:
with logfile_open(path_join(testdir, FAIL_JSON % platform.system()), 'r') as fp:
return json.load(fp)
except IOError:
return []
class TestReporter(object):
# Unfortunately, standard library doesn't handle timezone well
# DATETIME_FORMAT = '%a %b %d %H:%M:%S %Z %Y'
DATETIME_FORMAT = '%a %b %d %H:%M:%S %Y'
def __init__(self):
self._log = multiprocessing.get_logger()
self._lock = multiprocessing.Lock()
@classmethod
def test_logfile(cls, test_name, prog_kind, dir=None):
relpath = path_join('log', '%s_%s.log' % (test_name, prog_kind))
return relpath if not dir else os.path.realpath(path_join(dir, relpath))
def _start(self):
self._start_time = time.time()
@property
def _elapsed(self):
return time.time() - self._start_time
@classmethod
def _format_date(cls):
return '%s' % datetime.datetime.now().strftime(cls.DATETIME_FORMAT)
def _print_date(self):
print(self._format_date(), file=self.out)
def _print_bar(self, out=None):
print(
'==========================================================================',
file=(out or self.out))
def _print_exec_time(self):
print('Test execution took {:.1f} seconds.'.format(self._elapsed), file=self.out)
class ExecReporter(TestReporter):
def __init__(self, testdir, test, prog):
super(ExecReporter, self).__init__()
self._test = test
self._prog = prog
self.logpath = self.test_logfile(test.name, prog.kind, testdir)
self.out = None
def begin(self):
self._start()
self._open()
if self.out and not self.out.closed:
self._print_header()
else:
self._log.debug('Output stream is not available.')
def end(self, returncode):
self._lock.acquire()
try:
if self.out and not self.out.closed:
self._print_footer(returncode)
self._close()
self.out = None
else:
self._log.debug('Output stream is not available.')
finally:
self._lock.release()
def killed(self):
print(file=self.out)
print('Server process is successfully killed.', file=self.out)
self.end(None)
def died(self):
print(file=self.out)
print('*** Server process has died unexpectedly ***', file=self.out)
self.end(None)
_init_failure_exprs = {
'server': list(map(re.compile, [
'[Aa]ddress already in use',
'Could not bind',
'EADDRINUSE',
])),
'client': list(map(re.compile, [
'[Cc]onnection refused',
'Could not connect to localhost',
'ECONNREFUSED',
'No such file or directory', # domain socket
])),
}
def maybe_false_positive(self):
"""Searches through log file for socket bind error.
Returns True if suspicious expression is found, otherwise False"""
try:
if self.out and not self.out.closed:
self.out.flush()
exprs = self._init_failure_exprs[self._prog.kind]
def match(line):
for expr in exprs:
if expr.search(line):
return True
with logfile_open(self.logpath, 'r') as fp:
if any(map(match, fp)):
return True
except (KeyboardInterrupt, SystemExit):
raise
except Exception as ex:
self._log.warn('[%s]: Error while detecting false positive: %s' % (self._test.name, str(ex)))
self._log.info(traceback.print_exc())
return False
def _open(self):
self.out = logfile_open(self.logpath, 'w+')
def _close(self):
self.out.close()
def _print_header(self):
self._print_date()
print('Executing: %s' % str_join(' ', self._prog.command), file=self.out)
print('Directory: %s' % self._prog.workdir, file=self.out)
print('config:delay: %s' % self._test.delay, file=self.out)
print('config:timeout: %s' % self._test.timeout, file=self.out)
self._print_bar()
self.out.flush()
def _print_footer(self, returncode=None):
self._print_bar()
if returncode is not None:
print('Return code: %d' % returncode, file=self.out)
else:
print('Process is killed.', file=self.out)
self._print_exec_time()
self._print_date()
class SummaryReporter(TestReporter):
def __init__(self, basedir, testdir_relative, concurrent=True):
super(SummaryReporter, self).__init__()
self._basedir = basedir
self._testdir_rel = testdir_relative
self.logdir = path_join(self.testdir, LOG_DIR)
self.out_path = path_join(self.testdir, RESULT_JSON)
self.concurrent = concurrent
self.out = sys.stdout
self._platform = platform.system()
self._revision = self._get_revision()
self._tests = []
if not os.path.exists(self.logdir):
os.mkdir(self.logdir)
self._known_failures = load_known_failures(self.testdir)
self._unexpected_success = []
self._flaky_success = []
self._unexpected_failure = []
self._expected_failure = []
self._print_header()
@property
def testdir(self):
return path_join(self._basedir, self._testdir_rel)
def _result_string(self, test):
if test.success:
if test.retry_count == 0:
return 'success'
elif test.retry_count == 1:
return 'flaky(1 retry)'
else:
return 'flaky(%d retries)' % test.retry_count
elif test.expired:
return 'failure(timeout)'
else:
return 'failure(%d)' % test.returncode
def _get_revision(self):
p = subprocess.Popen(['git', 'rev-parse', '--short', 'HEAD'],
cwd=self.testdir, stdout=subprocess.PIPE)
out, _ = p.communicate()
return out.strip()
def _format_test(self, test, with_result=True):
name = '%s-%s' % (test.server.name, test.client.name)
trans = '%s-%s' % (test.transport, test.socket)
if not with_result:
return '{:24s}{:13s}{:25s}'.format(name[:23], test.protocol[:12], trans[:24])
else:
return '{:24s}{:13s}{:25s}{:s}\n'.format(name[:23], test.protocol[:12], trans[:24], self._result_string(test))
def _print_test_header(self):
self._print_bar()
print(
'{:24s}{:13s}{:25s}{:s}'.format('server-client:', 'protocol:', 'transport:', 'result:'),
file=self.out)
def _print_header(self):
self._start()
print('Apache Thrift - Integration Test Suite', file=self.out)
self._print_date()
self._print_test_header()
def _print_unexpected_failure(self):
if len(self._unexpected_failure) > 0:
self.out.writelines([
'*** Following %d failures were unexpected ***:\n' % len(self._unexpected_failure),
'If it is introduced by you, please fix it before submitting the code.\n',
# 'If not, please report at https://issues.apache.org/jira/browse/THRIFT\n',
])
self._print_test_header()
for i in self._unexpected_failure:
self.out.write(self._format_test(self._tests[i]))
self._print_bar()
else:
print('No unexpected failures.', file=self.out)
def _print_flaky_success(self):
if len(self._flaky_success) > 0:
print(
'Following %d tests were expected to cleanly succeed but needed retry:' % len(self._flaky_success),
file=self.out)
self._print_test_header()
for i in self._flaky_success:
self.out.write(self._format_test(self._tests[i]))
self._print_bar()
def _print_unexpected_success(self):
if len(self._unexpected_success) > 0:
print(
'Following %d tests were known to fail but succeeded (maybe flaky):' % len(self._unexpected_success),
file=self.out)
self._print_test_header()
for i in self._unexpected_success:
self.out.write(self._format_test(self._tests[i]))
self._print_bar()
def _http_server_command(self, port):
if sys.version_info[0] < 3:
return 'python -m SimpleHTTPServer %d' % port
else:
return 'python -m http.server %d' % port
def _print_footer(self):
fail_count = len(self._expected_failure) + len(self._unexpected_failure)
self._print_bar()
self._print_unexpected_success()
self._print_flaky_success()
self._print_unexpected_failure()
self._write_html_data()
self._assemble_log('unexpected failures', self._unexpected_failure)
self._assemble_log('known failures', self._expected_failure)
self.out.writelines([
'You can browse results at:\n',
'\tfile://%s/%s\n' % (self.testdir, RESULT_HTML),
'# If you use Chrome, run:\n',
'# \tcd %s\n#\t%s\n' % (self._basedir, self._http_server_command(8001)),
'# then browse:\n',
'# \thttp://localhost:%d/%s/\n' % (8001, self._testdir_rel),
'Full log for each test is here:\n',
'\ttest/log/client_server_protocol_transport_client.log\n',
'\ttest/log/client_server_protocol_transport_server.log\n',
'%d failed of %d tests in total.\n' % (fail_count, len(self._tests)),
])
self._print_exec_time()
self._print_date()
def _render_result(self, test):
return [
test.server.name,
test.client.name,
test.protocol,
test.transport,
test.socket,
test.success,
test.as_expected,
test.returncode,
{
'server': self.test_logfile(test.name, test.server.kind),
'client': self.test_logfile(test.name, test.client.kind),
},
]
def _write_html_data(self):
"""Writes JSON data to be read by result html"""
results = [self._render_result(r) for r in self._tests]
with logfile_open(self.out_path, 'w+') as fp:
fp.write(json.dumps({
'date': self._format_date(),
'revision': str(self._revision),
'platform': self._platform,
'duration': '{:.1f}'.format(self._elapsed),
'results': results,
}, indent=2))
def _assemble_log(self, title, indexes):
if len(indexes) > 0:
def add_prog_log(fp, test, prog_kind):
print('*************************** %s message ***************************' % prog_kind,
file=fp)
path = self.test_logfile(test.name, prog_kind, self.testdir)
if os.path.exists(path):
with logfile_open(path, 'r') as prog_fp:
print(prog_fp.read(), file=fp)
filename = title.replace(' ', '_') + '.log'
with logfile_open(os.path.join(self.logdir, filename), 'w+') as fp:
for test in map(self._tests.__getitem__, indexes):
fp.write('TEST: [%s]\n' % test.name)
add_prog_log(fp, test, test.server.kind)
add_prog_log(fp, test, test.client.kind)
fp.write('**********************************************************************\n\n')
print('%s are logged to %s/%s/%s' % (title.capitalize(), self._testdir_rel, LOG_DIR, filename))
def end(self):
self._print_footer()
return len(self._unexpected_failure) == 0
def add_test(self, test_dict):
test = TestEntry(self.testdir, **test_dict)
self._lock.acquire()
try:
if not self.concurrent:
self.out.write(self._format_test(test, False))
self.out.flush()
self._tests.append(test)
return len(self._tests) - 1
finally:
self._lock.release()
def add_result(self, index, returncode, expired, retry_count):
self._lock.acquire()
try:
failed = returncode is None or returncode != 0
flaky = not failed and retry_count != 0
test = self._tests[index]
known = test.name in self._known_failures
if failed:
if known:
self._log.debug('%s failed as expected' % test.name)
self._expected_failure.append(index)
else:
self._log.info('unexpected failure: %s' % test.name)
self._unexpected_failure.append(index)
elif flaky and not known:
self._log.info('unexpected flaky success: %s' % test.name)
self._flaky_success.append(index)
elif not flaky and known:
self._log.info('unexpected success: %s' % test.name)
self._unexpected_success.append(index)
test.success = not failed
test.returncode = returncode
test.retry_count = retry_count
test.expired = expired
test.as_expected = known == failed
if not self.concurrent:
self.out.write(self._result_string(test) + '\n')
else:
self.out.write(self._format_test(test))
finally:
self._lock.release()

View file

@ -0,0 +1,389 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
import contextlib
import multiprocessing
import multiprocessing.managers
import os
import platform
import random
import signal
import socket
import subprocess
import sys
import threading
import time
from .compat import str_join
from .test import TestEntry, domain_socket_path
from .report import ExecReporter, SummaryReporter
RESULT_TIMEOUT = 128
RESULT_ERROR = 64
# globals
ports = None
stop = None
class ExecutionContext(object):
def __init__(self, cmd, cwd, env, report):
self._log = multiprocessing.get_logger()
self.report = report
self.cmd = cmd
self.cwd = cwd
self.env = env
self.timer = None
self.expired = False
self.killed = False
self.proc = None
def _expire(self):
self._log.info('Timeout')
self.expired = True
self.kill()
def kill(self):
self._log.debug('Killing process : %d' % self.proc.pid)
self.killed = True
if platform.system() != 'Windows':
try:
os.killpg(self.proc.pid, signal.SIGKILL)
except Exception:
self._log.info('Failed to kill process group', exc_info=sys.exc_info())
try:
self.proc.kill()
except Exception:
self._log.info('Failed to kill process', exc_info=sys.exc_info())
def _popen_args(self):
args = {
'cwd': self.cwd,
'env': self.env,
'stdout': self.report.out,
'stderr': subprocess.STDOUT,
}
# make sure child processes doesn't remain after killing
if platform.system() == 'Windows':
DETACHED_PROCESS = 0x00000008
args.update(creationflags=DETACHED_PROCESS | subprocess.CREATE_NEW_PROCESS_GROUP)
else:
args.update(preexec_fn=os.setsid)
return args
def start(self, timeout=0):
joined = str_join(' ', self.cmd)
self._log.debug('COMMAND: %s', joined)
self._log.debug('WORKDIR: %s', self.cwd)
self._log.debug('LOGFILE: %s', self.report.logpath)
self.report.begin()
self.proc = subprocess.Popen(self.cmd, **self._popen_args())
if timeout > 0:
self.timer = threading.Timer(timeout, self._expire)
self.timer.start()
return self._scoped()
@contextlib.contextmanager
def _scoped(self):
yield self
self._log.debug('Killing scoped process')
if self.proc.poll() is None:
self.kill()
self.report.killed()
else:
self._log.debug('Process died unexpectedly')
self.report.died()
def wait(self):
self.proc.communicate()
if self.timer:
self.timer.cancel()
self.report.end(self.returncode)
@property
def returncode(self):
return self.proc.returncode if self.proc else None
def exec_context(port, logdir, test, prog):
report = ExecReporter(logdir, test, prog)
prog.build_command(port)
return ExecutionContext(prog.command, prog.workdir, prog.env, report)
def run_test(testdir, logdir, test_dict, max_retry, async=True):
logger = multiprocessing.get_logger()
def ensure_socket_open(proc, port, max_delay):
sleeped = 0.1
time.sleep(sleeped)
sleep_step = 0.2
while True:
# Create sockets every iteration because refused sockets cannot be
# reused on some systems.
sock4 = socket.socket()
sock6 = socket.socket(family=socket.AF_INET6)
try:
if sock4.connect_ex(('127.0.0.1', port)) == 0 \
or sock6.connect_ex(('::1', port)) == 0:
return True
if proc.poll() is not None:
logger.warn('server process is exited')
return False
if sleeped > max_delay:
logger.warn('sleeped for %f seconds but server port is not open' % sleeped)
return False
time.sleep(sleep_step)
sleeped += sleep_step
finally:
sock4.close()
sock6.close()
logger.debug('waited %f sec for server port open' % sleeped)
return True
try:
max_bind_retry = 3
retry_count = 0
bind_retry_count = 0
test = TestEntry(testdir, **test_dict)
while True:
if stop.is_set():
logger.debug('Skipping because shutting down')
return (retry_count, None)
logger.debug('Start')
with PortAllocator.alloc_port_scoped(ports, test.socket) as port:
logger.debug('Start with port %d' % port)
sv = exec_context(port, logdir, test, test.server)
cl = exec_context(port, logdir, test, test.client)
logger.debug('Starting server')
with sv.start():
if test.socket in ('domain', 'abstract'):
time.sleep(0.1)
port_ok = True
else:
port_ok = ensure_socket_open(sv.proc, port, test.delay)
if port_ok:
connect_retry_count = 0
max_connect_retry = 3
connect_retry_wait = 0.5
while True:
if sv.proc.poll() is not None:
logger.info('not starting client because server process is absent')
break
logger.debug('Starting client')
cl.start(test.timeout)
logger.debug('Waiting client')
cl.wait()
if not cl.report.maybe_false_positive() or connect_retry_count >= max_connect_retry:
if connect_retry_count > 0 and connect_retry_count < max_connect_retry:
logger.warn('[%s]: Connected after %d retry (%.2f sec each)' % (test.server.name, connect_retry_count, connect_retry_wait))
# Wait for 50ms to see if server does not die at the end.
time.sleep(0.05)
break
logger.debug('Server may not be ready, waiting %.2f second...' % connect_retry_wait)
time.sleep(connect_retry_wait)
connect_retry_count += 1
if sv.report.maybe_false_positive() and bind_retry_count < max_bind_retry:
logger.warn('[%s]: Detected socket bind failure, retrying...', test.server.name)
bind_retry_count += 1
else:
if cl.expired:
result = RESULT_TIMEOUT
else:
result = cl.proc.returncode if cl.proc else RESULT_ERROR
if not sv.killed:
# Server died without being killed.
result |= RESULT_ERROR
if result == 0 or retry_count >= max_retry:
return (retry_count, result)
else:
logger.info('[%s-%s]: test failed, retrying...', test.server.name, test.client.name)
retry_count += 1
except Exception:
if not async:
raise
logger.warn('Error executing [%s]', test.name, exc_info=True)
return (retry_count, RESULT_ERROR)
except:
logger.info('Interrupted execution', exc_info=True)
if not async:
raise
stop.set()
return (retry_count, RESULT_ERROR)
class PortAllocator(object):
def __init__(self):
self._log = multiprocessing.get_logger()
self._lock = multiprocessing.Lock()
self._ports = set()
self._dom_ports = set()
self._last_alloc = 0
def _get_tcp_port(self):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind(('', 0))
port = sock.getsockname()[1]
self._lock.acquire()
try:
ok = port not in self._ports
if ok:
self._ports.add(port)
self._last_alloc = time.time()
finally:
self._lock.release()
sock.close()
return port if ok else self._get_tcp_port()
def _get_domain_port(self):
port = random.randint(1024, 65536)
self._lock.acquire()
try:
ok = port not in self._dom_ports
if ok:
self._dom_ports.add(port)
finally:
self._lock.release()
return port if ok else self._get_domain_port()
def alloc_port(self, socket_type):
if socket_type in ('domain', 'abstract'):
return self._get_domain_port()
else:
return self._get_tcp_port()
# static method for inter-process invokation
@staticmethod
@contextlib.contextmanager
def alloc_port_scoped(allocator, socket_type):
port = allocator.alloc_port(socket_type)
yield port
allocator.free_port(socket_type, port)
def free_port(self, socket_type, port):
self._log.debug('free_port')
self._lock.acquire()
try:
if socket_type == 'domain':
self._dom_ports.remove(port)
path = domain_socket_path(port)
if os.path.exists(path):
os.remove(path)
elif socket_type == 'abstract':
self._dom_ports.remove(port)
else:
self._ports.remove(port)
except IOError:
self._log.info('Error while freeing port', exc_info=sys.exc_info())
finally:
self._lock.release()
class NonAsyncResult(object):
def __init__(self, value):
self._value = value
def get(self, timeout=None):
return self._value
def wait(self, timeout=None):
pass
def ready(self):
return True
def successful(self):
return self._value == 0
class TestDispatcher(object):
def __init__(self, testdir, basedir, logdir_rel, concurrency):
self._log = multiprocessing.get_logger()
self.testdir = testdir
self._report = SummaryReporter(basedir, logdir_rel, concurrency > 1)
self.logdir = self._report.testdir
# seems needed for python 2.x to handle keyboard interrupt
self._stop = multiprocessing.Event()
self._async = concurrency > 1
if not self._async:
self._pool = None
global stop
global ports
stop = self._stop
ports = PortAllocator()
else:
self._m = multiprocessing.managers.BaseManager()
self._m.register('ports', PortAllocator)
self._m.start()
self._pool = multiprocessing.Pool(concurrency, self._pool_init, (self._m.address,))
self._log.debug(
'TestDispatcher started with %d concurrent jobs' % concurrency)
def _pool_init(self, address):
global stop
global m
global ports
stop = self._stop
m = multiprocessing.managers.BaseManager(address)
m.connect()
ports = m.ports()
def _dispatch_sync(self, test, cont, max_retry):
r = run_test(self.testdir, self.logdir, test, max_retry, False)
cont(r)
return NonAsyncResult(r)
def _dispatch_async(self, test, cont, max_retry):
self._log.debug('_dispatch_async')
return self._pool.apply_async(func=run_test, args=(self.testdir, self.logdir, test, max_retry), callback=cont)
def dispatch(self, test, max_retry):
index = self._report.add_test(test)
def cont(result):
if not self._stop.is_set():
if result and len(result) == 2:
retry_count, returncode = result
else:
retry_count = 0
returncode = RESULT_ERROR
self._log.debug('freeing port')
self._log.debug('adding result')
self._report.add_result(index, returncode, returncode == RESULT_TIMEOUT, retry_count)
self._log.debug('finish continuation')
fn = self._dispatch_async if self._async else self._dispatch_sync
return fn(test, cont, max_retry)
def wait(self):
if self._async:
self._pool.close()
self._pool.join()
self._m.shutdown()
return self._report.end()
def terminate(self):
self._stop.set()
if self._async:
self._pool.terminate()
self._pool.join()
self._m.shutdown()

View file

@ -0,0 +1,2 @@
[flake8]
max-line-length = 100

View file

@ -0,0 +1,143 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
import copy
import multiprocessing
import os
import sys
from .compat import path_join
from .util import merge_dict
def domain_socket_path(port):
return '/tmp/ThriftTest.thrift.%d' % port
class TestProgram(object):
def __init__(self, kind, name, protocol, transport, socket, workdir, command, env=None,
extra_args=[], extra_args2=[], join_args=False, **kwargs):
self.kind = kind
self.name = name
self.protocol = protocol
self.transport = transport
self.socket = socket
self.workdir = workdir
self.command = None
self._base_command = self._fix_cmd_path(command)
if env:
self.env = copy.copy(os.environ)
self.env.update(env)
else:
self.env = os.environ
self._extra_args = extra_args
self._extra_args2 = extra_args2
self._join_args = join_args
def _fix_cmd_path(self, cmd):
# if the arg is a file in the current directory, make it path
def abs_if_exists(arg):
p = path_join(self.workdir, arg)
return p if os.path.exists(p) else arg
if cmd[0] == 'python':
cmd[0] = sys.executable
else:
cmd[0] = abs_if_exists(cmd[0])
return cmd
def _socket_args(self, socket, port):
return {
'ip-ssl': ['--ssl'],
'domain': ['--domain-socket=%s' % domain_socket_path(port)],
'abstract': ['--abstract-namespace', '--domain-socket=%s' % domain_socket_path(port)],
}.get(socket, None)
def build_command(self, port):
cmd = copy.copy(self._base_command)
args = copy.copy(self._extra_args2)
args.append('--protocol=' + self.protocol)
args.append('--transport=' + self.transport)
socket_args = self._socket_args(self.socket, port)
if socket_args:
args += socket_args
args.append('--port=%d' % port)
if self._join_args:
cmd.append('%s' % " ".join(args))
else:
cmd.extend(args)
if self._extra_args:
cmd.extend(self._extra_args)
self.command = cmd
return self.command
class TestEntry(object):
def __init__(self, testdir, server, client, delay, timeout, **kwargs):
self.testdir = testdir
self._log = multiprocessing.get_logger()
self._config = kwargs
self.protocol = kwargs['protocol']
self.transport = kwargs['transport']
self.socket = kwargs['socket']
srv_dict = self._fix_workdir(merge_dict(self._config, server))
cli_dict = self._fix_workdir(merge_dict(self._config, client))
cli_dict['extra_args2'] = srv_dict.pop('remote_args', [])
srv_dict['extra_args2'] = cli_dict.pop('remote_args', [])
self.server = TestProgram('server', **srv_dict)
self.client = TestProgram('client', **cli_dict)
self.delay = delay
self.timeout = timeout
self._name = None
# results
self.success = None
self.as_expected = None
self.returncode = None
self.expired = False
self.retry_count = 0
def _fix_workdir(self, config):
key = 'workdir'
path = config.get(key, None)
if not path:
path = self.testdir
if os.path.isabs(path):
path = os.path.realpath(path)
else:
path = os.path.realpath(path_join(self.testdir, path))
config.update({key: path})
return config
@classmethod
def get_name(cls, server, client, protocol, transport, socket, *args, **kwargs):
return '%s-%s_%s_%s-%s' % (server, client, protocol, transport, socket)
@property
def name(self):
if not self._name:
self._name = self.get_name(
self.server.name, self.client.name, self.protocol, self.transport, self.socket)
return self._name
@property
def transport_name(self):
return '%s-%s' % (self.transport, self.socket)
def test_name(server, client, protocol, transport, socket, **kwargs):
return TestEntry.get_name(server['name'], client['name'], protocol, transport, socket)

View file

@ -0,0 +1,31 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
import copy
def merge_dict(base, update):
"""Update dict concatenating list values"""
res = copy.deepcopy(base)
for k, v in list(update.items()):
if k in list(res.keys()) and isinstance(v, list):
res[k].extend(v)
else:
res[k] = v
return res

View file

@ -0,0 +1,87 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
GENERATED = \
gen-csharp/Thrift/Test/Bonk.cs \
gen-csharp/Thrift/Test/Bools.cs \
gen-csharp/Thrift/Test/BoolTest.cs \
gen-csharp/Thrift/Test/CrazyNesting.cs \
gen-csharp/Thrift/Test/EmptyStruct.cs \
gen-csharp/Thrift/Test/GuessProtocolStruct.cs \
gen-csharp/Thrift/Test/Insanity.cs \
gen-csharp/Thrift/Test/LargeDeltas.cs \
gen-csharp/Thrift/Test/ListBonks.cs \
gen-csharp/Thrift/Test/ListTypeVersioningV1.cs \
gen-csharp/Thrift/Test/ListTypeVersioningV2.cs \
gen-csharp/Thrift/Test/NestedListsBonk.cs \
gen-csharp/Thrift/Test/NestedListsI32x2.cs \
gen-csharp/Thrift/Test/NestedListsI32x3.cs \
gen-csharp/Thrift/Test/NestedMixedx2.cs \
gen-csharp/Thrift/Test/Numberz.cs \
gen-csharp/Thrift/Test/OneField.cs \
gen-csharp/Thrift/Test/SecondService.cs \
gen-csharp/Thrift/Test/StructA.cs \
gen-csharp/Thrift/Test/StructB.cs \
gen-csharp/Thrift/Test/ThriftTest.Constants.cs \
gen-csharp/Thrift/Test/ThriftTest.cs \
gen-csharp/Thrift/Test/VersioningTestV1.cs \
gen-csharp/Thrift/Test/VersioningTestV2.cs \
gen-csharp/Thrift/Test/Xception.cs \
gen-csharp/Thrift/Test/Xception2.cs \
gen-csharp/Thrift/Test/Xtruct.cs \
gen-csharp/Thrift/Test/Xtruct2.cs \
gen-csharp/Thrift/Test/Xtruct3.cs
BUILT_SOURCES = $(GENERATED)
if MONO_MCS
CSC = mcs
else
CSC = gmcs
endif
if NET_2_0
CSC_DEFINES = -d:NET_2_0
endif
LIBDIR = $(top_builddir)/lib/csharp
THRIFT = $(top_builddir)/compiler/cpp/thrift
$(GENERATED): $(top_srcdir)/test/ThriftTest.thrift $(THRIFT)
$(THRIFT) --gen csharp -o . $<
precross: TestClientServer.exe
ThriftImpl.dll: $(GENERATED) $(LIBDIR)/Thrift.dll
$(CSC) $(CSC_DEFINES) -t:library -out:$@ -reference:$(LIBDIR)/Thrift.dll $(GENERATED)
SRCS = TestClient.cs TestServer.cs Program.cs
TestClientServer.exe: $(SRCS) ThriftImpl.dll
$(CSC) $(CSC_DEFINES) -out:$@ -reference:$(LIBDIR)/Thrift.dll -reference:ThriftImpl.dll $(SRCS)
clean-local:
$(RM) -rf gen-csharp *.exe *.dll
TESTPORT = 9500
check-local: TestClientServer.exe
MONO_PATH=$(LIBDIR) timeout 10 mono TestClientServer.exe server --port=$(TESTPORT) &
sleep 1
MONO_PATH=$(LIBDIR) mono TestClientServer.exe client --port=$(TESTPORT)

View file

@ -0,0 +1,71 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Distributed under the Thrift Software License
//
// See accompanying file LICENSE or visit the Thrift site at:
// http://developers.facebook.com/thrift/
using System;
using Thrift.Transport;
using Thrift.Protocol;
using Thrift.Test; //generated code
namespace Test
{
class Program
{
static int Main(string[] args)
{
if (args.Length == 0)
{
Console.WriteLine("must provide 'server' or 'client' arg");
return -1;
}
try
{
Console.SetBufferSize(Console.BufferWidth, 4096);
}
catch (Exception)
{
Console.WriteLine("Failed to grow scroll-back buffer");
}
string[] subArgs = new string[args.Length - 1];
for(int i = 1; i < args.Length; i++)
{
subArgs[i-1] = args[i];
}
if (args[0] == "client")
{
return TestClient.Execute(subArgs);
}
else if (args[0] == "server")
{
return TestServer.Execute(subArgs) ? 0 : 1;
}
else
{
Console.WriteLine("first argument must be 'server' or 'client'");
}
return 0;
}
}
}

View file

@ -0,0 +1,55 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ThriftTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ThriftTest")]
[assembly: AssemblyCopyright("Copyright © 2009 The Apache Software Foundation")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f41b193b-f1ab-48ee-8843-f88e43084e26")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,836 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using System.Threading;
using System.Security.Cryptography.X509Certificates;
using Thrift.Collections;
using Thrift.Protocol;
using Thrift.Transport;
using Thrift.Test;
using System.Security.Authentication;
namespace Test
{
public class TestClient
{
private class TestParams
{
public int numIterations = 1;
public string host = "localhost";
public int port = 9090;
public string url;
public string pipe;
public bool buffered;
public bool framed;
public string protocol;
public bool encrypted = false;
protected bool _isFirstTransport = true;
public TTransport CreateTransport()
{
if (url == null)
{
// endpoint transport
TTransport trans = null;
if (pipe != null)
trans = new TNamedPipeClientTransport(pipe);
else
{
if (encrypted)
{
string certPath = "../keys/client.p12";
X509Certificate cert = new X509Certificate2(certPath, "thrift");
trans = new TTLSSocket(host, port, 0, cert, (o, c, chain, errors) => true, null, SslProtocols.Tls);
}
else
{
trans = new TSocket(host, port);
}
}
// layered transport
if (buffered)
trans = new TBufferedTransport(trans);
if (framed)
trans = new TFramedTransport(trans);
if (_isFirstTransport)
{
//ensure proper open/close of transport
trans.Open();
trans.Close();
_isFirstTransport = false;
}
return trans;
}
else
{
return new THttpClient(new Uri(url));
}
}
public TProtocol CreateProtocol(TTransport transport)
{
if (protocol == "compact")
return new TCompactProtocol(transport);
else if (protocol == "json")
return new TJSONProtocol(transport);
else
return new TBinaryProtocol(transport);
}
};
private const int ErrorBaseTypes = 1;
private const int ErrorStructs = 2;
private const int ErrorContainers = 4;
private const int ErrorExceptions = 8;
private const int ErrorUnknown = 64;
private class ClientTest
{
private readonly TTransport transport;
private readonly ThriftTest.Client client;
private readonly int numIterations;
private bool done;
public int ReturnCode { get; set; }
public ClientTest(TestParams param)
{
transport = param.CreateTransport();
client = new ThriftTest.Client(param.CreateProtocol(transport));
numIterations = param.numIterations;
}
public void Execute()
{
if (done)
{
Console.WriteLine("Execute called more than once");
throw new InvalidOperationException();
}
for (int i = 0; i < numIterations; i++)
{
try
{
if (!transport.IsOpen)
transport.Open();
}
catch (TTransportException ex)
{
Console.WriteLine("*** FAILED ***");
Console.WriteLine("Connect failed: " + ex.Message);
ReturnCode |= ErrorUnknown;
Console.WriteLine(ex.Message + " ST: " + ex.StackTrace);
continue;
}
try
{
ReturnCode |= ExecuteClientTest(client);
}
catch (Exception ex)
{
Console.WriteLine("*** FAILED ***");
Console.WriteLine(ex.Message + " ST: " + ex.StackTrace);
ReturnCode |= ErrorUnknown;
}
}
try
{
transport.Close();
}
catch(Exception ex)
{
Console.WriteLine("Error while closing transport");
Console.WriteLine(ex.Message + " ST: " + ex.StackTrace);
}
done = true;
}
}
public static int Execute(string[] args)
{
try
{
TestParams param = new TestParams();
int numThreads = 1;
try
{
for (int i = 0; i < args.Length; i++)
{
if (args[i] == "-u")
{
param.url = args[++i];
}
else if (args[i] == "-n")
{
param.numIterations = Convert.ToInt32(args[++i]);
}
else if (args[i] == "-pipe") // -pipe <name>
{
param.pipe = args[++i];
Console.WriteLine("Using named pipes transport");
}
else if (args[i].Contains("--host="))
{
param.host = args[i].Substring(args[i].IndexOf("=") + 1);
}
else if (args[i].Contains("--port="))
{
param.port = int.Parse(args[i].Substring(args[i].IndexOf("=")+1));
}
else if (args[i] == "-b" || args[i] == "--buffered" || args[i] == "--transport=buffered")
{
param.buffered = true;
Console.WriteLine("Using buffered sockets");
}
else if (args[i] == "-f" || args[i] == "--framed" || args[i] == "--transport=framed")
{
param.framed = true;
Console.WriteLine("Using framed transport");
}
else if (args[i] == "-t")
{
numThreads = Convert.ToInt32(args[++i]);
}
else if (args[i] == "--compact" || args[i] == "--protocol=compact")
{
param.protocol = "compact";
Console.WriteLine("Using compact protocol");
}
else if (args[i] == "--json" || args[i] == "--protocol=json")
{
param.protocol = "json";
Console.WriteLine("Using JSON protocol");
}
else if (args[i] == "--ssl")
{
param.encrypted = true;
Console.WriteLine("Using encrypted transport");
}
}
}
catch (Exception ex)
{
Console.WriteLine("*** FAILED ***");
Console.WriteLine("Error while parsing arguments");
Console.WriteLine(ex.Message + " ST: " + ex.StackTrace);
return ErrorUnknown;
}
var tests = Enumerable.Range(0, numThreads).Select(_ => new ClientTest(param)).ToArray();
//issue tests on separate threads simultaneously
var threads = tests.Select(test => new Thread(test.Execute)).ToArray();
DateTime start = DateTime.Now;
foreach (var t in threads)
t.Start();
foreach (var t in threads)
t.Join();
Console.WriteLine("Total time: " + (DateTime.Now - start));
Console.WriteLine();
return tests.Select(t => t.ReturnCode).Aggregate((r1, r2) => r1 | r2);
}
catch (Exception outerEx)
{
Console.WriteLine("*** FAILED ***");
Console.WriteLine("Unexpected error");
Console.WriteLine(outerEx.Message + " ST: " + outerEx.StackTrace);
return ErrorUnknown;
}
}
public static string BytesToHex(byte[] data) {
return BitConverter.ToString(data).Replace("-", string.Empty);
}
public static byte[] PrepareTestData(bool randomDist)
{
byte[] retval = new byte[0x100];
int initLen = Math.Min(0x100,retval.Length);
// linear distribution, unless random is requested
if (!randomDist) {
for (var i = 0; i < initLen; ++i) {
retval[i] = (byte)i;
}
return retval;
}
// random distribution
for (var i = 0; i < initLen; ++i) {
retval[i] = (byte)0;
}
var rnd = new Random();
for (var i = 1; i < initLen; ++i) {
while( true) {
int nextPos = rnd.Next() % initLen;
if (retval[nextPos] == 0) {
retval[nextPos] = (byte)i;
break;
}
}
}
return retval;
}
public static int ExecuteClientTest(ThriftTest.Client client)
{
int returnCode = 0;
Console.Write("testVoid()");
client.testVoid();
Console.WriteLine(" = void");
Console.Write("testString(\"Test\")");
string s = client.testString("Test");
Console.WriteLine(" = \"" + s + "\"");
if ("Test" != s)
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorBaseTypes;
}
Console.Write("testBool(true)");
bool t = client.testBool((bool)true);
Console.WriteLine(" = " + t);
if (!t)
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorBaseTypes;
}
Console.Write("testBool(false)");
bool f = client.testBool((bool)false);
Console.WriteLine(" = " + f);
if (f)
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorBaseTypes;
}
Console.Write("testByte(1)");
sbyte i8 = client.testByte((sbyte)1);
Console.WriteLine(" = " + i8);
if (1 != i8)
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorBaseTypes;
}
Console.Write("testI32(-1)");
int i32 = client.testI32(-1);
Console.WriteLine(" = " + i32);
if (-1 != i32)
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorBaseTypes;
}
Console.Write("testI64(-34359738368)");
long i64 = client.testI64(-34359738368);
Console.WriteLine(" = " + i64);
if (-34359738368 != i64)
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorBaseTypes;
}
// TODO: Validate received message
Console.Write("testDouble(5.325098235)");
double dub = client.testDouble(5.325098235);
Console.WriteLine(" = " + dub);
if (5.325098235 != dub)
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorBaseTypes;
}
Console.Write("testDouble(-0.000341012439638598279)");
dub = client.testDouble(-0.000341012439638598279);
Console.WriteLine(" = " + dub);
if (-0.000341012439638598279 != dub)
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorBaseTypes;
}
byte[] binOut = PrepareTestData(true);
Console.Write("testBinary(" + BytesToHex(binOut) + ")");
try
{
byte[] binIn = client.testBinary(binOut);
Console.WriteLine(" = " + BytesToHex(binIn));
if (binIn.Length != binOut.Length)
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorBaseTypes;
}
for (int ofs = 0; ofs < Math.Min(binIn.Length, binOut.Length); ++ofs)
if (binIn[ofs] != binOut[ofs])
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorBaseTypes;
}
}
catch (Thrift.TApplicationException ex)
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorBaseTypes;
Console.WriteLine(ex.Message + " ST: " + ex.StackTrace);
}
// binary equals? only with hashcode option enabled ...
Console.WriteLine("Test CrazyNesting");
if( typeof(CrazyNesting).GetMethod("Equals").DeclaringType == typeof(CrazyNesting))
{
CrazyNesting one = new CrazyNesting();
CrazyNesting two = new CrazyNesting();
one.String_field = "crazy";
two.String_field = "crazy";
one.Binary_field = new byte[10] { 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0xFF };
two.Binary_field = new byte[10] { 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0xFF };
if (!one.Equals(two))
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorContainers;
throw new Exception("CrazyNesting.Equals failed");
}
}
// TODO: Validate received message
Console.Write("testStruct({\"Zero\", 1, -3, -5})");
Xtruct o = new Xtruct();
o.String_thing = "Zero";
o.Byte_thing = (sbyte)1;
o.I32_thing = -3;
o.I64_thing = -5;
Xtruct i = client.testStruct(o);
Console.WriteLine(" = {\"" + i.String_thing + "\", " + i.Byte_thing + ", " + i.I32_thing + ", " + i.I64_thing + "}");
// TODO: Validate received message
Console.Write("testNest({1, {\"Zero\", 1, -3, -5}, 5})");
Xtruct2 o2 = new Xtruct2();
o2.Byte_thing = (sbyte)1;
o2.Struct_thing = o;
o2.I32_thing = 5;
Xtruct2 i2 = client.testNest(o2);
i = i2.Struct_thing;
Console.WriteLine(" = {" + i2.Byte_thing + ", {\"" + i.String_thing + "\", " + i.Byte_thing + ", " + i.I32_thing + ", " + i.I64_thing + "}, " + i2.I32_thing + "}");
Dictionary<int, int> mapout = new Dictionary<int, int>();
for (int j = 0; j < 5; j++)
{
mapout[j] = j - 10;
}
Console.Write("testMap({");
bool first = true;
foreach (int key in mapout.Keys)
{
if (first)
{
first = false;
}
else
{
Console.Write(", ");
}
Console.Write(key + " => " + mapout[key]);
}
Console.Write("})");
Dictionary<int, int> mapin = client.testMap(mapout);
Console.Write(" = {");
first = true;
foreach (int key in mapin.Keys)
{
if (first)
{
first = false;
}
else
{
Console.Write(", ");
}
Console.Write(key + " => " + mapin[key]);
}
Console.WriteLine("}");
// TODO: Validate received message
List<int> listout = new List<int>();
for (int j = -2; j < 3; j++)
{
listout.Add(j);
}
Console.Write("testList({");
first = true;
foreach (int j in listout)
{
if (first)
{
first = false;
}
else
{
Console.Write(", ");
}
Console.Write(j);
}
Console.Write("})");
List<int> listin = client.testList(listout);
Console.Write(" = {");
first = true;
foreach (int j in listin)
{
if (first)
{
first = false;
}
else
{
Console.Write(", ");
}
Console.Write(j);
}
Console.WriteLine("}");
//set
// TODO: Validate received message
THashSet<int> setout = new THashSet<int>();
for (int j = -2; j < 3; j++)
{
setout.Add(j);
}
Console.Write("testSet({");
first = true;
foreach (int j in setout)
{
if (first)
{
first = false;
}
else
{
Console.Write(", ");
}
Console.Write(j);
}
Console.Write("})");
THashSet<int> setin = client.testSet(setout);
Console.Write(" = {");
first = true;
foreach (int j in setin)
{
if (first)
{
first = false;
}
else
{
Console.Write(", ");
}
Console.Write(j);
}
Console.WriteLine("}");
Console.Write("testEnum(ONE)");
Numberz ret = client.testEnum(Numberz.ONE);
Console.WriteLine(" = " + ret);
if (Numberz.ONE != ret)
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorStructs;
}
Console.Write("testEnum(TWO)");
ret = client.testEnum(Numberz.TWO);
Console.WriteLine(" = " + ret);
if (Numberz.TWO != ret)
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorStructs;
}
Console.Write("testEnum(THREE)");
ret = client.testEnum(Numberz.THREE);
Console.WriteLine(" = " + ret);
if (Numberz.THREE != ret)
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorStructs;
}
Console.Write("testEnum(FIVE)");
ret = client.testEnum(Numberz.FIVE);
Console.WriteLine(" = " + ret);
if (Numberz.FIVE != ret)
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorStructs;
}
Console.Write("testEnum(EIGHT)");
ret = client.testEnum(Numberz.EIGHT);
Console.WriteLine(" = " + ret);
if (Numberz.EIGHT != ret)
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorStructs;
}
Console.Write("testTypedef(309858235082523)");
long uid = client.testTypedef(309858235082523L);
Console.WriteLine(" = " + uid);
if (309858235082523L != uid)
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorStructs;
}
// TODO: Validate received message
Console.Write("testMapMap(1)");
Dictionary<int, Dictionary<int, int>> mm = client.testMapMap(1);
Console.Write(" = {");
foreach (int key in mm.Keys)
{
Console.Write(key + " => {");
Dictionary<int, int> m2 = mm[key];
foreach (int k2 in m2.Keys)
{
Console.Write(k2 + " => " + m2[k2] + ", ");
}
Console.Write("}, ");
}
Console.WriteLine("}");
// TODO: Validate received message
Insanity insane = new Insanity();
insane.UserMap = new Dictionary<Numberz, long>();
insane.UserMap[Numberz.FIVE] = 5000L;
Xtruct truck = new Xtruct();
truck.String_thing = "Truck";
truck.Byte_thing = (sbyte)8;
truck.I32_thing = 8;
truck.I64_thing = 8;
insane.Xtructs = new List<Xtruct>();
insane.Xtructs.Add(truck);
Console.Write("testInsanity()");
Dictionary<long, Dictionary<Numberz, Insanity>> whoa = client.testInsanity(insane);
Console.Write(" = {");
foreach (long key in whoa.Keys)
{
Dictionary<Numberz, Insanity> val = whoa[key];
Console.Write(key + " => {");
foreach (Numberz k2 in val.Keys)
{
Insanity v2 = val[k2];
Console.Write(k2 + " => {");
Dictionary<Numberz, long> userMap = v2.UserMap;
Console.Write("{");
if (userMap != null)
{
foreach (Numberz k3 in userMap.Keys)
{
Console.Write(k3 + " => " + userMap[k3] + ", ");
}
}
else
{
Console.Write("null");
}
Console.Write("}, ");
List<Xtruct> xtructs = v2.Xtructs;
Console.Write("{");
if (xtructs != null)
{
foreach (Xtruct x in xtructs)
{
Console.Write("{\"" + x.String_thing + "\", " + x.Byte_thing + ", " + x.I32_thing + ", " + x.I32_thing + "}, ");
}
}
else
{
Console.Write("null");
}
Console.Write("}");
Console.Write("}, ");
}
Console.Write("}, ");
}
Console.WriteLine("}");
sbyte arg0 = 1;
int arg1 = 2;
long arg2 = long.MaxValue;
Dictionary<short, string> multiDict = new Dictionary<short, string>();
multiDict[1] = "one";
Numberz arg4 = Numberz.FIVE;
long arg5 = 5000000;
Console.Write("Test Multi(" + arg0 + "," + arg1 + "," + arg2 + "," + multiDict + "," + arg4 + "," + arg5 + ")");
Xtruct multiResponse = client.testMulti(arg0, arg1, arg2, multiDict, arg4, arg5);
Console.Write(" = Xtruct(byte_thing:" + multiResponse.Byte_thing + ",String_thing:" + multiResponse.String_thing
+ ",i32_thing:" + multiResponse.I32_thing + ",i64_thing:" + multiResponse.I64_thing + ")\n");
try
{
Console.WriteLine("testException(\"Xception\")");
client.testException("Xception");
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorExceptions;
}
catch (Xception ex)
{
if (ex.ErrorCode != 1001 || ex.Message != "Xception")
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorExceptions;
}
}
catch (Exception ex)
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorExceptions;
Console.WriteLine(ex.Message + " ST: " + ex.StackTrace);
}
try
{
Console.WriteLine("testException(\"TException\")");
client.testException("TException");
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorExceptions;
}
catch (Thrift.TException)
{
// OK
}
catch (Exception ex)
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorExceptions;
Console.WriteLine(ex.Message + " ST: " + ex.StackTrace);
}
try
{
Console.WriteLine("testException(\"ok\")");
client.testException("ok");
// OK
}
catch (Exception ex)
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorExceptions;
Console.WriteLine(ex.Message + " ST: " + ex.StackTrace);
}
try
{
Console.WriteLine("testMultiException(\"Xception\", ...)");
client.testMultiException("Xception", "ignore");
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorExceptions;
}
catch (Xception ex)
{
if (ex.ErrorCode != 1001 || ex.Message != "This is an Xception")
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorExceptions;
}
}
catch (Exception ex)
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorExceptions;
Console.WriteLine(ex.Message + " ST: " + ex.StackTrace);
}
try
{
Console.WriteLine("testMultiException(\"Xception2\", ...)");
client.testMultiException("Xception2", "ignore");
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorExceptions;
}
catch (Xception2 ex)
{
if (ex.ErrorCode != 2002 || ex.Struct_thing.String_thing != "This is an Xception2")
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorExceptions;
}
}
catch (Exception ex)
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorExceptions;
Console.WriteLine(ex.Message + " ST: " + ex.StackTrace);
}
try
{
Console.WriteLine("testMultiException(\"success\", \"OK\")");
if ("OK" != client.testMultiException("success", "OK").String_thing)
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorExceptions;
}
}
catch (Exception ex)
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorExceptions;
Console.WriteLine(ex.Message + " ST: " + ex.StackTrace);
}
Stopwatch sw = new Stopwatch();
sw.Start();
Console.WriteLine("Test Oneway(1)");
client.testOneway(1);
sw.Stop();
if (sw.ElapsedMilliseconds > 1000)
{
Console.WriteLine("*** FAILED ***");
returnCode |= ErrorBaseTypes;
}
Console.Write("Test Calltime()");
var times = 50;
sw.Reset();
sw.Start();
for (int k = 0; k < times; ++k)
client.testVoid();
sw.Stop();
Console.WriteLine(" = {0} ms a testVoid() call", sw.ElapsedMilliseconds / times);
return returnCode;
}
}
}

View file

@ -0,0 +1,547 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// Distributed under the Thrift Software License
//
// See accompanying file LICENSE or visit the Thrift site at:
// http://developers.facebook.com/thrift/
using System;
using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
using Thrift.Collections;
using Thrift.Test; //generated code
using Thrift.Transport;
using Thrift.Protocol;
using Thrift.Server;
using Thrift;
using System.Threading;
using System.Text;
using System.Security.Authentication;
namespace Test
{
public class TestServer
{
public static int _clientID = -1;
public delegate void TestLogDelegate(string msg, params object[] values);
public class TradeServerEventHandler : TServerEventHandler
{
public int callCount = 0;
public void preServe()
{
callCount++;
}
public Object createContext(Thrift.Protocol.TProtocol input, Thrift.Protocol.TProtocol output)
{
callCount++;
return null;
}
public void deleteContext(Object serverContext, Thrift.Protocol.TProtocol input, Thrift.Protocol.TProtocol output)
{
callCount++;
}
public void processContext(Object serverContext, Thrift.Transport.TTransport transport)
{
callCount++;
}
};
public class TestHandler : ThriftTest.Iface, Thrift.TControllingHandler
{
public TServer server { get; set; }
private int handlerID;
private StringBuilder reusableStringBuilder = new StringBuilder();
private TestLogDelegate testLogDelegate;
public TestHandler()
{
handlerID = Interlocked.Increment(ref _clientID);
testLogDelegate += testConsoleLogger;
testLogDelegate.Invoke("New TestHandler instance created");
}
public void testConsoleLogger(string msg, params object[] values)
{
reusableStringBuilder.Clear();
reusableStringBuilder.AppendFormat("handler{0:D3}:",handlerID);
reusableStringBuilder.AppendFormat(msg, values);
reusableStringBuilder.AppendLine();
Console.Write( reusableStringBuilder.ToString() );
}
public void testVoid()
{
testLogDelegate.Invoke("testVoid()");
}
public string testString(string thing)
{
testLogDelegate.Invoke("testString({0})", thing);
return thing;
}
public bool testBool(bool thing)
{
testLogDelegate.Invoke("testBool({0})", thing);
return thing;
}
public sbyte testByte(sbyte thing)
{
testLogDelegate.Invoke("testByte({0})", thing);
return thing;
}
public int testI32(int thing)
{
testLogDelegate.Invoke("testI32({0})", thing);
return thing;
}
public long testI64(long thing)
{
testLogDelegate.Invoke("testI64({0})", thing);
return thing;
}
public double testDouble(double thing)
{
testLogDelegate.Invoke("testDouble({0})", thing);
return thing;
}
public byte[] testBinary(byte[] thing)
{
string hex = BitConverter.ToString(thing).Replace("-", string.Empty);
testLogDelegate.Invoke("testBinary({0:X})", hex);
return thing;
}
public Xtruct testStruct(Xtruct thing)
{
testLogDelegate.Invoke("testStruct({{\"{0}\", {1}, {2}, {3}}})", thing.String_thing, thing.Byte_thing, thing.I32_thing, thing.I64_thing);
return thing;
}
public Xtruct2 testNest(Xtruct2 nest)
{
Xtruct thing = nest.Struct_thing;
testLogDelegate.Invoke("testNest({{{0}, {{\"{1}\", {2}, {3}, {4}, {5}}}}})",
nest.Byte_thing,
thing.String_thing,
thing.Byte_thing,
thing.I32_thing,
thing.I64_thing,
nest.I32_thing);
return nest;
}
public Dictionary<int, int> testMap(Dictionary<int, int> thing)
{
reusableStringBuilder.Clear();
reusableStringBuilder.Append("testMap({{");
bool first = true;
foreach (int key in thing.Keys)
{
if (first)
{
first = false;
}
else
{
reusableStringBuilder.Append(", ");
}
reusableStringBuilder.AppendFormat("{0} => {1}", key, thing[key]);
}
reusableStringBuilder.Append("}})");
testLogDelegate.Invoke(reusableStringBuilder.ToString());
return thing;
}
public Dictionary<string, string> testStringMap(Dictionary<string, string> thing)
{
reusableStringBuilder.Clear();
reusableStringBuilder.Append("testStringMap({{");
bool first = true;
foreach (string key in thing.Keys)
{
if (first)
{
first = false;
}
else
{
reusableStringBuilder.Append(", ");
}
reusableStringBuilder.AppendFormat("{0} => {1}", key, thing[key]);
}
reusableStringBuilder.Append("}})");
testLogDelegate.Invoke(reusableStringBuilder.ToString());
return thing;
}
public THashSet<int> testSet(THashSet<int> thing)
{
reusableStringBuilder.Clear();
reusableStringBuilder.Append("testSet({{");
bool first = true;
foreach (int elem in thing)
{
if (first)
{
first = false;
}
else
{
reusableStringBuilder.Append(", ");
}
reusableStringBuilder.AppendFormat("{0}", elem);
}
reusableStringBuilder.Append("}})");
testLogDelegate.Invoke(reusableStringBuilder.ToString());
return thing;
}
public List<int> testList(List<int> thing)
{
reusableStringBuilder.Clear();
reusableStringBuilder.Append("testList({{");
bool first = true;
foreach (int elem in thing)
{
if (first)
{
first = false;
}
else
{
reusableStringBuilder.Append(", ");
}
reusableStringBuilder.AppendFormat("{0}", elem);
}
reusableStringBuilder.Append("}})");
testLogDelegate.Invoke(reusableStringBuilder.ToString());
return thing;
}
public Numberz testEnum(Numberz thing)
{
testLogDelegate.Invoke("testEnum({0})", thing);
return thing;
}
public long testTypedef(long thing)
{
testLogDelegate.Invoke("testTypedef({0})", thing);
return thing;
}
public Dictionary<int, Dictionary<int, int>> testMapMap(int hello)
{
testLogDelegate.Invoke("testMapMap({0})", hello);
Dictionary<int, Dictionary<int, int>> mapmap =
new Dictionary<int, Dictionary<int, int>>();
Dictionary<int, int> pos = new Dictionary<int, int>();
Dictionary<int, int> neg = new Dictionary<int, int>();
for (int i = 1; i < 5; i++)
{
pos[i] = i;
neg[-i] = -i;
}
mapmap[4] = pos;
mapmap[-4] = neg;
return mapmap;
}
public Dictionary<long, Dictionary<Numberz, Insanity>> testInsanity(Insanity argument)
{
testLogDelegate.Invoke("testInsanity()");
Xtruct hello = new Xtruct();
hello.String_thing = "Hello2";
hello.Byte_thing = 2;
hello.I32_thing = 2;
hello.I64_thing = 2;
Xtruct goodbye = new Xtruct();
goodbye.String_thing = "Goodbye4";
goodbye.Byte_thing = (sbyte)4;
goodbye.I32_thing = 4;
goodbye.I64_thing = (long)4;
Insanity crazy = new Insanity();
crazy.UserMap = new Dictionary<Numberz, long>();
crazy.UserMap[Numberz.EIGHT] = (long)8;
crazy.Xtructs = new List<Xtruct>();
crazy.Xtructs.Add(goodbye);
Insanity looney = new Insanity();
crazy.UserMap[Numberz.FIVE] = (long)5;
crazy.Xtructs.Add(hello);
Dictionary<Numberz, Insanity> first_map = new Dictionary<Numberz, Insanity>();
Dictionary<Numberz, Insanity> second_map = new Dictionary<Numberz, Insanity>(); ;
first_map[Numberz.TWO] = crazy;
first_map[Numberz.THREE] = crazy;
second_map[Numberz.SIX] = looney;
Dictionary<long, Dictionary<Numberz, Insanity>> insane =
new Dictionary<long, Dictionary<Numberz, Insanity>>();
insane[(long)1] = first_map;
insane[(long)2] = second_map;
return insane;
}
public Xtruct testMulti(sbyte arg0, int arg1, long arg2, Dictionary<short, string> arg3, Numberz arg4, long arg5)
{
testLogDelegate.Invoke("testMulti()");
Xtruct hello = new Xtruct(); ;
hello.String_thing = "Hello2";
hello.Byte_thing = arg0;
hello.I32_thing = arg1;
hello.I64_thing = arg2;
return hello;
}
/**
* Print 'testException(%s)' with arg as '%s'
* @param string arg - a string indication what type of exception to throw
* if arg == "Xception" throw Xception with errorCode = 1001 and message = arg
* elsen if arg == "TException" throw TException
* else do not throw anything
*/
public void testException(string arg)
{
testLogDelegate.Invoke("testException({0})", arg);
if (arg == "Xception")
{
Xception x = new Xception();
x.ErrorCode = 1001;
x.Message = arg;
throw x;
}
if (arg == "TException")
{
throw new Thrift.TException();
}
return;
}
public Xtruct testMultiException(string arg0, string arg1)
{
testLogDelegate.Invoke("testMultiException({0}, {1})", arg0,arg1);
if (arg0 == "Xception")
{
Xception x = new Xception();
x.ErrorCode = 1001;
x.Message = "This is an Xception";
throw x;
}
else if (arg0 == "Xception2")
{
Xception2 x = new Xception2();
x.ErrorCode = 2002;
x.Struct_thing = new Xtruct();
x.Struct_thing.String_thing = "This is an Xception2";
throw x;
}
Xtruct result = new Xtruct();
result.String_thing = arg1;
return result;
}
public void testStop()
{
if (server != null)
{
server.Stop();
}
}
public void testOneway(int arg)
{
testLogDelegate.Invoke("testOneway({0}), sleeping...", arg);
System.Threading.Thread.Sleep(arg * 1000);
testLogDelegate.Invoke("testOneway finished");
}
} // class TestHandler
private enum ServerType
{
TSimpleServer,
TThreadedServer,
TThreadPoolServer,
}
private enum ProcessorFactoryType
{
TSingletonProcessorFactory,
TPrototypeProcessorFactory,
}
public static bool Execute(string[] args)
{
try
{
bool useBufferedSockets = false, useFramed = false, useEncryption = false, compact = false, json = false;
ServerType serverType = ServerType.TSimpleServer;
ProcessorFactoryType processorFactoryType = ProcessorFactoryType.TSingletonProcessorFactory;
int port = 9090;
string pipe = null;
for (int i = 0; i < args.Length; i++)
{
if (args[i] == "-pipe") // -pipe name
{
pipe = args[++i];
}
else if (args[i].Contains("--port="))
{
port = int.Parse(args[i].Substring(args[i].IndexOf("=") + 1));
}
else if (args[i] == "-b" || args[i] == "--buffered" || args[i] == "--transport=buffered")
{
useBufferedSockets = true;
}
else if (args[i] == "-f" || args[i] == "--framed" || args[i] == "--transport=framed")
{
useFramed = true;
}
else if (args[i] == "--compact" || args[i] == "--protocol=compact")
{
compact = true;
}
else if (args[i] == "--json" || args[i] == "--protocol=json")
{
json = true;
}
else if (args[i] == "--threaded" || args[i] == "--server-type=threaded")
{
serverType = ServerType.TThreadedServer;
}
else if (args[i] == "--threadpool" || args[i] == "--server-type=threadpool")
{
serverType = ServerType.TThreadPoolServer;
}
else if (args[i] == "--prototype" || args[i] == "--processor=prototype")
{
processorFactoryType = ProcessorFactoryType.TPrototypeProcessorFactory;
}
else if (args[i] == "--ssl")
{
useEncryption = true;
}
}
// Transport
TServerTransport trans;
if (pipe != null)
{
trans = new TNamedPipeServerTransport(pipe);
}
else
{
if (useEncryption)
{
string certPath = "../keys/server.p12";
trans = new TTLSServerSocket(port, 0, useBufferedSockets, new X509Certificate2(certPath, "thrift"), null, null, SslProtocols.Tls);
}
else
{
trans = new TServerSocket(port, 0, useBufferedSockets);
}
}
TProtocolFactory proto;
if (compact)
proto = new TCompactProtocol.Factory();
else if (json)
proto = new TJSONProtocol.Factory();
else
proto = new TBinaryProtocol.Factory();
TProcessorFactory processorFactory;
if (processorFactoryType == ProcessorFactoryType.TPrototypeProcessorFactory)
{
processorFactory = new TPrototypeProcessorFactory<ThriftTest.Processor, TestHandler>();
}
else
{
// Processor
TestHandler testHandler = new TestHandler();
ThriftTest.Processor testProcessor = new ThriftTest.Processor(testHandler);
processorFactory = new TSingletonProcessorFactory(testProcessor);
}
TTransportFactory transFactory;
if (useFramed)
transFactory = new TFramedTransport.Factory();
else
transFactory = new TTransportFactory();
TServer serverEngine;
switch (serverType)
{
case ServerType.TThreadPoolServer:
serverEngine = new TThreadPoolServer(processorFactory, trans, transFactory, proto);
break;
case ServerType.TThreadedServer:
serverEngine = new TThreadedServer(processorFactory, trans, transFactory, proto);
break;
default:
serverEngine = new TSimpleServer(processorFactory, trans, transFactory, proto);
break;
}
//Server event handler
TradeServerEventHandler serverEvents = new TradeServerEventHandler();
serverEngine.setEventHandler(serverEvents);
// Run it
string where = (pipe != null ? "on pipe " + pipe : "on port " + port);
Console.WriteLine("Starting the " + serverType.ToString() + " " + where +
(processorFactoryType == ProcessorFactoryType.TPrototypeProcessorFactory ? " with processor prototype factory " : "") +
(useBufferedSockets ? " with buffered socket" : "") +
(useFramed ? " with framed transport" : "") +
(useEncryption ? " with encryption" : "") +
(compact ? " with compact protocol" : "") +
(json ? " with json protocol" : "") +
"...");
serverEngine.Serve();
}
catch (Exception x)
{
Console.Error.Write(x);
return false;
}
Console.WriteLine("done.");
return true;
}
}
}

View file

@ -0,0 +1,141 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{48DD757F-CA95-4DD7-BDA4-58DB6F108C2C}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ThriftTest</RootNamespace>
<AssemblyName>ThriftTest</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="ThriftImpl, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\ThriftImpl.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestClient.cs" />
<Compile Include="TestServer.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
<Visible>False</Visible>
<ProductName>.NET Framework 2.0 %28x86%29</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
<Visible>False</Visible>
<ProductName>.NET Framework 3.0 %28x86%29</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\lib\csharp\Thrift.csproj">
<Project>{499EB63C-D74C-47E8-AE48-A2FC94538E9D}</Project>
<Name>Thrift</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<PropertyGroup>
<PreBuildEvent>rmdir /s /q "$(ProjectDir)gen-csharp"
del /f /q "$(ProjectDir)ThriftImpl.dll"
SET OUTPUT_DIR=$(ProjectDir)
SET THRIFT_FILE=$(ProjectDir)\..\ThriftTest.thrift
for %25%25I in ("%25OUTPUT_DIR%25") do set SHORT_DIR=%25%25~fsI
for %25%25I in ("%25THRIFT_FILE%25") do set THRIFT_SHORT=%25%25~fsI
"$(ProjectDir)\..\..\compiler\cpp\thrift.exe" --gen csharp -o %25SHORT_DIR%25 %25THRIFT_SHORT%25
$(MSBuildToolsPath)\Csc.exe /t:library /out:"$(ProjectDir)ThriftImpl.dll" /recurse:"$(ProjectDir)gen-csharp"\* /reference:"$(ProjectDir)..\..\lib\csharp\bin\Debug\Thrift.dll"</PreBuildEvent>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,17 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ThriftTest", "ThriftTest.csproj", "{48DD757F-CA95-4DD7-BDA4-58DB6F108C2C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{48DD757F-CA95-4DD7-BDA4-58DB6F108C2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48DD757F-CA95-4DD7-BDA4-58DB6F108C2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48DD757F-CA95-4DD7-BDA4-58DB6F108C2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48DD757F-CA95-4DD7-BDA4-58DB6F108C2C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

43
vendor/git.apache.org/thrift.git/test/dart/Makefile.am generated vendored Normal file
View file

@ -0,0 +1,43 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
THRIFT = $(top_builddir)/compiler/cpp/thrift
gen-dart/thrift_test/lib/thrift_test.dart: ../ThriftTest.thrift
$(THRIFT) --gen dart ../ThriftTest.thrift
pub-get-gen: gen-dart/thrift_test/lib/thrift_test.dart
cd gen-dart/thrift_test; ${DARTPUB} get
pub-get: pub-get-gen
cd test_client; ${DARTPUB} get
stubs: gen-dart/thrift_test/lib/thrift_test.dart pub-get
precross: stubs
check: stubs
clean-local:
$(RM) -r gen-dart test_client/.pub
find . -type d -name "packages" | xargs $(RM) -r
find . -type f -name ".packages" | xargs $(RM)
client: stubs
${DART} test_client/bin/main.dart

View file

@ -0,0 +1,2 @@
analyzer:
strong-mode: true

View file

@ -0,0 +1,337 @@
/// Licensed to the Apache Software Foundation (ASF) under one
/// or more contributor license agreements. See the NOTICE file
/// distributed with this work for additional information
/// regarding copyright ownership. The ASF licenses this file
/// to you under the Apache License, Version 2.0 (the
/// 'License'); you may not use this file except in compliance
/// with the License. You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing,
/// software distributed under the License is distributed on an
/// 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
/// KIND, either express or implied. See the License for the
/// specific language governing permissions and limitations
/// under the License.
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:args/args.dart';
import 'package:collection/collection.dart';
import 'package:http/http.dart' as http;
import 'package:thrift/thrift.dart';
import 'package:thrift/thrift_console.dart';
import 'package:thrift_test/thrift_test.dart';
const TEST_BASETYPES = 1; // 0000 0001
const TEST_STRUCTS = 2; // 0000 0010
const TEST_CONTAINERS = 4; // 0000 0100
const TEST_EXCEPTIONS = 8; // 0000 1000
const TEST_UNKNOWN = 64; // 0100 0000 (Failed to prepare environemt etc.)
const TEST_TIMEOUT = 128; // 1000 0000
const TEST_NOTUSED = 48; // 0011 0000 (reserved bits)
typedef Future FutureFunction();
class TTest {
final int errorCode;
final String name;
final FutureFunction func;
TTest(this.errorCode, this.name, this.func);
}
class TTestError extends Error {
final actual;
final expected;
TTestError(this.actual, this.expected);
String toString() => '$actual != $expected';
}
List<TTest> _tests;
ThriftTestClient client;
bool verbose;
/// Adapted from TestClient.php
main(List<String> args) async {
ArgResults results = _parseArgs(args);
if (results == null) {
exit(TEST_UNKNOWN);
}
verbose = results['verbose'] == true;
await _initTestClient(
host: results['host'],
port: int.parse(results['port']),
transportType: results['transport'],
protocolType: results['protocol']).catchError((e) {
stdout.writeln('Error:');
stdout.writeln('$e');
if (e is Error) {
stdout.writeln('${e.stackTrace}');
}
exit(TEST_UNKNOWN);
});
// run tests
_tests = _createTests();
int result = 0;
for (TTest test in _tests) {
if (verbose) stdout.write('${test.name}... ');
try {
await test.func();
if (verbose) stdout.writeln('success!');
} catch (e) {
if (verbose) stdout.writeln('$e');
result = result | test.errorCode;
}
}
exit(result);
}
ArgResults _parseArgs(List<String> args) {
var parser = new ArgParser();
parser.addOption('host', defaultsTo: 'localhost', help: 'The server host');
parser.addOption('port', defaultsTo: '9090', help: 'The port to connect to');
parser.addOption('transport',
defaultsTo: 'buffered',
allowed: ['buffered', 'framed', 'http'],
help: 'The transport name',
allowedHelp: {
'buffered': 'TBufferedTransport',
'framed': 'TFramedTransport'
});
parser.addOption('protocol',
defaultsTo: 'binary',
allowed: ['binary', 'compact', 'json'],
help: 'The protocol name',
allowedHelp: {
'binary': 'TBinaryProtocol',
'compact': 'TCompactProtocol',
'json': 'TJsonProtocol'
});
parser.addFlag('verbose', defaultsTo: false);
ArgResults results;
try {
results = parser.parse(args);
} catch (e) {
stdout.writeln('$e\n');
}
if (results == null) stdout.write(parser.usage);
return results;
}
TProtocolFactory getProtocolFactory(String protocolType) {
if (protocolType == 'binary') {
return new TBinaryProtocolFactory();
} else if (protocolType == 'compact') {
return new TCompactProtocolFactory();
} else if (protocolType == 'json') {
return new TJsonProtocolFactory();
}
throw new ArgumentError.value(protocolType);
}
Future _initTestClient(
{String host, int port, String transportType, String protocolType}) async {
TTransport transport;
var protocolFactory = getProtocolFactory(protocolType);
if (transportType == 'http') {
var httpClient = new http.IOClient();
var uri = Uri.parse('http://$host:$port');
var config = new THttpConfig(uri, {});
transport = new THttpClientTransport(httpClient, config);
} else {
var socket = await Socket.connect(host, port);
transport = new TClientSocketTransport(new TTcpSocket(socket));
if (transportType == 'framed') {
transport = new TFramedTransport(transport);
}
}
var protocol = protocolFactory.getProtocol(transport);
client = new ThriftTestClient(protocol);
await transport.open();
}
List<TTest> _createTests() {
List<TTest> tests = [];
var xtruct = new Xtruct()
..string_thing = 'Zero'
..byte_thing = 1
..i32_thing = -3
..i64_thing = -5;
tests.add(new TTest(TEST_BASETYPES, 'testVoid', () async {
await client.testVoid();
}));
tests.add(new TTest(TEST_BASETYPES, 'testString', () async {
var input = 'Test';
var result = await client.testString(input);
if (result != input) throw new TTestError(result, input);
}));
tests.add(new TTest(TEST_BASETYPES, 'testBool', () async {
var input = true;
var result = await client.testBool(input);
if (result != input) throw new TTestError(result, input);
}));
tests.add(new TTest(TEST_BASETYPES, 'testByte', () async {
var input = 64;
var result = await client.testByte(input);
if (result != input) throw new TTestError(result, input);
}));
tests.add(new TTest(TEST_BASETYPES, 'testI32', () async {
var input = 2147483647;
var result = await client.testI32(input);
if (result != input) throw new TTestError(result, input);
}));
tests.add(new TTest(TEST_BASETYPES, 'testI64', () async {
var input = 9223372036854775807;
var result = await client.testI64(input);
if (result != input) throw new TTestError(result, input);
}));
tests.add(new TTest(TEST_BASETYPES, 'testDouble', () async {
var input = 3.1415926;
var result = await client.testDouble(input);
if (result != input) throw new TTestError(result, input);
}));
tests.add(new TTest(TEST_BASETYPES, 'testBinary', () async {
var utf8Codec = const Utf8Codec();
var input = utf8Codec.encode('foo');
var result = await client.testBinary(input);
var equality = const ListEquality();
if (!equality.equals(result, input)) throw new TTestError(result, input);
}));
tests.add(new TTest(TEST_CONTAINERS, 'testStruct', () async {
var result = await client.testStruct(xtruct);
if ('$result' != '$xtruct') throw new TTestError(result, xtruct);
}));
tests.add(new TTest(TEST_CONTAINERS, 'testNest', () async {
var input = new Xtruct2()
..byte_thing = 1
..struct_thing = xtruct
..i32_thing = -3;
var result = await client.testNest(input);
if ('$result' != '$input') throw new TTestError(result, input);
}));
tests.add(new TTest(TEST_CONTAINERS, 'testMap', () async {
Map<int, int> input = {1: -10, 2: -9, 3: -8, 4: -7, 5: -6};
var result = await client.testMap(input);
var equality = const MapEquality();
if (!equality.equals(result, input)) throw new TTestError(result, input);
}));
tests.add(new TTest(TEST_CONTAINERS, 'testSet', () async {
var input = new Set<int>.from([-2, -1, 0, 1, 2]);
var result = await client.testSet(input);
var equality = const SetEquality();
if (!equality.equals(result, input)) throw new TTestError(result, input);
}));
tests.add(new TTest(TEST_CONTAINERS, 'testList', () async {
var input = [-2, -1, 0, 1, 2];
var result = await client.testList(input);
var equality = const ListEquality();
if (!equality.equals(result, input)) throw new TTestError(result, input);
}));
tests.add(new TTest(TEST_CONTAINERS, 'testEnum', () async {
await _testEnum(Numberz.ONE);
await _testEnum(Numberz.TWO);
await _testEnum(Numberz.THREE);
await _testEnum(Numberz.FIVE);
await _testEnum(Numberz.EIGHT);
}));
tests.add(new TTest(TEST_BASETYPES, 'testTypedef', () async {
var input = 309858235082523;
var result = await client.testTypedef(input);
if (result != input) throw new TTestError(result, input);
}));
tests.add(new TTest(TEST_CONTAINERS, 'testMapMap', () async {
Map<int, Map<int, int>> result = await client.testMapMap(1);
if (result.isEmpty || result[result.keys.first].isEmpty) {
throw new TTestError(result, 'Map<int, Map<int, int>>');
}
}));
tests.add(new TTest(TEST_CONTAINERS, 'testInsanity', () async {
var input = new Insanity();
input.userMap = {Numberz.FIVE: 5000};
input.xtructs = [xtruct];
Map<int, Map<int, Insanity>> result = await client.testInsanity(input);
if (result.isEmpty || result[result.keys.first].isEmpty) {
throw new TTestError(result, 'Map<int, Map<int, Insanity>>');
}
}));
tests.add(new TTest(TEST_CONTAINERS, 'testMulti', () async {
var input = new Xtruct()
..string_thing = 'Hello2'
..byte_thing = 123
..i32_thing = 456
..i64_thing = 789;
var result = await client.testMulti(input.byte_thing, input.i32_thing,
input.i64_thing, {1: 'one'}, Numberz.EIGHT, 5678);
if ('$result' != '$input') throw new TTestError(result, input);
}));
tests.add(new TTest(TEST_EXCEPTIONS, 'testException', () async {
try {
await client.testException('Xception');
} on Xception catch (_) {
return;
}
throw new TTestError(null, 'Xception');
}));
tests.add(new TTest(TEST_EXCEPTIONS, 'testMultiException', () async {
try {
await client.testMultiException('Xception2', 'foo');
} on Xception2 catch (_) {
return;
}
throw new TTestError(null, 'Xception2');
}));
return tests;
}
Future _testEnum(int input) async {
var result = await client.testEnum(input);
if (result != input) throw new TTestError(result, input);
}

View file

@ -0,0 +1,36 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# 'License'); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
name: thrift_test_client
version: 0.10.0
description: A client integration test for the Dart Thrift library
author: Apache Thrift Developers <dev@thrift.apache.org>
homepage: http://thrift.apache.org
environment:
sdk: ">=1.13.0 <2.0.0"
dependencies:
args: ^0.13.0
http: ^0.11.0
thrift:
path: ../../../lib/dart
thrift_test:
path: ../gen-dart/thrift_test
dev_dependencies:
test: "^0.12.0"

43
vendor/git.apache.org/thrift.git/test/erl/Makefile.am generated vendored Normal file
View file

@ -0,0 +1,43 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
THRIFT = $(top_builddir)/compiler/cpp/thrift
THRIFT_FILES = $(wildcard ../*.thrift)
if ERLANG_OTP16
ERL_FLAG = erl:otp16
else
ERL_FLAG = erl
endif
# make sure ThriftTest.thrift is generated last to prevent conflicts with other *.thrift files
.generated: $(THRIFT_FILES)
for f in $(THRIFT_FILES) ; do \
$(THRIFT) --gen $(ERL_FLAG) -o src $$f ; \
done ; \
$(THRIFT) --gen $(ERL_FLAG) -o src ../ThriftTest.thrift
touch .generated
precross: .generated
$(REBAR) compile
clean:
rm -f .generated
rm -rf src/gen-erl
$(REBAR) clean

View file

@ -0,0 +1,6 @@
{sub_dirs, ["../../lib/erl"]}.
{erl_opts, [
debug_info,
{i, "../../lib/erl/include"}
]}.

View file

@ -0,0 +1,174 @@
%%
%% Licensed to the Apache Software Foundation (ASF) under one
%% or more contributor license agreements. See the NOTICE file
%% distributed with this work for additional information
%% regarding copyright ownership. The ASF licenses this file
%% to you under the Apache License, Version 2.0 (the
%% "License"); you may not use this file except in compliance
%% with the License. You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing,
%% software distributed under the License is distributed on an
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
%% KIND, either express or implied. See the License for the
%% specific language governing permissions and limitations
%% under the License.
%%
-module(test_client).
-export([start/0, start/1]).
-include("gen-erl/thrift_test_types.hrl").
-record(options, {port = 9090,
client_opts = []}).
parse_args(Args) -> parse_args(Args, #options{}).
parse_args([], Opts) ->
Opts;
parse_args([Head | Rest], Opts) ->
NewOpts =
case Head of
"--port=" ++ Port ->
case string:to_integer(Port) of
{IntPort,_} when is_integer(IntPort) ->
Opts#options{port = IntPort};
_Else ->
erlang:error({bad_arg, Head})
end;
"--transport=" ++ Trans ->
% TODO: Enable Buffered and HTTP transport
case Trans of
"framed" ->
Opts#options{client_opts = [{framed, true} | Opts#options.client_opts]};
_Else ->
Opts
end;
"--ssl" ->
ssl:start(),
SslOptions =
{ssloptions, [
{certfile, "../keys/client.crt"}
,{keyfile, "../keys/server.key"}
]},
Opts#options{client_opts = [{ssltransport, true} | [SslOptions | Opts#options.client_opts]]};
"--protocol=" ++ Proto ->
Opts#options{client_opts = [{protocol, list_to_atom(Proto)}]};
_Else ->
erlang:error({bad_arg, Head})
end,
parse_args(Rest, NewOpts).
start() -> start(init:get_plain_arguments()).
start(Args) ->
#options{port = Port, client_opts = ClientOpts} = parse_args(Args),
{ok, Client0} = thrift_client_util:new(
"127.0.0.1", Port, thrift_test_thrift, ClientOpts),
DemoXtruct = #'thrift.test.Xtruct'{
string_thing = <<"Zero">>,
byte_thing = 1,
i32_thing = 9128361,
i64_thing = 9223372036854775807},
DemoNest = #'thrift.test.Xtruct2'{
byte_thing = 7,
struct_thing = DemoXtruct,
% Note that we don't set i32_thing, it will come back as undefined
% from the Python server, but 0 from the C++ server, since it is not
% optional
i32_thing = 2},
% Is it safe to match these things?
DemoDict = dict:from_list([ {Key, Key-10} || Key <- lists:seq(0,10) ]),
DemoSet = sets:from_list([ Key || Key <- lists:seq(-3,3) ]),
DemoInsane = #'thrift.test.Insanity'{
userMap = dict:from_list([{?THRIFT_TEST_NUMBERZ_FIVE, 5000}]),
xtructs = [#'thrift.test.Xtruct'{ string_thing = <<"Truck">>, byte_thing = 8, i32_thing = 8, i64_thing = 8}]},
error_logger:info_msg("testVoid"),
{Client01, {ok, ok}} = thrift_client:call(Client0, testVoid, []),
error_logger:info_msg("testString"),
{Client02, {ok, <<"Test">>}} = thrift_client:call(Client01, testString, ["Test"]),
error_logger:info_msg("testString"),
{Client03, {ok, <<"Test">>}} = thrift_client:call(Client02, testString, [<<"Test">>]),
error_logger:info_msg("testByte"),
{Client04, {ok, 63}} = thrift_client:call(Client03, testByte, [63]),
error_logger:info_msg("testI32"),
{Client05, {ok, -1}} = thrift_client:call(Client04, testI32, [-1]),
error_logger:info_msg("testI32"),
{Client06, {ok, 0}} = thrift_client:call(Client05, testI32, [0]),
error_logger:info_msg("testI64"),
{Client07, {ok, -34359738368}} = thrift_client:call(Client06, testI64, [-34359738368]),
error_logger:info_msg("testDouble"),
{Client08, {ok, -5.2098523}} = thrift_client:call(Client07, testDouble, [-5.2098523]),
%% TODO: add testBinary() call
error_logger:info_msg("testStruct"),
{Client09, {ok, DemoXtruct}} = thrift_client:call(Client08, testStruct, [DemoXtruct]),
error_logger:info_msg("testNest"),
{Client10, {ok, DemoNest}} = thrift_client:call(Client09, testNest, [DemoNest]),
error_logger:info_msg("testMap"),
{Client11, {ok, DemoDict}} = thrift_client:call(Client10, testMap, [DemoDict]),
error_logger:info_msg("testSet"),
{Client12, {ok, DemoSet}} = thrift_client:call(Client11, testSet, [DemoSet]),
error_logger:info_msg("testList"),
{Client13, {ok, [-1,2,3]}} = thrift_client:call(Client12, testList, [[-1,2,3]]),
error_logger:info_msg("testEnum"),
{Client14, {ok, 1}} = thrift_client:call(Client13, testEnum, [?THRIFT_TEST_NUMBERZ_ONE]),
error_logger:info_msg("testTypedef"),
{Client15, {ok, 309858235082523}} = thrift_client:call(Client14, testTypedef, [309858235082523]),
error_logger:info_msg("testInsanity"),
{Client16, {ok, InsaneResult}} = thrift_client:call(Client15, testInsanity, [DemoInsane]),
io:format("~p~n", [InsaneResult]),
{Client17, {ok, #'thrift.test.Xtruct'{string_thing = <<"Message">>}}} =
thrift_client:call(Client16, testMultiException, ["Safe", "Message"]),
Client18 =
try
{ClientS1, Result1} = thrift_client:call(Client17, testMultiException, ["Xception", "Message"]),
io:format("Unexpected return! ~p~n", [Result1]),
ClientS1
catch
throw:{ClientS2, {exception, ExnS1 = #'thrift.test.Xception'{}}} ->
#'thrift.test.Xception'{errorCode = 1001, message = <<"This is an Xception">>} = ExnS1,
ClientS2;
throw:{ClientS2, {exception, _ExnS1 = #'thrift.test.Xception2'{}}} ->
io:format("Wrong exception type!~n", []),
ClientS2
end,
Client19 =
try
{ClientS3, Result2} = thrift_client:call(Client18, testMultiException, ["Xception2", "Message"]),
io:format("Unexpected return! ~p~n", [Result2]),
ClientS3
catch
throw:{ClientS4, {exception, _ExnS2 = #'thrift.test.Xception'{}}} ->
io:format("Wrong exception type!~n", []),
ClientS4;
throw:{ClientS4, {exception, ExnS2 = #'thrift.test.Xception2'{}}} ->
#'thrift.test.Xception2'{errorCode = 2002,
struct_thing = #'thrift.test.Xtruct'{
string_thing = <<"This is an Xception2">>}} = ExnS2,
ClientS4
end,
%% Use deprecated erlang:now until we start requiring OTP18
%% Started = erlang:monotonic_time(milli_seconds),
{_, StartSec, StartUSec} = erlang:now(),
error_logger:info_msg("testOneway"),
{Client20, {ok, ok}} = thrift_client:call(Client19, testOneway, [1]),
{_, EndSec, EndUSec} = erlang:now(),
Elapsed = (EndSec - StartSec) * 1000 + (EndUSec - StartUSec) / 1000,
if
Elapsed > 1000 -> exit(1);
true -> true
end,
thrift_client:close(Client20).

View file

@ -0,0 +1,233 @@
%%
%% Licensed to the Apache Software Foundation (ASF) under one
%% or more contributor license agreements. See the NOTICE file
%% distributed with this work for additional information
%% regarding copyright ownership. The ASF licenses this file
%% to you under the Apache License, Version 2.0 (the
%% "License"); you may not use this file except in compliance
%% with the License. You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing,
%% software distributed under the License is distributed on an
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
%% KIND, either express or implied. See the License for the
%% specific language governing permissions and limitations
%% under the License.
%%
-module(test_thrift_server).
-export([start/0, start/1, start_link/2, handle_function/2]).
-include("thrift_constants.hrl").
-include("gen-erl/thrift_test_types.hrl").
-record(options, {port = 9090,
server_opts = []}).
parse_args(Args) -> parse_args(Args, #options{}).
parse_args([], Opts) ->
Opts;
parse_args([Head | Rest], Opts) ->
NewOpts =
case Head of
"--port=" ++ Port ->
case string:to_integer(Port) of
{IntPort,_} when is_integer(IntPort) ->
Opts#options{port = IntPort};
_Else ->
erlang:error({bad_arg, Head})
end;
"--transport=" ++ Trans ->
case Trans of
"framed" ->
Opts#options{server_opts = [{framed, true} | Opts#options.server_opts]};
_Else ->
Opts
end;
"--ssl" ->
ssl:start(),
SslOptions =
{ssloptions, [
{certfile, "../keys/server.crt"}
,{keyfile, "../keys/server.key"}
]},
Opts#options{server_opts = [{ssltransport, true} | [SslOptions | Opts#options.server_opts]]};
"--protocol=" ++ Proto ->
Opts#options{server_opts = [{protocol, list_to_atom(Proto)} | Opts#options.server_opts]};
_Else ->
erlang:error({bad_arg, Head})
end,
parse_args(Rest, NewOpts).
start() -> start(init:get_plain_arguments()).
start(Args) ->
#options{port = Port, server_opts = ServerOpts} = parse_args(Args),
spawn(fun() -> start_link(Port, ServerOpts), receive after infinity -> ok end end).
start_link(Port, ServerOpts) ->
thrift_socket_server:start([{handler, ?MODULE},
{service, thrift_test_thrift},
{port, Port}] ++
ServerOpts).
handle_function(testVoid, {}) ->
io:format("testVoid~n"),
ok;
handle_function(testString, {S}) when is_binary(S) ->
io:format("testString: ~p~n", [S]),
{reply, S};
handle_function(testBool, {B}) when is_boolean(B) ->
io:format("testBool: ~p~n", [B]),
{reply, B};
handle_function(testByte, {I8}) when is_integer(I8) ->
io:format("testByte: ~p~n", [I8]),
{reply, I8};
handle_function(testI32, {I32}) when is_integer(I32) ->
io:format("testI32: ~p~n", [I32]),
{reply, I32};
handle_function(testI64, {I64}) when is_integer(I64) ->
io:format("testI64: ~p~n", [I64]),
{reply, I64};
handle_function(testDouble, {Double}) when is_float(Double) ->
io:format("testDouble: ~p~n", [Double]),
{reply, Double};
handle_function(testBinary, {S}) when is_binary(S) ->
io:format("testBinary: ~p~n", [S]),
{reply, S};
handle_function(testStruct,
{Struct = #'thrift.test.Xtruct'{string_thing = String,
byte_thing = Byte,
i32_thing = I32,
i64_thing = I64}})
when is_binary(String),
is_integer(Byte),
is_integer(I32),
is_integer(I64) ->
io:format("testStruct: ~p~n", [Struct]),
{reply, Struct};
handle_function(testNest,
{Nest}) when is_record(Nest, 'thrift.test.Xtruct2'),
is_record(Nest#'thrift.test.Xtruct2'.struct_thing, 'thrift.test.Xtruct') ->
io:format("testNest: ~p~n", [Nest]),
{reply, Nest};
handle_function(testMap, {Map}) ->
io:format("testMap: ~p~n", [dict:to_list(Map)]),
{reply, Map};
handle_function(testStringMap, {Map}) ->
io:format("testStringMap: ~p~n", [dict:to_list(Map)]),
{reply, Map};
handle_function(testSet, {Set}) ->
true = sets:is_set(Set),
io:format("testSet: ~p~n", [sets:to_list(Set)]),
{reply, Set};
handle_function(testList, {List}) when is_list(List) ->
io:format("testList: ~p~n", [List]),
{reply, List};
handle_function(testEnum, {Enum}) when is_integer(Enum) ->
io:format("testEnum: ~p~n", [Enum]),
{reply, Enum};
handle_function(testTypedef, {UserID}) when is_integer(UserID) ->
io:format("testTypedef: ~p~n", [UserID]),
{reply, UserID};
handle_function(testMapMap, {Hello}) ->
io:format("testMapMap: ~p~n", [Hello]),
PosList = [{I, I} || I <- lists:seq(1, 4)],
NegList = [{-I, -I} || I <- lists:seq(1, 4)],
MapMap = dict:from_list([{4, dict:from_list(PosList)},
{-4, dict:from_list(NegList)}]),
{reply, MapMap};
handle_function(testInsanity, {Insanity}) when is_record(Insanity, 'thrift.test.Insanity') ->
Hello = #'thrift.test.Xtruct'{string_thing = <<"Hello2">>,
byte_thing = 2,
i32_thing = 2,
i64_thing = 2},
Goodbye = #'thrift.test.Xtruct'{string_thing = <<"Goodbye4">>,
byte_thing = 4,
i32_thing = 4,
i64_thing = 4},
Crazy = #'thrift.test.Insanity'{
userMap = dict:from_list([{?THRIFT_TEST_NUMBERZ_EIGHT, 8}]),
xtructs = [Goodbye]
},
Looney = #'thrift.test.Insanity'{},
FirstMap = dict:from_list([{?THRIFT_TEST_NUMBERZ_TWO, Insanity},
{?THRIFT_TEST_NUMBERZ_THREE, Insanity}]),
SecondMap = dict:from_list([{?THRIFT_TEST_NUMBERZ_SIX, Looney}]),
Insane = dict:from_list([{1, FirstMap},
{2, SecondMap}]),
io:format("Return = ~p~n", [Insane]),
{reply, Insane};
handle_function(testMulti, Args = {Arg0, Arg1, Arg2, _Arg3, Arg4, Arg5})
when is_integer(Arg0),
is_integer(Arg1),
is_integer(Arg2),
is_integer(Arg4),
is_integer(Arg5) ->
io:format("testMulti(~p)~n", [Args]),
{reply, #'thrift.test.Xtruct'{string_thing = <<"Hello2">>,
byte_thing = Arg0,
i32_thing = Arg1,
i64_thing = Arg2}};
handle_function(testException, {String}) when is_binary(String) ->
io:format("testException(~p)~n", [String]),
case String of
<<"Xception">> ->
throw(#'thrift.test.Xception'{errorCode = 1001,
message = String});
<<"TException">> ->
throw({?TApplicationException_Structure});
_ ->
ok
end;
handle_function(testMultiException, {Arg0, Arg1}) ->
io:format("testMultiException(~p, ~p)~n", [Arg0, Arg1]),
case Arg0 of
<<"Xception">> ->
throw(#'thrift.test.Xception'{errorCode = 1001,
message = <<"This is an Xception">>});
<<"Xception2">> ->
throw(#'thrift.test.Xception2'{errorCode = 2002,
struct_thing =
#'thrift.test.Xtruct'{string_thing = <<"This is an Xception2">>}});
_ ->
{reply, #'thrift.test.Xtruct'{string_thing = Arg1}}
end;
handle_function(testOneway, {Seconds}) ->
io:format("testOneway: ~p~n", [Seconds]),
timer:sleep(1000 * Seconds),
ok.

View file

@ -0,0 +1,54 @@
%%
%% Licensed to the Apache Software Foundation (ASF) under one
%% or more contributor license agreements. See the NOTICE file
%% distributed with this work for additional information
%% regarding copyright ownership. The ASF licenses this file
%% to you under the Apache License, Version 2.0 (the
%% "License"); you may not use this file except in compliance
%% with the License. You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing,
%% software distributed under the License is distributed on an
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
%% KIND, either express or implied. See the License for the
%% specific language governing permissions and limitations
%% under the License.
%%
%%% -*- mode:erlang -*-
{application, thrift_test, [
% A quick description of the application.
{description, "Thrift cross language test"},
% The version of the applicaton
{vsn, "0.10.0"},
% All modules used by the application.
{modules, [
test_client,
test_thrift_server
]},
% All of the registered names the application uses. This can be ignored.
{registered, []},
% Applications that are to be started prior to this one. This can be ignored
% leave it alone unless you understand it well and let the .rel files in
% your release handle this.
{applications, [kernel, stdlib]},
% OTP application loader will load, but not start, included apps. Again
% this can be ignored as well. To load but not start an application it
% is easier to include it in the .rel file followed by the atom 'none'
{included_applications, []},
% configuration parameters similar to those in the config file specified
% on the command line. can be fetched with gas:get_env
{env, [
% If an error/crash occurs during processing of a function,
% should the TApplicationException serialized back to the client
% include the erlang backtrace?
{exceptions_include_traces, true}
]}
]}.

View file

@ -0,0 +1,28 @@
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
EXTRA_DIST = \
local_thrift \
index.html \
container_limit.py \
index.html \
known_failures_Linux.json \
Makefile.am \
string_limit.py \
tests.json \
theader_binary.py \
setup.cfg \
util.py

Some files were not shown because too many files have changed in this diff Show more