Github user zhouxinyu commented on a diff in the pull request:

    https://github.com/apache/incubator-rocketmq/pull/146#discussion_r134938289
  
    --- Diff: 
store/src/test/java/org/apache/rocketmq/store/ConsumeQueueTest.java ---
    @@ -148,6 +148,52 @@ protected void deleteFile(File file) {
         }
     
         @Test
    +    public void 
test_putMessagePositionInfo_build_consume_queue_idempotent() {
    +        DefaultMessageStore messageStore = null;
    +        try {
    +
    +            messageStore = gen();
    +
    +            int totalMessages = 10;
    +
    +            for (int i = 0; i < totalMessages; i++) {
    +                putMsg(messageStore);
    +            }
    +            Thread.sleep(5);
    +
    +            ConsumeQueue cq = 
messageStore.getConsumeQueueTable().get(topic).get(queueId);
    +            Method method = 
cq.getClass().getDeclaredMethod("putMessagePositionInfo", long.class, 
int.class, long.class, long.class);
    +
    +            assertThat(method).isNotNull();
    +
    +            method.setAccessible(true);
    +
    +            SelectMappedBufferResult result = 
messageStore.getCommitLog().getData(0);
    +            assertThat(result != null).isTrue();
    +
    +            DispatchRequest dispatchRequest = 
messageStore.getCommitLog().checkMessageAndReturnSize(result.getByteBuffer(), 
false, false);
    +
    +            assertThat(cq).isNotNull();
    +
    +            Object dispatchResult = method.invoke(cq, 
dispatchRequest.getCommitLogOffset(),
    +                dispatchRequest.getMsgSize(), 
dispatchRequest.getTagsCode(), dispatchRequest.getConsumeQueueOffset());
    +
    +            
assertThat(Boolean.parseBoolean(dispatchResult.toString())).isTrue();
    +
    +        } catch (Exception e) {
    +            e.printStackTrace();
    +            assertThat(Boolean.FALSE).isTrue();
    --- End diff --
    
    `assertThat(Boolean.FALSE).isTrue()`, it's really a trick, there is no need 
to catch exception, we can just add exception to method signature.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to