You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by di...@apache.org on 2019/05/14 08:18:41 UTC

[rocketmq] branch develop updated: [RIP-10] Add test class for QueryConsumeQueueResponseBody (#918)

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

dinglei pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/develop by this push:
     new 05d48cf  [RIP-10] Add test class for QueryConsumeQueueResponseBody (#918)
05d48cf is described below

commit 05d48cf9d9e492eee2cde3a0312788d32933731f
Author: guishou520 <13...@qq.com>
AuthorDate: Tue May 14 16:18:35 2019 +0800

    [RIP-10] Add test class for QueryConsumeQueueResponseBody (#918)
---
 .../body/QueryConsumeQueueResponseBodyTest.java    | 70 ++++++++++++++++++++++
 1 file changed, 70 insertions(+)

diff --git a/common/src/test/java/org/apache/rocketmq/common/protocol/body/QueryConsumeQueueResponseBodyTest.java b/common/src/test/java/org/apache/rocketmq/common/protocol/body/QueryConsumeQueueResponseBodyTest.java
new file mode 100644
index 0000000..fad86f7
--- /dev/null
+++ b/common/src/test/java/org/apache/rocketmq/common/protocol/body/QueryConsumeQueueResponseBodyTest.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.rocketmq.common.protocol.body;
+
+import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class QueryConsumeQueueResponseBodyTest {
+
+    @Test
+    public void test(){
+        QueryConsumeQueueResponseBody body = new QueryConsumeQueueResponseBody();
+
+        SubscriptionData subscriptionData = new SubscriptionData();
+        ConsumeQueueData data = new ConsumeQueueData();
+        data.setBitMap("defaultBitMap");
+        data.setEval(false);
+        data.setMsg("this is default msg");
+        data.setPhysicOffset(10L);
+        data.setPhysicSize(1);
+        data.setTagsCode(1L);
+        List<ConsumeQueueData> list = new ArrayList<ConsumeQueueData>();
+        list.add(data);
+
+        body.setQueueData(list);
+        body.setFilterData("default filter data");
+        body.setMaxQueueIndex(100L);
+        body.setMinQueueIndex(1L);
+        body.setSubscriptionData(subscriptionData);
+
+        String json = RemotingSerializable.toJson(body, true);
+        QueryConsumeQueueResponseBody fromJson = RemotingSerializable.fromJson(json, QueryConsumeQueueResponseBody.class);
+        System.out.println(json);
+        //test ConsumeQueue
+        ConsumeQueueData jsonData = fromJson.getQueueData().get(0);
+        assertThat(jsonData.getMsg()).isEqualTo("this is default msg");
+        assertThat(jsonData.getPhysicSize()).isEqualTo(1);
+        assertThat(jsonData.getBitMap()).isEqualTo("defaultBitMap");
+        assertThat(jsonData.getTagsCode()).isEqualTo(1L);
+        assertThat(jsonData.getPhysicSize()).isEqualTo(1);
+
+        //test QueryConsumeQueueResponseBody
+        assertThat(fromJson.getFilterData()).isEqualTo("default filter data");
+        assertThat(fromJson.getMaxQueueIndex()).isEqualTo(100L);
+        assertThat(fromJson.getMinQueueIndex()).isEqualTo(1L);
+        assertThat(fromJson.getSubscriptionData()).isEqualTo(subscriptionData);
+
+    }
+}