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
diff --git a/test/SmallTest.thrift b/test/SmallTest.thrift
index 6e89221..58357fe 100644
--- a/test/SmallTest.thrift
+++ b/test/SmallTest.thrift
@@ -1,9 +1,26 @@
-struct Hello {
- 1: i32 simple,
- 2: map<i32,i32> complex,
- 3: map<i32, map<i32,i32>> complexer,
+
+struct Goodbyez {
+ 1: i32 val = 325;
}
+senum Thinger {
+ "ASDFKJ",
+ "r32)*F#@",
+ "ASDFLJASDF"
+}
+
+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,
@@ -11,7 +28,8 @@
}
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 f5642ac..d4b0a4d 100644
--- a/test/ThriftTest.thrift
+++ b/test/ThriftTest.thrift
@@ -13,6 +13,12 @@
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 3868456..e1110b4 100644
--- a/test/cpp/src/TestClient.cpp
+++ b/test/cpp/src/TestClient.cpp
@@ -102,9 +102,13 @@
/**
* 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 bc95036..3c8d8b3 100644
--- a/test/java/src/TestClient.java
+++ b/test/java/src/TestClient.java
@@ -3,6 +3,7 @@
// 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 @@
}
TBinaryProtocol binaryProtocol =
- new TBinaryProtocol(transport, transport);
+ new TBinaryProtocol(transport);
ThriftTest.Client testClient =
new ThriftTest.Client(binaryProtocol);
@@ -96,9 +97,13 @@
/**
* 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 @@
* 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 =
diff --git a/test/php/TestClient.php b/test/php/TestClient.php
index 0f1540c..07068e4 100644
--- a/test/php/TestClient.php
+++ b/test/php/TestClient.php
@@ -23,7 +23,8 @@
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;