Polish "Auto-configure JVM heap pressure metrics"

See gh-27868
pull/27660/head
Stephane Nicoll 3 years ago
parent ba21c90355
commit 39a1c854d8

@ -55,6 +55,12 @@ class JvmMetricsAutoConfigurationTests {
.run(assertMetricsBeans().andThen((context) -> assertThat(context).hasBean("customJvmGcMetrics")));
}
@Test
void allowsCustomJvmHeapPressureMetricsToBeUsed() {
this.contextRunner.withUserConfiguration(CustomJvmHeapPressureMetricsConfiguration.class).run(
assertMetricsBeans().andThen((context) -> assertThat(context).hasBean("customJvmHeapPressureMetrics")));
}
@Test
void allowsCustomJvmMemoryMetricsToBeUsed() {
this.contextRunner.withUserConfiguration(CustomJvmMemoryMetricsConfiguration.class)
@ -74,9 +80,9 @@ class JvmMetricsAutoConfigurationTests {
}
private ContextConsumer<AssertableApplicationContext> assertMetricsBeans() {
return (context) -> assertThat(context).hasSingleBean(JvmGcMetrics.class).hasSingleBean(JvmMemoryMetrics.class)
.hasSingleBean(JvmHeapPressureMetrics.class).hasSingleBean(JvmThreadMetrics.class)
.hasSingleBean(ClassLoaderMetrics.class);
return (context) -> assertThat(context).hasSingleBean(JvmGcMetrics.class)
.hasSingleBean(JvmHeapPressureMetrics.class).hasSingleBean(JvmMemoryMetrics.class)
.hasSingleBean(JvmThreadMetrics.class).hasSingleBean(ClassLoaderMetrics.class);
}
@Configuration(proxyBeanMethods = false)
@ -89,6 +95,16 @@ class JvmMetricsAutoConfigurationTests {
}
@Configuration(proxyBeanMethods = false)
static class CustomJvmHeapPressureMetricsConfiguration {
@Bean
JvmHeapPressureMetrics customJvmHeapPressureMetrics() {
return new JvmHeapPressureMetrics();
}
}
@Configuration(proxyBeanMethods = false)
static class CustomJvmMemoryMetricsConfiguration {

Loading…
Cancel
Save