rocketmq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ding...@apache.org
Subject [rocketmq-client-cpp] branch master updated: fix(protocol): delete string print in header decode and open test cases. (#223)
Date Fri, 10 Jan 2020 09:35:12 GMT
This is an automated email from the ASF dual-hosted git repository.

dinglei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-client-cpp.git


The following commit(s) were added to refs/heads/master by this push:
     new 54a3878  fix(protocol): delete string print in header decode and open test cases.
(#223)
54a3878 is described below

commit 54a38788908d48f9abbb1969e46b7c47d06bb716
Author: dinglei <libya_003@163.com>
AuthorDate: Fri Jan 10 17:35:02 2020 +0800

    fix(protocol): delete string print in header decode and open test cases. (#223)
    
    * fix(protocol): delete string print in header decode and open test cases.
    
    * fix(protocol): delete string print in header decode and open test cases.
    
    * fix(protocol): delete string print in header decode and open test cases.
    
    * fix(protocol): delete string print in header decode and open test cases.
---
 src/protocol/CommandHeader.cpp                     |   8 +-
 test/src/message/MQMessageExtTest.cpp              |   2 +-
 .../{message => producer}/StringIdMakerTest.cpp    |   0
 test/src/protocol/CommandHeaderTest.cpp            | 262 ++++++++++++++++++++-
 test/src/protocol/ConsumerRunningInfoTest.cpp      | 123 +++++-----
 test/src/protocol/LockBatchBodyTest.cpp            |  22 +-
 6 files changed, 337 insertions(+), 80 deletions(-)

diff --git a/src/protocol/CommandHeader.cpp b/src/protocol/CommandHeader.cpp
index e2b6234..46d3cbf 100644
--- a/src/protocol/CommandHeader.cpp
+++ b/src/protocol/CommandHeader.cpp
@@ -225,15 +225,11 @@ void PullMessageRequestHeader::Encode(Json::Value& outData) {
   outData["topic"] = topic;
   outData["queueId"] = queueId;
   outData["queueOffset"] = UtilAll::to_string(queueOffset);
-  ;
   outData["maxMsgNums"] = maxMsgNums;
   outData["sysFlag"] = sysFlag;
   outData["commitOffset"] = UtilAll::to_string(commitOffset);
-  ;
   outData["subVersion"] = UtilAll::to_string(subVersion);
-  ;
   outData["suspendTimeoutMillis"] = UtilAll::to_string(suspendTimeoutMillis);
-  ;
   outData["subscription"] = subscription;
 }
 
@@ -534,8 +530,8 @@ CommandHeader* ResetOffsetRequestHeader::Decode(Json::Value& ext)
{
   if (tempValue.isString()) {
     h->isForce = UtilAll::to_bool(tempValue.asCString());
   }
-  LOG_INFO("topic:%s, group:%s, timestamp:%lld, isForce:%d,isForce:%s", h->topic.c_str(),
h->group.c_str(),
-           h->timestamp, h->isForce, tempValue.asCString());
+  LOG_INFO("topic:%s, group:%s, timestamp:%lld, isForce:%d", h->topic.c_str(), h->group.c_str(),
h->timestamp,
+           h->isForce);
   return h;
 }
 
diff --git a/test/src/message/MQMessageExtTest.cpp b/test/src/message/MQMessageExtTest.cpp
index df8303d..a1f989a 100644
--- a/test/src/message/MQMessageExtTest.cpp
+++ b/test/src/message/MQMessageExtTest.cpp
@@ -132,7 +132,7 @@ TEST(messageExt, init) {
 int main(int argc, char* argv[]) {
   InitGoogleMock(&argc, argv);
 
-  testing::GTEST_FLAG(filter) = "messageExt.init";
+  testing::GTEST_FLAG(filter) = "messageExt.*";
   int itestts = RUN_ALL_TESTS();
   return itestts;
 }
diff --git a/test/src/message/StringIdMakerTest.cpp b/test/src/producer/StringIdMakerTest.cpp
similarity index 100%
rename from test/src/message/StringIdMakerTest.cpp
rename to test/src/producer/StringIdMakerTest.cpp
diff --git a/test/src/protocol/CommandHeaderTest.cpp b/test/src/protocol/CommandHeaderTest.cpp
index ee19e0e..5d46974 100644
--- a/test/src/protocol/CommandHeaderTest.cpp
+++ b/test/src/protocol/CommandHeaderTest.cpp
@@ -16,7 +16,6 @@
  */
 
 #include <memory>
-#include <string>
 
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -25,11 +24,7 @@
 #include "json/writer.h"
 
 #include "CommandHeader.h"
-#include "MQClientException.h"
-#include "MessageSysFlag.h"
-#include "UtilAll.h"
 #include "dataBlock.h"
-#include "json/json.h"
 
 using std::shared_ptr;
 
@@ -40,9 +35,11 @@ using testing::Return;
 using Json::FastWriter;
 using Json::Value;
 
+using rocketmq::CheckTransactionStateRequestHeader;
 using rocketmq::CommandHeader;
 using rocketmq::ConsumerSendMsgBackRequestHeader;
 using rocketmq::CreateTopicRequestHeader;
+using rocketmq::EndTransactionRequestHeader;
 using rocketmq::GetConsumerListByGroupRequestHeader;
 using rocketmq::GetConsumerListByGroupResponseBody;
 using rocketmq::GetConsumerListByGroupResponseHeader;
@@ -69,7 +66,260 @@ using rocketmq::UnregisterClientRequestHeader;
 using rocketmq::UpdateConsumerOffsetRequestHeader;
 using rocketmq::ViewMessageRequestHeader;
 
-TEST(commandHeader, ConsumerSendMsgBackRequestHeader) {}
+TEST(commandHeader, GetRouteInfoRequestHeader) {
+  GetRouteInfoRequestHeader header("testTopic");
+  map<string, string> requestMap;
+  header.SetDeclaredFieldOfCommandHeader(requestMap);
+  EXPECT_EQ(requestMap["topic"], "testTopic");
+
+  Value outData;
+  header.Encode(outData);
+  EXPECT_EQ(outData["topic"], "testTopic");
+}
+
+TEST(commandHeader, UnregisterClientRequestHeader) {
+  UnregisterClientRequestHeader header("testGroup", "testProducer", "testConsumer");
+  map<string, string> requestMap;
+  header.SetDeclaredFieldOfCommandHeader(requestMap);
+  EXPECT_EQ(requestMap["clientID"], "testGroup");
+  EXPECT_EQ(requestMap["producerGroup"], "testProducer");
+  EXPECT_EQ(requestMap["consumerGroup"], "testConsumer");
+
+  Value outData;
+  header.Encode(outData);
+  EXPECT_EQ(outData["clientID"], "testGroup");
+  EXPECT_EQ(outData["producerGroup"], "testProducer");
+  EXPECT_EQ(outData["consumerGroup"], "testConsumer");
+}
+
+TEST(commandHeader, CreateTopicRequestHeader) {
+  string topic = "testTopic";
+  string defaultTopic = "defaultTopic";
+  int readQueueNums = 4;
+  int writeQueueNums = 6;
+  int perm = 8;
+  string topicFilterType = "filterType";
+  CreateTopicRequestHeader header;
+  header.topic = topic;
+  header.defaultTopic = defaultTopic;
+  header.readQueueNums = readQueueNums;
+  header.writeQueueNums = writeQueueNums;
+  header.perm = perm;
+  header.topicFilterType = topicFilterType;
+  map<string, string> requestMap;
+  header.SetDeclaredFieldOfCommandHeader(requestMap);
+  EXPECT_EQ(requestMap["topic"], topic);
+  EXPECT_EQ(requestMap["defaultTopic"], defaultTopic);
+  EXPECT_EQ(requestMap["readQueueNums"], "4");
+  EXPECT_EQ(requestMap["writeQueueNums"], "6");
+  EXPECT_EQ(requestMap["perm"], "8");
+  EXPECT_EQ(requestMap["topicFilterType"], topicFilterType);
+
+  Value outData;
+  header.Encode(outData);
+  EXPECT_EQ(outData["topic"], topic);
+  EXPECT_EQ(outData["defaultTopic"], defaultTopic);
+  EXPECT_EQ(outData["readQueueNums"], readQueueNums);
+  EXPECT_EQ(outData["writeQueueNums"], writeQueueNums);
+  EXPECT_EQ(outData["perm"], perm);
+  EXPECT_EQ(outData["topicFilterType"], topicFilterType);
+}
+
+TEST(commandHeader, CheckTransactionStateRequestHeader) {
+  CheckTransactionStateRequestHeader header(2000, 1000, "ABC", "DEF", "GHI");
+  map<string, string> requestMap;
+  header.SetDeclaredFieldOfCommandHeader(requestMap);
+  EXPECT_EQ(requestMap["msgId"], "ABC");
+  EXPECT_EQ(requestMap["transactionId"], "DEF");
+  EXPECT_EQ(requestMap["offsetMsgId"], "GHI");
+  EXPECT_EQ(requestMap["commitLogOffset"], "1000");
+  EXPECT_EQ(requestMap["tranStateTableOffset"], "2000");
+
+  Value value;
+  value["msgId"] = "ABC";
+  value["transactionId"] = "DEF";
+  value["offsetMsgId"] = "GHI";
+  value["commitLogOffset"] = "1000";
+  value["tranStateTableOffset"] = "2000";
+  shared_ptr<CheckTransactionStateRequestHeader> headerDecode(
+      static_cast<CheckTransactionStateRequestHeader*>(CheckTransactionStateRequestHeader::Decode(value)));
+  EXPECT_EQ(headerDecode->m_msgId, "ABC");
+  EXPECT_EQ(headerDecode->m_commitLogOffset, 1000);
+  EXPECT_EQ(headerDecode->m_tranStateTableOffset, 2000);
+  EXPECT_EQ(headerDecode->toString(), header.toString());
+}
+
+TEST(commandHeader, EndTransactionRequestHeader) {
+  EndTransactionRequestHeader header("testProducer", 1000, 2000, 3000, true, "ABC", "DEF");
+  map<string, string> requestMap;
+  header.SetDeclaredFieldOfCommandHeader(requestMap);
+  EXPECT_EQ(requestMap["msgId"], "ABC");
+  EXPECT_EQ(requestMap["transactionId"], "DEF");
+  EXPECT_EQ(requestMap["producerGroup"], "testProducer");
+  EXPECT_EQ(requestMap["tranStateTableOffset"], "1000");
+  EXPECT_EQ(requestMap["commitLogOffset"], "2000");
+  EXPECT_EQ(requestMap["commitOrRollback"], "3000");
+  EXPECT_EQ(requestMap["fromTransactionCheck"], "1");
+
+  Value outData;
+  header.Encode(outData);
+  EXPECT_EQ(outData["msgId"], "ABC");
+  EXPECT_EQ(outData["transactionId"], "DEF");
+  EXPECT_EQ(outData["producerGroup"], "testProducer");
+  EXPECT_EQ(outData["tranStateTableOffset"], "1000");
+  EXPECT_EQ(outData["commitLogOffset"], "2000");
+  EXPECT_EQ(outData["commitOrRollback"], "3000");
+  EXPECT_EQ(outData["fromTransactionCheck"], "1");
+
+  EXPECT_NO_THROW(header.toString());
+}
+
+TEST(commandHeader, SendMessageRequestHeader) {
+  string producerGroup = "testProducer";
+  string topic = "testTopic";
+  string defaultTopic = "defaultTopic";
+  int defaultTopicQueueNums = 1;
+  int queueId = 2;
+  int sysFlag = 3;
+  int64 bornTimestamp = 4;
+  int flag = 5;
+  string properties = "testProperty";
+  int reconsumeTimes = 6;
+  bool unitMode = true;
+  bool batch = false;
+
+  SendMessageRequestHeader header;
+  header.producerGroup = producerGroup;
+  header.topic = topic;
+  header.defaultTopic = defaultTopic;
+  header.defaultTopicQueueNums = defaultTopicQueueNums;
+  header.queueId = queueId;
+  header.sysFlag = sysFlag;
+  header.bornTimestamp = bornTimestamp;
+  header.flag = flag;
+  header.properties = properties;
+  header.reconsumeTimes = reconsumeTimes;
+  header.unitMode = unitMode;
+  header.batch = batch;
+  header.setReconsumeTimes(reconsumeTimes);
+  EXPECT_EQ(header.getReconsumeTimes(), reconsumeTimes);
+  map<string, string> requestMap;
+  header.SetDeclaredFieldOfCommandHeader(requestMap);
+  EXPECT_EQ(requestMap["topic"], topic);
+  EXPECT_EQ(requestMap["producerGroup"], producerGroup);
+  EXPECT_EQ(requestMap["defaultTopic"], defaultTopic);
+  EXPECT_EQ(requestMap["defaultTopicQueueNums"], "1");
+  EXPECT_EQ(requestMap["queueId"], "2");
+  EXPECT_EQ(requestMap["sysFlag"], "3");
+  EXPECT_EQ(requestMap["bornTimestamp"], "4");
+  EXPECT_EQ(requestMap["flag"], "5");
+  EXPECT_EQ(requestMap["properties"], properties);
+  EXPECT_EQ(requestMap["reconsumeTimes"], "6");
+  EXPECT_EQ(requestMap["unitMode"], "1");
+  EXPECT_EQ(requestMap["batch"], "0");
+
+  Value outData;
+  header.Encode(outData);
+  EXPECT_EQ(outData["topic"], topic);
+  EXPECT_EQ(outData["producerGroup"], producerGroup);
+  EXPECT_EQ(outData["defaultTopic"], defaultTopic);
+  EXPECT_EQ(outData["defaultTopicQueueNums"], defaultTopicQueueNums);
+  EXPECT_EQ(outData["queueId"], queueId);
+  EXPECT_EQ(outData["sysFlag"], sysFlag);
+  EXPECT_EQ(outData["bornTimestamp"], "4");
+  EXPECT_EQ(outData["flag"], flag);
+  EXPECT_EQ(outData["properties"], properties);
+  EXPECT_EQ(outData["reconsumeTimes"], "6");
+  EXPECT_EQ(outData["unitMode"], "1");
+  EXPECT_EQ(outData["batch"], "0");
+}
+
+TEST(commandHeader, SendMessageResponseHeader) {
+  SendMessageResponseHeader header;
+  header.msgId = "ABCDEFG";
+  header.queueId = 1;
+  header.queueOffset = 2;
+  map<string, string> requestMap;
+  header.SetDeclaredFieldOfCommandHeader(requestMap);
+  EXPECT_EQ(requestMap["msgId"], "ABCDEFG");
+  EXPECT_EQ(requestMap["queueId"], "1");
+  EXPECT_EQ(requestMap["queueOffset"], "2");
+
+  Value value;
+  value["msgId"] = "EFGHIJK";
+  value["queueId"] = "3";
+  value["queueOffset"] = "4";
+  shared_ptr<SendMessageResponseHeader> headerDecode(
+      static_cast<SendMessageResponseHeader*>(SendMessageResponseHeader::Decode(value)));
+  EXPECT_EQ(headerDecode->msgId, "EFGHIJK");
+  EXPECT_EQ(headerDecode->queueId, 3);
+  EXPECT_EQ(headerDecode->queueOffset, 4);
+}
+
+TEST(commandHeader, PullMessageRequestHeader) {
+  PullMessageRequestHeader header;
+  header.consumerGroup = "testConsumer";
+  header.topic = "testTopic";
+  header.queueId = 1;
+  header.maxMsgNums = 2;
+  header.sysFlag = 3;
+  header.subscription = "testSub";
+  header.queueOffset = 4;
+  header.commitOffset = 5;
+  header.suspendTimeoutMillis = 6;
+  header.subVersion = 7;
+  map<string, string> requestMap;
+  header.SetDeclaredFieldOfCommandHeader(requestMap);
+  EXPECT_EQ(requestMap["consumerGroup"], "testConsumer");
+  EXPECT_EQ(requestMap["topic"], "testTopic");
+  EXPECT_EQ(requestMap["queueId"], "1");
+  EXPECT_EQ(requestMap["maxMsgNums"], "2");
+  EXPECT_EQ(requestMap["sysFlag"], "3");
+  EXPECT_EQ(requestMap["subscription"], "testSub");
+  EXPECT_EQ(requestMap["queueOffset"], "4");
+  EXPECT_EQ(requestMap["commitOffset"], "5");
+  EXPECT_EQ(requestMap["suspendTimeoutMillis"], "6");
+  EXPECT_EQ(requestMap["subVersion"], "7");
+
+  Value outData;
+  header.Encode(outData);
+  EXPECT_EQ(outData["consumerGroup"], "testConsumer");
+  EXPECT_EQ(outData["topic"], "testTopic");
+  EXPECT_EQ(outData["queueId"], 1);
+  EXPECT_EQ(outData["maxMsgNums"], 2);
+  EXPECT_EQ(outData["sysFlag"], 3);
+  EXPECT_EQ(outData["subscription"], "testSub");
+  EXPECT_EQ(outData["queueOffset"], "4");
+  EXPECT_EQ(outData["commitOffset"], "5");
+  EXPECT_EQ(outData["suspendTimeoutMillis"], "6");
+  EXPECT_EQ(outData["subVersion"], "7");
+}
+
+TEST(commandHeader, PullMessageResponseHeader) {
+  PullMessageResponseHeader header;
+  header.suggestWhichBrokerId = 100;
+  header.nextBeginOffset = 200;
+  header.minOffset = 3000;
+  header.maxOffset = 5000;
+  map<string, string> requestMap;
+  header.SetDeclaredFieldOfCommandHeader(requestMap);
+  EXPECT_EQ(requestMap["suggestWhichBrokerId"], "100");
+  EXPECT_EQ(requestMap["nextBeginOffset"], "200");
+  EXPECT_EQ(requestMap["minOffset"], "3000");
+  EXPECT_EQ(requestMap["maxOffset"], "5000");
+
+  Value value;
+  value["suggestWhichBrokerId"] = "5";
+  value["nextBeginOffset"] = "102400";
+  value["minOffset"] = "1";
+  value["maxOffset"] = "123456789";
+  shared_ptr<PullMessageResponseHeader> headerDecode(
+      static_cast<PullMessageResponseHeader*>(PullMessageResponseHeader::Decode(value)));
+  EXPECT_EQ(headerDecode->suggestWhichBrokerId, 5);
+  EXPECT_EQ(headerDecode->nextBeginOffset, 102400);
+  EXPECT_EQ(headerDecode->minOffset, 1);
+  EXPECT_EQ(headerDecode->maxOffset, 123456789);
+}
 
 TEST(commandHeader, GetConsumerListByGroupResponseBody) {
   Value value;
diff --git a/test/src/protocol/ConsumerRunningInfoTest.cpp b/test/src/protocol/ConsumerRunningInfoTest.cpp
index fbea4b2..70b305f 100644
--- a/test/src/protocol/ConsumerRunningInfoTest.cpp
+++ b/test/src/protocol/ConsumerRunningInfoTest.cpp
@@ -44,81 +44,72 @@ using rocketmq::MessageQueue;
 using rocketmq::ProcessQueueInfo;
 using rocketmq::SubscriptionData;
 
-TEST(consumerRunningInfo, init) {
-  ConsumerRunningInfo consumerRunningInfo;
-  consumerRunningInfo.setJstack("jstack");
-  EXPECT_EQ(consumerRunningInfo.getJstack(), "jstack");
+TEST(ConsumerRunningInfo, init) {
+  ConsumerRunningInfo info;
 
-  EXPECT_TRUE(consumerRunningInfo.getProperties().empty());
+  // jstack
+  info.setJstack("jstack");
+  EXPECT_EQ(info.getJstack(), "jstack");
 
-  consumerRunningInfo.setProperty("testKey", "testValue");
-  map<string, string> properties = consumerRunningInfo.getProperties();
+  // property
+  EXPECT_TRUE(info.getProperties().empty());
+  info.setProperty("testKey", "testValue");
+  map<string, string> properties = info.getProperties();
   EXPECT_EQ(properties["testKey"], "testValue");
-
-  consumerRunningInfo.setProperties(map<string, string>());
-  EXPECT_TRUE(consumerRunningInfo.getProperties().empty());
-
-  EXPECT_TRUE(consumerRunningInfo.getSubscriptionSet().empty());
-
+  info.setProperties(map<string, string>());
+  EXPECT_TRUE(info.getProperties().empty());
+  info.setProperty("testKey", "testValue");
+  map<string, string> properties2 = info.getProperties();
+  EXPECT_EQ(properties2["testKey"], "testValue");
+
+  // subscription
+  EXPECT_TRUE(info.getSubscriptionSet().empty());
   vector<SubscriptionData> subscriptionSet;
-  subscriptionSet.push_back(SubscriptionData());
-
-  consumerRunningInfo.setSubscriptionSet(subscriptionSet);
-  EXPECT_EQ(consumerRunningInfo.getSubscriptionSet().size(), 1);
-
-  EXPECT_TRUE(consumerRunningInfo.getMqTable().empty());
-
-  MessageQueue messageQueue("testTopic", "testBroker", 3);
-  ProcessQueueInfo processQueueInfo;
-  processQueueInfo.commitOffset = 1024;
-  consumerRunningInfo.setMqTable(messageQueue, processQueueInfo);
-  map<MessageQueue, ProcessQueueInfo> mqTable = consumerRunningInfo.getMqTable();
-  EXPECT_EQ(mqTable[messageQueue].commitOffset, processQueueInfo.commitOffset);
+  SubscriptionData sData1("testTopic", "testSub");
+  sData1.putTagsSet("testTag");
+  sData1.putCodeSet("11234");
+  subscriptionSet.push_back(sData1);
+  SubscriptionData sData2("testTopic2", "testSub2");
+  sData2.putTagsSet("testTag2");
+  sData2.putCodeSet("21234");
+  subscriptionSet.push_back(sData2);
+  info.setSubscriptionSet(subscriptionSet);
+  EXPECT_EQ(info.getSubscriptionSet().size(), 2);
+
+  // mqtable
+  EXPECT_TRUE(info.getMqTable().empty());
+
+  MessageQueue messageQueue1("testTopic", "testBrokerA", 3);
+  ProcessQueueInfo processQueueInfo1;
+  processQueueInfo1.commitOffset = 1024;
+  info.setMqTable(messageQueue1, processQueueInfo1);
+  MessageQueue messageQueue2("testTopic", "testBrokerB", 4);
+  ProcessQueueInfo processQueueInfo2;
+  processQueueInfo2.cachedMsgCount = 1023;
+  info.setMqTable(messageQueue2, processQueueInfo2);
+  map<MessageQueue, ProcessQueueInfo> mqTable = info.getMqTable();
+  EXPECT_EQ(mqTable.size(), 2);
+  EXPECT_EQ(mqTable[messageQueue1].commitOffset, 1024);
+  EXPECT_EQ(mqTable[messageQueue2].cachedMsgCount, 1023);
 
   // encode start
-  consumerRunningInfo.setProperty(ConsumerRunningInfo::PROP_NAMESERVER_ADDR, "127.0.0.1:9876");
-  consumerRunningInfo.setProperty(ConsumerRunningInfo::PROP_THREADPOOL_CORE_SIZE, "core_size");
-  consumerRunningInfo.setProperty(ConsumerRunningInfo::PROP_CONSUME_ORDERLY, "consume_orderly");
-  consumerRunningInfo.setProperty(ConsumerRunningInfo::PROP_CONSUME_TYPE, "consume_type");
-  consumerRunningInfo.setProperty(ConsumerRunningInfo::PROP_CLIENT_VERSION, "client_version");
-  consumerRunningInfo.setProperty(ConsumerRunningInfo::PROP_CONSUMER_START_TIMESTAMP, "127");
-  // TODO
-  /* string outstr = consumerRunningInfo.encode();
-   std::cout<< outstr;
-   Value root;
-   Reader reader;
-   reader.parse(outstr.c_str(), root);
-
-   EXPECT_EQ(root["jstack"].asString() , "jstack");
-
-   Json::Value outData = root["properties"];
-   EXPECT_EQ(outData[ConsumerRunningInfo::PROP_NAMESERVER_ADDR].asString(),"127.0.0.1:9876");
-   EXPECT_EQ(
-           outData[ConsumerRunningInfo::PROP_THREADPOOL_CORE_SIZE].asString(),
-           "core_size");
-   EXPECT_EQ(outData[ConsumerRunningInfo::PROP_CONSUME_ORDERLY].asString(),
-             "consume_orderly");
-   EXPECT_EQ(outData[ConsumerRunningInfo::PROP_CONSUME_TYPE].asString(),
-             "consume_type");
-   EXPECT_EQ(outData[ConsumerRunningInfo::PROP_CLIENT_VERSION].asString(),
-             "client_version");
-   EXPECT_EQ(
-           outData[ConsumerRunningInfo::PROP_CONSUMER_START_TIMESTAMP].asString(),
-           "127");
-
-   Json::Value subscriptionSetJson = root["subscriptionSet"];
-   EXPECT_EQ(subscriptionSetJson[0], subscriptionSet[0].toJson());
-
-   Json::Value mqTableJson = root["mqTable"];
-   EXPECT_EQ(mqTableJson[messageQueue.toJson().toStyledString()].asString(),
-             processQueueInfo.toJson().toStyledString());
-*/
+  info.setProperty(ConsumerRunningInfo::PROP_NAMESERVER_ADDR, "127.0.0.1:9876");
+  info.setProperty(ConsumerRunningInfo::PROP_THREADPOOL_CORE_SIZE, "core_size");
+  info.setProperty(ConsumerRunningInfo::PROP_CONSUME_ORDERLY, "consume_orderly");
+  info.setProperty(ConsumerRunningInfo::PROP_CONSUME_TYPE, "consume_type");
+  info.setProperty(ConsumerRunningInfo::PROP_CLIENT_VERSION, "client_version");
+  info.setProperty(ConsumerRunningInfo::PROP_CONSUMER_START_TIMESTAMP, "127");
+
+  // encode
+  string outStr = info.encode();
+  EXPECT_GT(outStr.length(), 1);
+  EXPECT_NE(outStr.find("testTopic"), string::npos);
 }
 
 int main(int argc, char* argv[]) {
   InitGoogleMock(&argc, argv);
   testing::GTEST_FLAG(throw_on_failure) = true;
-  testing::GTEST_FLAG(filter) = "consumerRunningInfo.*";
-  int itestts = RUN_ALL_TESTS();
-  return itestts;
+  testing::GTEST_FLAG(filter) = "ConsumerRunningInfo.*";
+  int iTests = RUN_ALL_TESTS();
+  return iTests;
 }
diff --git a/test/src/protocol/LockBatchBodyTest.cpp b/test/src/protocol/LockBatchBodyTest.cpp
index 9f8f300..81f5e4f 100644
--- a/test/src/protocol/LockBatchBodyTest.cpp
+++ b/test/src/protocol/LockBatchBodyTest.cpp
@@ -67,7 +67,27 @@ TEST(lockBatchBody, LockBatchRequestBody) {
   EXPECT_EQ(root["consumerGroup"], "testGroup");
 }
 
-TEST(lockBatchBody, UnlockBatchRequestBody) {}
+TEST(lockBatchBody, UnlockBatchRequestBody) {
+  UnlockBatchRequestBody uRB;
+  uRB.setClientId("testClient");
+  EXPECT_EQ(uRB.getClientId(), "testClient");
+  uRB.setConsumerGroup("testGroup");
+  EXPECT_EQ(uRB.getConsumerGroup(), "testGroup");
+
+  // message queue
+  EXPECT_TRUE(uRB.getMqSet().empty());
+  vector<MQMessageQueue> mqs;
+  MQMessageQueue mqA("testTopic", "testBrokerA", 1);
+  mqs.push_back(mqA);
+  MQMessageQueue mqB("testTopic", "testBrokerB", 2);
+  mqs.push_back(mqB);
+  uRB.setMqSet(mqs);
+  EXPECT_EQ(uRB.getMqSet().size(), 2);
+  string outData;
+  uRB.Encode(outData);
+  EXPECT_GT(outData.length(), 1);
+  EXPECT_NE(outData.find("testTopic"), string::npos);
+}
 
 TEST(lockBatchBody, LockBatchResponseBody) {
   Json::Value root;


Mime
View raw message