diff --git a/spring-cloud-sleuth-stream/pom.xml b/spring-cloud-sleuth-stream/pom.xml
index 68647ec05..403e28622 100644
--- a/spring-cloud-sleuth-stream/pom.xml
+++ b/spring-cloud-sleuth-stream/pom.xml
@@ -59,6 +59,11 @@
spring-boot-starter-test
test
+
+ org.aspectj
+ aspectjweaver
+ test
+
diff --git a/spring-cloud-sleuth-stream/src/test/java/org/springframework/cloud/sleuth/stream/StreamSpanListenerTests.java b/spring-cloud-sleuth-stream/src/test/java/org/springframework/cloud/sleuth/stream/StreamSpanListenerTests.java
index cf41a4c9c..c99df54f0 100644
--- a/spring-cloud-sleuth-stream/src/test/java/org/springframework/cloud/sleuth/stream/StreamSpanListenerTests.java
+++ b/spring-cloud-sleuth-stream/src/test/java/org/springframework/cloud/sleuth/stream/StreamSpanListenerTests.java
@@ -84,8 +84,10 @@ public class StreamSpanListenerTests {
@Test
public void acquireAndRelease() {
Span context = this.tracer.createSpan("http:foo");
+
this.tracer.close(context);
- assertEquals(1, this.test.spans.size());
+
+ assertThat(this.test.spans).hasSize(1);
}
@Test
@@ -96,8 +98,10 @@ public class StreamSpanListenerTests {
context.logEvent(Span.CLIENT_SEND);
logServerReceived(parent);
logServerSent(this.spanReporter, parent);
+
this.tracer.close(context);
- assertEquals(2, this.test.spans.size());
+
+ assertThat(this.test.spans).hasSize(2);
}
void logServerReceived(Span parent) {
diff --git a/spring-cloud-sleuth-stream/src/test/java/org/springframework/cloud/sleuth/stream/TraceIgnoringChannelInterceptorTests.java b/spring-cloud-sleuth-stream/src/test/java/org/springframework/cloud/sleuth/stream/TraceIgnoringChannelInterceptorTests.java
new file mode 100644
index 000000000..3d7e395ea
--- /dev/null
+++ b/spring-cloud-sleuth-stream/src/test/java/org/springframework/cloud/sleuth/stream/TraceIgnoringChannelInterceptorTests.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2013-2015 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.stream;
+
+import javax.annotation.PostConstruct;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import org.junit.After;
+import org.junit.Before;
+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.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.cloud.sleuth.Sampler;
+import org.springframework.cloud.sleuth.Span;
+import org.springframework.cloud.sleuth.Tracer;
+import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
+import org.springframework.cloud.sleuth.util.ExceptionUtils;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.integration.core.MessagingTemplate;
+import org.springframework.integration.support.MessageBuilder;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import static org.assertj.core.api.BDDAssertions.then;
+
+/**
+ * @author Dave Syer
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = TraceIgnoringChannelInterceptorTests.App.class)
+@DirtiesContext
+public class TraceIgnoringChannelInterceptorTests {
+
+ @Autowired Tracer tracer;
+ @Autowired App app;
+ @Autowired MessagingTemplate messagingTemplate;
+
+ @Before
+ public void init() {
+ this.app.clear();
+ }
+
+ @After
+ public void close() {
+ then(ExceptionUtils.getLastException()).isNull();
+ this.app.clear();
+ }
+
+ @Test
+ public void shouldNotTraceTheTracer() {
+ this.messagingTemplate.send(MessageBuilder.withPayload("hi").build());
+
+ Spans spans = this.app.listener.poll();
+
+ then(spans).isNull();
+ then(this.tracer.getCurrentSpan()).isNull();
+ }
+
+ @Configuration
+ @EnableAutoConfiguration
+ static class App {
+
+ private final BlockingQueue spans = new LinkedBlockingQueue<>();
+
+ @Autowired StreamSpanReporter listener;
+
+ @Bean MessagingTemplate messagingTemplate(SleuthSource sleuthSource) {
+ return new MessagingTemplate(sleuthSource.output());
+ }
+
+ @Bean Sampler alwaysSampler() {
+ return new AlwaysSampler();
+ }
+
+
+ @PostConstruct
+ public void init() {
+ this.listener.setQueue(this.spans);
+ }
+
+ public void clear() {
+ this.spans.clear();
+ }
+ }
+}