@Override public boolean containsBean(I id) { return this.cache.containsKey(this.beanFactory.createKey(id)); }
/** * @see java.util.Map#containsKey(java.lang.Object) */ @Override public boolean containsKey(Object key) { return cache.containsKey(key); }
@Override public boolean isSatisfied() throws Exception { return cache1.containsKey(magicKey) && cache2.containsKey(magicKey); } });
public void testLocksOnEvictNonexistent() throws Exception { LockTestData tl = lockTestData; Cache<String, String> cache = tl.cache; TransactionManager tm = tl.tm; assert !cache.containsKey("k") : "Should not exist"; tm.begin(); cache.evict("k"); assertNotLocked("k"); tm.commit(); assert !cache.containsKey("k") : "Should not exist"; assertNoLocks(); }
@Override public void call() { Cache<Integer, Person> cache = cm.getCache(); CacheListener cacheListener = new CacheListener(); cache.addListener(cacheListener); assertTrue(cache.containsKey(1)); assertTrue(cache.containsKey(2)); assertEquals(cacheListener.numberOfPassivations(), 0); assertEquals(cacheListener.numberOfActivations(), 0); assertFalse(luceneIndexTracker.indexChanged()); } });
public void testRemoveViaComputeOnEvictedEntry() throws Exception { Cache<String, String> testCache = cacheManager.getCache(CACHE_NAME); for (int i = 0; i < EVICTION_MAX_ENTRIES + 1; i++) { testCache.put("key" + i, "value" + i); } String evictedKey = evictionListener.getEvictedKey(); assertTrue(isEntryInStore(evictedKey)); testCache.compute(evictedKey, (k ,v) -> null); assertFalse(testCache.containsKey(evictedKey)); assertFalse(isEntryInStore(evictedKey)); }
public void testRemovalOfEvictedEntry() throws Exception { Cache<String, String> testCache = cacheManager.getCache(CACHE_NAME); for (int i = 0; i < EVICTION_MAX_ENTRIES + 1; i++) { testCache.put("key" + i, "value" + i); } String evictedKey = evictionListener.getEvictedKey(); assertTrue(isEntryInStore(evictedKey)); testCache.remove(evictedKey); assertFalse(testCache.containsKey(evictedKey)); assertNull(testCache.get(evictedKey)); }
public void testMultipleIdenticalPutForExternalReadCalls() { final Cache<String, String> cache1 = cache(0, CACHE_NAME); final Cache<String, String> cache2 = cache(1, CACHE_NAME); cache1.putForExternalRead(key, value); // wait for command the finish executing asynchronously eventually(() -> cache1.containsKey(key) && cache2.containsKey(key)); cache1.putForExternalRead(key, value2); assertEquals(value, cache1.get(key)); }
public void testIntIterator() { Cache<Integer, String> cache = getCache(0); testIntOperation(() -> { PrimitiveIterator.OfInt iterator = createStream(cache.entrySet()).mapToInt(toInt).iterator(); AtomicInteger count = new AtomicInteger(); iterator.forEachRemaining((int e) -> { assertTrue(cache.containsKey(e)); count.addAndGet(e); }); return count.get(); }, cache); }
public void testLongIterator() { Cache<Long, String> cache = getCache(0); testLongOperation(() -> { PrimitiveIterator.OfLong iterator = createStream(cache.entrySet()).mapToLong(toLong).iterator(); AtomicLong count = new AtomicLong(); iterator.forEachRemaining((long e) -> { assertTrue(cache.containsKey(e)); count.addAndGet(e); }); return count.get(); }, cache); }
public void testIntToArray() { Cache<Integer, String> cache = getCache(0); int range = 10; // First populate the cache with a bunch of values IntStream.range(0, range).boxed().forEach(i -> cache.put(i, i + "-value")); assertEquals(range, cache.size()); CacheSet<Map.Entry<Integer, String>> entrySet = cache.entrySet(); int[] array = createStream(entrySet).mapToInt(toInt).toArray(); assertEquals(cache.size(), array.length); Spliterator.OfInt spliterator = Spliterators.spliterator(array, Spliterator.DISTINCT); StreamSupport.intStream(spliterator, true).forEach(e -> assertTrue(cache.containsKey(e))); }
public void testDangling() throws Exception { Interpreter interpreter = getInterpreter(); String sessionId = interpreter.createSessionId("default"); interpreter.execute(sessionId, "begin; put 'a' 'a';"); assertNull(cache.getAdvancedCache().getTransactionManager().getTransaction()); assertFalse(cache.containsKey("a")); interpreter.execute(sessionId, "start; put 'a' 'a';"); assertNull(cache.getAdvancedCache().getBatchContainer().getBatchTransaction()); assertFalse(cache.containsKey("a")); }
public void testEvictWithMarshalledValueKey() { Cache<Object, Object> cache1 = cache(0, "replSync"); cache(1, "replSync"); Pojo pojo = new Pojo(); cache1.put(pojo, pojo); cache1.evict(pojo); assertTrue(!cache1.containsKey(pojo)); }
public void testExpirationMaxIdleInOps() throws Exception { for (int i = 0; i < SIZE; i++) { cache.put("key-" + i, "value-" + i,-1, null, 1, TimeUnit.MILLISECONDS); } timeService.advance(2); for (int i = 0; i < SIZE; i++) { assertFalse(cache.containsKey("key-" + 1)); assertNull(cache.get("key-" + i)); assertNull(cache.remove("key-" + i)); } }
public void testExpirationLifespanInOps() throws Exception { for (int i = 0; i < SIZE; i++) { cache.put("key-" + i, "value-" + i, 1, TimeUnit.MILLISECONDS); } timeService.advance(2); for (int i = 0; i < SIZE; i++) { assertFalse(cache.containsKey("key-" + 1)); assertNull(cache.get("key-" + i)); assertNull(cache.remove("key-" + i)); } }
public void testDoubleIterator() { Cache<Double, String> cache = getCache(0); testDoubleOperation(() -> { PrimitiveIterator.OfDouble iterator = createStream(cache.entrySet()).mapToDouble(toDouble).iterator(); DoubleSummaryStatistics doubleSummaryStatistics = new DoubleSummaryStatistics(); iterator.forEachRemaining((double e) -> { assertTrue(cache.containsKey(e)); doubleSummaryStatistics.accept(e); }); return doubleSummaryStatistics; }, cache); }
public void testLongToArray() { Cache<Long, String> cache = getCache(0); int range = 10; // First populate the cache with a bunch of values LongStream.range(0, range).boxed().forEach(i -> cache.put(i, i + "-value")); assertEquals(range, cache.size()); CacheSet<Map.Entry<Long, String>> entrySet = cache.entrySet(); long[] array = createStream(entrySet).mapToLong(toLong).toArray(); assertEquals(cache.size(), array.length); Spliterator.OfLong spliterator = Spliterators.spliterator(array, Spliterator.DISTINCT); StreamSupport.longStream(spliterator, true).forEach(e -> assertTrue(cache.containsKey(e))); }
public void testPutOnDefaultCache(Method m) { TestResponse resp = client().execute(0xA0, (byte) 0x01, "", k(m), 0, 0, v(m), 0, (byte) 1, 0); assertStatus(resp, Success); assertHotRodEquals(cacheManager, ANOTHER_CACHE, k(m), v(m)); assertFalse(cacheManager.getCache().containsKey(k(m))); } }
public void testDoubleToArray() { Cache<Double, String> cache = getCache(0); int range = 10; // First populate the cache with a bunch of values DoubleStream.iterate(0.0, d -> d + .5).limit(10).boxed().forEach(i -> cache.put(i, i + "-value")); assertEquals(range, cache.size()); CacheSet<Map.Entry<Double, String>> entrySet = cache.entrySet(); double[] array = createStream(entrySet).mapToDouble(toDouble).toArray(); assertEquals(cache.size(), array.length); Spliterator.OfDouble spliterator = Spliterators.spliterator(array, Spliterator.DISTINCT); StreamSupport.doubleStream(spliterator, true).forEach(e -> assertTrue(cache.containsKey(e))); }
public void testEvictInBatch() throws Exception { cache().put("myKey", "myValue"); cache().getAdvancedCache().startBatch(); //this should execute non-transactionally despite the batch transaction and should not fail as in https://issues.jboss.org/browse/ISPN-2845 cache().evict("myKey"); cache().getAdvancedCache().endBatch(true); assertFalse(cache().containsKey("myKey")); } }