RESOLVED - issue SPR-6779: imported @Configuration classes do not get enhanced and fail to satisfy scoping requirements
refactoring, polishing.
This commit is contained in:
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.context.annotation.configuration;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.sameInstance;
|
||||
@@ -7,6 +23,7 @@ import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -59,7 +76,12 @@ public class ImportedConfigurationClassEnhancementTests {
|
||||
assertThat("got two distinct instances of testBean when singleton scoping was expected",
|
||||
testBean1, sameInstance(testBean2));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(expected=BeanDefinitionParsingException.class)
|
||||
public void importingAnNonConfigurationClassCausesIllegalArgumentException() {
|
||||
new AnnotationConfigApplicationContext(ConfigThatImportsNonConfigClass.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@@ -79,3 +101,7 @@ class ConfigThatDoesImport extends Config { }
|
||||
|
||||
@Configuration
|
||||
class ConfigThatDoesNotImport extends Config { }
|
||||
|
||||
@Configuration
|
||||
@Import(Void.class)
|
||||
class ConfigThatImportsNonConfigClass { }
|
||||
Reference in New Issue
Block a user