Add testAsync to ThriftTest.thrift which verifies async void works properly.
Summary:
- testAsync takes a number of seconds to sleep. The test client makes sure
that the RPC returns in less than 0.2 seconds even though it asks the server
to sleep for 3 seconds.
- Implemented this test for C++ and Java.
Test Plan:
- ran cpp TestServer and TestClient and verified functionality
- tested cpp and java test server/client against each other - tests passed
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665484 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp
index 9b350b0..2b8cced 100644
--- a/test/cpp/src/TestClient.cpp
+++ b/test/cpp/src/TestClient.cpp
@@ -430,6 +430,19 @@
printf(" exception\nFAILURE\n");
}
+ /* test async void */
+ {
+ printf("testClient.testAsync(3) =>");
+ uint64_t startAsync = now();
+ testClient.testAsync(3);
+ uint64_t elapsed = now() - startAsync;
+ if (elapsed > 200 * 1000) { // 0.2 seconds
+ printf(" FAILURE - took %.2f ms\n", (double)elapsed/1000.0);
+ } else {
+ printf(" success - took %.2f ms\n", (double)elapsed/1000.0);
+ }
+ }
+
uint64_t stop = now();
uint64_t tot = stop-start;