@Override public void testRemove(Method method) { final String counterName = method.getName(); final long initialValue = 5; T counter = defineAndCreateCounter(counterName, initialValue); add(counter, 100, 105); assertCounterValue(counter, 105); remove(counter); assertCounterValue(counter, initialValue); add(counter, -100, -95); assertCounterValue(counter, -95); counterManagerSupplier.get().remove(counterName); assertCounterValue(counter, initialValue); }
private TestCounter assertCounterManagerRemove(String name, TestCounter counter, Factory factory, int index) { CounterManager manager = counterManager(index); manager.remove(name); assertTrue(cache(0, CounterModuleLifecycle.COUNTER_CACHE_NAME).isEmpty()); TestCounter anotherCounter = factory.get(manager, name); if (counter != null) { assertFalse(counter.isSame(anotherCounter)); } return anotherCounter; }
@Override public void testRemove(Method method) { //we need to cleanup other tests counters from the caches because of cache.size() clearCaches(); final Random random = generateRandom(); final String counterName = method.getName(); final CounterManager counterManager = getTestedCounterManager(); CounterConfiguration config = builder(CounterType.UNBOUNDED_STRONG).initialValue(random.nextLong()).build(); assertTrue(counterManager.defineCounter(counterName, config)); awaitCounterOperation(counterManager.getStrongCounter(counterName).addAndGet(10)); EmbeddedCacheManager cacheManager = cacheManagerSupplier.get(); Cache<?, ?> cache = cacheManager.getCache(CounterModuleLifecycle.COUNTER_CACHE_NAME); assertEquals(1, cache.size()); counterManager.remove(counterName); assertEquals(0, cache.size()); }