From: Roger Meier Date: Wed, 2 May 2012 22:56:47 +0000 (+0000) Subject: THRIFT-1590 Document the excepted return values and behaviors ThriftTest.thrift so... X-Git-Tag: 0.9.1~385 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=1f8b48f5bdfc49dc1992684c56b0e0c22335ceb0;p=common%2Fthrift.git THRIFT-1590 Document the excepted return values and behaviors ThriftTest.thrift so that all languages can implement a test server Patch: Nathaniel Cook git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1333243 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/test/ThriftTest.thrift b/test/ThriftTest.thrift index b9b7fdaf..2be53fa2 100644 --- a/test/ThriftTest.thrift +++ b/test/ThriftTest.thrift @@ -122,38 +122,165 @@ struct OneField { 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 'testByte("%d")' with thing as '%d' + * @param byte thing - the byte to print + * @return byte - returns the byte 'thing' + */ byte testByte(1: byte 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 'testStruct("{%s}")' where thing has been formatted into a string of comma seperated 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 + * seperated by commas and new lines + * @param map thing - the map to print + * @return map - returns the map 'thing' + */ map testMap(1: map thing), + + /** + * Prints 'testStringMap("{%s}")' where thing has been formatted into a string of 'key => value' pairs + * seperated by commas and new lines + * @param map thing - the map to print + * @return map - returns the map 'thing' + */ map testStringMap(1: map thing), + + /** + * Prints 'testSet("{%s}")' where thing has been formatted into a string of values + * seperated by commas and new lines + * @param set thing - the set to print + * @return set - returns the set 'thing' + */ set testSet(1: set thing), + + /** + * Prints 'testList("{%s}")' where thing has been formatted into a string of values + * seperated by commas and new lines + * @param list thing - the list to print + * @return list - returns the list 'thing' + */ list testList(1: list 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> - 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> testMapMap(1: i32 hello), - /* So you think you've got this all worked, out eh? */ + /** + * 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 => , }, + * } + * @return map> - a map with the above values + */ map> testInsanity(1: Insanity argument), - /* Multiple parameters */ + /** + * Prints 'testMulti()' + * @param byte arg0 - + * @param i32 arg1 - + * @param i64 arg2 - + * @param map 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: byte arg0, 2: i32 arg1, 3: i64 arg2, 4: map arg3, 5: Numberz arg4, 6: UserId arg5), - /* Exception specifier */ - + /** + * 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), - /* Multiple exceptions specifier */ - + /** + * 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 message = "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) - /* Test oneway void */ + /** + * 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) } diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp index f90bde8f..c99fbac0 100755 --- a/test/cpp/src/TestServer.cpp +++ b/test/cpp/src/TestServer.cpp @@ -284,7 +284,7 @@ class TestHandler : public ThriftTestIf { e.errorCode = 1001; e.message = arg; throw e; - } else if (arg.compare("ApplicationException") == 0) { + } else if (arg.compare("TException") == 0) { apache::thrift::TException e; throw e; } else {