aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/grpc++
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2016-10-19 13:36:59 -0700
committerGravatar Craig Tiller <ctiller@google.com>2016-10-19 13:36:59 -0700
commit6952b213b7e55426a965d2c58b03f6f86eb598c9 (patch)
treeb5b88962e93998cf1d82c7e90d87b825defea255 /include/grpc++
parente2f696895f0e76514f2f3f1098a4d92acfbf477a (diff)
parent81e419bd173a0604ab15b6c58aa5de598937cfe6 (diff)
Merge github.com:grpc/grpc into buffer_pools_for_realsies
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