Java Code Examples for org.ehcache.PersistentCacheManager#destroyCache()

The following examples show how to use org.ehcache.PersistentCacheManager#destroyCache() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PersistentCacheManagerTest.java    From ehcache3 with Apache License 2.0 5 votes vote down vote up
@Test
public void testDestroyCache_NullAliasNotAllowed() throws CachePersistenceException {
  PersistentCacheManager manager = builder.build(true);
  thrown.expect(NullPointerException.class);
  thrown.expectMessage("Alias cannot be null");
  manager.destroyCache(null);
}
 
Example 2
Source File: PersistentCacheManagerTest.java    From ehcache3 with Apache License 2.0 5 votes vote down vote up
@Test
public void testDestroyCache_Initialized_DestroyExistingCache() throws CachePersistenceException {
  PersistentCacheManager manager = buildCacheManagerWithCache(true);

  manager.destroyCache(TEST_CACHE_ALIAS);

  assertThat(rootDirectory, isLocked());
  assertThat(rootDirectory, not(containsCacheDirectory(TEST_CACHE_ALIAS)));
}
 
Example 3
Source File: PersistentCacheManagerTest.java    From ehcache3 with Apache License 2.0 5 votes vote down vote up
@Test
public void testDestroyCache_Uninitialized_DestroyExistingCache() throws CachePersistenceException {
  PersistentCacheManager manager = buildCacheManagerWithCache(true);

  manager.close();
  manager.destroyCache(TEST_CACHE_ALIAS);

  assertThat(rootDirectory, not(isLocked()));
  assertThat(rootDirectory, not(containsCacheDirectory(TEST_CACHE_ALIAS)));
}
 
Example 4
Source File: PersistentCacheManagerTest.java    From ehcache3 with Apache License 2.0 5 votes vote down vote up
@Test
public void testDestroyCache_CacheManagerUninitialized() throws CachePersistenceException {
  PersistentCacheManager manager = buildCacheManagerWithCache(false);

  manager.destroyCache(TEST_CACHE_ALIAS);

  assertThat(rootDirectory, not(isLocked()));
  assertThat(rootDirectory, not(containsCacheDirectory(TEST_CACHE_ALIAS)));
}
 
Example 5
Source File: ClusteredCacheDestroyTest.java    From ehcache3 with Apache License 2.0 5 votes vote down vote up
@Test
public void testDestroyCacheWithCacheManagerStopped() throws CachePersistenceException {
  PersistentCacheManager persistentCacheManager = clusteredCacheManagerBuilder.build(true);
  persistentCacheManager.close();
  persistentCacheManager.destroyCache(CLUSTERED_CACHE);
  assertThat(persistentCacheManager.getStatus(), is(Status.UNINITIALIZED));
}
 
Example 6
Source File: ClusteredCacheDestroyTest.java    From ehcache3 with Apache License 2.0 5 votes vote down vote up
@Test
public void testDestroyNonExistentCacheWithCacheManagerStopped() throws CachePersistenceException {
  PersistentCacheManager persistentCacheManager = clusteredCacheManagerBuilder.build(true);
  persistentCacheManager.close();
  persistentCacheManager.destroyCache("this-is-not-the-cache-you-are-looking-for");
  assertThat(persistentCacheManager.getStatus(), is(Status.UNINITIALIZED));
}
 
Example 7
Source File: ClusteredCacheDestroyTest.java    From ehcache3 with Apache License 2.0 5 votes vote down vote up
@Test
public void testDestroyCacheOnNonExistentCacheManager() throws CachePersistenceException {
  PersistentCacheManager persistentCacheManager = clusteredCacheManagerBuilder.build(true);
  persistentCacheManager.close();
  persistentCacheManager.destroy();

  persistentCacheManager.destroyCache("this-is-not-the-cache-you-are-looking-for");
  assertThat(persistentCacheManager.getStatus(), is(Status.UNINITIALIZED));
}
 
Example 8
Source File: ClusteredCacheDestroyTest.java    From ehcache3 with Apache License 2.0 5 votes vote down vote up
@Test
public void testDestroyCacheWithTwoCacheManagerOnSameCache_secondDoesntHaveTheCacheButPreventExclusiveAccessToCluster() throws CachePersistenceException {
  PersistentCacheManager persistentCacheManager1 = clusteredCacheManagerBuilder.build(false);
  try (PersistentCacheManager persistentCacheManager2 = clusteredCacheManagerBuilder.build(true)) {
    persistentCacheManager2.removeCache(CLUSTERED_CACHE);
    persistentCacheManager1.destroyCache(CLUSTERED_CACHE);
  }
}
 
Example 9
Source File: PersistentCacheManagerTest.java    From ehcache3 with Apache License 2.0 4 votes vote down vote up
@Test
public void testDestroyCache_UnexistingCacheDoesNothing() throws CachePersistenceException {
  PersistentCacheManager manager = builder.build(true);
  manager.destroyCache(TEST_CACHE_ALIAS);
}
 
Example 10
Source File: CacheManagerDestroyRemovesPersistenceTest.java    From ehcache3 with Apache License 2.0 4 votes vote down vote up
@Test
public void testDestroyCacheWithUnknownAlias() throws Exception {
  File file = new File(getStoragePath(), "testDestroyUnknownAlias");
  initCacheManager(file);

  Cache<Long, String > cache = persistentCacheManager.getCache(PERSISTENT_CACHE, Long.class, String.class);

  cache.put(1L, "One");

  persistentCacheManager.close();

  PersistentCacheManager anotherPersistentCacheManager = CacheManagerBuilder.newCacheManagerBuilder()
      .with(new CacheManagerPersistenceConfiguration(file)).build(true);

  anotherPersistentCacheManager.destroyCache(PERSISTENT_CACHE);

  assertThat(file, not(containsCacheDirectory(PERSISTENT_CACHE)));
}