|
| 1 | +/* |
| 2 | + * Copyright 2012-2022 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.springframework.boot.actuate.autoconfigure.tracing.zipkin; |
| 18 | + |
| 19 | +import org.junit.jupiter.api.Test; |
| 20 | +import zipkin2.reporter.urlconnection.URLConnectionSender; |
| 21 | + |
| 22 | +import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration; |
| 23 | +import org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration; |
| 24 | +import org.springframework.boot.actuate.autoconfigure.metrics.web.client.HttpClientMetricsAutoConfiguration; |
| 25 | +import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration; |
| 26 | +import org.springframework.boot.actuate.autoconfigure.tracing.BraveAutoConfiguration; |
| 27 | +import org.springframework.boot.actuate.autoconfigure.tracing.MicrometerTracingAutoConfiguration; |
| 28 | +import org.springframework.boot.autoconfigure.AutoConfigurations; |
| 29 | +import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration; |
| 30 | +import org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAutoConfiguration; |
| 31 | +import org.springframework.boot.test.context.FilteredClassLoader; |
| 32 | +import org.springframework.boot.test.context.assertj.ApplicationContextAssertProvider; |
| 33 | +import org.springframework.boot.test.context.runner.AbstractApplicationContextRunner; |
| 34 | +import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner; |
| 35 | +import org.springframework.boot.test.context.runner.WebApplicationContextRunner; |
| 36 | +import org.springframework.context.ConfigurableApplicationContext; |
| 37 | + |
| 38 | +import static org.assertj.core.api.Assertions.assertThat; |
| 39 | + |
| 40 | +/** |
| 41 | + * Integration tests for {@link ZipkinAutoConfiguration} and other related |
| 42 | + * auto-configurations. |
| 43 | + * |
| 44 | + * @author Andy Wilkinson |
| 45 | + */ |
| 46 | +class ZipkinAutoConfigurationIntegrationTests { |
| 47 | + |
| 48 | + @Test |
| 49 | + void zipkinsUseOfRestTemplateDoesNotCauseACycle() { |
| 50 | + configure(new WebApplicationContextRunner()) |
| 51 | + .withConfiguration(AutoConfigurations.of(RestTemplateAutoConfiguration.class)) |
| 52 | + .run((context) -> assertThat(context).hasNotFailed()); |
| 53 | + } |
| 54 | + |
| 55 | + @Test |
| 56 | + void zipkinsUseOfWebClientDoesNotCauseACycle() { |
| 57 | + configure(new ReactiveWebApplicationContextRunner()) |
| 58 | + .withConfiguration(AutoConfigurations.of(WebClientAutoConfiguration.class)) |
| 59 | + .run((context) -> assertThat(context).hasNotFailed()); |
| 60 | + } |
| 61 | + |
| 62 | + <SELF extends AbstractApplicationContextRunner<SELF, C, A>, C extends ConfigurableApplicationContext, A extends ApplicationContextAssertProvider<C>> AbstractApplicationContextRunner<SELF, C, A> configure( |
| 63 | + AbstractApplicationContextRunner<SELF, ?, ?> runner) { |
| 64 | + return runner |
| 65 | + .withConfiguration(AutoConfigurations.of(MicrometerTracingAutoConfiguration.class, |
| 66 | + ObservationAutoConfiguration.class, BraveAutoConfiguration.class, ZipkinAutoConfiguration.class, |
| 67 | + HttpClientMetricsAutoConfiguration.class, MetricsAutoConfiguration.class, |
| 68 | + SimpleMetricsExportAutoConfiguration.class)) |
| 69 | + .withClassLoader(new FilteredClassLoader(URLConnectionSender.class)); |
| 70 | + } |
| 71 | + |
| 72 | +} |
0 commit comments