diff --git a/pom.xml b/pom.xml index ad600ecae..bca53de35 100644 --- a/pom.xml +++ b/pom.xml @@ -274,7 +274,7 @@ 2.1.0.BUILD-SNAPSHOT 2.1.0.BUILD-SNAPSHOT 5.2.0 - 2.0.0.RELEASE + 2.0.4.RELEASE diff --git a/spring-cloud-sleuth-core/pom.xml b/spring-cloud-sleuth-core/pom.xml index 924ec10da..e8882d5e5 100644 --- a/spring-cloud-sleuth-core/pom.xml +++ b/spring-cloud-sleuth-core/pom.xml @@ -52,6 +52,11 @@ reactor-core true + + io.projectreactor.netty + reactor-netty + true + org.reactivestreams reactive-streams @@ -107,6 +112,11 @@ 2.2.0.RELEASE true + + org.springframework.boot + spring-boot-starter-security + true + org.springframework spring-context diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/autoconfig/TraceAutoConfiguration.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/autoconfig/TraceAutoConfiguration.java index 2244c40e8..6046afe72 100644 --- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/autoconfig/TraceAutoConfiguration.java +++ b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/autoconfig/TraceAutoConfiguration.java @@ -134,7 +134,7 @@ public class TraceAutoConfiguration { } @Bean - CurrentTraceContext currentTraceContext(CurrentTraceContext.Builder builder) { + CurrentTraceContext sleuthCurrentTraceContext(CurrentTraceContext.Builder builder) { for (CurrentTraceContext.ScopeDecorator scopeDecorator : this.scopeDecorators) { builder.addScopeDecorator(scopeDecorator); } diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/AsyncAutoConfiguration.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/AsyncAutoConfiguration.java index 9c0580992..5b9facb0e 100644 --- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/AsyncAutoConfiguration.java +++ b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/AsyncAutoConfiguration.java @@ -27,7 +27,6 @@ import org.springframework.scheduling.annotation.AsyncConfigurer; * @author Jesus Alonso * @since 2.1.0 */ - @Configuration @EnableConfigurationProperties(SleuthAsyncProperties.class) public class AsyncAutoConfiguration { diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/client/TraceWebClientAutoConfiguration.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/client/TraceWebClientAutoConfiguration.java index 04507b6df..12d365307 100644 --- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/client/TraceWebClientAutoConfiguration.java +++ b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/client/TraceWebClientAutoConfiguration.java @@ -17,15 +17,12 @@ package org.springframework.cloud.sleuth.instrument.web.client; import java.io.IOException; -import java.nio.charset.Charset; -import java.nio.file.Path; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Consumer; -import java.util.function.Function; +import java.util.function.BiFunction; import brave.Span; import brave.Tracer; @@ -36,8 +33,6 @@ import brave.httpclient.TracingHttpClientBuilder; import brave.propagation.Propagation; import brave.propagation.TraceContext; import brave.spring.web.TracingClientHttpRequestInterceptor; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.ByteBufAllocator; import io.netty.handler.codec.http.HttpHeaders; import io.netty.handler.codec.http.HttpMethod; import io.netty.handler.codec.http.HttpVersion; @@ -51,7 +46,6 @@ import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; import org.reactivestreams.Publisher; -import org.reactivestreams.Subscriber; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.ListableBeanFactory; @@ -76,16 +70,11 @@ import org.springframework.http.client.ClientHttpResponse; import org.springframework.security.oauth2.client.OAuth2RestTemplate; import org.springframework.web.client.RestTemplate; import org.springframework.web.reactive.function.client.WebClient; -import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -import reactor.ipc.netty.NettyContext; -import reactor.ipc.netty.NettyOutbound; -import reactor.ipc.netty.NettyPipeline; -import reactor.ipc.netty.channel.data.FileChunkedStrategy; -import reactor.ipc.netty.http.client.HttpClient; -import reactor.ipc.netty.http.client.HttpClientRequest; -import reactor.ipc.netty.http.client.HttpClientResponse; -import reactor.ipc.netty.http.websocket.WebsocketOutbound; +import reactor.netty.NettyOutbound; +import reactor.netty.http.client.HttpClient; +import reactor.netty.http.client.HttpClientRequest; +import reactor.netty.http.client.HttpClientResponse; /** * {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration @@ -309,17 +298,16 @@ class NettyAspect { this.instrumentation = TracingHttpClientInstrumentation.create(httpTracing); } - @Pointcut("execution(public * reactor.ipc.netty.http.client.HttpClient.request(..)) && args(method, url, handler)") - private void anyHttpClientRequestSending(HttpMethod method, - String url, Function> handler) { } // NOSONAR + @Pointcut("execution(public * reactor.netty.http.client.HttpClient.RequestSender.send(..)) && args(function)") + private void anyHttpClientRequestSending( + BiFunction> function) { } // NOSONAR - @Around("anyHttpClientRequestSending(method, url, handler)") + @Around("anyHttpClientRequestSending(function)") public Object wrapHttpClientRequestSending(ProceedingJoinPoint pjp, - HttpMethod method, - String url, Function> handler) throws Throwable { + BiFunction> function) throws Throwable { return Mono.defer(() -> { try { - return this.instrumentation.wrapHttpClientRequestSending(pjp, method, url, handler); + return this.instrumentation.wrapHttpClientRequestSending(pjp, function); } catch (Throwable e) { return Mono.error(e); @@ -370,13 +358,12 @@ class TracingHttpClientInstrumentation { } Mono wrapHttpClientRequestSending(ProceedingJoinPoint pjp, - HttpMethod method, - String url, Function> handler) throws Throwable { + BiFunction> function) throws Throwable { // add headers and set CS final Span currentSpan = this.tracer.currentSpan(); final AtomicReference span = new AtomicReference<>(); - Function> combinedFunction = - req -> { + BiFunction> combinedFunction = + (req, nettyOutbound) -> { try (Tracer.SpanInScope spanInScope = this.tracer.withSpanInScope(currentSpan)) { io.netty.handler.codec.http.HttpHeaders originalHeaders = req .requestHeaders().copy(); @@ -392,13 +379,13 @@ class TracingHttpClientInstrumentation { if (log.isDebugEnabled()) { log.debug("Created a new client span for Netty client"); } - return handle(handler, new TracedHttpClientRequest(req, addedHeaders)); + return handle(function, new TracedHttpClientRequest(req, addedHeaders), nettyOutbound); } } }; // run Mono responseMono = - (Mono) pjp.proceed(new Object[] { method , url, combinedFunction }); + (Mono) pjp.proceed(new Object[] { combinedFunction }); // get response return responseMono.doOnSuccessOrError((httpClientResponse, throwable) -> { try (Tracer.SpanInScope ws = this.tracer.withSpanInScope(span.get())) { @@ -441,38 +428,6 @@ class TracingHttpClientInstrumentation { return this; } - @Override public HttpClientRequest context( - Consumer contextCallback) { - this.delegate = this.delegate.context(contextCallback); - return this; - } - - @Override public HttpClientRequest chunkedTransfer(boolean chunked) { - this.delegate = this.delegate.chunkedTransfer(chunked); - return this; - } - - @Override public HttpClientRequest options( - Consumer configurator) { - this.delegate = this.delegate.options(configurator); - return this; - } - - @Override public HttpClientRequest followRedirect() { - this.delegate = this.delegate.followRedirect(); - return this; - } - - @Override public HttpClientRequest failOnClientError(boolean shouldFail) { - this.delegate = this.delegate.failOnClientError(shouldFail); - return this; - } - - @Override public HttpClientRequest failOnServerError(boolean shouldFail) { - this.delegate = this.delegate.failOnServerError(shouldFail); - return this; - } - @Override public boolean hasSentHeaders() { return this.delegate.hasSentHeaders(); } @@ -498,12 +453,6 @@ class TracingHttpClientInstrumentation { return this; } - @Override public HttpClientRequest onWriteIdle(long idleTimeout, - Runnable onWriteIdle) { - this.delegate = this.delegate.onWriteIdle(idleTimeout, onWriteIdle); - return this; - } - @Override public String[] redirectedFrom() { return this.delegate.redirectedFrom(); } @@ -512,99 +461,6 @@ class TracingHttpClientInstrumentation { return this.delegate.requestHeaders(); } - @Override public Mono send() { - return this.delegate.send(); - } - - @Override public Flux sendForm(Consumer
formCallback) { - return this.delegate.sendForm(formCallback); - } - - @Override public NettyOutbound sendHeaders() { - return this.delegate.sendHeaders(); - } - - @Override public WebsocketOutbound sendWebsocket() { - return this.delegate.sendWebsocket(); - } - - @Override public WebsocketOutbound sendWebsocket(String subprotocols) { - return this.delegate.sendWebsocket(subprotocols); - } - - @Override public ByteBufAllocator alloc() { - return this.delegate.alloc(); - } - - @Override public NettyContext context() { - return this.delegate.context(); - } - - @Override public FileChunkedStrategy getFileChunkedStrategy() { - return this.delegate.getFileChunkedStrategy(); - } - - @Override public Mono neverComplete() { - return this.delegate.neverComplete(); - } - - @Override public NettyOutbound send(Publisher dataStream) { - return this.delegate.send(dataStream); - } - - @Override public NettyOutbound sendByteArray( - Publisher dataStream) { - return this.delegate.sendByteArray(dataStream); - } - - @Override public NettyOutbound sendFile(Path file) { - return this.delegate.sendFile(file); - } - - @Override public NettyOutbound sendFile(Path file, long position, long count) { - return this.delegate.sendFile(file, position, count); - } - - @Override public NettyOutbound sendFileChunked(Path file, long position, - long count) { - return this.delegate.sendFileChunked(file, position, count); - } - - @Override public NettyOutbound sendGroups( - Publisher> dataStreams) { - return this.delegate.sendGroups(dataStreams); - } - - @Override public NettyOutbound sendObject(Publisher dataStream) { - return this.delegate.sendObject(dataStream); - } - - @Override public NettyOutbound sendObject(Object msg) { - return this.delegate.sendObject(msg); - } - - @Override public NettyOutbound sendString( - Publisher dataStream) { - return this.delegate.sendString(dataStream); - } - - @Override public NettyOutbound sendString(Publisher dataStream, - Charset charset) { - return this.delegate.sendString(dataStream, charset); - } - - @Override public void subscribe(Subscriber s) { - this.delegate.subscribe(s); - } - - @Override public Mono then() { - return this.delegate.then(); - } - - @Override public NettyOutbound then(Publisher other) { - return this.delegate.then(other); - } - @Override public Map> cookies() { return this.delegate.cookies(); } @@ -635,12 +491,12 @@ class TracingHttpClientInstrumentation { } private Publisher handle( - Function> handler, - HttpClientRequest req) { + BiFunction> handler, + HttpClientRequest req, NettyOutbound nettyOutbound) { if (handler != null) { - return handler.apply(req); + return handler.apply(req, nettyOutbound); } - return req; + return nettyOutbound; } static final class HttpAdapter diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/DisableSecurity.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/DisableSecurity.java new file mode 100644 index 000000000..bd3f5bb03 --- /dev/null +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/DisableSecurity.java @@ -0,0 +1,35 @@ +/* + * Copyright 2013-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.cloud.sleuth; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.springframework.context.annotation.Import; + +/** + * @author Marcin Grzejszczak + */ +@Import(PermitAllServletConfiguration.class) +@Target({ ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface DisableSecurity { +} diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/DisableWebFluxSecurity.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/DisableWebFluxSecurity.java new file mode 100644 index 000000000..254ce3179 --- /dev/null +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/DisableWebFluxSecurity.java @@ -0,0 +1,35 @@ +/* + * Copyright 2013-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.cloud.sleuth; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.springframework.context.annotation.Import; + +/** + * @author Marcin Grzejszczak + */ +@Import(PermitAllWebFluxSecurityConfiguration.class) +@Target({ ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface DisableWebFluxSecurity { +} diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/PermitAllServletConfiguration.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/PermitAllServletConfiguration.java new file mode 100644 index 000000000..b64004bf5 --- /dev/null +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/PermitAllServletConfiguration.java @@ -0,0 +1,35 @@ +/* + * Copyright 2013-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.cloud.sleuth; + +import org.springframework.context.annotation.Configuration; +import org.springframework.core.annotation.Order; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +@Configuration +@EnableWebSecurity +@Order(99) +public class PermitAllServletConfiguration extends WebSecurityConfigurerAdapter { + @Override + protected void configure(HttpSecurity http) throws Exception { + http + .authorizeRequests() + .antMatchers("/*").permitAll(); + } +} \ No newline at end of file diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/PermitAllWebFluxSecurityConfiguration.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/PermitAllWebFluxSecurityConfiguration.java new file mode 100644 index 000000000..521b382d0 --- /dev/null +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/PermitAllWebFluxSecurityConfiguration.java @@ -0,0 +1,33 @@ +/* + * Copyright 2013-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.cloud.sleuth; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.web.server.ServerHttpSecurity; +import org.springframework.security.web.server.SecurityWebFilterChain; + +@Configuration +public class PermitAllWebFluxSecurityConfiguration { + @Bean SecurityWebFilterChain springWebFilterChain(ServerHttpSecurity http) throws Exception { + return http.authorizeExchange() + .anyExchange().permitAll() + .and() + .csrf().disable() + .build(); + } +} \ No newline at end of file diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/SleuthTestAutoConfiguration.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/SleuthTestAutoConfiguration.java new file mode 100644 index 000000000..f74ec89d7 --- /dev/null +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/SleuthTestAutoConfiguration.java @@ -0,0 +1,46 @@ +/* + * Copyright 2013-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.cloud.sleuth; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; + +/** + * @author Marcin Grzejszczak + */ +@Configuration +public class SleuthTestAutoConfiguration { + + @Configuration + @ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.REACTIVE) + static class ReactiveConfiguration { + @Import(PermitAllWebFluxSecurityConfiguration.class) + static class ImportConfiguration { + + } + } + + @Configuration + @ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET) + static class ServletConfiguration { + @Import(PermitAllServletConfiguration.class) + static class ImportConfiguration { + + } + } +} diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/SpanAdjusterTests.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/SpanAdjusterTests.java index 49f02ba58..3674dc668 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/SpanAdjusterTests.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/SpanAdjusterTests.java @@ -24,6 +24,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.sleuth.util.ArrayListSpanReporter; import org.springframework.context.annotation.Bean; @@ -53,7 +54,7 @@ public class SpanAdjusterTests { } @Configuration - @EnableAutoConfiguration + @EnableAutoConfiguration(exclude = IntegrationAutoConfiguration.class) static class SpanAdjusterAspectTestsConfig { @Bean Sampler sampler() { return Sampler.ALWAYS_SAMPLE; diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/annotation/SleuthSpanCreatorAspectWebFluxTests.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/annotation/SleuthSpanCreatorAspectWebFluxTests.java index 41c73a067..e34f37fe1 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/annotation/SleuthSpanCreatorAspectWebFluxTests.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/annotation/SleuthSpanCreatorAspectWebFluxTests.java @@ -32,6 +32,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.security.reactive.ReactiveUserDetailsServiceAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.cloud.sleuth.DisableWebFluxSecurity; import org.springframework.cloud.sleuth.util.ArrayListSpanReporter; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -191,7 +192,8 @@ public class SleuthSpanCreatorAspectWebFluxTests { @Configuration - @EnableAutoConfiguration(exclude = {org.springframework.boot.autoconfigure.security.reactive.ReactiveSecurityAutoConfiguration.class, ReactiveUserDetailsServiceAutoConfiguration.class}) + @EnableAutoConfiguration + @DisableWebFluxSecurity protected static class TestConfiguration { @Bean diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/annotation/SleuthSpanCreatorCircularDependencyTests.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/annotation/SleuthSpanCreatorCircularDependencyTests.java index 29fd247ca..a0c0cbfd8 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/annotation/SleuthSpanCreatorCircularDependencyTests.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/annotation/SleuthSpanCreatorCircularDependencyTests.java @@ -47,7 +47,8 @@ public class SleuthSpanCreatorCircularDependencyTests { } } - @Configuration @EnableAutoConfiguration + @Configuration + @EnableAutoConfiguration protected static class TestConfiguration { @Bean Reporter spanReporter() { return new ArrayListSpanReporter(); diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/messaging/ITTracingChannelInterceptor.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/messaging/ITTracingChannelInterceptor.java index db36b9b74..fc47fcf81 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/messaging/ITTracingChannelInterceptor.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/messaging/ITTracingChannelInterceptor.java @@ -20,7 +20,6 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; - import javax.annotation.PreDestroy; import brave.Span; @@ -39,12 +38,10 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.integration.channel.DirectChannel; import org.springframework.integration.channel.ExecutorChannel; -import org.springframework.integration.config.GlobalChannelInterceptor; import org.springframework.integration.core.MessagingTemplate; import org.springframework.integration.support.MessageBuilder; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHandler; -import org.springframework.messaging.support.ChannelInterceptor; import org.springframework.messaging.support.MessageHeaderAccessor; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; @@ -128,7 +125,9 @@ public class ITTracingChannelInterceptor implements MessageHandler { .isNull(); } - @Configuration @EnableAutoConfiguration static class App { + @Configuration + @EnableAutoConfiguration + static class App { @Bean List spans() { return new ArrayList<>(); @@ -162,10 +161,5 @@ public class ITTracingChannelInterceptor implements MessageHandler { @Bean public MessagingTemplate messagingTemplate() { return new MessagingTemplate(directChannel()); } - - @Bean @GlobalChannelInterceptor - public ChannelInterceptor tracingChannelInterceptor(Tracing tracing) { - return TracingChannelInterceptor.create(tracing); - } } } \ No newline at end of file diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/messaging/TraceContextPropagationChannelInterceptorTests.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/messaging/TraceContextPropagationChannelInterceptorTests.java index a703d1dd6..9131f91b7 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/messaging/TraceContextPropagationChannelInterceptorTests.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/messaging/TraceContextPropagationChannelInterceptorTests.java @@ -26,6 +26,7 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.sleuth.util.ArrayListSpanReporter; import org.springframework.cloud.sleuth.util.SpanUtil; diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/messaging/TraceMessagingAutoConfigurationTests.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/messaging/TraceMessagingAutoConfigurationTests.java index cc1e26ba5..481bacf5c 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/messaging/TraceMessagingAutoConfigurationTests.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/messaging/TraceMessagingAutoConfigurationTests.java @@ -16,25 +16,37 @@ package org.springframework.cloud.sleuth.instrument.messaging; +import java.util.HashMap; + import brave.Tracer; import brave.kafka.clients.KafkaTracing; import brave.sampler.Sampler; import brave.spring.rabbit.SpringRabbitTracing; +import org.apache.kafka.clients.consumer.Consumer; import org.apache.kafka.clients.consumer.ConsumerRecord; +import org.apache.kafka.clients.producer.Producer; import org.aspectj.lang.ProceedingJoinPoint; +import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.BDDMockito; +import org.mockito.Mockito; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.boot.test.mock.mockito.SpyBean; import org.springframework.cloud.sleuth.util.ArrayListSpanReporter; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.kafka.annotation.KafkaListener; import org.springframework.kafka.core.ConsumerFactory; import org.springframework.kafka.core.ProducerFactory; +import org.springframework.kafka.listener.MessageListenerContainer; import org.springframework.kafka.listener.adapter.MessagingMessageListenerAdapter; import org.springframework.test.context.junit4.SpringRunner; @@ -124,18 +136,18 @@ class MySleuthKafkaAspect extends SleuthKafkaAspect { @Override public Object wrapProducerFactory(ProceedingJoinPoint pjp) throws Throwable { this.producerWrapped = true; - return super.wrapProducerFactory(pjp); + return Mockito.mock(Producer.class); } @Override public Object wrapConsumerFactory(ProceedingJoinPoint pjp) throws Throwable { this.consumerWrapped = true; - return super.wrapConsumerFactory(pjp); + return Mockito.mock(Consumer.class); } @Override public Object wrapListenerContainerCreation(ProceedingJoinPoint pjp) throws Throwable { this.adapterWrapped = true; - return super.wrapListenerContainerCreation(pjp); + return Mockito.mock(MessageListenerContainer.class); } } \ No newline at end of file diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/messaging/websocket/TraceWebSocketAutoConfigurationTests.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/messaging/websocket/TraceWebSocketAutoConfigurationTests.java index 7203f0658..95e589e13 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/messaging/websocket/TraceWebSocketAutoConfigurationTests.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/messaging/websocket/TraceWebSocketAutoConfigurationTests.java @@ -56,7 +56,9 @@ public class TraceWebSocketAutoConfigurationTests { .hasAtLeastOneElementOfType(TracingChannelInterceptor.class); } - @EnableAutoConfiguration @Configuration @EnableWebSocketMessageBroker + @EnableAutoConfiguration + @Configuration + @EnableWebSocketMessageBroker public static class Config extends AbstractWebSocketMessageBrokerConfigurer { @Override public void configureMessageBroker(MessageBrokerRegistry config) { diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/multiple/DemoApplication.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/multiple/DemoApplication.java similarity index 96% rename from spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/multiple/DemoApplication.java rename to spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/multiple/DemoApplication.java index 4c3a2d6c0..d2efb5323 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/multiple/DemoApplication.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/multiple/DemoApplication.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.cloud.sleuth.instrument.web.multiple; +package org.springframework.cloud.sleuth.instrument.multiple; import java.util.Arrays; import java.util.List; @@ -43,8 +43,7 @@ import org.springframework.web.bind.annotation.RestController; @IntegrationComponentScan public class DemoApplication { - private static final Log log = LogFactory.getLog( - DemoApplication.class); + private static final Log log = LogFactory.getLog(DemoApplication.class); Span httpSpan; Span splitterSpan; @@ -98,6 +97,7 @@ public class DemoApplication { public List allSpans() { return Arrays.asList(this.httpSpan, this.splitterSpan, this.aggregatorSpan, this.serviceActivatorSpan); } + } @MessagingGateway(name = "greeter") diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/multiple/MultipleHopsIntegrationTests.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/multiple/MultipleHopsIntegrationTests.java similarity index 99% rename from spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/multiple/MultipleHopsIntegrationTests.java rename to spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/multiple/MultipleHopsIntegrationTests.java index b26fe9858..e8c9aedbd 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/multiple/MultipleHopsIntegrationTests.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/multiple/MultipleHopsIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.cloud.sleuth.instrument.web.multiple; +package org.springframework.cloud.sleuth.instrument.multiple; import java.net.URI; import java.util.Collections; @@ -184,5 +184,6 @@ public class MultipleHopsIntegrationTests { @Bean Sampler defaultTraceSampler() { return Sampler.ALWAYS_SAMPLE; } + } } diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/reactor/sample/FlatMapTests.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/reactor/sample/FlatMapTests.java index 8d427b4e4..afad25a50 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/reactor/sample/FlatMapTests.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/reactor/sample/FlatMapTests.java @@ -31,16 +31,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.WebApplicationType; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.security.reactive.ReactiveSecurityAutoConfiguration; -import org.springframework.boot.autoconfigure.security.reactive.ReactiveUserDetailsServiceAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.test.rule.OutputCapture; +import org.springframework.cloud.sleuth.DisableWebFluxSecurity; import org.springframework.cloud.sleuth.instrument.reactor.Issue866Configuration; import org.springframework.cloud.sleuth.util.ArrayListSpanReporter; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; import org.springframework.core.env.Environment; import org.springframework.web.reactive.function.client.ClientResponse; import org.springframework.web.reactive.function.client.WebClient; @@ -49,7 +47,6 @@ import org.springframework.web.reactive.function.server.ServerResponse; import reactor.core.publisher.Flux; import reactor.core.publisher.Hooks; import reactor.core.publisher.Mono; -import reactor.core.scheduler.Scheduler; import reactor.core.scheduler.Schedulers; import zipkin2.Span; @@ -149,9 +146,8 @@ public class FlatMapTests { } @Configuration - @EnableAutoConfiguration( - exclude = { ReactiveUserDetailsServiceAutoConfiguration.class, - ReactiveSecurityAutoConfiguration.class }) + @EnableAutoConfiguration + @DisableWebFluxSecurity static class TestConfiguration { brave.Span spanInFoo; @@ -159,11 +155,11 @@ public class FlatMapTests { @Bean RouterFunction handlers(Tracer tracer, RequestSender requestSender) { return route(GET("/noFlatMap"), request -> { LOGGER.info("noFlatMap"); - Flux one = requestSender.getAll().map(string -> string.length()); + Flux one = requestSender.getAll().map(String::length); return ServerResponse.ok().body(one, Integer.class); }).andRoute(GET("/withFlatMap"), request -> { LOGGER.info("withFlatMap"); - Flux one = requestSender.getAll().map(string -> string.length()); + Flux one = requestSender.getAll().map(String::length); Flux response = one.flatMap(size -> requestSender.getAll() .doOnEach(sig -> LOGGER.info(sig.getContext().toString()))) .map(string -> { diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/TraceFilterTests.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/TraceFilterTests.java index 91f35557b..9cc35b329 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/TraceFilterTests.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/TraceFilterTests.java @@ -507,7 +507,7 @@ public class TraceFilterTests { then(this.reporter.getSpans()) .hasSize(1); then(this.reporter.getSpans().get(0).tags()) - .containsEntry("http.status_code", status.toString()); + .containsEntry("http.status_code", "500"); } } } diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/TraceNoWebEnvironmentTests.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/TraceNoWebEnvironmentTests.java index aab7d7158..cfbddc87f 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/TraceNoWebEnvironmentTests.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/TraceNoWebEnvironmentTests.java @@ -19,6 +19,7 @@ package org.springframework.cloud.sleuth.instrument.web; import org.junit.Test; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.boot.SpringApplication; +import org.springframework.boot.WebApplicationType; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -39,7 +40,7 @@ public class TraceNoWebEnvironmentTests { @Test public void should_work_when_using_web_client_without_the_web_environment() { SpringApplication springApplication = new SpringApplication(Config.class); - springApplication.setWebEnvironment(false); + springApplication.setWebApplicationType(WebApplicationType.NONE); try (ConfigurableApplicationContext context = springApplication.run()) { Config.SomeFeignClient client = context.getBean(Config.SomeFeignClient.class); @@ -52,11 +53,10 @@ public class TraceNoWebEnvironmentTests { @Configuration @EnableAutoConfiguration - @EnableFeignClients + @EnableFeignClients(clients = Config.SomeFeignClient.class) @EnableCircuitBreaker public static class Config { - @FeignClient(name = "google", url = "https://www.google.com/") public interface SomeFeignClient { diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/TraceWebFluxTests.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/TraceWebFluxTests.java index 8a3de36bb..a634cc992 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/TraceWebFluxTests.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/TraceWebFluxTests.java @@ -16,8 +16,6 @@ package org.springframework.cloud.sleuth.instrument.web; -import java.util.Random; - import brave.Span; import brave.Tracer; import brave.sampler.Sampler; @@ -27,9 +25,8 @@ import org.junit.Test; import org.slf4j.MDC; import org.springframework.boot.WebApplicationType; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.security.reactive.ReactiveSecurityAutoConfiguration; -import org.springframework.boot.autoconfigure.security.reactive.ReactiveUserDetailsServiceAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.cloud.sleuth.DisableWebFluxSecurity; import org.springframework.cloud.sleuth.instrument.web.client.TraceWebClientAutoConfiguration; import org.springframework.cloud.sleuth.util.ArrayListSpanReporter; import org.springframework.context.ConfigurableApplicationContext; @@ -41,7 +38,10 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.reactive.function.client.ClientResponse; import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.reactive.function.server.*; +import org.springframework.web.reactive.function.server.RequestPredicates; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.RouterFunctions; +import org.springframework.web.reactive.function.server.ServerResponse; import reactor.core.publisher.Flux; import reactor.core.publisher.Hooks; import reactor.core.publisher.Mono; @@ -162,10 +162,8 @@ public class TraceWebFluxTests { } @Configuration - @EnableAutoConfiguration( - exclude = { TraceWebClientAutoConfiguration.class, - ReactiveUserDetailsServiceAutoConfiguration.class, - ReactiveSecurityAutoConfiguration.class }) + @EnableAutoConfiguration(exclude = { TraceWebClientAutoConfiguration.class }) + @DisableWebFluxSecurity static class Config { @Bean WebClient webClient() { diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/exceptionresolver/Issue585Tests.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/exceptionresolver/Issue585Tests.java index cafca32f4..b0c6660bc 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/exceptionresolver/Issue585Tests.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/exceptionresolver/Issue585Tests.java @@ -16,12 +16,13 @@ package org.springframework.cloud.sleuth.instrument.web.client.exceptionresolver; -import javax.servlet.http.HttpServletRequest; import java.time.Instant; +import javax.servlet.http.HttpServletRequest; import brave.Span; import brave.Tracing; import brave.sampler.Sampler; +import com.fasterxml.jackson.annotation.JsonInclude; import org.junit.Test; import org.junit.runner.RunWith; import org.slf4j.Logger; @@ -44,8 +45,6 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; -import com.fasterxml.jackson.annotation.JsonInclude; - import static org.assertj.core.api.BDDAssertions.then; @RunWith(SpringRunner.class) diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/feign/issues/issue307/Issue307Tests.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/feign/issues/issue307/Issue307Tests.java index 1f180f667..c122231c0 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/feign/issues/issue307/Issue307Tests.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/feign/issues/issue307/Issue307Tests.java @@ -53,8 +53,7 @@ public class Issue307Tests { } @EnableAutoConfiguration -@Import({ - ParticipantsBean.class, ParticipantsClient.class}) +@Import({ ParticipantsBean.class}) @RestController @EnableFeignClients @EnableCircuitBreaker diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/feign/issues/issue350/Issue350Tests.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/feign/issues/issue350/Issue350Tests.java index d2f643051..3c0668b94 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/feign/issues/issue350/Issue350Tests.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/feign/issues/issue350/Issue350Tests.java @@ -77,8 +77,7 @@ public class Issue350Tests { @Configuration @EnableAutoConfiguration(exclude = TraceWebServletAutoConfiguration.class) -@EnableFeignClients(basePackageClasses = { - SleuthTestController.class}) +@EnableFeignClients(basePackageClasses = { SleuthTestController.class}) class Application { @Bean diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/feign/issues/issue362/Issue362Tests.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/feign/issues/issue362/Issue362Tests.java index 3e2f97468..02b16dbdf 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/feign/issues/issue362/Issue362Tests.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/feign/issues/issue362/Issue362Tests.java @@ -115,8 +115,7 @@ public class Issue362Tests { @Configuration @EnableAutoConfiguration(exclude = TraceWebServletAutoConfiguration.class) -@EnableFeignClients(basePackageClasses = { - SleuthTestController.class}) +@EnableFeignClients(basePackageClasses = { SleuthTestController.class}) class Application { @Bean diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/integration/WebClientTests.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/integration/WebClientTests.java index 568effa75..b1623205e 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/integration/WebClientTests.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/integration/WebClientTests.java @@ -88,8 +88,8 @@ import org.springframework.web.client.RestTemplate; import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Hooks; import reactor.core.scheduler.Schedulers; -import reactor.ipc.netty.http.client.HttpClient; -import reactor.ipc.netty.http.client.HttpClientResponse; +import reactor.netty.http.client.HttpClient; +import reactor.netty.http.client.HttpClientResponse; import zipkin2.Annotation; import zipkin2.reporter.Reporter; @@ -246,7 +246,10 @@ public class WebClientTests { try (Tracer.SpanInScope ws = this.tracer.withSpanInScope(span)) { HttpClientResponse response = this.nettyHttpClient - .get("http://localhost:" + port).block(); + .get() + .uri("http://localhost:" + port) + .response() + .block(); then(response).isNotNull(); } diff --git a/spring-cloud-sleuth-core/src/test/resources/META-INF/spring.factories b/spring-cloud-sleuth-core/src/test/resources/META-INF/spring.factories new file mode 100644 index 000000000..c7297376d --- /dev/null +++ b/spring-cloud-sleuth-core/src/test/resources/META-INF/spring.factories @@ -0,0 +1,3 @@ +# Auto Configuration +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +org.springframework.cloud.sleuth.SleuthTestAutoConfiguration diff --git a/spring-cloud-sleuth-core/src/test/resources/application.yml b/spring-cloud-sleuth-core/src/test/resources/application.yml index 7933549c9..c2916927c 100644 --- a/spring-cloud-sleuth-core/src/test/resources/application.yml +++ b/spring-cloud-sleuth-core/src/test/resources/application.yml @@ -18,6 +18,5 @@ spring.sleuth.rxjava.schedulers.ignoredthreads: HystixMetricPoller,^MyCustomThre logging.level.org.springframework.cloud: DEBUG - #disable hibernate by default spring.autoconfigure.exclude: org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration, org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration, org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration \ No newline at end of file diff --git a/spring-cloud-sleuth-dependencies/pom.xml b/spring-cloud-sleuth-dependencies/pom.xml index c3422b578..ef7737155 100644 --- a/spring-cloud-sleuth-dependencies/pom.xml +++ b/spring-cloud-sleuth-dependencies/pom.xml @@ -39,11 +39,6 @@ spring-cloud-sleuth-core ${project.version} - - org.springframework.cloud - spring-cloud-sleuth-reactor - ${project.version} - org.springframework.cloud spring-cloud-sleuth-zipkin-legacy @@ -64,11 +59,6 @@ spring-cloud-sleuth-zipkin-stream ${project.version} - - org.springframework.cloud - spring-cloud-starter-zipkin-legacy - ${project.version} - org.springframework.cloud spring-cloud-starter-zipkin