|
|
|
@ -21,6 +21,7 @@ import java.net.http.HttpClient; |
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
import zipkin2.reporter.BytesMessageSender; |
|
|
|
import zipkin2.reporter.BytesMessageSender; |
|
|
|
import zipkin2.reporter.HttpEndpointSupplier; |
|
|
|
import zipkin2.reporter.HttpEndpointSupplier; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.actuate.autoconfigure.tracing.zipkin.ZipkinConfigurations.HttpClientSenderConfiguration; |
|
|
|
import org.springframework.boot.actuate.autoconfigure.tracing.zipkin.ZipkinConfigurations.HttpClientSenderConfiguration; |
|
|
|
import org.springframework.boot.actuate.autoconfigure.tracing.zipkin.ZipkinConfigurations.SenderConfiguration; |
|
|
|
import org.springframework.boot.actuate.autoconfigure.tracing.zipkin.ZipkinConfigurations.SenderConfiguration; |
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigurations; |
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigurations; |
|
|
|
@ -38,11 +39,10 @@ import static org.mockito.Mockito.mock; |
|
|
|
* @author Moritz Halbritter |
|
|
|
* @author Moritz Halbritter |
|
|
|
* @author Wick Dynex |
|
|
|
* @author Wick Dynex |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@SuppressWarnings({ "deprecation", "removal" }) |
|
|
|
|
|
|
|
class ZipkinConfigurationsSenderConfigurationTests { |
|
|
|
class ZipkinConfigurationsSenderConfigurationTests { |
|
|
|
|
|
|
|
|
|
|
|
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() |
|
|
|
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() |
|
|
|
.withConfiguration(AutoConfigurations.of(DefaultEncodingConfiguration.class, SenderConfiguration.class)); |
|
|
|
.withConfiguration(AutoConfigurations.of(DefaultEncodingConfiguration.class, SenderConfiguration.class)); |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void shouldSupplyDefaultHttpClientSenderBean() { |
|
|
|
void shouldSupplyDefaultHttpClientSenderBean() { |
|
|
|
@ -55,10 +55,8 @@ class ZipkinConfigurationsSenderConfigurationTests { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void shouldNotProvideHttpClientSenderIfHttpClientIsNotAvailable() { |
|
|
|
void shouldNotProvideHttpClientSenderIfHttpClientIsNotAvailable() { |
|
|
|
this.contextRunner.withUserConfiguration(HttpClientSenderConfiguration.class) |
|
|
|
this.contextRunner.withUserConfiguration(HttpClientSenderConfiguration.class) |
|
|
|
.withClassLoader(new FilteredClassLoader(HttpClient.class)) |
|
|
|
.withClassLoader(new FilteredClassLoader(HttpClient.class)) |
|
|
|
.run((context) -> { |
|
|
|
.run((context) -> assertThat(context).doesNotHaveBean(ZipkinHttpClientSender.class)); |
|
|
|
assertThat(context).doesNotHaveBean(ZipkinHttpClientSender.class); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
@ -72,15 +70,15 @@ class ZipkinConfigurationsSenderConfigurationTests { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void shouldUseCustomHttpEndpointSupplierFactory() { |
|
|
|
void shouldUseCustomHttpEndpointSupplierFactory() { |
|
|
|
this.contextRunner.withUserConfiguration(CustomHttpEndpointSupplierFactoryConfiguration.class) |
|
|
|
this.contextRunner.withUserConfiguration(CustomHttpEndpointSupplierFactoryConfiguration.class) |
|
|
|
.run((context) -> { |
|
|
|
.run((context) -> { |
|
|
|
ZipkinHttpClientSender httpClientSender = context.getBean(ZipkinHttpClientSender.class); |
|
|
|
ZipkinHttpClientSender httpClientSender = context.getBean(ZipkinHttpClientSender.class); |
|
|
|
assertThat(httpClientSender).extracting("endpointSupplier") |
|
|
|
assertThat(httpClientSender).extracting("endpointSupplier") |
|
|
|
.isInstanceOf(CustomHttpEndpointSupplier.class); |
|
|
|
.isInstanceOf(CustomHttpEndpointSupplier.class); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false) |
|
|
|
@Configuration(proxyBeanMethods = false) |
|
|
|
private static final class CustomConfiguration { |
|
|
|
static class CustomConfiguration { |
|
|
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
BytesMessageSender customSender() { |
|
|
|
BytesMessageSender customSender() { |
|
|
|
@ -90,7 +88,7 @@ class ZipkinConfigurationsSenderConfigurationTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false) |
|
|
|
@Configuration(proxyBeanMethods = false) |
|
|
|
private static final class CustomHttpEndpointSupplierFactoryConfiguration { |
|
|
|
static class CustomHttpEndpointSupplierFactoryConfiguration { |
|
|
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
HttpEndpointSupplier.Factory httpEndpointSupplier() { |
|
|
|
HttpEndpointSupplier.Factory httpEndpointSupplier() { |
|
|
|
@ -99,7 +97,7 @@ class ZipkinConfigurationsSenderConfigurationTests { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static final class CustomHttpEndpointSupplierFactory implements HttpEndpointSupplier.Factory { |
|
|
|
static class CustomHttpEndpointSupplierFactory implements HttpEndpointSupplier.Factory { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public HttpEndpointSupplier create(String endpoint) { |
|
|
|
public HttpEndpointSupplier create(String endpoint) { |
|
|
|
@ -108,7 +106,13 @@ class ZipkinConfigurationsSenderConfigurationTests { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private record CustomHttpEndpointSupplier(String endpoint) implements HttpEndpointSupplier { |
|
|
|
static class CustomHttpEndpointSupplier implements HttpEndpointSupplier { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final String endpoint; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CustomHttpEndpointSupplier(String endpoint) { |
|
|
|
|
|
|
|
this.endpoint = endpoint; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public String get() { |
|
|
|
public String get() { |
|
|
|
@ -118,6 +122,7 @@ class ZipkinConfigurationsSenderConfigurationTests { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void close() { |
|
|
|
public void close() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|