From e129a2db0c2f05a209be1e514214aa6b83ba1d91 Mon Sep 17 00:00:00 2001 From: Mark Slee Date: Wed, 21 Feb 2007 05:17:48 +0000 Subject: [PATCH] Some thrift test code fixes Reviewed By: tbr-testaditya git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665014 13f79535-47bb-0310-9956-ffa450edef68 --- test/SmallTest.thrift | 24 +++++++++++++++++++++--- test/ThriftTest.thrift | 6 ++++++ test/cpp/src/TestClient.cpp | 10 +++++++--- test/java/src/TestClient.java | 15 +++++++++++---- test/php/TestClient.php | 3 ++- 5 files changed, 47 insertions(+), 11 deletions(-) diff --git a/test/SmallTest.thrift b/test/SmallTest.thrift index 6e89221f..58357fe3 100644 --- a/test/SmallTest.thrift +++ b/test/SmallTest.thrift @@ -1,9 +1,26 @@ + +struct Goodbyez { + 1: i32 val = 325; +} + +senum Thinger { + "ASDFKJ", + "r32)*F#@", + "ASDFLJASDF" +} + struct Hello { - 1: i32 simple, - 2: map complex, + 1: i32 simple = 53, + 2: map complex = {23:532, 6243:632, 2355:532}, 3: map> complexer, + 4: string words = "words", + 5: Goodbyez thinz = {'val' : 36632} } +const map> CMAP = { 235: {235:235}, 53:{53:53} } +const i32 CINT = 325; +const Hello WHOA = {'simple' : 532} + exception Goodbye { 1: i32 simple, 2: map complex, @@ -11,7 +28,8 @@ exception Goodbye { } service SmallService { - Hello testMe(1:i32 hello, 2: Hello wonk) throws (1: Goodbye g), + 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) } diff --git a/test/ThriftTest.thrift b/test/ThriftTest.thrift index f5642ac5..d4b0a4dd 100644 --- a/test/ThriftTest.thrift +++ b/test/ThriftTest.thrift @@ -13,6 +13,12 @@ enum Numberz typedef i64 UserId +struct Bonk +{ + 1: string message, + 2: i32 type +} + struct Xtruct { 1: string string_thing, diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp index 38684564..e1110b4d 100644 --- a/test/cpp/src/TestClient.cpp +++ b/test/cpp/src/TestClient.cpp @@ -102,9 +102,13 @@ int main(int argc, char** argv) { /** * VOID TEST */ - printf("testVoid()"); - testClient.testVoid(); - printf(" = void\n"); + try { + printf("testVoid()"); + testClient.testVoid(); + printf(" = void\n"); + } catch (TApplicationException tax) { + printf("%s\n", tax.what()); + } /** * STRING TEST diff --git a/test/java/src/TestClient.java b/test/java/src/TestClient.java index bc950364..3c8d8b33 100644 --- a/test/java/src/TestClient.java +++ b/test/java/src/TestClient.java @@ -3,6 +3,7 @@ package com.facebook.thrift.test; // Generated code import thrift.test.*; +import com.facebook.thrift.TApplicationException; import com.facebook.thrift.transport.TTransport; import com.facebook.thrift.transport.TSocket; import com.facebook.thrift.transport.THttpClient; @@ -70,7 +71,7 @@ public class TestClient { } TBinaryProtocol binaryProtocol = - new TBinaryProtocol(transport, transport); + new TBinaryProtocol(transport); ThriftTest.Client testClient = new ThriftTest.Client(binaryProtocol); @@ -96,9 +97,13 @@ public class TestClient { /** * VOID TEST */ - System.out.print("testVoid()"); - testClient.testVoid(); - System.out.print(" = void\n"); + try { + System.out.print("testVoid()"); + testClient.testVoid(); + System.out.print(" = void\n"); + } catch (TApplicationException tax) { + tax.printStackTrace(); + } /** * STRING TEST @@ -303,12 +308,14 @@ public class TestClient { * INSANITY TEST */ Insanity insane = new Insanity(); + insane.userMap = new HashMap(); insane.userMap.put(Numberz.FIVE, (long)5000); Xtruct truck = new Xtruct(); truck.string_thing = "Truck"; truck.byte_thing = (byte)8; truck.i32_thing = 8; truck.i64_thing = 8; + insane.xtructs = new ArrayList(); insane.xtructs.add(truck); System.out.print("testInsanity()"); AbstractMap> whoa = diff --git a/test/php/TestClient.php b/test/php/TestClient.php index 0f1540c2..07068e40 100644 --- a/test/php/TestClient.php +++ b/test/php/TestClient.php @@ -23,7 +23,8 @@ require_once $GLOBALS['THRIFT_ROOT'].'/transport/TSocketPool.php'; require_once $GLOBALS['THRIFT_ROOT'].'/transport/TBufferedTransport.php'; /** Include the generated code */ -require_once '/home/mcslee/code/projects/thrift/test/php/'.$GEN_DIR.'/ThriftTest.php'; +require_once $GEN_DIR.'/ThriftTest.php'; +require_once $GEN_DIR.'/ThriftTest_types.php'; $host = 'localhost'; $port = 9090; -- 2.17.1