SSMCacheManager implements CacheManager, InitializingBean { @Override public SSMCache getCache(final String name) { SSMCache cache = (SSMCache) this.cacheMap.get(name); if (cache == null) { return null; } if (cache.getCache().getProperties().isUseNameAsKeyPrefix()) { return new SSMCache(new PrefixedCacheImpl(cache.getCache(), name, cache.getCache().getProperties().getKeyPrefixSeparator()), cache.getExpiration(), cache.isAllowClear(), cache.isRegisterAliases(), cache.isMuteExceptions()); } return cache; }  @Override void afterPropertiesSet(); @Override Collection<String> getCacheNames(); @Override SSMCache getCache(final String name); void addCache(final SSMCache cache); void removeCache(final String nameOrAlias); void setCaches(Collection<SSMCache> caches);  }
@Test public void getCache() { org.springframework.cache.Cache cache = ssmCacheManager.getCache("cache1"); assertNotNull(cache); assertSame(cache1, cache.getNativeCache()); cache = ssmCacheManager.getCache("cache2"); assertNotNull(cache); assertSame(cache2, cache.getNativeCache()); cache = ssmCacheManager.getCache("cache3"); assertNotNull(cache); assertNotSame(cache3, cache.getNativeCache()); assertTrue(cache.getNativeCache() instanceof PrefixedCacheImpl); cache = ssmCacheManager.getCache("cache3Alias1"); assertNotNull(cache); assertNotSame(cache3, cache.getNativeCache()); assertTrue(cache.getNativeCache() instanceof PrefixedCacheImpl); cache = ssmCacheManager.getCache("cache3Alias2"); assertNotNull(cache); assertNotSame(cache3, cache.getNativeCache()); assertTrue(cache.getNativeCache() instanceof PrefixedCacheImpl); }