final String group = "test-grp";
final Partition partition = new Partition("0-1");
Collection<TopicPartitionRegInfo> infoList = new ArrayList<TopicPartitionRegInfo>();
for (int i = 0; i < 3; i++) {
final String topic = "test" + (i + 1);
infoList.add(new TopicPartitionRegInfo(topic, partition, i));
}
this.offsetStorage.commitOffset(group, infoList);
this.offsetStorage.commitOffset(group, null);
for (int i = 0; i < 3; i++) {
final String topic = "test" + (i + 1);
TopicPartitionRegInfo info = this.offsetStorage.load(topic, "test-grp", partition);
assertEquals(topic, info.getTopic());
assertEquals(partition, info.getPartition());
assertEquals(i, info.getOffset().get());
info.getOffset().set(i);
infoList.add(info);
}
OffsetStorage newOffsetStorage = new LocalOffsetStorage();
for (int i = 0; i < 3; i++) {
final String topic = "test" + (i + 1);
TopicPartitionRegInfo info = newOffsetStorage.load(topic, "test-grp", partition);
assertEquals(topic, info.getTopic());
assertEquals(partition, info.getPartition());
assertEquals(i, info.getOffset().get());
info.getOffset().set(i);
infoList.add(info);
}
this.offsetStorage.commitOffset(group, Collections.EMPTY_LIST);
for (int i = 0; i < 3; i++) {
final String topic = "test" + (i + 1);
TopicPartitionRegInfo info = newOffsetStorage.load(topic, "test-grp", partition);
assertEquals(topic, info.getTopic());
assertEquals(partition, info.getPartition());
assertEquals(i, info.getOffset().get());
info.getOffset().set(i);
infoList.add(info);
}
newOffsetStorage.close();
}