@Test public final void getCacheShouldReturnDifferentInstancesForDifferentNames() { withCacheManager(new CacheManagerCallable(TestCacheManagerFactory.createCacheManager()) { @Override public void call() { cm.defineConfiguration("thisCache", new ConfigurationBuilder().build()); cm.defineConfiguration("thatCache", new ConfigurationBuilder().build()); final SpringEmbeddedCacheManager objectUnderTest = new SpringEmbeddedCacheManager(cm); final String firstCacheName = "thisCache"; final String secondCacheName = "thatCache"; final SpringCache firstObtainedSpringCache = objectUnderTest.getCache(firstCacheName); final SpringCache secondObtainedSpringCache = objectUnderTest.getCache(secondCacheName); assertNotSame( "getCache() should have returned different SpringCache instances for different names", firstObtainedSpringCache, secondObtainedSpringCache); } }); }
@Override public SpringCache getCache(final String name) { return springCaches.computeIfAbsent(name, n -> { final Cache<Object, Object> nativeCache = this.nativeCacheManager.getCache(n); return new SpringCache(nativeCache); }); }
SpringEmbeddedCacheManager implements CacheManager { @Override public SpringCache getCache(final String name) { return springCaches.computeIfAbsent(name, n -> { final Cache<Object, Object> nativeCache = this.nativeCacheManager.getCache(n); return new SpringCache(nativeCache); }); } }
SpringEmbeddedCacheManager implements CacheManager { @Override public SpringCache getCache(final String name) { return springCaches.computeIfAbsent(name, n -> { final Cache<Object, Object> nativeCache = this.nativeCacheManager.getCache(n); return new SpringCache(nativeCache); }); } SpringEmbeddedCacheManager(final EmbeddedCacheManager nativeCacheManager); }
SpringEmbeddedCacheManager implements CacheManager { @Override public SpringCache getCache(final String name) { return springCaches.computeIfAbsent(name, n -> { final Cache<Object, Object> nativeCache = this.nativeCacheManager.getCache(n); return new SpringCache(nativeCache); }); } SpringEmbeddedCacheManager(final EmbeddedCacheManager nativeCacheManager); @Override SpringCache getCache(final String name); @Override Collection<String> getCacheNames(); EmbeddedCacheManager getNativeCacheManager(); void stop(); }
SpringEmbeddedCacheManager implements CacheManager { @Override public SpringCache getCache(final String name) { return springCaches.computeIfAbsent(name, n -> { final Cache<Object, Object> nativeCache = this.nativeCacheManager.getCache(n); return new SpringCache(nativeCache); }); } SpringEmbeddedCacheManager(final EmbeddedCacheManager nativeCacheManager); @Override SpringCache getCache(final String name); @Override Collection<String> getCacheNames(); EmbeddedCacheManager getNativeCacheManager(); void stop();  }