aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/grpc++
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2016-10-18 12:15:08 -0700
committerGravatar Vijay Pai <vpai@google.com>2016-10-18 12:15:08 -0700
commit9fa9315d62c3163a93eeae2b3d3bb70231567b83 (patch)
tree49968018548e4a294026a9f95b8ea5363efceb0e /include/grpc++
parent23c5b812687d0ebb86ed86d64416b232f8771e56 (diff)
parent948f95b2ce4204f859c867207bd991d30ca17ee7 (diff)
Merge remote-tracking branch 'upstream/master' into fc_1dstream
Diffstat (limited to 'include/grpc++')
-rw-r--r--include/grpc++/impl/codegen/server_context.h2
-rw-r--r--include/grpc++/test/server_context_test_spouse.h67
2 files changed, 69 insertions, 0 deletions
diff --git a/include/grpc++/impl/codegen/server_context.h b/include/grpc++/impl/codegen/server_context.h
index bce8d2c2f8..975f710f13 100644
--- a/include/grpc++/impl/codegen/server_context.h
+++ b/include/grpc++/impl/codegen/server_context.h
@@ -86,6 +86,7 @@ class ServerInterface;
namespace testing {
class InteropServerContextInspector;
+class ServerContextTestSpouse;
} // namespace testing
// Interface of server side rpc context.
@@ -173,6 +174,7 @@ class ServerContext {
private:
friend class ::grpc::testing::InteropServerContextInspector;
+ friend class ::grpc::testing::ServerContextTestSpouse;
friend class ::grpc::ServerInterface;
friend class ::grpc::Server;
template <class W, class R>
diff --git a/include/grpc++/test/server_context_test_spouse.h b/include/grpc++/test/server_context_test_spouse.h
new file mode 100644
index 0000000000..b2482854b5
--- /dev/null
+++ b/include/grpc++/test/server_context_test_spouse.h
@@ -0,0 +1,67 @@
+/*
+ *
+ * Copyright 2016, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef GRPCXX_TEST_SERVER_CONTEXT_TEST_SPOUSE_H
+#define GRPCXX_TEST_SERVER_CONTEXT_TEST_SPOUSE_H
+
+#include <map>
+
+#include <grpc++/server_context.h>
+
+namespace grpc {
+namespace testing {
+
+// A test-only class to access private members and methods of ServerContext.
+class ServerContextTestSpouse {
+ public:
+ explicit ServerContextTestSpouse(ServerContext* ctx) : ctx_(ctx) {}
+
+ // Inject client metadata to the ServerContext for the test. The test spouse
+ // must be alive when ServerContext::client_metadata is called.
+ void AddClientMetadata(const grpc::string& key, const grpc::string& value);
+ std::multimap<grpc::string, grpc::string> GetInitialMetadata() const {
+ return ctx_->initial_metadata_;
+ }
+ std::multimap<grpc::string, grpc::string> GetTrailingMetadata() const {
+ return ctx_->trailing_metadata_;
+ }
+
+ private:
+ ServerContext* ctx_; // not owned
+ std::multimap<grpc::string, grpc::string> client_metadata_storage_;
+};
+
+} // namespace testing
+} // namespace grpc
+
+#endif // GRPCXX_TEST_SERVER_CONTEXT_TEST_SPOUSE_H