Skip to content

Instantly share code, notes, and snippets.

@gavlyukovskiy
Last active February 21, 2017 12:04
Show Gist options
  • Save gavlyukovskiy/6dc65992d85805710bcb871351708c5e to your computer and use it in GitHub Desktop.
Save gavlyukovskiy/6dc65992d85805710bcb871351708c5e to your computer and use it in GitHub Desktop.
package org.springframework.cloud.sleuth.annotation;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.sleuth.SpanReporter;
import org.springframework.cloud.sleuth.annotation.SleuthSpanCreatorCircularDependencyTests.TestConfiguration;
import org.springframework.cloud.sleuth.util.ArrayListSpanAccumulator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@SpringBootTest(classes = TestConfiguration.class)
@RunWith(SpringJUnit4ClassRunner.class)
public class SleuthSpanCreatorCircularDependencyTests {
@Test
public void contextLoads() throws Exception {
}
private static class Service1 {
@Autowired
private Service2 service2;
@NewSpan
public void foo() {
}
}
private static class Service2 {
@Autowired
private Service1 service1;
@NewSpan
public void bar() {
}
}
@Configuration
@EnableAutoConfiguration
protected static class TestConfiguration {
@Bean
SpanReporter spanReporter() {
return new ArrayListSpanAccumulator();
}
@Bean
public Service1 service1() {
return new Service1();
}
@Bean
public Service2 service2() {
return new Service2();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment