@Test public void notElasticsearchHealthIndicator() { EnvironmentTestUtils.addEnvironment(this.context, "management.health.elasticsearch.enabled:false", "spring.data.elasticsearch.properties.path.home:target", "management.health.diskspace.enabled:false"); this.context.register(JestClientConfiguration.class, JestAutoConfiguration.class, ElasticsearchAutoConfiguration.class, ManagementServerProperties.class, 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(ApplicationHealthIndicator.class); }
@Test public void notElasticSearchHealthIndicator() { EnvironmentTestUtils.addEnvironment(this.context, "management.health.elasticsearch.enabled:false", "spring.data.elasticsearch.properties.path.home:target", "management.health.diskspace.enabled:false"); this.context.register(ElasticsearchAutoConfiguration.class, ManagementServerProperties.class, 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(ApplicationHealthIndicator.class); }
@Test public void notElasticSearchHealthIndicator() { EnvironmentTestUtils.addEnvironment(this.context, "management.health.elasticsearch.enabled:false", "spring.data.elasticsearch.properties.path.data:target/data", "spring.data.elasticsearch.properties.path.logs:target/logs", "management.health.diskspace.enabled:false"); this.context.register(ElasticsearchAutoConfiguration.class, ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); this.context.refresh(); Map<String, HealthIndicator> beans = this.context .getBeansOfType(HealthIndicator.class); assertEquals(1, beans.size()); assertEquals(ApplicationHealthIndicator.class, beans.values().iterator().next().getClass()); }
@Test public void defaultHealthIndicator() { this.context.register(HealthIndicatorAutoConfiguration.class, ManagementServerProperties.class); EnvironmentTestUtils.addEnvironment(this.context, "management.health.diskspace.enabled:false"); this.context.refresh(); Map<String, HealthIndicator> beans = this.context .getBeansOfType(HealthIndicator.class); assertThat(beans).hasSize(1); assertThat(beans.values().iterator().next().getClass()) .isEqualTo(ApplicationHealthIndicator.class); }
@Test public void defaultHealthIndicatorsDisabled() { this.context.register(HealthIndicatorAutoConfiguration.class, ManagementServerProperties.class); EnvironmentTestUtils.addEnvironment(this.context, "management.health.defaults.enabled:false"); this.context.refresh(); Map<String, HealthIndicator> beans = this.context .getBeansOfType(HealthIndicator.class); assertThat(beans).hasSize(1); assertThat(beans.values().iterator().next().getClass()) .isEqualTo(ApplicationHealthIndicator.class); }
@Test public void notRedisHealthIndicator() { this.context.register(RedisAutoConfiguration.class, ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); EnvironmentTestUtils.addEnvironment(this.context, "management.health.redis.enabled:false", "management.health.diskspace.enabled:false"); this.context.refresh(); Map<String, HealthIndicator> beans = this.context .getBeansOfType(HealthIndicator.class); assertThat(beans).hasSize(1); assertThat(beans.values().iterator().next().getClass()) .isEqualTo(ApplicationHealthIndicator.class); }
@Test public void notMongoHealthIndicator() { this.context.register(MongoAutoConfiguration.class, ManagementServerProperties.class, MongoDataAutoConfiguration.class, HealthIndicatorAutoConfiguration.class); EnvironmentTestUtils.addEnvironment(this.context, "management.health.mongo.enabled:false", "management.health.diskspace.enabled:false"); this.context.refresh(); Map<String, HealthIndicator> beans = this.context .getBeansOfType(HealthIndicator.class); assertThat(beans).hasSize(1); assertThat(beans.values().iterator().next().getClass()) .isEqualTo(ApplicationHealthIndicator.class); }
@Test public void notDataSourceHealthIndicator() { this.context.register(EmbeddedDataSourceConfiguration.class, ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); EnvironmentTestUtils.addEnvironment(this.context, "management.health.db.enabled:false", "management.health.diskspace.enabled:false"); this.context.refresh(); Map<String, HealthIndicator> beans = this.context .getBeansOfType(HealthIndicator.class); assertThat(beans).hasSize(1); assertThat(beans.values().iterator().next().getClass()) .isEqualTo(ApplicationHealthIndicator.class); }
@Test public void notRabbitHealthIndicator() { this.context.register(RabbitAutoConfiguration.class, ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); EnvironmentTestUtils.addEnvironment(this.context, "management.health.rabbit.enabled:false", "management.health.diskspace.enabled:false"); this.context.refresh(); Map<String, HealthIndicator> beans = this.context .getBeansOfType(HealthIndicator.class); assertThat(beans).hasSize(1); assertThat(beans.values().iterator().next().getClass()) .isEqualTo(ApplicationHealthIndicator.class); }
@Test public void notSolrHealthIndicator() { this.context.register(SolrAutoConfiguration.class, ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); EnvironmentTestUtils.addEnvironment(this.context, "management.health.solr.enabled:false", "management.health.diskspace.enabled:false"); this.context.refresh(); Map<String, HealthIndicator> beans = this.context .getBeansOfType(HealthIndicator.class); assertThat(beans).hasSize(1); assertThat(beans.values().iterator().next().getClass()) .isEqualTo(ApplicationHealthIndicator.class); }
@Test public void notMailHealthIndicator() { EnvironmentTestUtils.addEnvironment(this.context, "spring.mail.host:smtp.acme.org", "management.health.mail.enabled:false", "management.health.diskspace.enabled:false"); this.context.register(MailSenderAutoConfiguration.class, ManagementServerProperties.class, 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(ApplicationHealthIndicator.class); }
@Test public void notJmsHealthIndicator() { EnvironmentTestUtils.addEnvironment(this.context, "management.health.jms.enabled:false", "management.health.diskspace.enabled:false"); this.context.register(ActiveMQAutoConfiguration.class, ManagementServerProperties.class, 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(ApplicationHealthIndicator.class); }
@Test public void defaultHealthIndicator() { this.context.register(HealthIndicatorAutoConfiguration.class, ManagementServerProperties.class); EnvironmentTestUtils.addEnvironment(this.context, "management.health.diskspace.enabled:false"); this.context.refresh(); Map<String, HealthIndicator> beans = this.context .getBeansOfType(HealthIndicator.class); assertEquals(1, beans.size()); assertEquals(ApplicationHealthIndicator.class, beans.values().iterator().next().getClass()); }
@Test public void defaultHealthIndicatorsDisabled() { this.context.register(HealthIndicatorAutoConfiguration.class, ManagementServerProperties.class); EnvironmentTestUtils.addEnvironment(this.context, "management.health.defaults.enabled:false"); this.context.refresh(); Map<String, HealthIndicator> beans = this.context .getBeansOfType(HealthIndicator.class); assertEquals(1, beans.size()); assertEquals(ApplicationHealthIndicator.class, beans.values().iterator().next().getClass()); }
@Test public void notRedisHealthIndicator() { this.context.register(RedisAutoConfiguration.class, ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); EnvironmentTestUtils.addEnvironment(this.context, "management.health.redis.enabled:false", "management.health.diskspace.enabled:false"); this.context.refresh(); Map<String, HealthIndicator> beans = this.context .getBeansOfType(HealthIndicator.class); assertEquals(1, beans.size()); assertEquals(ApplicationHealthIndicator.class, beans.values().iterator().next().getClass()); }
@Test public void notMongoHealthIndicator() { this.context.register(MongoAutoConfiguration.class, ManagementServerProperties.class, MongoDataAutoConfiguration.class, HealthIndicatorAutoConfiguration.class); EnvironmentTestUtils.addEnvironment(this.context, "management.health.mongo.enabled:false", "management.health.diskspace.enabled:false"); this.context.refresh(); Map<String, HealthIndicator> beans = this.context .getBeansOfType(HealthIndicator.class); assertEquals(1, beans.size()); assertEquals(ApplicationHealthIndicator.class, beans.values().iterator().next().getClass()); }
@Test public void notDataSourceHealthIndicator() { this.context.register(EmbeddedDataSourceConfiguration.class, ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); EnvironmentTestUtils.addEnvironment(this.context, "management.health.db.enabled:false", "management.health.diskspace.enabled:false"); this.context.refresh(); Map<String, HealthIndicator> beans = this.context .getBeansOfType(HealthIndicator.class); assertEquals(1, beans.size()); assertEquals(ApplicationHealthIndicator.class, beans.values().iterator().next().getClass()); }
@Test public void notRabbitHealthIndicator() { this.context.register(RabbitAutoConfiguration.class, ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); EnvironmentTestUtils.addEnvironment(this.context, "management.health.rabbit.enabled:false", "management.health.diskspace.enabled:false"); this.context.refresh(); Map<String, HealthIndicator> beans = this.context .getBeansOfType(HealthIndicator.class); assertEquals(1, beans.size()); assertEquals(ApplicationHealthIndicator.class, beans.values().iterator().next().getClass()); }
@Test public void notSolrHeathIndicator() { this.context.register(SolrAutoConfiguration.class, ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); EnvironmentTestUtils.addEnvironment(this.context, "management.health.solr.enabled:false", "management.health.diskspace.enabled:false"); this.context.refresh(); Map<String, HealthIndicator> beans = this.context .getBeansOfType(HealthIndicator.class); assertEquals(1, beans.size()); assertEquals(ApplicationHealthIndicator.class, beans.values().iterator().next().getClass()); }
@Test public void notMailHealthIndicator() { EnvironmentTestUtils.addEnvironment(this.context, "spring.mail.host:smtp.acme.org", "management.health.mail.enabled:false", "management.health.diskspace.enabled:false"); this.context.register(MailSenderAutoConfiguration.class, ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); this.context.refresh(); Map<String, HealthIndicator> beans = this.context .getBeansOfType(HealthIndicator.class); assertEquals(1, beans.size()); assertEquals(ApplicationHealthIndicator.class, beans.values().iterator().next().getClass()); }
@Test public void notJmsHealthIndicator() { EnvironmentTestUtils.addEnvironment(this.context, "management.health.jms.enabled:false", "management.health.diskspace.enabled:false"); this.context.register(ActiveMQAutoConfiguration.class, ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); this.context.refresh(); Map<String, HealthIndicator> beans = this.context .getBeansOfType(HealthIndicator.class); assertEquals(1, beans.size()); assertEquals(ApplicationHealthIndicator.class, beans.values().iterator().next().getClass()); }
@Bean @ConditionalOnMissingBean(HealthIndicator.class) public ApplicationHealthIndicator applicationHealthIndicator() { return new ApplicationHealthIndicator(); }
@Bean public HealthIndicator binderHealthIndicator() { return new ApplicationHealthIndicator(); }