Skip to content

Commit

Permalink
[ISSUE apache#8553] Add UnitTest of ZoneRouteRPCHook、OffsetSerialize
Browse files Browse the repository at this point in the history
  • Loading branch information
syhleo committed Aug 19, 2024
1 parent 7cab56e commit 78573b5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public void setUp() {
public void testGetOffsetTable_ShouldReturnConcurrentHashMap() {
ConcurrentMap<Integer, Long> offsetTable = wrapper.getOffsetTable();
assertNotNull("The offsetTable should not be null", offsetTable);
assertEquals("The offsetTable should be a ConcurrentMap", ConcurrentMap.class, offsetTable.getClass());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ public void testFilterByZoneName_ValidInput_ShouldFilterCorrectly() {
topicRouteData.setQueueDatas(generateQueueDataList());

RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ROUTEINFO_BY_TOPIC,null);
request.setExtFields(new HashMap<String, String>() {{
put(MixAll.ZONE_MODE, "true");
put(MixAll.ZONE_NAME, "ZoneA");
}});
request.setExtFields(createExtFields("true","ZoneA"));

RemotingCommand response = RemotingCommand.createResponseCommand(ResponseCode.SUCCESS, "remark");

Expand All @@ -77,9 +74,9 @@ public void testFilterByZoneName_NoZoneName_ShouldNotFilter() {
topicRouteData.setQueueDatas(generateQueueDataList());

RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ROUTEINFO_BY_TOPIC,null);
request.setExtFields(new HashMap<String, String>() {{
put(MixAll.ZONE_MODE, "true");
}});
HashMap<String, String> extFields = new HashMap<>();
extFields.put(MixAll.ZONE_MODE, "true");
request.setExtFields(extFields);

RemotingCommand response = RemotingCommand.createResponseCommand(ResponseCode.SUCCESS, null);

Expand All @@ -100,10 +97,7 @@ public void testFilterByZoneName_ZoneModeFalse_ShouldNotFilter() {
topicRouteData.setQueueDatas(generateQueueDataList());

RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ROUTEINFO_BY_TOPIC,null);
request.setExtFields(new HashMap<String, String>() {{
put(MixAll.ZONE_MODE, "false");
put(MixAll.ZONE_NAME, "ZoneA");
}});
request.setExtFields(createExtFields("false","ZoneA"));

RemotingCommand response = RemotingCommand.createResponseCommand(ResponseCode.SUCCESS ,null);

Expand Down Expand Up @@ -149,4 +143,12 @@ private List<QueueData> generateQueueDataList() {

return queueDataList;
}

private HashMap<String, String> createExtFields(String zoneMode, String zoneName) {
HashMap<String, String> extFields = new HashMap<>();
extFields.put(MixAll.ZONE_MODE, zoneMode);
extFields.put(MixAll.ZONE_NAME, zoneName);
return extFields;
}

}

0 comments on commit 78573b5

Please sign in to comment.