This is an automated email from the ASF dual-hosted git repository. yukon pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/rocketmq.git
commit f34c185e05f5b1a1cc372fa72718d6b40ed6e5cc Author: zhouxiang <[email protected]> AuthorDate: Tue Jun 7 20:14:47 2022 +0800 [ISSUE #3906] Add unit test --- .../rocketmq/acl/common/AclClientRPCHookTest.java | 2 -- .../remoting/protocol/RequestTypeTest.java | 33 ++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/acl/src/test/java/org/apache/rocketmq/acl/common/AclClientRPCHookTest.java b/acl/src/test/java/org/apache/rocketmq/acl/common/AclClientRPCHookTest.java index 8c0d57d62..1dd94d8a1 100644 --- a/acl/src/test/java/org/apache/rocketmq/acl/common/AclClientRPCHookTest.java +++ b/acl/src/test/java/org/apache/rocketmq/acl/common/AclClientRPCHookTest.java @@ -50,7 +50,6 @@ public class AclClientRPCHookTest { requestHeader.setCommitOffset(0L); requestHeader.setSuspendTimeoutMillis(15000L); requestHeader.setSubVersion(0L); - requestHeader.setBrokerName("brokerName"); RemotingCommand testPullRemotingCommand = RemotingCommand.createRequestCommand(RequestCode.PULL_MESSAGE, requestHeader); SortedMap<String, String> oldContent = oldVersionParseRequestContent(testPullRemotingCommand, "ak", null); byte[] oldBytes = AclUtils.combineRequestContent(testPullRemotingCommand, oldContent); @@ -72,7 +71,6 @@ public class AclClientRPCHookTest { requestHeader.setCommitOffset(0L); requestHeader.setSuspendTimeoutMillis(15000L); requestHeader.setSubVersion(0L); - requestHeader.setBrokerName("brokerName"); RemotingCommand testPullRemotingCommand = RemotingCommand.createRequestCommand(RequestCode.PULL_MESSAGE, requestHeader); testPullRemotingCommand.addExtField(MixAll.REQ_T, String.valueOf(RequestType.STREAM.getCode())); testPullRemotingCommand.addExtField(ACCESS_KEY, "ak"); diff --git a/remoting/src/test/java/org/apache/rocketmq/remoting/protocol/RequestTypeTest.java b/remoting/src/test/java/org/apache/rocketmq/remoting/protocol/RequestTypeTest.java new file mode 100644 index 000000000..7457926d7 --- /dev/null +++ b/remoting/src/test/java/org/apache/rocketmq/remoting/protocol/RequestTypeTest.java @@ -0,0 +1,33 @@ +/* + * 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.remoting.protocol; + +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class RequestTypeTest { + @Test + public void testValueOf() { + RequestType requestType = RequestType.valueOf(RequestType.STREAM.getCode()); + assertThat(requestType).isEqualTo(RequestType.STREAM); + + requestType = RequestType.valueOf((byte) 1); + assertThat(requestType).isNull(); + } +} \ No newline at end of file
