@Test public void overrideRabbitMQQueue() throws Exception { context = new AnnotationConfigApplicationContext(); addEnvironment(context, "spring.zipkin.rabbitmq.queue:zipkin2"); context.register( PropertyPlaceholderAutoConfiguration.class, TraceMetricsAutoConfiguration.class, RabbitAutoConfiguration.class, ZipkinAutoConfiguration.class); context.refresh(); SpanReporter spanReporter = context.getBean(SpanReporter.class); assertThat(spanReporter).extracting("reporter.sender.queue") .contains("zipkin2"); context.close(); }
@Test public void canOverrideBySender() throws Exception { context = new AnnotationConfigApplicationContext(); addEnvironment(context, "spring.zipkin.sender.type:web"); context.register( PropertyPlaceholderAutoConfiguration.class, TraceMetricsAutoConfiguration.class, RabbitAutoConfiguration.class, KafkaAutoConfiguration.class, ZipkinAutoConfiguration.class); context.refresh(); SpanReporter spanReporter = context.getBean(SpanReporter.class); assertThat(spanReporter).extracting("reporter.sender").allSatisfy( s -> assertThat(s.getClass().getSimpleName()).isEqualTo("RestTemplateSender") ); context.close(); }
@Test public void rabbitWinsWhenKafkaPresent() throws Exception { context = new AnnotationConfigApplicationContext(); context.register( PropertyPlaceholderAutoConfiguration.class, TraceMetricsAutoConfiguration.class, RabbitAutoConfiguration.class, KafkaAutoConfiguration.class, ZipkinAutoConfiguration.class); context.refresh(); SpanReporter spanReporter = context.getBean(SpanReporter.class); assertThat(spanReporter).extracting("reporter.sender") .allSatisfy(s -> assertThat(s).isInstanceOf(RabbitMQSender.class)); context.close(); }
@Test public void rabbitHealthIndicator() { this.context.register(RabbitAutoConfiguration.class, ManagementServerProperties.class, HealthIndicatorAutoConfiguration.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(RabbitHealthIndicator.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 indicatorExists() { this.context = new AnnotationConfigApplicationContext( PropertyPlaceholderAutoConfiguration.class, RabbitAutoConfiguration.class, EndpointAutoConfiguration.class, HealthIndicatorAutoConfiguration.class); assertThat(this.context.getBeanNamesForType(RabbitAdmin.class).length) .isEqualTo(1); RabbitHealthIndicator healthIndicator = this.context .getBean(RabbitHealthIndicator.class); assertThat(healthIndicator).isNotNull(); }
@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 indicatorExists() { this.context = new AnnotationConfigApplicationContext( PropertyPlaceholderAutoConfiguration.class, RabbitAutoConfiguration.class, EndpointAutoConfiguration.class, HealthIndicatorAutoConfiguration.class); assertEquals(1, this.context.getBeanNamesForType(RabbitAdmin.class).length); RabbitHealthIndicator healthIndicator = this.context .getBean(RabbitHealthIndicator.class); assertNotNull(healthIndicator); }
@Test public void rabbitHealthIndicator() { this.context.register(RabbitAutoConfiguration.class, ManagementServerProperties.class, HealthIndicatorAutoConfiguration.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(RabbitHealthIndicator.class, beans.values().iterator().next().getClass()); }