### Question:
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();  }### Answer:
@Test public final void getCacheShouldReturnSameInstanceForSameName() { withCacheManager(new CacheManagerCallable(TestCacheManagerFactory.createCacheManager()) { @Override public void call() { cm.defineConfiguration("same", new ConfigurationBuilder().build()); final SpringEmbeddedCacheManager objectUnderTest = new SpringEmbeddedCacheManager(cm); final String sameCacheName = "same"; final SpringCache firstObtainedSpringCache = objectUnderTest.getCache(sameCacheName); final SpringCache secondObtainedSpringCache = objectUnderTest.getCache(sameCacheName); assertSame( "getCache() should have returned the same SpringCache instance for the same name", firstObtainedSpringCache, secondObtainedSpringCache); } }); }
@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); } }); }