public void testRemoveCacheClusteredSharedStores(Method m) throws Exception { doTestRemoveCacheClustered(m, true); }
private EmbeddedCacheManager getManagerWithStore(Method m, boolean isClustered, boolean isStoreShared) { return getManagerWithStore(m, isClustered, isStoreShared, "store-"); }
public void testRemoveCacheLocal(Method m) { EmbeddedCacheManager manager = getManagerWithStore(m, false, false); try { Cache<String, String> cache = manager.getCache("cache"); cache.put(k(m, 1), v(m, 1)); cache.put(k(m, 2), v(m, 2)); cache.put(k(m, 3), v(m, 3)); DummyInMemoryStore store = getDummyStore(cache); DataContainer data = getDataContainer(cache); assertFalse(store.isEmpty()); assertTrue(0 != data.size()); manager.administration().removeCache("cache"); assertEquals(0, DummyInMemoryStore.getStoreDataSize(store.getStoreName())); assertEquals(0, data.size()); // Try removing the cache again, it should be a no-op manager.administration().removeCache("cache"); assertEquals(0, DummyInMemoryStore.getStoreDataSize(store.getStoreName())); assertEquals(0, data.size()); } finally { manager.stop(); } }
Future<?> cacheStartFuture = fork(() -> manager.getCache(CACHE_NAME)); cacheStartBlocked.get(10, SECONDS); Future<?> managerStopFuture = fork(() -> manager.stop()); Exceptions.expectException(TimeoutException.class, () -> managerStopBlocked.get(1, SECONDS)); Future<?> cacheStartFuture2 = fork(() -> manager.getCache(CACHE_NAME)); Exceptions.expectExecutionException(IllegalLifecycleStateException.class, cacheStartFuture2);
private void doTestRemoveCacheClustered(final Method m, final boolean isStoreShared) { withCacheManagers(new MultiCacheManagerCallable( getManagerWithStore(m, true, isStoreShared, "store1-"), getManagerWithStore(m, true, isStoreShared, "store2-")) { @Override public void call() {
public void testRemoveCacheClusteredLocalStores(Method m) throws Exception { doTestRemoveCacheClustered(m, false); }
public void testRemoveNonExistentCache(Method m) { EmbeddedCacheManager manager = getManagerWithStore(m, false, false); try { manager.getCache("cache"); // An attempt to remove a non-existing cache should be a no-op manager.administration().removeCache("does-not-exist"); } finally { manager.stop(); } }