Made tests less brittle
This commit is contained in:
@@ -32,6 +32,7 @@ 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.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -40,12 +41,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;
|
||||
@@ -166,9 +165,5 @@ public class ITTracingChannelInterceptor implements MessageHandler {
|
||||
return new MessagingTemplate(directChannel());
|
||||
}
|
||||
|
||||
@Bean @GlobalChannelInterceptor
|
||||
public ChannelInterceptor tracingChannelInterceptor(Tracing tracing) {
|
||||
return TracingChannelInterceptor.create(tracing);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -70,6 +70,7 @@ public class TracingOnScheduledTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void should_have_span_set_after_scheduled_method_has_been_executed() {
|
||||
await().atMost(10, SECONDS).untilAsserted(() -> {
|
||||
then(this.beanWithScheduledMethod.isExecuted()).isTrue();
|
||||
@@ -109,7 +110,7 @@ public class TracingOnScheduledTests {
|
||||
then(storedSpan).isNotNull();
|
||||
then(storedSpan.context().traceId()).isNotNull();
|
||||
zipkin2.Span foundSpan = this.reporter.getSpans().stream()
|
||||
.filter(span -> !span.tags().containsKey("error"))
|
||||
.filter(span -> !span.tags().containsKey("error") && span.tags().containsValue("TestBeanWithScheduledMethod"))
|
||||
.findFirst().orElseThrow(() -> new AssertionError("Span is missing"));
|
||||
then(foundSpan.tags())
|
||||
.contains(new AbstractMap.SimpleEntry<>("class", "TestBeanWithScheduledMethod"),
|
||||
|
||||
Reference in New Issue
Block a user