aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar yang-g <yangg@google.com>2016-12-02 22:16:53 -0800
committerGravatar yang-g <yangg@google.com>2016-12-08 23:05:50 -0800
commit6c8de363cafd129e8f8bd4b1d8e3dec3a1531e0d (patch)
tree8217fdcf31115551e1c482819090905543736243
parentc204647295437b01337ad8e6c17c4296609c7a13 (diff)
Use user provided method name when using binary files in cli
-rw-r--r--test/cpp/util/grpc_tool.cc9
-rw-r--r--test/cpp/util/proto_file_parser.cc12
-rw-r--r--test/cpp/util/proto_file_parser.h4
3 files changed, 14 insertions, 11 deletions
diff --git a/test/cpp/util/grpc_tool.cc b/test/cpp/util/grpc_tool.cc
index 03c33abe9f..a3da5682dc 100644
--- a/test/cpp/util/grpc_tool.cc
+++ b/test/cpp/util/grpc_tool.cc
@@ -414,6 +414,7 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
grpc::string request_text;
grpc::string server_address(argv[0]);
grpc::string method_name(argv[1]);
+ grpc::string formatted_method_name;
std::unique_ptr<grpc::testing::ProtoFileParser> parser;
grpc::string serialized_request_proto;
@@ -450,7 +451,9 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
if (FLAGS_binary_input) {
serialized_request_proto = request_text;
+ formatted_method_name = method_name;
} else {
+ formatted_method_name = parser->GetFormattedMethodName(method_name);
serialized_request_proto = parser->GetSerializedProtoFromMethod(
method_name, request_text, true /* is_request */);
if (parser->HasError()) {
@@ -466,9 +469,9 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
ParseMetadataFlag(&client_metadata);
PrintMetadata(client_metadata, "Sending client initial metadata:");
grpc::Status status = grpc::testing::CliCall::Call(
- channel, parser->GetFormatedMethodName(method_name),
- serialized_request_proto, &serialized_response_proto, client_metadata,
- &server_initial_metadata, &server_trailing_metadata);
+ channel, formatted_method_name, serialized_request_proto,
+ &serialized_response_proto, client_metadata, &server_initial_metadata,
+ &server_trailing_metadata);
PrintMetadata(server_initial_metadata,
"Received initial metadata from server:");
PrintMetadata(server_trailing_metadata,
diff --git a/test/cpp/util/proto_file_parser.cc b/test/cpp/util/proto_file_parser.cc
index 3e524227e5..bc8a6083f4 100644
--- a/test/cpp/util/proto_file_parser.cc
+++ b/test/cpp/util/proto_file_parser.cc
@@ -172,19 +172,19 @@ grpc::string ProtoFileParser::GetFullMethodName(const grpc::string& method) {
return method_descriptor->full_name();
}
-grpc::string ProtoFileParser::GetFormatedMethodName(
+grpc::string ProtoFileParser::GetFormattedMethodName(
const grpc::string& method) {
has_error_ = false;
- grpc::string formated_method_name = GetFullMethodName(method);
+ grpc::string formatted_method_name = GetFullMethodName(method);
if (has_error_) {
return "";
}
- size_t last_dot = formated_method_name.find_last_of('.');
+ size_t last_dot = formatted_method_name.find_last_of('.');
if (last_dot != grpc::string::npos) {
- formated_method_name[last_dot] = '/';
+ formatted_method_name[last_dot] = '/';
}
- formated_method_name.insert(formated_method_name.begin(), '/');
- return formated_method_name;
+ formatted_method_name.insert(formatted_method_name.begin(), '/');
+ return formatted_method_name;
}
grpc::string ProtoFileParser::GetMessageTypeFromMethod(
diff --git a/test/cpp/util/proto_file_parser.h b/test/cpp/util/proto_file_parser.h
index eda3991e72..c1070a37b5 100644
--- a/test/cpp/util/proto_file_parser.h
+++ b/test/cpp/util/proto_file_parser.h
@@ -64,9 +64,9 @@ class ProtoFileParser {
// descriptor database queries.
grpc::string GetFullMethodName(const grpc::string& method);
- // Formated method name is in the form of /Service/Method, it's good to be
+ // Formatted method name is in the form of /Service/Method, it's good to be
// used as the argument of Stub::Call()
- grpc::string GetFormatedMethodName(const grpc::string& method);
+ grpc::string GetFormattedMethodName(const grpc::string& method);
grpc::string GetSerializedProtoFromMethod(
const grpc::string& method, const grpc::string& text_format_proto,