Polishing

This commit is contained in:
Sam Brannen
2019-12-13 16:12:39 +01:00
parent bee2b7cd73
commit 47b18e5ea9
2 changed files with 126 additions and 128 deletions

View File

@@ -79,7 +79,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Chris Beams
* @author Sam Brannen
*/
public class XmlBeanFactoryTests {
class XmlBeanFactoryTests {
private static final Class<?> CLASS = XmlBeanFactoryTests.class;
private static final String CLASSNAME = CLASS.getSimpleName();
@@ -125,14 +125,14 @@ public class XmlBeanFactoryTests {
@Test // SPR-2368
public void testCollectionsReferredToAsRefLocals() {
void collectionsReferredToAsRefLocals() {
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(factory).loadBeanDefinitions(COLLECTIONS_XSD_CONTEXT);
factory.preInstantiateSingletons();
}
@Test
public void testRefToSeparatePrototypeInstances() {
void refToSeparatePrototypeInstances() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
@@ -151,7 +151,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testRefToSingleton() {
void refToSingleton() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
@@ -167,7 +167,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testInnerBeans() throws IOException {
void innerBeans() throws IOException {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
@@ -245,7 +245,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testInnerBeansWithoutDestroy() {
void innerBeansWithoutDestroy() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
@@ -279,7 +279,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testFailsOnInnerBean() {
void failsOnInnerBean() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
@@ -307,7 +307,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testInheritanceFromParentFactoryPrototype() {
void inheritanceFromParentFactoryPrototype() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@@ -323,7 +323,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testInheritanceWithDifferentClass() {
void inheritanceWithDifferentClass() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@@ -338,7 +338,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testInheritanceWithClass() {
void inheritanceWithClass() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@@ -353,7 +353,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testPrototypeInheritanceFromParentFactoryPrototype() {
void prototypeInheritanceFromParentFactoryPrototype() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@@ -373,7 +373,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testPrototypeInheritanceFromParentFactorySingleton() {
void prototypeInheritanceFromParentFactorySingleton() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@@ -392,7 +392,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testAutowireModeNotInherited() {
void autowireModeNotInherited() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(OVERRIDES_CONTEXT);
@@ -407,7 +407,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testAbstractParentBeans() {
void abstractParentBeans() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
parent.preInstantiateSingletons();
@@ -428,7 +428,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testDependenciesMaterializeThis() {
void dependenciesMaterializeThis() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(DEP_MATERIALIZE_CONTEXT);
@@ -447,7 +447,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testChildOverridesParentBean() {
void childOverridesParentBean() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@@ -466,7 +466,7 @@ public class XmlBeanFactoryTests {
* If a singleton does this the factory will fail to load.
*/
@Test
public void testBogusParentageFromParentFactory() {
void bogusParentageFromParentFactory() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@@ -483,7 +483,7 @@ public class XmlBeanFactoryTests {
* instances even if derived from a prototype
*/
@Test
public void testSingletonInheritsFromParentFactoryPrototype() {
void singletonInheritsFromParentFactoryPrototype() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@@ -498,7 +498,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testSingletonFromParent() {
void singletonFromParent() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
TestBean beanFromParent = (TestBean) parent.getBean("inheritedTestBeanSingleton");
@@ -509,7 +509,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testNestedPropertyValue() {
void nestedPropertyValue() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@@ -519,7 +519,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testCircularReferences() {
void circularReferences() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
@@ -537,47 +537,47 @@ public class XmlBeanFactoryTests {
}
@Test
public void testCircularReferencesWithConstructor() {
void circularReferencesWithConstructor() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
reader.loadBeanDefinitions(REFTYPES_CONTEXT);
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
xbf.getBean("jenny_constructor"))
assertThatExceptionOfType(BeanCreationException.class)
.isThrownBy(() -> xbf.getBean("jenny_constructor"))
.matches(ex -> ex.contains(BeanCurrentlyInCreationException.class));
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
xbf.getBean("david_constructor"))
assertThatExceptionOfType(BeanCreationException.class)
.isThrownBy(() -> xbf.getBean("david_constructor"))
.matches(ex -> ex.contains(BeanCurrentlyInCreationException.class));
}
@Test
public void testCircularReferencesWithPrototype() {
void circularReferencesWithPrototype() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
reader.loadBeanDefinitions(REFTYPES_CONTEXT);
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
xbf.getBean("jenny_prototype"))
assertThatExceptionOfType(BeanCreationException.class)
.isThrownBy(() -> xbf.getBean("jenny_prototype"))
.matches(ex -> ex.contains(BeanCurrentlyInCreationException.class));
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
xbf.getBean("david_prototype"))
assertThatExceptionOfType(BeanCreationException.class)
.isThrownBy(() -> xbf.getBean("david_prototype"))
.matches(ex -> ex.contains(BeanCurrentlyInCreationException.class));
}
@Test
public void testCircularReferencesWithDependOn() {
void circularReferencesWithDependOn() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
reader.loadBeanDefinitions(REFTYPES_CONTEXT);
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
xbf.getBean("jenny_depends_on"));
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
xbf.getBean("david_depends_on"));
assertThatExceptionOfType(BeanCreationException.class)
.isThrownBy(() -> xbf.getBean("jenny_depends_on"));
assertThatExceptionOfType(BeanCreationException.class)
.isThrownBy(() -> xbf.getBean("david_depends_on"));
}
@Test
public void testCircularReferenceWithFactoryBeanFirst() {
void circularReferenceWithFactoryBeanFirst() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
@@ -588,7 +588,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testCircularReferenceWithTwoFactoryBeans() {
void circularReferenceWithTwoFactoryBeans() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
@@ -600,7 +600,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testCircularReferencesWithNotAllowed() {
void circularReferencesWithNotAllowed() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
xbf.setAllowCircularReferences(false);
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
@@ -612,7 +612,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testCircularReferencesWithWrapping() {
void circularReferencesWithWrapping() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
@@ -624,7 +624,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testCircularReferencesWithWrappingAndRawInjectionAllowed() {
void circularReferencesWithWrappingAndRawInjectionAllowed() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
xbf.setAllowRawInjectionDespiteWrapping(true);
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
@@ -645,7 +645,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testFactoryReferenceCircle() {
void factoryReferenceCircle() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(FACTORY_CIRCLE_CONTEXT);
TestBean tb = (TestBean) xbf.getBean("singletonFactory");
@@ -654,14 +654,14 @@ public class XmlBeanFactoryTests {
}
@Test
public void testFactoryReferenceWithDoublePrefix() {
void factoryReferenceWithDoublePrefix() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(FACTORY_CIRCLE_CONTEXT);
assertThat(xbf.getBean("&&singletonFactory")).isInstanceOf(DummyFactory.class);
}
@Test
public void testComplexFactoryReferenceCircle() {
void complexFactoryReferenceCircle() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(COMPLEX_FACTORY_CIRCLE_CONTEXT);
xbf.getBean("proxy1");
@@ -673,7 +673,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void noSuchFactoryBeanMethod() {
void noSuchFactoryBeanMethod() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(NO_SUCH_FACTORY_METHOD_CONTEXT);
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
@@ -681,7 +681,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testInitMethodIsInvoked() {
void initMethodIsInvoked() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT);
DoubleInitializer in = (DoubleInitializer) xbf.getBean("init-method1");
@@ -693,7 +693,7 @@ public class XmlBeanFactoryTests {
* Test that if a custom initializer throws an exception, it's handled correctly
*/
@Test
public void testInitMethodThrowsException() {
void initMethodThrowsException() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT);
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
@@ -706,7 +706,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testNoSuchInitMethod() {
void noSuchInitMethod() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT);
assertThatExceptionOfType(FatalBeanException.class).isThrownBy(() ->
@@ -720,7 +720,7 @@ public class XmlBeanFactoryTests {
* Check that InitializingBean method is called first.
*/
@Test
public void testInitializingBeanAndInitMethod() {
void initializingBeanAndInitMethod() {
InitAndIB.constructed = false;
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT);
@@ -741,7 +741,7 @@ public class XmlBeanFactoryTests {
* Check that InitializingBean method is not called twice.
*/
@Test
public void testInitializingBeanAndSameInitMethod() {
void initializingBeanAndSameInitMethod() {
InitAndIB.constructed = false;
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT);
@@ -759,7 +759,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testDefaultLazyInit() {
void defaultLazyInit() {
InitAndIB.constructed = false;
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(DEFAULT_LAZY_CONTEXT);
@@ -775,21 +775,21 @@ public class XmlBeanFactoryTests {
}
@Test
public void noSuchXmlFile() {
void noSuchXmlFile() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() ->
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(MISSING_CONTEXT));
}
@Test
public void invalidXmlFile() {
void invalidXmlFile() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() ->
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INVALID_CONTEXT));
}
@Test
public void testAutowire() {
void autowire() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(AUTOWIRE_CONTEXT);
TestBean spouse = new TestBean("kerry", 0);
@@ -798,7 +798,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testAutowireWithParent() {
void autowireWithParent() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(AUTOWIRE_CONTEXT);
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
@@ -855,7 +855,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testAutowireWithDefault() {
void autowireWithDefault() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(DEFAULT_AUTOWIRE_CONTEXT);
@@ -871,7 +871,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testAutowireByConstructor() {
void autowireByConstructor() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
ConstructorDependenciesBean rod1 = (ConstructorDependenciesBean) xbf.getBean("rod1");
@@ -909,7 +909,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testAutowireByConstructorWithSimpleValues() {
void autowireByConstructorWithSimpleValues() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
@@ -939,7 +939,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testRelatedCausesFromConstructorResolution() {
void relatedCausesFromConstructorResolution() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
@@ -954,7 +954,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testConstructorArgResolution() {
void constructorArgResolution() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
TestBean kerry1 = (TestBean) xbf.getBean("kerry1");
@@ -1003,7 +1003,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testPrototypeWithExplicitArguments() {
void prototypeWithExplicitArguments() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
SimpleConstructorArgBean cd1 = (SimpleConstructorArgBean) xbf.getBean("rod18");
@@ -1019,7 +1019,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testConstructorArgWithSingleMatch() {
void constructorArgWithSingleMatch() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
File file = (File) xbf.getBean("file");
@@ -1027,7 +1027,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void throwsExceptionOnTooManyArguments() {
void throwsExceptionOnTooManyArguments() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
@@ -1035,7 +1035,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void throwsExceptionOnAmbiguousResolution() {
void throwsExceptionOnAmbiguousResolution() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(() ->
@@ -1043,52 +1043,52 @@ public class XmlBeanFactoryTests {
}
@Test
public void testDependsOn() {
void dependsOn() {
doTestDependencies(DEP_DEPENDSON_CONTEXT, 1);
}
@Test
public void testDependsOnInInnerBean() {
void dependsOnInInnerBean() {
doTestDependencies(DEP_DEPENDSON_INNER_CONTEXT, 4);
}
@Test
public void testDependenciesThroughConstructorArguments() {
void dependenciesThroughConstructorArguments() {
doTestDependencies(DEP_CARG_CONTEXT, 1);
}
@Test
public void testDependenciesThroughConstructorArgumentAutowiring() {
void dependenciesThroughConstructorArgumentAutowiring() {
doTestDependencies(DEP_CARG_AUTOWIRE_CONTEXT, 1);
}
@Test
public void testDependenciesThroughConstructorArgumentsInInnerBean() {
void dependenciesThroughConstructorArgumentsInInnerBean() {
doTestDependencies(DEP_CARG_INNER_CONTEXT, 1);
}
@Test
public void testDependenciesThroughProperties() {
void dependenciesThroughProperties() {
doTestDependencies(DEP_PROP, 1);
}
@Test
public void testDependenciesThroughPropertiesWithInTheMiddle() {
void dependenciesThroughPropertiesWithInTheMiddle() {
doTestDependencies(DEP_PROP_MIDDLE_CONTEXT, 1);
}
@Test
public void testDependenciesThroughPropertyAutowiringByName() {
void dependenciesThroughPropertyAutowiringByName() {
doTestDependencies(DEP_PROP_ABN_CONTEXT, 1);
}
@Test
public void testDependenciesThroughPropertyAutowiringByType() {
void dependenciesThroughPropertyAutowiringByType() {
doTestDependencies(DEP_PROP_ABT_CONTEXT, 1);
}
@Test
public void testDependenciesThroughPropertiesInInnerBean() {
void dependenciesThroughPropertiesInInnerBean() {
doTestDependencies(DEP_PROP_INNER_CONTEXT, 1);
}
@@ -1120,7 +1120,7 @@ public class XmlBeanFactoryTests {
* must rather only be picked up when the bean is instantiated.
*/
@Test
public void testClassNotFoundWithDefaultBeanClassLoader() {
void classNotFoundWithDefaultBeanClassLoader() {
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(factory).loadBeanDefinitions(CLASS_NOT_FOUND_CONTEXT);
// cool, no errors, so the rubbish class name in the bean def was not resolved
@@ -1132,7 +1132,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testClassNotFoundWithNoBeanClassLoader() {
void classNotFoundWithNoBeanClassLoader() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(bf);
reader.setBeanClassLoader(null);
@@ -1141,7 +1141,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testResourceAndInputStream() throws IOException {
void resourceAndInputStream() throws IOException {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(RESOURCE_CONTEXT);
// comes from "resourceImport.xml"
@@ -1165,7 +1165,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testClassPathResourceWithImport() {
void classPathResourceWithImport() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(RESOURCE_CONTEXT);
// comes from "resourceImport.xml"
@@ -1175,7 +1175,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testUrlResourceWithImport() {
void urlResourceWithImport() {
URL url = getClass().getResource(RESOURCE_CONTEXT.getPath());
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(new UrlResource(url));
@@ -1186,7 +1186,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testFileSystemResourceWithImport() throws URISyntaxException {
void fileSystemResourceWithImport() throws URISyntaxException {
String file = getClass().getResource(RESOURCE_CONTEXT.getPath()).toURI().getPath();
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(new FileSystemResource(file));
@@ -1197,7 +1197,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void recursiveImport() {
void recursiveImport() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() ->
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(RECURSIVE_IMPORT_CONTEXT));
@@ -1209,7 +1209,8 @@ public class XmlBeanFactoryTests {
* @since 3.2.8 and 4.0.2
*/
@Test
public void methodInjectedBeanMustBeOfSameEnhancedCglibSubclassTypeAcrossBeanFactories() {
@SuppressWarnings("deprecation")
void methodInjectedBeanMustBeOfSameEnhancedCglibSubclassTypeAcrossBeanFactories() {
Class<?> firstClass = null;
for (int i = 0; i < 10; i++) {
@@ -1229,7 +1230,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void lookupOverrideMethodsWithSetterInjection() {
void lookupOverrideMethodsWithSetterInjection() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(OVERRIDES_CONTEXT);
@@ -1296,7 +1297,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testReplaceMethodOverrideWithSetterInjection() {
void replaceMethodOverrideWithSetterInjection() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(DELEGATION_OVERRIDES_CONTEXT);
@@ -1343,7 +1344,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void lookupOverrideOneMethodWithConstructorInjection() {
void lookupOverrideOneMethodWithConstructorInjection() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(CONSTRUCTOR_OVERRIDES_CONTEXT);
@@ -1366,7 +1367,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testRejectsOverrideOfBogusMethodName() {
void rejectsOverrideOfBogusMethodName() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(INVALID_NO_SUCH_METHOD_CONTEXT);
@@ -1376,7 +1377,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void serializableMethodReplacerAndSuperclass() throws IOException {
void serializableMethodReplacerAndSuperclass() throws IOException {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(DELEGATION_OVERRIDES_CONTEXT);
@@ -1389,7 +1390,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testInnerBeanInheritsScopeFromConcreteChildDefinition() {
void innerBeanInheritsScopeFromConcreteChildDefinition() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(OVERRIDES_CONTEXT);
@@ -1409,7 +1410,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testConstructorArgWithSingleSimpleTypeMatch() {
void constructorArgWithSingleSimpleTypeMatch() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
@@ -1421,7 +1422,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testConstructorArgWithDoubleSimpleTypeMatch() {
void constructorArgWithDoubleSimpleTypeMatch() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
@@ -1435,7 +1436,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testDoubleBooleanAutowire() {
void doubleBooleanAutowire() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
DoubleBooleanConstructorBean bean = (DoubleBooleanConstructorBean) xbf.getBean("beanWithDoubleBoolean");
@@ -1444,7 +1445,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testDoubleBooleanAutowireWithIndex() {
void doubleBooleanAutowireWithIndex() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
DoubleBooleanConstructorBean bean = (DoubleBooleanConstructorBean) xbf.getBean("beanWithDoubleBooleanAndIndex");
@@ -1453,7 +1454,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testLenientDependencyMatching() {
void lenientDependencyMatching() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
LenientDependencyTestBean bean = (LenientDependencyTestBean) xbf.getBean("lenientDependencyTestBean");
@@ -1461,7 +1462,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testLenientDependencyMatchingFactoryMethod() {
void lenientDependencyMatchingFactoryMethod() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
LenientDependencyTestBean bean = (LenientDependencyTestBean) xbf.getBean("lenientDependencyTestBeanFactoryMethod");
@@ -1469,7 +1470,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testNonLenientDependencyMatching() {
void nonLenientDependencyMatching() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("lenientDependencyTestBean");
@@ -1480,7 +1481,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testNonLenientDependencyMatchingFactoryMethod() {
void nonLenientDependencyMatchingFactoryMethod() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("lenientDependencyTestBeanFactoryMethod");
@@ -1491,7 +1492,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testJavaLangStringConstructor() {
void javaLangStringConstructor() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("string");
@@ -1501,7 +1502,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testCustomStringConstructor() {
void customStringConstructor() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("stringConstructor");
@@ -1511,7 +1512,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testPrimitiveConstructorArray() {
void primitiveConstructorArray() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
ConstructorArrayTestBean bean = (ConstructorArrayTestBean) xbf.getBean("constructorArray");
@@ -1521,7 +1522,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testIndexedPrimitiveConstructorArray() {
void indexedPrimitiveConstructorArray() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
ConstructorArrayTestBean bean = (ConstructorArrayTestBean) xbf.getBean("indexedConstructorArray");
@@ -1531,7 +1532,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testStringConstructorArrayNoType() {
void stringConstructorArrayNoType() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
ConstructorArrayTestBean bean = (ConstructorArrayTestBean) xbf.getBean("constructorArrayNoType");
@@ -1540,7 +1541,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testStringConstructorArrayNoTypeNonLenient() {
void stringConstructorArrayNoTypeNonLenient() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("constructorArrayNoType");
@@ -1551,7 +1552,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testConstructorWithUnresolvableParameterName() {
void constructorWithUnresolvableParameterName() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
AtomicInteger bean = (AtomicInteger) xbf.getBean("constructorUnresolvableName");
@@ -1561,7 +1562,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testWithDuplicateName() {
void withDuplicateName() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
assertThatExceptionOfType(BeansException.class).isThrownBy(() ->
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(TEST_WITH_DUP_NAMES_CONTEXT))
@@ -1569,7 +1570,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testWithDuplicateNameInAlias() {
void withDuplicateNameInAlias() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
assertThatExceptionOfType(BeansException.class).isThrownBy(() ->
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(TEST_WITH_DUP_NAME_IN_ALIAS_CONTEXT))
@@ -1577,7 +1578,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testOverrideMethodByArgTypeAttribute() {
void overrideMethodByArgTypeAttribute() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(DELEGATION_OVERRIDES_CONTEXT);
@@ -1587,7 +1588,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testOverrideMethodByArgTypeElement() {
void overrideMethodByArgTypeElement() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(DELEGATION_OVERRIDES_CONTEXT);
@@ -1596,7 +1597,7 @@ public class XmlBeanFactoryTests {
assertThat(oom.replaceMe("abc")).as("should replace").isEqualTo("cba");
}
public static class DoSomethingReplacer implements MethodReplacer {
static class DoSomethingReplacer implements MethodReplacer {
public Object lastArg;
@@ -1610,7 +1611,7 @@ public class XmlBeanFactoryTests {
}
public static class BadInitializer {
static class BadInitializer {
/** Init method */
public void init2() throws IOException {
@@ -1619,7 +1620,7 @@ public class XmlBeanFactoryTests {
}
public static class DoubleInitializer {
static class DoubleInitializer {
private int num;
@@ -1638,7 +1639,7 @@ public class XmlBeanFactoryTests {
}
public static class InitAndIB implements InitializingBean, DisposableBean {
static class InitAndIB implements InitializingBean, DisposableBean {
public static boolean constructed;
@@ -1685,7 +1686,7 @@ public class XmlBeanFactoryTests {
}
public static class PreparingBean1 implements DisposableBean {
static class PreparingBean1 implements DisposableBean {
public static boolean prepared = false;
@@ -1702,7 +1703,7 @@ public class XmlBeanFactoryTests {
}
public static class PreparingBean2 implements DisposableBean {
static class PreparingBean2 implements DisposableBean {
public static boolean prepared = false;
@@ -1719,7 +1720,7 @@ public class XmlBeanFactoryTests {
}
public static class DependingBean implements InitializingBean, DisposableBean {
static class DependingBean implements InitializingBean, DisposableBean {
public static int destroyCount = 0;
@@ -1758,7 +1759,7 @@ public class XmlBeanFactoryTests {
}
public static class InTheMiddleBean {
static class InTheMiddleBean {
public void setBean1(PreparingBean1 bean1) {
}
@@ -1768,7 +1769,7 @@ public class XmlBeanFactoryTests {
}
public static class HoldingBean implements DisposableBean {
static class HoldingBean implements DisposableBean {
public static int destroyCount = 0;
@@ -1791,7 +1792,7 @@ public class XmlBeanFactoryTests {
}
public static class DoubleBooleanConstructorBean {
static class DoubleBooleanConstructorBean {
private Boolean boolean1;
private Boolean boolean2;
@@ -1815,7 +1816,7 @@ public class XmlBeanFactoryTests {
}
public static class LenientDependencyTestBean {
static class LenientDependencyTestBean {
public final ITestBean tb;
@@ -1850,7 +1851,7 @@ public class XmlBeanFactoryTests {
}
public static class ConstructorArrayTestBean {
static class ConstructorArrayTestBean {
public final Object array;
@@ -1872,7 +1873,7 @@ public class XmlBeanFactoryTests {
}
public static class StringConstructorTestBean {
static class StringConstructorTestBean {
public final String name;
@@ -1882,7 +1883,7 @@ public class XmlBeanFactoryTests {
}
public static class WrappingPostProcessor implements BeanPostProcessor {
static class WrappingPostProcessor implements BeanPostProcessor {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {