1717package org .springframework .boot .actuate .autoconfigure .tracing .zipkin ;
1818
1919import java .io .IOException ;
20+ import java .net .http .HttpClient ;
2021import java .nio .charset .StandardCharsets ;
2122import java .util .List ;
2223import java .util .concurrent .TimeUnit ;
4041import org .springframework .boot .web .client .RestTemplateBuilder ;
4142import org .springframework .context .annotation .Bean ;
4243import org .springframework .context .annotation .Configuration ;
44+ import org .springframework .web .client .RestTemplate ;
4345import org .springframework .web .reactive .function .client .WebClient ;
4446
4547import static org .assertj .core .api .Assertions .assertThat ;
@@ -79,8 +81,7 @@ void shouldSupplyDefaultHttpClientSenderBeans() {
7981 @ Test
8082 void shouldUseUrlSenderIfHttpSenderIsNotAvailable () {
8183 this .contextRunner .withUserConfiguration (UrlConnectionSenderConfiguration .class )
82- .withClassLoader (new FilteredClassLoader ("java.net.http.HttpClient" , "org.springframework.web.client" ,
83- "org.springframework.web.reactive.function.client" ))
84+ .withClassLoader (new FilteredClassLoader (HttpClient .class , WebClient .class , RestTemplate .class ))
8485 .run ((context ) -> {
8586 assertThat (context ).doesNotHaveBean (ZipkinHttpClientSender .class );
8687 assertThat (context ).hasSingleBean (BytesMessageSender .class );
@@ -92,7 +93,7 @@ void shouldUseUrlSenderIfHttpSenderIsNotAvailable() {
9293 @ Test
9394 void shouldPreferWebClientSenderIfWebApplicationIsReactiveAndHttpClientSenderIsNotAvailable () {
9495 this .reactiveContextRunner .withUserConfiguration (RestTemplateConfiguration .class , WebClientConfiguration .class )
95- .withClassLoader (new FilteredClassLoader ("java.net.http. HttpClient" ))
96+ .withClassLoader (new FilteredClassLoader (HttpClient . class ))
9697 .run ((context ) -> {
9798 assertThat (context ).doesNotHaveBean (ZipkinHttpClientSender .class );
9899 assertThat (context ).hasSingleBean (BytesMessageSender .class );
@@ -106,7 +107,7 @@ void shouldPreferWebClientSenderIfWebApplicationIsReactiveAndHttpClientSenderIsN
106107 @ Test
107108 void shouldPreferWebClientSenderIfWebApplicationIsServletAndHttpClientSenderIsNotAvailable () {
108109 this .servletContextRunner .withUserConfiguration (RestTemplateConfiguration .class , WebClientConfiguration .class )
109- .withClassLoader (new FilteredClassLoader ("java.net.http. HttpClient" ))
110+ .withClassLoader (new FilteredClassLoader (HttpClient . class ))
110111 .run ((context ) -> {
111112 assertThat (context ).doesNotHaveBean (ZipkinHttpClientSender .class );
112113 assertThat (context ).hasSingleBean (BytesMessageSender .class );
@@ -118,7 +119,7 @@ void shouldPreferWebClientSenderIfWebApplicationIsServletAndHttpClientSenderIsNo
118119 @ Test
119120 void shouldPreferWebClientInNonWebApplicationAndHttpClientSenderIsNotAvailable () {
120121 this .contextRunner .withUserConfiguration (RestTemplateConfiguration .class , WebClientConfiguration .class )
121- .withClassLoader (new FilteredClassLoader ("java.net.http. HttpClient" ))
122+ .withClassLoader (new FilteredClassLoader (HttpClient . class ))
122123 .run ((context ) -> {
123124 assertThat (context ).doesNotHaveBean (ZipkinHttpClientSender .class );
124125 assertThat (context ).hasSingleBean (BytesMessageSender .class );
@@ -142,7 +143,7 @@ void willUseRestTemplateInNonWebApplicationIfSenderAndWebClientAreNotAvailable()
142143 @ Test
143144 void willUseRestTemplateInServletWebApplicationIfHttpClientSenderAndWebClientNotAvailable () {
144145 this .servletContextRunner .withUserConfiguration (RestTemplateConfiguration .class )
145- .withClassLoader (new FilteredClassLoader ("java.net.http. HttpClient" , "org.springframework.web.reactive.function.client" ))
146+ .withClassLoader (new FilteredClassLoader (HttpClient . class , WebClient . class ))
146147 .run ((context ) -> {
147148 assertThat (context ).doesNotHaveBean (ZipkinHttpClientSender .class );
148149 assertThat (context ).hasSingleBean (BytesMessageSender .class );
@@ -154,7 +155,7 @@ void willUseRestTemplateInServletWebApplicationIfHttpClientSenderAndWebClientNot
154155 @ Test
155156 void willUseRestTemplateInReactiveWebApplicationIfHttpClientSenderAndWebClientAreNotAvailable () {
156157 this .reactiveContextRunner .withUserConfiguration (RestTemplateConfiguration .class )
157- .withClassLoader (new FilteredClassLoader ("java.net.http. HttpClient" , "org.springframework.web.reactive.function.client" ))
158+ .withClassLoader (new FilteredClassLoader (HttpClient . class , WebClient . class ))
158159 .run ((context ) -> {
159160 assertThat (context ).doesNotHaveBean (ZipkinHttpClientSender .class );
160161 assertThat (context ).hasSingleBean (BytesMessageSender .class );
@@ -189,7 +190,7 @@ void shouldApplyZipkinRestTemplateBuilderCustomizers() throws IOException {
189190 this .reactiveContextRunner
190191 .withPropertyValues ("management.zipkin.tracing.endpoint=" + mockWebServer .url ("/" ))
191192 .withUserConfiguration (RestTemplateConfiguration .class )
192- .withClassLoader (new FilteredClassLoader ("java.net.http. HttpClient" , "org.springframework.web.reactive.function.client" ))
193+ .withClassLoader (new FilteredClassLoader (HttpClient . class , WebClient . class ))
193194 .run ((context ) -> {
194195 assertThat (context ).hasSingleBean (ZipkinRestTemplateSender .class );
195196 ZipkinRestTemplateSender sender = context .getBean (ZipkinRestTemplateSender .class );
0 commit comments