@Test public void jmsHealthIndicator() { EnvironmentTestUtils.addEnvironment(this.context, "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(JmsHealthIndicator.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); }
private AnnotationConfigApplicationContext doLoad(Class<?>[] configs, String... environment) { AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(); applicationContext.register(configs); applicationContext.register(ActiveMQAutoConfiguration.class, JmsAutoConfiguration.class); EnvironmentTestUtils.addEnvironment(applicationContext, environment); applicationContext.refresh(); return applicationContext; }
@Test public void jmsHealthIndicator() { EnvironmentTestUtils.addEnvironment(this.context, "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(JmsHealthIndicator.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()); }