You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by li...@apache.org on 2022/02/18 08:01:44 UTC

[rocketmq-client-csharp] branch develop updated: Create Unit Tests for SendMessage and NotifyClientTermination (#3)

This is an automated email from the ASF dual-hosted git repository.

lizhanhui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq-client-csharp.git


The following commit(s) were added to refs/heads/develop by this push:
     new 9563341  Create Unit Tests for SendMessage and NotifyClientTermination (#3)
9563341 is described below

commit 95633418bf6f2eb0df377d81aefe6f3d616d291e
Author: Zhanhui Li <li...@apache.org>
AuthorDate: Fri Feb 18 16:01:37 2022 +0800

    Create Unit Tests for SendMessage and NotifyClientTermination (#3)
---
 tests/RpcClientTest.cs | 52 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 51 insertions(+), 1 deletion(-)

diff --git a/tests/RpcClientTest.cs b/tests/RpcClientTest.cs
index 94a43c2..dd5b322 100644
--- a/tests/RpcClientTest.cs
+++ b/tests/RpcClientTest.cs
@@ -21,6 +21,8 @@ using Grpc.Net.Client;
 using rmq = global::apache.rocketmq.v1;
 using grpc = global::Grpc.Core;
 using System;
+using pb = global::Google.Protobuf;
+
 
 namespace org.apache.rocketmq
 {
@@ -80,7 +82,6 @@ namespace org.apache.rocketmq
         [TestMethod]
         public void testHeartbeat()
         {
-
             var request = new rmq::HeartbeatRequest();
             request.ClientId = clientId;
             request.ProducerData = new rmq::ProducerData();
@@ -97,6 +98,55 @@ namespace org.apache.rocketmq
             var response = rpcClient.heartbeat(request, callOptions).GetAwaiter().GetResult();
         }
 
+        [TestMethod]
+        public void testSendMessage()
+        {
+            var request = new rmq::SendMessageRequest();
+            request.Message = new rmq::Message();
+            byte[] body = new byte[1024];
+            for (int i = 0; i < body.Length; i++)
+            {
+                body[i] = (byte)'x';
+            }
+            request.Message.Body = pb::ByteString.CopyFrom(body);
+            request.Message.Topic = new rmq::Resource();
+            request.Message.Topic.ResourceNamespace = resourceNamespace;
+            request.Message.Topic.Name = topic;
+            request.Message.UserAttribute.Add("k", "v");
+            request.Message.UserAttribute.Add("key", "value");
+            request.Message.SystemAttribute = new rmq::SystemAttribute();
+            request.Message.SystemAttribute.Tag = "TagA";
+            request.Message.SystemAttribute.Keys.Add("key1");
+            request.Message.SystemAttribute.MessageId = "message-id-1";
+
+            var metadata = new grpc::Metadata();
+            Signature.sign(clientConfig, metadata);
+
+            var deadline = DateTime.UtcNow.AddSeconds(3);
+            var callOptions = new grpc::CallOptions(metadata, deadline);
+
+            var response = rpcClient.sendMessage(request, callOptions).GetAwaiter().GetResult();
+        }
+
+        // Remove the Ignore annotation if server has fixed
+        [Ignore]
+        [TestMethod]
+        public void testNotifyClientTermiantion()
+        {
+            var request = new rmq::NotifyClientTerminationRequest();
+            request.ClientId = clientId;
+            request.ProducerGroup = new rmq::Resource();
+            request.ProducerGroup.ResourceNamespace = resourceNamespace;
+            request.ProducerGroup.Name = group;
+
+            var metadata = new grpc::Metadata();
+            Signature.sign(clientConfig, metadata);
+
+            var deadline = DateTime.UtcNow.AddSeconds(3);
+            var callOptions = new grpc::CallOptions(metadata, deadline);
+            var response = rpcClient.notifyClientTermination(request, callOptions).GetAwaiter().GetResult();
+        }
+
         private static string resourceNamespace = "MQ_INST_1080056302921134_BXuIbML7";
 
         private static string topic = "cpp_sdk_standard";