Skip to content

Commit

Permalink
Add test case for LocalFileOffsetStore closes apache#59
Browse files Browse the repository at this point in the history
  • Loading branch information
kination authored and dongeforever committed May 27, 2017
1 parent e5d01b4 commit 0adad6f
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import java.io.File;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;

import org.apache.rocketmq.client.ClientConfig;
import org.apache.rocketmq.client.impl.factory.MQClientInstance;
import org.apache.rocketmq.common.message.MessageQueue;
Expand Down Expand Up @@ -72,4 +74,15 @@ public void testReadOffset_FromStore() throws Exception {
offsetStore.persistAll(new HashSet<MessageQueue>(Collections.singletonList(messageQueue)));
assertThat(offsetStore.readOffset(messageQueue, ReadOffsetType.READ_FROM_STORE)).isEqualTo(1024);
}

@Test
public void testCloneOffset() throws Exception {
OffsetStore offsetStore = new LocalFileOffsetStore(mQClientFactory, group);
MessageQueue messageQueue = new MessageQueue(topic, brokerName, 3);
offsetStore.updateOffset(messageQueue, 1024, false);
Map<MessageQueue, Long> cloneOffsetTable = offsetStore.cloneOffsetTable(topic);

assertThat(cloneOffsetTable.size()).isEqualTo(1);
assertThat(cloneOffsetTable.get(messageQueue)).isEqualTo(1024);
}
}

0 comments on commit 0adad6f

Please sign in to comment.