### Question:
AbstractCacheManager implements CacheManager { @Override public <K, V, C extends Configuration<K, V>> Cache<K, V> createCache( String cacheName, C configuration ) { Preconditions.checkState( !closed.get(), "Cache manager is closed" ); Cache<K, V> cache = null; try { cache = newCache( cacheName, configuration ); if ( managedCacheMap.putIfAbsent( cacheName, cache ) == null ) { return cache; } else { throw new CacheException( "Cache already exists: " + cacheName ); } } catch ( Throwable t ) { if ( cache != null ) { cache.close(); } throw Throwables.propagate( t ); } } AbstractCacheManager(); @Override CachingProvider getCachingProvider(); @Override Cache<K, V> createCache( String cacheName, C configuration ); @Override URI getURI(); @Override ClassLoader getClassLoader(); @Override Properties getProperties(); @Override Cache<K, V> getCache( String cacheName ); @Override Cache<K, V> getCache( String cacheName, Class<K> keyType, Class<V> valueType ); @Override Iterable<String> getCacheNames(); @Override void destroyCache( String cacheName ); @Override void enableManagement( String cacheName, boolean enabled ); @Override void enableStatistics( String cacheName, boolean enabled ); @Override void close(); @Override boolean isClosed(); @Override T unwrap( Class<T> clazz );  }### Answer:
@Test public void testCreateCache() throws Exception { MutableConfiguration<String, Map> configuration = new MutableConfiguration<String, Map>(); configuration.setTypes( String.class, Map.class ); Cache<String, Map> cache = cacheManager.createCache( CACHE_NAME, configuration ); assertThat( cache.getConfiguration( Configuration.class ), sameInstance( (Configuration) configuration ) ); assertThat( cache.getName(), is( CACHE_NAME ) ); assertThat( mockCaches, hasSize( 1 ) ); try { cacheManager.createCache( CACHE_NAME, configuration ); fail( "Exception should have been thrown" ); } catch ( Throwable t ) { assertThat( t, instanceOf( CacheException.class ) ); } assertThat( mockCaches, hasSize( 2 ) ); verify( mockCaches.get( 1 ) ).close(); }