Added a test for a pollable channel

This commit is contained in:
Marcin Grzejszczak
2018-01-11 11:17:49 +01:00
parent 2ac0b6187a
commit 89176772bc
2 changed files with 22 additions and 1 deletions

View File

@@ -219,5 +219,4 @@ public class TraceChannelInterceptor extends AbstractTraceChannelInterceptor {
getErrorParser().parseErrorTags(getTracer().getCurrentSpan(), ex);
}
}
}

View File

@@ -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();