@@ -0,0 +1,1950 @@
+/*%0A * Copyright 2002-2014 the original author or authors.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage org.springframework.context.annotation.spr12334;%0A%0Aimport org.junit.Test;%0A%0Aimport org.springframework.beans.factory.support.BeanDefinitionRegistry;%0Aimport org.springframework.context.annotation.AnnotationConfigApplicationContext;%0Aimport org.springframework.context.annotation.Configuration;%0Aimport org.springframework.context.annotation.Import;%0Aimport org.springframework.context.annotation.ImportBeanDefinitionRegistrar;%0Aimport org.springframework.core.type.AnnotationMetadata;%0A%0A/**%0A * @author Juergen Hoeller%0A * @author Alex Pogrebnyak%0A */%0Apublic class Spr12334Tests %7B%0A%0A%09@Test%0A%09public void shouldNotScanTwice() %7B%0A%09%09AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();%0A%09%09context.scan(TestImport.class.getPackage().getName());%0A%09%09context.refresh();%0A%09%09context.getBean(TestConfiguration.class);%0A%09%7D%0A%0A%0A%09@Import(TestImport.class)%0A%09public @interface AnotherImport %7B%0A%09%7D%0A%0A%0A%09@Configuration%0A%09@AnotherImport%0A%09public static class TestConfiguration %7B%0A%09%7D%0A%0A%0A%09public static class TestImport implements ImportBeanDefinitionRegistrar %7B%0A%0A%09%09private boolean scanned = false;%0A%0A%09%09@Override%0A%09%09public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry)  %7B%0A%09%09%09if (this.scanned) %7B%0A%09%09%09%09throw new IllegalStateException(%22Already scanned%22);%0A%09%09%09%7D%0A%09%09%09this.scanned = true;%0A%09%09%7D%0A%09%7D%0A%0A%7D%0A

Test for ImportBeanDefinitionRegistrar double scan