|
23 | 23 |
|
24 | 24 | import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
25 | 25 | import org.springframework.context.annotation.Bean;
|
| 26 | +import org.springframework.context.annotation.ComponentScan; |
26 | 27 | import org.springframework.context.annotation.Configuration;
|
27 | 28 | import org.springframework.context.annotation.Import;
|
28 | 29 | import org.springframework.stereotype.Component;
|
@@ -74,6 +75,20 @@ void contextCustomizerEqualsAndHashCode() {
|
74 | 75 | assertThat(customizer3).isEqualTo(customizer4);
|
75 | 76 | }
|
76 | 77 |
|
| 78 | + @Test |
| 79 | + void contextCustomizerEqualsAndHashCodeConsidersComponentScan() { |
| 80 | + ContextCustomizer customizer1 = this.factory |
| 81 | + .createContextCustomizer(TestWithImportAndComponentScanOfSomePackage.class, null); |
| 82 | + ContextCustomizer customizer2 = this.factory |
| 83 | + .createContextCustomizer(TestWithImportAndComponentScanOfSomePackage.class, null); |
| 84 | + ContextCustomizer customizer3 = this.factory |
| 85 | + .createContextCustomizer(TestWithImportAndComponentScanOfAnotherPackage.class, null); |
| 86 | + assertThat(customizer1.hashCode()).isEqualTo(customizer2.hashCode()); |
| 87 | + assertThat(customizer1).isEqualTo(customizer2); |
| 88 | + assertThat(customizer3.hashCode()).isNotEqualTo(customizer2.hashCode()).isNotEqualTo(customizer1.hashCode()); |
| 89 | + assertThat(customizer3).isNotEqualTo(customizer2).isNotEqualTo(customizer1); |
| 90 | + } |
| 91 | + |
77 | 92 | @Test
|
78 | 93 | void getContextCustomizerWhenClassHasBeanMethodsShouldThrowException() {
|
79 | 94 | assertThatIllegalStateException()
|
@@ -105,6 +120,18 @@ static class TestWithImport {
|
105 | 120 |
|
106 | 121 | }
|
107 | 122 |
|
| 123 | + @Import(ImportedBean.class) |
| 124 | + @ComponentScan("some.package") |
| 125 | + static class TestWithImportAndComponentScanOfSomePackage { |
| 126 | + |
| 127 | + } |
| 128 | + |
| 129 | + @Import(ImportedBean.class) |
| 130 | + @ComponentScan("another.package") |
| 131 | + static class TestWithImportAndComponentScanOfAnotherPackage { |
| 132 | + |
| 133 | + } |
| 134 | + |
108 | 135 | @MetaImport
|
109 | 136 | static class TestWithMetaImport {
|
110 | 137 |
|
|
0 commit comments