Added a test for a pollable channel
This commit is contained in:
@@ -219,5 +219,4 @@ public class TraceChannelInterceptor extends AbstractTraceChannelInterceptor {
|
||||
getErrorParser().parseErrorTags(getTracer().getCurrentSpan(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.support.ChannelInterceptor;
|
||||
import org.springframework.messaging.support.ChannelInterceptorAdapter;
|
||||
import org.springframework.messaging.support.ErrorMessage;
|
||||
@@ -89,6 +90,10 @@ public class TraceChannelInterceptorTests implements MessageHandler {
|
||||
@Qualifier("ignoredChannel")
|
||||
private DirectChannel ignoredChannel;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("tracedPollableChannel")
|
||||
private QueueChannel queueChannel;
|
||||
|
||||
@Autowired
|
||||
private Tracer tracer;
|
||||
|
||||
@@ -129,6 +134,18 @@ public class TraceChannelInterceptorTests implements MessageHandler {
|
||||
this.accumulator.getSpans().clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldWorkForQueue() {
|
||||
this.queueChannel.send(MessageBuilder.withPayload("hi").build());
|
||||
this.message = this.queueChannel.receive();
|
||||
assertNotNull("message was null", this.message);
|
||||
|
||||
String spanId = this.message.getHeaders().get(TraceMessageHeaders.SPAN_ID_NAME, String.class);
|
||||
then(spanId).isNotNull();
|
||||
then(TestSpanContextHolder.getCurrentSpan()).isNull();
|
||||
then(this.accumulator.getSpans()).isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonExportableSpanCreation() {
|
||||
this.tracedChannel.send(MessageBuilder.withPayload("hi")
|
||||
@@ -413,6 +430,11 @@ public class TraceChannelInterceptorTests implements MessageHandler {
|
||||
return new ExecutorChannel(Executors.newSingleThreadExecutor());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PollableChannel tracedPollableChannel() {
|
||||
return new QueueChannel(10);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DirectChannel tracedChannel() {
|
||||
return new DirectChannel();
|
||||
|
||||
Reference in New Issue
Block a user