@Bean DiskSpaceHealthIndicator diskSpaceHealthIndicator(@Value("${health.disk.threshold}") long threshold) { DiskSpaceHealthIndicatorProperties diskSpaceHealthIndicatorProperties = new DiskSpaceHealthIndicatorProperties(); diskSpaceHealthIndicatorProperties.setThreshold(threshold); return new DiskSpaceHealthIndicator(diskSpaceHealthIndicatorProperties); }
@Test public void defaultHealthIndicatorsDisabledButOne() { this.context.register(HealthIndicatorAutoConfiguration.class, ManagementServerProperties.class); EnvironmentTestUtils.addEnvironment(this.context, "management.health.defaults.enabled:false", "management.health.diskspace.enabled:true"); this.context.refresh(); Map<String, HealthIndicator> beans = this.context .getBeansOfType(HealthIndicator.class); assertThat(beans).hasSize(1); assertThat(beans.values().iterator().next().getClass()) .isEqualTo(DiskSpaceHealthIndicator.class); }
@Test public void diskSpaceHealthIndicator() { this.context.register(HealthIndicatorAutoConfiguration.class); this.context.refresh(); Map<String, HealthIndicator> beans = this.context .getBeansOfType(HealthIndicator.class); assertThat(beans).hasSize(1); assertThat(beans.values().iterator().next().getClass()) .isEqualTo(DiskSpaceHealthIndicator.class); }
@Test public void defaultHealthIndicatorsDisabledButOne() { this.context.register(HealthIndicatorAutoConfiguration.class, ManagementServerProperties.class); EnvironmentTestUtils.addEnvironment(this.context, "management.health.defaults.enabled:false", "management.health.diskspace.enabled:true"); this.context.refresh(); Map<String, HealthIndicator> beans = this.context .getBeansOfType(HealthIndicator.class); assertEquals(1, beans.size()); assertEquals(DiskSpaceHealthIndicator.class, beans.values().iterator().next().getClass()); }
@Test public void diskSpaceHealthIndicator() { this.context.register(HealthIndicatorAutoConfiguration.class); this.context.refresh(); Map<String, HealthIndicator> beans = this.context .getBeansOfType(HealthIndicator.class); assertEquals(1, beans.size()); assertEquals(DiskSpaceHealthIndicator.class, beans.values().iterator().next().getClass()); }
@Bean @ConditionalOnMissingBean(name = "diskSpaceHealthIndicator") public DiskSpaceHealthIndicator diskSpaceHealthIndicator( DiskSpaceHealthIndicatorProperties properties) { return new DiskSpaceHealthIndicator(properties); }