|
|
|
@ -25,6 +25,7 @@ import org.springframework.boot.autoconfigure.AutoConfigurations;
|
|
|
|
|
import org.springframework.boot.test.context.FilteredClassLoader;
|
|
|
|
|
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
|
|
|
|
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
|
|
|
|
|
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
|
|
|
|
|
import org.springframework.boot.web.client.RestTemplateBuilder;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
@ -46,6 +47,9 @@ class ZipkinConfigurationsSenderConfigurationTests {
|
|
|
|
|
private final ReactiveWebApplicationContextRunner reactiveContextRunner = new ReactiveWebApplicationContextRunner()
|
|
|
|
|
.withConfiguration(AutoConfigurations.of(SenderConfiguration.class));
|
|
|
|
|
|
|
|
|
|
private final WebApplicationContextRunner servletContextRunner = new WebApplicationContextRunner()
|
|
|
|
|
.withConfiguration(AutoConfigurations.of(SenderConfiguration.class));
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void shouldSupplyBeans() {
|
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
@ -56,8 +60,8 @@ class ZipkinConfigurationsSenderConfigurationTests {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void shouldUseWebClientSenderIfWebApplicationIsReactive() {
|
|
|
|
|
this.reactiveContextRunner.withUserConfiguration(WebClientConfiguration.class)
|
|
|
|
|
void shouldPreferWebClientSenderIfWebApplicationIsReactiveAndUrlSenderIsNotAvailable() {
|
|
|
|
|
this.reactiveContextRunner.withUserConfiguration(RestTemplateConfiguration.class, WebClientConfiguration.class)
|
|
|
|
|
.withClassLoader(new FilteredClassLoader("zipkin2.reporter.urlconnection")).run((context) -> {
|
|
|
|
|
assertThat(context).doesNotHaveBean(URLConnectionSender.class);
|
|
|
|
|
assertThat(context).hasSingleBean(Sender.class);
|
|
|
|
@ -66,16 +70,27 @@ class ZipkinConfigurationsSenderConfigurationTests {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void shouldNotUseWebClientSenderIfNoBuilderIsAvailable() {
|
|
|
|
|
this.reactiveContextRunner.run((context) -> {
|
|
|
|
|
assertThat(context).doesNotHaveBean(ZipkinWebClientSender.class);
|
|
|
|
|
void shouldPreferWebClientSenderIfWebApplicationIsServletAndUrlSenderIsNotAvailable() {
|
|
|
|
|
this.servletContextRunner.withUserConfiguration(RestTemplateConfiguration.class, WebClientConfiguration.class)
|
|
|
|
|
.withClassLoader(new FilteredClassLoader("zipkin2.reporter.urlconnection")).run((context) -> {
|
|
|
|
|
assertThat(context).doesNotHaveBean(URLConnectionSender.class);
|
|
|
|
|
assertThat(context).hasSingleBean(Sender.class);
|
|
|
|
|
assertThat(context).hasSingleBean(URLConnectionSender.class);
|
|
|
|
|
assertThat(context).hasSingleBean(ZipkinWebClientSender.class);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void shouldUseRestTemplateSenderIfUrlConnectionSenderIsNotAvailableAndWebAppIsNotReactive() {
|
|
|
|
|
void shouldPreferWebClientInNonWebApplicationAndUrlConnectionSenderIsNotAvailable() {
|
|
|
|
|
this.contextRunner.withUserConfiguration(RestTemplateConfiguration.class, WebClientConfiguration.class)
|
|
|
|
|
.withClassLoader(new FilteredClassLoader("zipkin2.reporter.urlconnection")).run((context) -> {
|
|
|
|
|
assertThat(context).doesNotHaveBean(URLConnectionSender.class);
|
|
|
|
|
assertThat(context).hasSingleBean(Sender.class);
|
|
|
|
|
assertThat(context).hasSingleBean(ZipkinWebClientSender.class);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void willUseRestTemplateInNonWebApplicationIfUrlConnectionSenderIsNotAvailable() {
|
|
|
|
|
this.contextRunner.withUserConfiguration(RestTemplateConfiguration.class)
|
|
|
|
|
.withClassLoader(new FilteredClassLoader("zipkin2.reporter.urlconnection")).run((context) -> {
|
|
|
|
|
assertThat(context).doesNotHaveBean(URLConnectionSender.class);
|
|
|
|
@ -84,6 +99,35 @@ class ZipkinConfigurationsSenderConfigurationTests {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void willUseRestTemplateInServletWebApplicationIfUrlConnectionSenderIsNotAvailable() {
|
|
|
|
|
this.servletContextRunner.withUserConfiguration(RestTemplateConfiguration.class)
|
|
|
|
|
.withClassLoader(new FilteredClassLoader("zipkin2.reporter.urlconnection")).run((context) -> {
|
|
|
|
|
assertThat(context).doesNotHaveBean(URLConnectionSender.class);
|
|
|
|
|
assertThat(context).hasSingleBean(Sender.class);
|
|
|
|
|
assertThat(context).hasSingleBean(ZipkinRestTemplateSender.class);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void willUseRestTemplateInReactiveWebApplicationIfUrlConnectionSenderIsNotAvailable() {
|
|
|
|
|
this.reactiveContextRunner.withUserConfiguration(RestTemplateConfiguration.class)
|
|
|
|
|
.withClassLoader(new FilteredClassLoader("zipkin2.reporter.urlconnection")).run((context) -> {
|
|
|
|
|
assertThat(context).doesNotHaveBean(URLConnectionSender.class);
|
|
|
|
|
assertThat(context).hasSingleBean(Sender.class);
|
|
|
|
|
assertThat(context).hasSingleBean(ZipkinRestTemplateSender.class);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void shouldNotUseWebClientSenderIfNoBuilderIsAvailable() {
|
|
|
|
|
this.reactiveContextRunner.run((context) -> {
|
|
|
|
|
assertThat(context).doesNotHaveBean(ZipkinWebClientSender.class);
|
|
|
|
|
assertThat(context).hasSingleBean(Sender.class);
|
|
|
|
|
assertThat(context).hasSingleBean(URLConnectionSender.class);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void shouldBackOffOnCustomBeans() {
|
|
|
|
|
this.contextRunner.withUserConfiguration(CustomConfiguration.class).run((context) -> {
|
|
|
|
|