diff options
author | 2015-10-20 16:45:52 -0700 | |
---|---|---|
committer | 2015-10-20 16:45:52 -0700 | |
commit | ac7edec71f2d4d076bc43bc5cef1abc44578a8fd (patch) | |
tree | 0248ca75eb24e41586a1c4839f3288f8a43bf4bc /test/cpp/interop/interop_client.h | |
parent | 2bc3ac30322efd14919653544bbbd4da5819b1a1 (diff) |
Add an option to reuse the TestService::Stub in interop client class
Diffstat (limited to 'test/cpp/interop/interop_client.h')
-rw-r--r-- | test/cpp/interop/interop_client.h | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/test/cpp/interop/interop_client.h b/test/cpp/interop/interop_client.h index 1f13d5b971..1bfb49d514 100644 --- a/test/cpp/interop/interop_client.h +++ b/test/cpp/interop/interop_client.h @@ -47,9 +47,14 @@ namespace testing { class InteropClient { public: explicit InteropClient(std::shared_ptr<Channel> channel); + explicit InteropClient( + std::shared_ptr<Channel> channel, + bool new_stub_every_test_case); // If new_stub_every_test_case is true, + // a new TestService::Stub object is + // created for every test case below ~InteropClient() {} - void Reset(std::shared_ptr<Channel> channel) { channel_ = channel; } + void Reset(std::shared_ptr<Channel> channel); void DoEmpty(); void DoLargeUnary(); @@ -77,11 +82,26 @@ class InteropClient { void DoPerRpcCreds(const grpc::string& json_key); private: + class ServiceStub { + public: + // If new_stub_every_call = true, pointer to a new instance of + // TestServce::Stub is returned by Get() everytime it is called + ServiceStub(std::shared_ptr<Channel> channel, bool new_stub_every_call); + + TestService::Stub* Get(); + + void Reset(std::shared_ptr<Channel> channel); + + private: + std::unique_ptr<TestService::Stub> stub_; + std::shared_ptr<Channel> channel_; + bool new_stub_every_call_; // If true, a new stub is returned by every + // Get() call + }; + void PerformLargeUnary(SimpleRequest* request, SimpleResponse* response); void AssertOkOrPrintErrorStatus(const Status& s); - - std::shared_ptr<Channel> channel_; - std::unique_ptr<TestService::Stub> stub_; + ServiceStub serviceStub_; }; } // namespace testing |