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/02/21 09:05:10 UTC

[rocketmq] branch develop updated: [RIP-10] Add test cases for CheckClientRequestBody (#808)

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 698effa  [RIP-10]  Add test cases for CheckClientRequestBody (#808)
698effa is described below

commit 698effa6caa76671a160de890481b0ea90258115
Author: Jack Xu <xu...@126.com>
AuthorDate: Thu Feb 21 17:05:05 2019 +0800

    [RIP-10]  Add test cases for CheckClientRequestBody (#808)
---
 .../protocol/body/CheckClientRequestBodyTest.java  | 43 ++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/common/src/test/java/org/apache/rocketmq/common/protocol/body/CheckClientRequestBodyTest.java b/common/src/test/java/org/apache/rocketmq/common/protocol/body/CheckClientRequestBodyTest.java
new file mode 100644
index 0000000..22bc6b3
--- /dev/null
+++ b/common/src/test/java/org/apache/rocketmq/common/protocol/body/CheckClientRequestBodyTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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 static org.assertj.core.api.Assertions.assertThat;
+
+public class CheckClientRequestBodyTest {
+
+    @Test
+    public void testFromJson() {
+        SubscriptionData subscriptionData = new SubscriptionData();
+        String expectedClientId = "defalutId";
+        String expectedGroup = "defaultGroup";
+        CheckClientRequestBody checkClientRequestBody = new CheckClientRequestBody();
+        checkClientRequestBody.setClientId(expectedClientId);
+        checkClientRequestBody.setGroup(expectedGroup);
+        checkClientRequestBody.setSubscriptionData(subscriptionData);
+        String json = RemotingSerializable.toJson(checkClientRequestBody, true);
+        CheckClientRequestBody fromJson = RemotingSerializable.fromJson(json, CheckClientRequestBody.class);
+        assertThat(fromJson.getClientId()).isEqualTo(expectedClientId);
+        assertThat(fromJson.getGroup()).isEqualTo(expectedGroup);
+        assertThat(fromJson.getSubscriptionData()).isEqualTo(subscriptionData);
+    }
+}
\ No newline at end of file