From: Roger Meier Date: Wed, 2 May 2012 22:49:55 +0000 (+0000) Subject: THRIFT-1588 Java Generated Exceptions don't follow inheritance pattern as other Languages X-Git-Tag: 0.9.1~386 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=f50df7f2ba60e26e72a084381aa96344e7ec01f8;p=common%2Fthrift.git 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 aee3bbfe..85dbecd2 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 @@ public class TestClient { } 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 d8618d5e..f461a879 100755 --- a/test/cpp/src/TestClient.cpp +++ b/test/cpp/src/TestClient.cpp @@ -529,6 +529,15 @@ int main(int argc, char** argv) { printf(" {%u, \"%s\"}\n", e.errorCode, e.message.c_str()); } + 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");