Skip to content

Commit 586e3c8

Browse files
committed
Add zipkin auto-configuration tests
See spring-projectsgh-30156
1 parent af85c3d commit 586e3c8

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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;
18+
19+
import io.opentelemetry.exporter.zipkin.ZipkinSpanExporter;
20+
import org.junit.jupiter.api.Test;
21+
import zipkin2.reporter.Sender;
22+
import zipkin2.reporter.brave.ZipkinSpanHandler;
23+
24+
import org.springframework.boot.autoconfigure.AutoConfigurations;
25+
import org.springframework.boot.test.context.FilteredClassLoader;
26+
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
27+
28+
import static org.assertj.core.api.Assertions.assertThat;
29+
30+
/**
31+
* Tests for {@link ZipkinAutoConfiguration}.
32+
*
33+
* @author Moritz Halbritter
34+
*/
35+
class ZipkinAutoConfigurationTests {
36+
37+
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
38+
.withConfiguration(AutoConfigurations.of(ZipkinAutoConfiguration.class));
39+
40+
@Test
41+
void shouldNotFailIfZipkinIsMissing() {
42+
this.contextRunner.withClassLoader(new FilteredClassLoader("zipkin2"))
43+
.run((context) -> assertThat(context).doesNotHaveBean(Sender.class));
44+
}
45+
46+
@Test
47+
void shouldNotFailIfZipkinUrlConnectionIsMissing() {
48+
this.contextRunner.withClassLoader(new FilteredClassLoader("zipkin2.reporter.urlconnection"))
49+
.run((context) -> assertThat(context).doesNotHaveBean(Sender.class));
50+
}
51+
52+
@Test
53+
void shouldNotFailIfZipkinBraveIsMissing() {
54+
this.contextRunner.withClassLoader(new FilteredClassLoader("zipkin2.reporter.brave"))
55+
.run((context) -> assertThat(context).doesNotHaveBean(ZipkinSpanHandler.class));
56+
}
57+
58+
@Test
59+
void shouldNotFailIfZipkinOpenTelemetryIsMissing() {
60+
this.contextRunner.withClassLoader(new FilteredClassLoader("io.opentelemetry.exporter.zipkin"))
61+
.run((context) -> assertThat(context).doesNotHaveBean(ZipkinSpanExporter.class));
62+
}
63+
64+
}

0 commit comments

Comments
 (0)