Fixed wrong merging
This commit is contained in:
@@ -15,8 +15,9 @@
|
||||
*/
|
||||
package integration;
|
||||
|
||||
import com.github.kristofa.brave.LoggingSpanCollector;
|
||||
import com.twitter.zipkin.gen.Span;
|
||||
import io.zipkin.Span;
|
||||
import lombok.extern.apachecommons.CommonsLog;
|
||||
import org.springframework.cloud.sleuth.zipkin.ZipkinSpanReporter;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
@@ -27,13 +28,14 @@ import java.util.List;
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public class IntegrationTestSpanCollector extends LoggingSpanCollector {
|
||||
@CommonsLog
|
||||
public class IntegrationTestZipkinSpanReporter implements ZipkinSpanReporter {
|
||||
|
||||
public List<Span> hashedSpans = Collections.<Span>synchronizedList(new LinkedList<Span>());
|
||||
public List<Span> hashedSpans = Collections.synchronizedList(new LinkedList<>());
|
||||
|
||||
@Override
|
||||
public void collect(Span span) {
|
||||
super.collect(span);
|
||||
public void report(Span span) {
|
||||
log.info(span);
|
||||
hashedSpans.add(span);
|
||||
}
|
||||
|
||||
@@ -15,31 +15,26 @@
|
||||
*/
|
||||
package integration;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import integration.MessagingApplicationTests.IntegrationSpanCollectorConfig;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
import org.springframework.cloud.sleuth.zipkin.ZipkinSpanReporter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.util.JdkIdGenerator;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.github.kristofa.brave.SpanCollector;
|
||||
import com.twitter.zipkin.gen.BinaryAnnotation;
|
||||
import com.twitter.zipkin.gen.Span;
|
||||
|
||||
import integration.MessagingApplicationTests.IntegrationSpanCollectorConfig;
|
||||
import sample.SampleMessagingApplication;
|
||||
import tools.AbstractIntegrationTest;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration(classes = { IntegrationSpanCollectorConfig.class, SampleMessagingApplication.class })
|
||||
@WebIntegrationTest
|
||||
@@ -48,7 +43,7 @@ public class MessagingApplicationTests extends AbstractIntegrationTest {
|
||||
|
||||
private static int port = 3381;
|
||||
private static String sampleAppUrl = "http://localhost:" + port;
|
||||
@Autowired IntegrationTestSpanCollector integrationTestSpanCollector;
|
||||
@Autowired IntegrationTestZipkinSpanReporter integrationTestSpanCollector;
|
||||
|
||||
@After
|
||||
public void cleanup() {
|
||||
@@ -79,21 +74,21 @@ public class MessagingApplicationTests extends AbstractIntegrationTest {
|
||||
}
|
||||
|
||||
private void thenThereIsAtLeastOneBinaryAnnotationWithKey(String binaryAnnotationKey) {
|
||||
then(reporter.hashedSpans.stream()
|
||||
then(integrationTestSpanCollector.hashedSpans.stream()
|
||||
.map(s -> s.binaryAnnotations)
|
||||
.flatMap(Collection::stream)
|
||||
.anyMatch(b -> b.key.equals(binaryAnnotationKey))).isTrue();
|
||||
}
|
||||
|
||||
private void thenAllSpansHaveTraceIdEqualTo(String traceId) {
|
||||
then(this.integrationTestSpanCollector.hashedSpans.stream().allMatch(span -> span.getTrace_id() == zipkinHashedTraceId(traceId))).isTrue();
|
||||
then(integrationTestSpanCollector.hashedSpans.stream().allMatch(span -> span.traceId == zipkinHashedTraceId(traceId))).isTrue();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
public static class IntegrationSpanCollectorConfig {
|
||||
@Bean
|
||||
SpanCollector integrationTestSpanCollector() {
|
||||
return new IntegrationTestSpanCollector();
|
||||
ZipkinSpanReporter integrationTestZipkinSpanReporter() {
|
||||
return new IntegrationTestZipkinSpanReporter();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user