Revised test for ImportBeanDefinitionRegistrar double scan

Issue: SPR-12334
(cherry picked from commit 6e5711a)
This commit is contained in:
Juergen Hoeller
2014-10-22 02:16:39 +02:00
parent 3106905877
commit a2731f1a4f
2 changed files with 18 additions and 11 deletions

View File

@@ -33,6 +33,8 @@ public class Spr12334Tests {
@Test
public void shouldNotScanTwice() {
TestImport.scanned = false;
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
context.scan(TestImport.class.getPackage().getName());
context.refresh();
@@ -53,14 +55,14 @@ public class Spr12334Tests {
public static class TestImport implements ImportBeanDefinitionRegistrar {
private boolean scanned = false;
private static boolean scanned = false;
@Override
public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) {
if (this.scanned) {
if (scanned) {
throw new IllegalStateException("Already scanned");
}
this.scanned = true;
scanned = true;
}
}