| 1785 | } |
| 1786 | |
| 1787 | void TestGenericCall(brpc::Channel& channel, brpc::ContentType content_type, |
| 1788 | brpc::CompressType compress_type, |
| 1789 | brpc::ChecksumType checksum_type) { |
| 1790 | LOG(INFO) << "TestGenericCall: content_type=" << content_type |
| 1791 | << ", compress_type=" << compress_type |
| 1792 | << ", checksum_type=" << checksum_type; |
| 1793 | test::EchoRequest request; |
| 1794 | test::EchoResponse response; |
| 1795 | request.set_message(EXP_REQUEST); |
| 1796 | |
| 1797 | brpc::SerializedResponse serialized_response; |
| 1798 | brpc::SerializedRequest serialized_request; |
| 1799 | |
| 1800 | brpc::Controller cntl; |
| 1801 | cntl.set_request_content_type(content_type); |
| 1802 | cntl.set_request_compress_type(compress_type); |
| 1803 | cntl.set_request_checksum_type(checksum_type); |
| 1804 | cntl.request_attachment().append(EXP_REQUEST); |
| 1805 | |
| 1806 | std::string error; |
| 1807 | ASSERT_TRUE(brpc::policy::SerializeRpcMessage( |
| 1808 | request, cntl, content_type, compress_type, checksum_type, |
| 1809 | &serialized_request.serialized_data())); |
| 1810 | auto sampled_request = new (std::nothrow) brpc::SampledRequest(); |
| 1811 | sampled_request->meta.set_service_name( |
| 1812 | test::EchoService::descriptor()->full_name()); |
| 1813 | sampled_request->meta.set_method_name( |
| 1814 | test::EchoService::descriptor()->FindMethodByName("Echo")->name()); |
| 1815 | cntl.reset_sampled_request(sampled_request); |
| 1816 | |
| 1817 | channel.CallMethod(NULL, &cntl, &serialized_request, &serialized_response, NULL); |
| 1818 | ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText(); |
| 1819 | |
| 1820 | ASSERT_TRUE(brpc::policy::DeserializeRpcMessage( |
| 1821 | serialized_response.serialized_data(), cntl, |
| 1822 | cntl.response_content_type(), cntl.response_compress_type(), |
| 1823 | cntl.response_checksum_type(), &response)); |
| 1824 | ASSERT_EQ(EXP_RESPONSE, response.message()); |
| 1825 | ASSERT_EQ(EXP_RESPONSE, cntl.response_attachment().to_string()); |
| 1826 | } |
| 1827 | |
| 1828 | TEST_F(ServerTest, generic_call) { |
| 1829 | butil::EndPoint ep; |
no test coverage detected