THRIFT-1588 Java Generated Exceptions don't follow inheritance pattern as other Languages
Patch: Nathaniel Cook
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1333239 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/java/test/org/apache/thrift/test/TestClient.java b/lib/java/test/org/apache/thrift/test/TestClient.java
index aee3bbf..85dbecd 100644
--- a/lib/java/test/org/apache/thrift/test/TestClient.java
+++ b/lib/java/test/org/apache/thrift/test/TestClient.java
@@ -372,7 +372,68 @@
}
System.out.print("}\n");
- // Test oneway
+
+ /**
+ * EXECPTION TEST
+ */
+ try {
+ System.out.print("testClient.testException(\"Xception\") =>");
+ testClient.testException("Xception");
+ System.out.print(" void\nFAILURE\n");
+ } catch(Xception e) {
+ System.out.print(" {%u, \"%s\"}\n", e.errorCode, e.message.c_str());
+ }
+
+ try {
+ System.out.print("testClient.testException(\"Xception\") =>");
+ testClient.testException("Xception");
+ System.out.print(" void\nFAILURE\n");
+ } catch(TException e) {
+ System.out.print(" {%u, \"%s\"}\n", e.errorCode, e.message.c_str());
+ }
+
+ try {
+ System.out.print("testClient.testException(\"success\") =>");
+ testClient.testException("success");
+ System.out.print(" void\n");
+ }catch(Exception e) {
+ System.out.print(" exception\nFAILURE\n");
+ }
+
+
+ /**
+ * MULTI EXCEPTION TEST
+ */
+
+ try {
+ System.out.print("testClient.testMultiException(\"Xception\", \"test 1\") =>");
+ testClient.testMultiException("Xception", "test 1");
+ System.out.print(" result\nFAILURE\n");
+ } catch(Xception e) {
+ System.out.print(" {%u, \"%s\"}\n", e.errorCode, e.message.c_str());
+ }
+
+ try {
+ System.out.print("testClient.testMultiException(\"Xception2\", \"test 2\") =>");
+ testClient.testMultiException("Xception2", "test 2");
+ System.out.print(" result\nFAILURE\n");
+ } catch(Xception2 e) {
+ System.out.print(" {%u, {\"%s\"}}\n", e.errorCode, e.struct_thing.string_thing.c_str());
+ }
+
+ try {
+ System.out.print("testClient.testMultiException(\"success\", \"test 3\") =>");
+ testClient.testMultiException("success", "test 3");
+ System.out.print(" {{\"%s\"}}\n", result.string_thing.c_str());
+ } catch(Exception e) {
+ System.out.print(" exception\nFAILURE\n");
+ }
+
+
+
+ /**
+ * ONEWAY TEST
+ */
System.out.print("testOneway(3)...");
long startOneway = System.nanoTime();
testClient.testOneway(3);
diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp
index d8618d5..f461a87 100755
--- a/test/cpp/src/TestClient.cpp
+++ b/test/cpp/src/TestClient.cpp
@@ -530,6 +530,15 @@
}
try {
+ printf("testClient.testException(\"Xception\") =>");
+ testClient.testException("Xception");
+ printf(" void\nFAILURE\n");
+
+ } catch(TException& e) {
+ printf(" Caught TException\n");
+ }
+
+ try {
printf("testClient.testException(\"success\") =>");
testClient.testException("success");
printf(" void\n");