Skip to content

Commit

Permalink
[ISSUE apache#3906] Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
drpmma authored and zhouxinyu committed Jun 20, 2022
1 parent 014dd82 commit 7f4cf96
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
Expand Up @@ -50,7 +50,6 @@ public void testParseRequestContent() {
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);
Expand All @@ -72,7 +71,6 @@ public void testParseRequestContentWithStreamRequestType() {
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");
Expand Down
@@ -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();
}
}

0 comments on commit 7f4cf96

Please sign in to comment.