diff options
author | Craig Tiller <craig.tiller@gmail.com> | 2015-02-13 14:44:16 -0800 |
---|---|---|
committer | Craig Tiller <craig.tiller@gmail.com> | 2015-02-13 14:44:16 -0800 |
commit | 88c5f3de78d5a8d10ce10087b1ea6efa9f56c37f (patch) | |
tree | 7ee4bdf087ea95e3161fecc657a420d26c577136 | |
parent | 421e87a1b0d1db696c792b997497c13dbb777b34 (diff) | |
parent | 0e0d8e11e63629a3953ceed60278f7ff2abd21d7 (diff) |
Merge pull request #17 from yang-g/c++api
add a simple server streaming e2e test, which passes
-rw-r--r-- | test/cpp/end2end/async_end2end_test.cc | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index b85aabf09e..35c068549a 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -152,6 +152,7 @@ TEST_F(End2endTest, SimpleRpc) { EXPECT_TRUE(recv_status.IsOk()); } +// Two pings and a final pong. TEST_F(End2endTest, SimpleClientStreaming) { ResetStub(); @@ -205,6 +206,58 @@ TEST_F(End2endTest, SimpleClientStreaming) { EXPECT_TRUE(recv_status.IsOk()); } +// One ping, two pongs. +TEST_F(End2endTest, SimpleServerStreaming) { + ResetStub(); + + EchoRequest send_request; + EchoRequest recv_request; + EchoResponse send_response; + EchoResponse recv_response; + Status recv_status; + ClientContext cli_ctx; + ServerContext srv_ctx; + ServerAsyncWriter<EchoResponse> srv_stream(&srv_ctx); + + send_request.set_message("Hello"); + ClientAsyncReader<EchoResponse>* cli_stream = + stub_->ResponseStream(&cli_ctx, send_request, &cli_cq_, tag(1)); + + service_.RequestResponseStream( + &srv_ctx, &recv_request, &srv_stream, &srv_cq_, tag(2)); + + server_ok(2); + client_ok(1); + EXPECT_EQ(send_request.message(), recv_request.message()); + + send_response.set_message(recv_request.message()); + srv_stream.Write(send_response, tag(3)); + server_ok(3); + + cli_stream->Read(&recv_response, tag(4)); + client_ok(4); + EXPECT_EQ(send_response.message(), recv_response.message()); + + srv_stream.Write(send_response, tag(5)); + server_ok(5); + + cli_stream->Read(&recv_response, tag(6)); + client_ok(6); + EXPECT_EQ(send_response.message(), recv_response.message()); + + srv_stream.Finish(Status::OK, tag(7)); + server_ok(7); + + cli_stream->Read(&recv_response, tag(8)); + client_fail(8); + + cli_stream->Finish(&recv_status, tag(9)); + client_ok(9); + + EXPECT_TRUE(recv_status.IsOk()); +} + +// One ping, one pong. TEST_F(End2endTest, SimpleBidiStreaming) { ResetStub(); |