}
@Test
public void clear() throws InterruptedException {
final LinkedList<Integer> size = new LinkedList<Integer>();
final BatchCounterDataStore store = new BatchCounterDataStore() {
@Override
protected void pushCountersByBatch(final Collection<Counter> instance) {
size.add(instance.size());
}
@Override
protected int getPeriod(final String prefix) {
return 100;
}
@Override
protected boolean isClearAfterCollect(final String prefix) {
return true;
}
};
Repository.INSTANCE.getCounter(new Counter.Key(Role.PERFORMANCES, "counter")).add(123);
Thread.sleep(250);
store.shutdown();
assertTrue(size.size() >= 2);
assertEquals(1, size.iterator().next().intValue());
assertEquals(0, size.get(1).intValue());
}