Skip to content

Commit 754e428

Browse files
authored
Fix CaffeineCacheMetricsTest.doNotReportMetricsForNonLoadingCache() (#6137)
Signed-off-by: Johnny Lim <[email protected]>
1 parent 50cd4ae commit 754e428

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

micrometer-core/src/test/java/io/micrometer/core/instrument/binder/cache/CaffeineCacheMetricsTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,16 @@ void constructInstanceViaStaticMethodMonitor() {
9292
}
9393

9494
@Test
95-
void doNotReportMetricsForNonLoadingCache() {
95+
void doNotReportMetricsForNonLoadingCache(CapturedOutput output) {
9696
MeterRegistry meterRegistry = new SimpleMeterRegistry();
97-
Cache<Object, Object> cache = Caffeine.newBuilder().build();
97+
Cache<Object, Object> cache = Caffeine.newBuilder().recordStats().build();
9898
CaffeineCacheMetrics<Object, Object, Cache<Object, Object>> metrics = new CaffeineCacheMetrics<>(cache,
9999
"testCache", expectedTag);
100100
metrics.bindTo(meterRegistry);
101101

102102
assertThat(meterRegistry.find("cache.load.duration").timeGauge()).isNull();
103+
assertThat(output).doesNotContain(
104+
"The cache 'testCache' is not recording statistics. No meters except 'cache.size' will be registered. Call 'Caffeine#recordStats()' prior to building the cache for metrics to be recorded.");
103105
}
104106

105107
@Test

0 commit comments

Comments
 (0)