Some thrift test code fixes
authorMark Slee <mcslee@apache.org>
Wed, 21 Feb 2007 05:17:48 +0000 (05:17 +0000)
committerMark Slee <mcslee@apache.org>
Wed, 21 Feb 2007 05:17:48 +0000 (05:17 +0000)
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
test/ThriftTest.thrift
test/cpp/src/TestClient.cpp
test/java/src/TestClient.java
test/php/TestClient.php

index 6e89221..58357fe 100644 (file)
@@ -1,9 +1,26 @@
+
+struct Goodbyez {
+  1: i32 val = 325;
+}
+
+senum Thinger {
+  "ASDFKJ",
+  "r32)*F#@",
+  "ASDFLJASDF"
+}
+
 struct Hello {
-  1: i32 simple,
-  2: map<i32,i32> complex,
+  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,
@@ -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)
 }
index f5642ac..d4b0a4d 100644 (file)
@@ -13,6 +13,12 @@ enum Numberz
 
 typedef i64 UserId
 
+struct Bonk
+{
+  1: string message,
+  2: i32 type
+}
+
 struct Xtruct
 {
   1:  string string_thing,
index 3868456..e1110b4 100644 (file)
@@ -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
index bc95036..3c8d8b3 100644 (file)
@@ -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<Integer, Long>();
         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<Xtruct>();
         insane.xtructs.add(truck);
         System.out.print("testInsanity()");
         AbstractMap<Long,AbstractMap<Integer,Insanity>> whoa =
index 0f1540c..07068e4 100644 (file)
@@ -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;