odbozhou commented on a change in pull request #1240: [ISSUE #1199] Implement 
the 1.0.0 openmessaging new consumer API for rocketmq oms module
URL: https://github.com/apache/rocketmq/pull/1240#discussion_r294089941
 
 

 ##########
 File path: 
openmessaging/src/test/java/io/openmessaging/rocketmq/consumer/LocalMessageCacheTest.java
 ##########
 @@ -86,4 +95,77 @@ public void testSubmitConsumeRequest() throws Exception {
         localMessageCache.submitConsumeRequest(consumeRequest);
         assertThat(localMessageCache.poll()).isEqualTo(consumedMsg);
     }
+
+    @Test
+    public void testBatchPollMessage() throws Exception {
+        byte[] body = new byte[] {'1', '2', '3'};
+        MessageExt consumedMsg = new MessageExt();
+        consumedMsg.setMsgId("NewMsgId");
+        consumedMsg.setBody(body);
+        consumedMsg.putUserProperty(NonStandardKeys.MESSAGE_DESTINATION, 
"TOPIC");
+        consumedMsg.setTopic("HELLO_QUEUE");
+
+        byte[] body1 = new byte[] {'4', '5', '6'};
+        MessageExt consumedMsg1 = new MessageExt();
+        consumedMsg1.setMsgId("NewMsgId1");
+        consumedMsg1.setBody(body1);
+        consumedMsg1.putUserProperty(NonStandardKeys.MESSAGE_DESTINATION, 
"TOPIC");
+        consumedMsg1.setTopic("HELLO_QUEUE1");
+
+        when(consumeRequest.getMessageExt()).thenReturn(consumedMsg);
+        when(consumeRequest1.getMessageExt()).thenReturn(consumedMsg1);
+        localMessageCache.submitConsumeRequest(consumeRequest);
+        localMessageCache.submitConsumeRequest(consumeRequest1);
+        KeyValue properties = new DefaultKeyValue();
+        properties.put(NonStandardKeys.TIMEOUT, 3000);
+        List<MessageExt> messageExts = localMessageCache.batchPoll(properties);
+        assertThat(messageExts.size()).isEqualTo(2);
+        MessageExt messageExt1 = null;
+        MessageExt messageExt2 = null;
+        for (MessageExt messageExt : messageExts) {
+            if (messageExt.getMsgId().equals("NewMsgId")) {
+                messageExt1 = messageExt;
+            }
+            if (messageExt.getMsgId().equals("NewMsgId1")) {
+                messageExt2 = messageExt;
+            }
+        }
+        assertThat(messageExt1).isNotNull();
 
 Review comment:
   This has increased verification

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to