Added tests for exporting to Zipkin

This commit is contained in:
Marcin Grzejszczak
2016-03-23 14:28:06 +01:00
parent e31edbd254
commit 184afe698d
2 changed files with 28 additions and 0 deletions

View File

@@ -16,6 +16,7 @@
package org.springframework.cloud.sleuth.stream;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.atLeastOnce;
@@ -125,6 +126,24 @@ public class StreamSpanListenerTests {
verify(this.counterService, atLeastOnce()).increment(anyString());
}
@Test
public void shouldNotReportToZipkinWhenSpanIsNotExportable() {
Span span = Span.builder().exportable(false).build();
this.spanReporter.report(span);
assertThat(this.test.spans).isEmpty();
}
@Test
public void shouldReportToZipkinWhenSpanIsExportable() {
Span span = Span.builder().exportable(true).build();
this.spanReporter.report(span);
assertThat(this.test.spans).isNotEmpty();
}
@Configuration
@Import({ ZipkinTestConfiguration.class, SleuthStreamAutoConfiguration.class,
TraceMetricsAutoConfiguration.class, TestSupportBinderAutoConfiguration.class,

View File

@@ -176,6 +176,15 @@ public class ZipkinSpanListenerTests {
.containsOnly("fooservice");
}
@Test
public void shouldNotReportToZipkinWhenSpanIsNotExportable() {
Span span = Span.builder().exportable(false).build();
this.spanReporter.report(span);
assertThat(this.test.zipkinSpans).isEmpty();
}
@Configuration
@EnableAutoConfiguration
protected static class TestConfiguration {