From: Roger Meier Date: Thu, 3 May 2012 21:21:43 +0000 (+0000) Subject: THRIFT-1588 Java Generated Exceptions don't follow inheritance pattern as other Languages X-Git-Tag: 0.9.1~383 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=99b3672530b4b6da939e17bbb37b2a041a5575c6;p=common%2Fthrift.git THRIFT-1588 Java Generated Exceptions don't follow inheritance pattern as other Languages - fix the build! - add test/gen-html for ThriftTest.thrift git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1333628 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 old mode 100644 new mode 100755 index 85dbecd2..45369ba2 --- a/lib/java/test/org/apache/thrift/test/TestClient.java +++ b/lib/java/test/org/apache/thrift/test/TestClient.java @@ -23,6 +23,7 @@ package org.apache.thrift.test; import thrift.test.*; import org.apache.thrift.TApplicationException; +import org.apache.thrift.TException; import org.apache.thrift.TSerializer; import org.apache.thrift.transport.TTransport; import org.apache.thrift.transport.TSocket; @@ -381,15 +382,15 @@ public class TestClient { testClient.testException("Xception"); System.out.print(" void\nFAILURE\n"); } catch(Xception e) { - System.out.print(" {%u, \"%s\"}\n", e.errorCode, e.message.c_str()); + System.out.printf(" {%u, \"%s\"}\n", e.errorCode, e.message); } try { - System.out.print("testClient.testException(\"Xception\") =>"); - testClient.testException("Xception"); + System.out.print("testClient.testException(\"TException\") =>"); + testClient.testException("TException"); System.out.print(" void\nFAILURE\n"); } catch(TException e) { - System.out.print(" {%u, \"%s\"}\n", e.errorCode, e.message.c_str()); + System.out.printf(" {\"%s\"}\n", e.getMessage()); } try { @@ -397,7 +398,7 @@ public class TestClient { testClient.testException("success"); System.out.print(" void\n"); }catch(Exception e) { - System.out.print(" exception\nFAILURE\n"); + System.out.printf(" exception\nFAILURE\n"); } @@ -406,27 +407,28 @@ public class TestClient { */ try { - System.out.print("testClient.testMultiException(\"Xception\", \"test 1\") =>"); + System.out.printf("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()); + System.out.printf(" {%u, \"%s\"}\n", e.errorCode, e.message); } try { - System.out.print("testClient.testMultiException(\"Xception2\", \"test 2\") =>"); + System.out.printf("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()); + System.out.printf(" {%u, {\"%s\"}}\n", e.errorCode, e.struct_thing.string_thing); } try { System.out.print("testClient.testMultiException(\"success\", \"test 3\") =>"); - testClient.testMultiException("success", "test 3"); - System.out.print(" {{\"%s\"}}\n", result.string_thing.c_str()); + Xtruct result; + result = testClient.testMultiException("success", "test 3"); + System.out.printf(" {{\"%s\"}}\n", result.string_thing); } catch(Exception e) { - System.out.print(" exception\nFAILURE\n"); + System.out.printf(" exception\nFAILURE\n"); } diff --git a/test/Makefile.am b/test/Makefile.am old mode 100644 new mode 100755 index 2b3b8a93..1ad9063e --- a/test/Makefile.am +++ b/test/Makefile.am @@ -44,6 +44,12 @@ if WITH_HASKELL SUBDIRS += hs endif +# +# generate html for ThriftTest.thrift +# +check-local: + $(top_builddir)/compiler/cpp/thrift --gen html -r $(top_srcdir)/test/ThriftTest.thrift + EXTRA_DIST = \ cpp \ csharp \ diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp index f461a879..a1af77e0 100755 --- a/test/cpp/src/TestClient.cpp +++ b/test/cpp/src/TestClient.cpp @@ -530,8 +530,8 @@ int main(int argc, char** argv) { } try { - printf("testClient.testException(\"Xception\") =>"); - testClient.testException("Xception"); + printf("testClient.testException(\"TException\") =>"); + testClient.testException("TException"); printf(" void\nFAILURE\n"); } catch(TException& e) {