@Test public void autoCacheManager() { load(CacheConfiguration.class); CachePublicMetrics bean = this.context.getBean(CachePublicMetrics.class); Collection<Metric<?>> metrics = bean.metrics(); assertMetrics(metrics, "cache.books.size", "cache.speakers.size"); }
@Test public void multipleCacheManagers() { load(MultipleCacheConfiguration.class); CachePublicMetrics bean = this.context.getBean(CachePublicMetrics.class); Collection<Metric<?>> metrics = bean.metrics(); assertMetrics(metrics, "cache.books.size", "cache.second_speakers.size", "cache.first_speakers.size", "cache.users.size"); }
@Bean @ConditionalOnMissingBean @ConditionalOnBean(CacheStatisticsProvider.class) public CachePublicMetrics cachePublicMetrics() { return new CachePublicMetrics(); }
@Test public void noCacheMetrics() { load(); assertThat(this.context.getBeansOfType(CachePublicMetrics.class)).isEmpty(); }
@Test public void noCacheMetrics() { load(); assertEquals(0, this.context.getBeansOfType(CachePublicMetrics.class).size()); }