|
|
|
|
@ -109,6 +109,19 @@ class BeanCurrentlyInCreationFailureAnalyzerTests {
@@ -109,6 +109,19 @@ class BeanCurrentlyInCreationFailureAnalyzerTests {
|
|
|
|
|
assertThat(lines.get(11)).isEqualTo("└─────┘"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void testSelfReferenceCycle() throws IOException { |
|
|
|
|
FailureAnalysis analysis = performAnalysis(SelfReferenceBeanConfiguration.class); |
|
|
|
|
List<String> lines = readDescriptionLines(analysis); |
|
|
|
|
assertThat(lines).hasSize(5); |
|
|
|
|
assertThat(lines.get(0)) |
|
|
|
|
.isEqualTo("The dependencies of some of the beans in the application context form a cycle:"); |
|
|
|
|
assertThat(lines.get(1)).isEqualTo(""); |
|
|
|
|
assertThat(lines.get(2)).isEqualTo("┌──->──┐"); |
|
|
|
|
assertThat(lines.get(3)).startsWith("| bean defined in " + SelfReferenceBeanConfiguration.class.getName()); |
|
|
|
|
assertThat(lines.get(4)).isEqualTo("└──<-──┘"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void cycleWithAnUnknownStartIsNotAnalyzed() { |
|
|
|
|
assertThat(this.analyzer.analyze(new BeanCurrentlyInCreationException("test"))).isNull(); |
|
|
|
|
@ -137,6 +150,7 @@ class BeanCurrentlyInCreationFailureAnalyzerTests {
@@ -137,6 +150,7 @@ class BeanCurrentlyInCreationFailureAnalyzerTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@org.springframework.context.annotation.Configuration(proxyBeanMethods = false) |
|
|
|
|
@SuppressWarnings("unused") |
|
|
|
|
static class CyclicBeanMethodsConfiguration { |
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
@ -167,6 +181,7 @@ class BeanCurrentlyInCreationFailureAnalyzerTests {
@@ -167,6 +181,7 @@ class BeanCurrentlyInCreationFailureAnalyzerTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false) |
|
|
|
|
@SuppressWarnings("unused") |
|
|
|
|
static class CycleReferencedViaOtherBeansConfiguration { |
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
@ -231,6 +246,7 @@ class BeanCurrentlyInCreationFailureAnalyzerTests {
@@ -231,6 +246,7 @@ class BeanCurrentlyInCreationFailureAnalyzerTests {
|
|
|
|
|
@org.springframework.context.annotation.Configuration(proxyBeanMethods = false) |
|
|
|
|
static class BeanThreeConfiguration { |
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unused") |
|
|
|
|
@Bean |
|
|
|
|
BeanThree three(BeanOne one) { |
|
|
|
|
return new BeanThree(); |
|
|
|
|
@ -240,6 +256,17 @@ class BeanCurrentlyInCreationFailureAnalyzerTests {
@@ -240,6 +256,17 @@ class BeanCurrentlyInCreationFailureAnalyzerTests {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false) |
|
|
|
|
static class SelfReferenceBeanConfiguration { |
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unused") |
|
|
|
|
@Bean |
|
|
|
|
SelfReferenceBean bean(SelfReferenceBean bean) { |
|
|
|
|
return new SelfReferenceBean(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static class RefererOne { |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
@ -266,4 +293,11 @@ class BeanCurrentlyInCreationFailureAnalyzerTests {
@@ -266,4 +293,11 @@ class BeanCurrentlyInCreationFailureAnalyzerTests {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static class SelfReferenceBean { |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
SelfReferenceBean bean; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|