From 7a1a8e16238a073c3aec6c513cd2d864688bd3a4 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 17 Sep 2019 10:40:25 +0200 Subject: [PATCH] Polish DefaultListableBeanFactoryTests --- .../DefaultListableBeanFactoryTests.java | 365 +++++++++--------- 1 file changed, 182 insertions(+), 183 deletions(-) diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java index eb09368642..d2cf2619d8 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java @@ -126,7 +126,7 @@ import static org.mockito.Mockito.verify; * @author Phillip Webb * @author Stephane Nicoll */ -public class DefaultListableBeanFactoryTests { +class DefaultListableBeanFactoryTests { private static final Log factoryLog = LogFactory.getLog(DefaultListableBeanFactory.class); @@ -134,7 +134,7 @@ public class DefaultListableBeanFactoryTests { @Test - public void testUnreferencedSingletonWasInstantiated() { + void unreferencedSingletonWasInstantiated() { KnowsIfInstantiated.clearInstantiationRecord(); Properties p = new Properties(); p.setProperty("x1.(class)", KnowsIfInstantiated.class.getName()); @@ -145,7 +145,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testLazyInitialization() { + void lazyInitialization() { KnowsIfInstantiated.clearInstantiationRecord(); Properties p = new Properties(); p.setProperty("x1.(class)", KnowsIfInstantiated.class.getName()); @@ -161,7 +161,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testFactoryBeanDidNotCreatePrototype() { + void factoryBeanDidNotCreatePrototype() { Properties p = new Properties(); p.setProperty("x1.(class)", DummyFactory.class.getName()); // Reset static state @@ -182,7 +182,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testPrototypeFactoryBeanIgnoredByNonEagerTypeMatching() { + void prototypeFactoryBeanIgnoredByNonEagerTypeMatching() { Properties p = new Properties(); p.setProperty("x1.(class)", DummyFactory.class.getName()); // Reset static state @@ -216,7 +216,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testSingletonFactoryBeanIgnoredByNonEagerTypeMatching() { + void singletonFactoryBeanIgnoredByNonEagerTypeMatching() { Properties p = new Properties(); p.setProperty("x1.(class)", DummyFactory.class.getName()); // Reset static state @@ -250,7 +250,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testNonInitializedFactoryBeanIgnoredByNonEagerTypeMatching() { + void nonInitializedFactoryBeanIgnoredByNonEagerTypeMatching() { Properties p = new Properties(); p.setProperty("x1.(class)", DummyFactory.class.getName()); // Reset static state @@ -283,7 +283,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testInitializedFactoryBeanFoundByNonEagerTypeMatching() { + void initializedFactoryBeanFoundByNonEagerTypeMatching() { Properties p = new Properties(); p.setProperty("x1.(class)", DummyFactory.class.getName()); // Reset static state @@ -341,7 +341,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testStaticFactoryMethodFoundByNonEagerTypeMatching() { + void staticFactoryMethodFoundByNonEagerTypeMatching() { RootBeanDefinition rbd = new RootBeanDefinition(TestBeanFactory.class); rbd.setFactoryMethodName("createTestBean"); lbf.registerBeanDefinition("x1", rbd); @@ -365,7 +365,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testStaticPrototypeFactoryMethodFoundByNonEagerTypeMatching() { + void staticPrototypeFactoryMethodFoundByNonEagerTypeMatching() { RootBeanDefinition rbd = new RootBeanDefinition(TestBeanFactory.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); rbd.setFactoryMethodName("createTestBean"); @@ -390,7 +390,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testNonStaticFactoryMethodFoundByNonEagerTypeMatching() { + void nonStaticFactoryMethodFoundByNonEagerTypeMatching() { RootBeanDefinition factoryBd = new RootBeanDefinition(TestBeanFactory.class); lbf.registerBeanDefinition("factory", factoryBd); RootBeanDefinition rbd = new RootBeanDefinition(TestBeanFactory.class); @@ -417,7 +417,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testNonStaticPrototypeFactoryMethodFoundByNonEagerTypeMatching() { + void nonStaticPrototypeFactoryMethodFoundByNonEagerTypeMatching() { RootBeanDefinition factoryBd = new RootBeanDefinition(TestBeanFactory.class); lbf.registerBeanDefinition("factory", factoryBd); RootBeanDefinition rbd = new RootBeanDefinition(); @@ -473,7 +473,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testEmpty() { + void empty() { ListableBeanFactory lbf = new DefaultListableBeanFactory(); assertThat(lbf.getBeanDefinitionNames() != null).as("No beans defined --> array != null").isTrue(); assertThat(lbf.getBeanDefinitionNames().length == 0).as("No beans defined after no arg constructor").isTrue(); @@ -481,14 +481,14 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testEmptyPropertiesPopulation() { + void emptyPropertiesPopulation() { Properties p = new Properties(); (new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p); assertThat(lbf.getBeanDefinitionCount() == 0).as("No beans defined after ignorable invalid").isTrue(); } @Test - public void testHarmlessIgnorableRubbish() { + void harmlessIgnorableRubbish() { Properties p = new Properties(); p.setProperty("foo", "bar"); p.setProperty("qwert", "er"); @@ -497,18 +497,18 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testPropertiesPopulationWithNullPrefix() { + void propertiesPopulationWithNullPrefix() { Properties p = new Properties(); p.setProperty("test.(class)", TestBean.class.getName()); p.setProperty("test.name", "Tony"); p.setProperty("test.age", "48"); int count = (new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p); assertThat(count == 1).as("1 beans registered, not " + count).isTrue(); - testSingleTestBean(lbf); + singleTestBean(lbf); } @Test - public void testPropertiesPopulationWithPrefix() { + void propertiesPopulationWithPrefix() { String PREFIX = "beans."; Properties p = new Properties(); p.setProperty(PREFIX + "test.(class)", TestBean.class.getName()); @@ -516,11 +516,11 @@ public class DefaultListableBeanFactoryTests { p.setProperty(PREFIX + "test.age", "0x30"); int count = (new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p, PREFIX); assertThat(count == 1).as("1 beans registered, not " + count).isTrue(); - testSingleTestBean(lbf); + singleTestBean(lbf); } @Test - public void testSimpleReference() { + void simpleReference() { String PREFIX = "beans."; Properties p = new Properties(); @@ -543,7 +543,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testPropertiesWithDotsInKey() { + void propertiesWithDotsInKey() { Properties p = new Properties(); p.setProperty("tb.(class)", TestBean.class.getName()); @@ -558,7 +558,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testUnresolvedReference() { + void unresolvedReference() { String PREFIX = "beans."; Properties p = new Properties(); @@ -573,7 +573,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testSelfReference() { + void selfReference() { MutablePropertyValues pvs = new MutablePropertyValues(); pvs.add("spouse", new RuntimeBeanReference("self")); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); @@ -585,7 +585,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testReferenceByName() { + void referenceByName() { MutablePropertyValues pvs = new MutablePropertyValues(); pvs.add("doctor", new RuntimeBeanReference("doc")); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); @@ -598,7 +598,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testReferenceByType() { + void referenceByType() { MutablePropertyValues pvs = new MutablePropertyValues(); pvs.add("doctor", new RuntimeBeanReference(NestedTestBean.class)); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); @@ -611,7 +611,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testReferenceByAutowire() { + void referenceByAutowire() { MutablePropertyValues pvs = new MutablePropertyValues(); pvs.add("doctor", AutowiredPropertyMarker.INSTANCE); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); @@ -624,7 +624,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testArrayReferenceByName() { + void arrayReferenceByName() { MutablePropertyValues pvs = new MutablePropertyValues(); pvs.add("stringArray", new RuntimeBeanReference("string")); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); @@ -638,7 +638,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testArrayReferenceByType() { + void arrayReferenceByType() { MutablePropertyValues pvs = new MutablePropertyValues(); pvs.add("stringArray", new RuntimeBeanReference(String.class)); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); @@ -652,7 +652,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testArrayReferenceByAutowire() { + void arrayReferenceByAutowire() { MutablePropertyValues pvs = new MutablePropertyValues(); pvs.add("stringArray", AutowiredPropertyMarker.INSTANCE); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); @@ -668,7 +668,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testPossibleMatches() { + void possibleMatches() { MutablePropertyValues pvs = new MutablePropertyValues(); pvs.add("ag", "foobar"); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); @@ -686,7 +686,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testPrototype() { + void prototype() { Properties p = new Properties(); p.setProperty("kerry.(class)", TestBean.class.getName()); p.setProperty("kerry.age", "35"); @@ -720,7 +720,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testPrototypeCircleLeadsToException() { + void prototypeCircleLeadsToException() { Properties p = new Properties(); p.setProperty("kerry.(class)", TestBean.class.getName()); p.setProperty("kerry.(singleton)", "false"); @@ -738,7 +738,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testPrototypeExtendsPrototype() { + void prototypeExtendsPrototype() { Properties p = new Properties(); p.setProperty("wife.(class)", TestBean.class.getName()); p.setProperty("wife.name", "kerry"); @@ -780,7 +780,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testCanReferenceParentBeanFromChildViaAlias() { + void canReferenceParentBeanFromChildViaAlias() { final String EXPECTED_NAME = "Juergen"; final int EXPECTED_AGE = 41; @@ -805,7 +805,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testGetTypeWorksAfterParentChildMerging() { + void getTypeWorksAfterParentChildMerging() { RootBeanDefinition parentDefinition = new RootBeanDefinition(TestBean.class); ChildBeanDefinition childDefinition = new ChildBeanDefinition("parent", DerivedTestBean.class, null, null); @@ -819,7 +819,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testNameAlreadyBound() { + void nameAlreadyBound() { Properties p = new Properties(); p.setProperty("kerry.(class)", TestBean.class.getName()); p.setProperty("kerry.age", "35"); @@ -833,7 +833,7 @@ public class DefaultListableBeanFactoryTests { } } - private void testSingleTestBean(ListableBeanFactory lbf) { + private void singleTestBean(ListableBeanFactory lbf) { assertThat(lbf.getBeanDefinitionCount() == 1).as("1 beans defined").isTrue(); String[] names = lbf.getBeanDefinitionNames(); assertThat(names != lbf.getBeanDefinitionNames()).isTrue(); @@ -846,7 +846,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testAliasCircle() { + void aliasCircle() { lbf.registerAlias("test", "test2"); lbf.registerAlias("test2", "test3"); assertThatIllegalStateException().isThrownBy(() -> @@ -857,31 +857,33 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testBeanDefinitionOverriding() { + void beanDefinitionOverriding() { lbf.registerBeanDefinition("test", new RootBeanDefinition(TestBean.class)); lbf.registerBeanDefinition("test", new RootBeanDefinition(NestedTestBean.class)); lbf.registerAlias("otherTest", "test2"); lbf.registerAlias("test", "test2"); - assertThat(lbf.getBean("test") instanceof NestedTestBean).isTrue(); - assertThat(lbf.getBean("test2") instanceof NestedTestBean).isTrue(); + assertThat(lbf.getBean("test")).isInstanceOf(NestedTestBean.class); + assertThat(lbf.getBean("test2")).isInstanceOf(NestedTestBean.class); } @Test - public void testBeanDefinitionRemoval() { + void beanDefinitionRemoval() { lbf.setAllowBeanDefinitionOverriding(false); lbf.registerBeanDefinition("test", new RootBeanDefinition(TestBean.class)); lbf.registerAlias("test", "test2"); lbf.preInstantiateSingletons(); + assertThat(lbf.getBean("test")).isInstanceOf(TestBean.class); + assertThat(lbf.getBean("test2")).isInstanceOf(TestBean.class); lbf.removeBeanDefinition("test"); lbf.removeAlias("test2"); lbf.registerBeanDefinition("test", new RootBeanDefinition(NestedTestBean.class)); lbf.registerAlias("test", "test2"); - assertThat(lbf.getBean("test") instanceof NestedTestBean).isTrue(); - assertThat(lbf.getBean("test2") instanceof NestedTestBean).isTrue(); + assertThat(lbf.getBean("test")).isInstanceOf(NestedTestBean.class); + assertThat(lbf.getBean("test2")).isInstanceOf(NestedTestBean.class); } @Test - public void testBeanDefinitionOverridingNotAllowed() { + void beanDefinitionOverridingNotAllowed() { lbf.setAllowBeanDefinitionOverriding(false); BeanDefinition oldDef = new RootBeanDefinition(TestBean.class); BeanDefinition newDef = new RootBeanDefinition(NestedTestBean.class); @@ -896,17 +898,17 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testBeanDefinitionOverridingWithAlias() { + void beanDefinitionOverridingWithAlias() { lbf.registerBeanDefinition("test", new RootBeanDefinition(TestBean.class)); lbf.registerAlias("test", "testAlias"); lbf.registerBeanDefinition("test", new RootBeanDefinition(NestedTestBean.class)); lbf.registerAlias("test", "testAlias"); - assertThat(lbf.getBean("test") instanceof NestedTestBean).isTrue(); - assertThat(lbf.getBean("testAlias") instanceof NestedTestBean).isTrue(); + assertThat(lbf.getBean("test")).isInstanceOf(NestedTestBean.class); + assertThat(lbf.getBean("testAlias")).isInstanceOf(NestedTestBean.class); } @Test - public void testAliasChaining() { + void aliasChaining() { lbf.registerBeanDefinition("test", new RootBeanDefinition(NestedTestBean.class)); lbf.registerAlias("test", "testAlias"); lbf.registerAlias("testAlias", "testAlias2"); @@ -918,7 +920,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testBeanReferenceWithNewSyntax() { + void beanReferenceWithNewSyntax() { Properties p = new Properties(); p.setProperty("r.(class)", TestBean.class.getName()); p.setProperty("r.name", "rod"); @@ -932,7 +934,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testCanEscapeBeanReferenceSyntax() { + void canEscapeBeanReferenceSyntax() { String name = "*name"; Properties p = new Properties(); p.setProperty("r.(class)", TestBean.class.getName()); @@ -943,13 +945,10 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testCustomEditor() { - lbf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() { - @Override - public void registerCustomEditors(PropertyEditorRegistry registry) { + void customEditor() { + lbf.addPropertyEditorRegistrar(registry -> { NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN); registry.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, nf, true)); - } }); MutablePropertyValues pvs = new MutablePropertyValues(); pvs.add("myFloat", "1,1"); @@ -961,7 +960,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testCustomConverter() { + void customConverter() { GenericConversionService conversionService = new DefaultConversionService(); conversionService.addConverter(new Converter() { @Override @@ -986,7 +985,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testCustomEditorWithBeanReference() { + void customEditorWithBeanReference() { lbf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() { @Override public void registerCustomEditors(PropertyEditorRegistry registry) { @@ -1005,7 +1004,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testCustomTypeConverter() { + void customTypeConverter() { NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN); lbf.setTypeConverter(new CustomTypeConverter(nf)); MutablePropertyValues pvs = new MutablePropertyValues(); @@ -1021,7 +1020,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testCustomTypeConverterWithBeanReference() { + void customTypeConverterWithBeanReference() { NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN); lbf.setTypeConverter(new CustomTypeConverter(nf)); MutablePropertyValues pvs = new MutablePropertyValues(); @@ -1038,7 +1037,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testRegisterExistingSingletonWithReference() { + void registerExistingSingletonWithReference() { Properties p = new Properties(); p.setProperty("test.(class)", TestBean.class.getName()); p.setProperty("test.name", "Tony"); @@ -1074,7 +1073,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testRegisterExistingSingletonWithNameOverriding() { + void registerExistingSingletonWithNameOverriding() { Properties p = new Properties(); p.setProperty("test.(class)", TestBean.class.getName()); p.setProperty("test.name", "Tony"); @@ -1112,7 +1111,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testRegisterExistingSingletonWithAutowire() { + void registerExistingSingletonWithAutowire() { MutablePropertyValues pvs = new MutablePropertyValues(); pvs.add("name", "Tony"); pvs.add("age", "48"); @@ -1134,7 +1133,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testRegisterExistingSingletonWithAlreadyBound() { + void registerExistingSingletonWithAlreadyBound() { Object singletonObject = new TestBean(); lbf.registerSingleton("singletonObject", singletonObject); assertThatIllegalStateException().isThrownBy(() -> @@ -1142,19 +1141,19 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testReregisterBeanDefinition() { + void reregisterBeanDefinition() { RootBeanDefinition bd1 = new RootBeanDefinition(TestBean.class); bd1.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); lbf.registerBeanDefinition("testBean", bd1); - assertThat(lbf.getBean("testBean") instanceof TestBean).isTrue(); + assertThat(lbf.getBean("testBean")).isInstanceOf(TestBean.class); RootBeanDefinition bd2 = new RootBeanDefinition(NestedTestBean.class); bd2.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); lbf.registerBeanDefinition("testBean", bd2); - assertThat(lbf.getBean("testBean") instanceof NestedTestBean).isTrue(); + assertThat(lbf.getBean("testBean")).isInstanceOf(NestedTestBean.class); } @Test - public void testArrayPropertyWithAutowiring() throws MalformedURLException { + void arrayPropertyWithAutowiring() throws MalformedURLException { lbf.registerSingleton("resource1", new UrlResource("http://localhost:8080")); lbf.registerSingleton("resource2", new UrlResource("http://localhost:9090")); @@ -1168,7 +1167,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testArrayPropertyWithOptionalAutowiring() throws MalformedURLException { + void arrayPropertyWithOptionalAutowiring() throws MalformedURLException { RootBeanDefinition rbd = new RootBeanDefinition(ArrayBean.class); rbd.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE); lbf.registerBeanDefinition("arrayBean", rbd); @@ -1178,7 +1177,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testArrayConstructorWithAutowiring() { + void arrayConstructorWithAutowiring() { lbf.registerSingleton("integer1", new Integer(4)); lbf.registerSingleton("integer2", new Integer(5)); @@ -1192,7 +1191,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testArrayConstructorWithOptionalAutowiring() { + void arrayConstructorWithOptionalAutowiring() { RootBeanDefinition rbd = new RootBeanDefinition(ArrayBean.class); rbd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR); lbf.registerBeanDefinition("arrayBean", rbd); @@ -1202,7 +1201,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testDoubleArrayConstructorWithAutowiring() throws MalformedURLException { + void doubleArrayConstructorWithAutowiring() throws MalformedURLException { lbf.registerSingleton("integer1", new Integer(4)); lbf.registerSingleton("integer2", new Integer(5)); lbf.registerSingleton("resource1", new UrlResource("http://localhost:8080")); @@ -1220,7 +1219,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testDoubleArrayConstructorWithOptionalAutowiring() throws MalformedURLException { + void doubleArrayConstructorWithOptionalAutowiring() throws MalformedURLException { lbf.registerSingleton("resource1", new UrlResource("http://localhost:8080")); lbf.registerSingleton("resource2", new UrlResource("http://localhost:9090")); @@ -1234,7 +1233,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testExpressionInStringArray() { + void expressionInStringArray() { BeanExpressionResolver beanExpressionResolver = mock(BeanExpressionResolver.class); given(beanExpressionResolver.evaluate(eq("#{foo}"), any(BeanExpressionContext.class))) .willReturn("classpath:/org/springframework/beans/factory/xml/util.properties"); @@ -1250,7 +1249,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testAutowireWithNoDependencies() { + void autowireWithNoDependencies() { RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("rod", bd); assertThat(lbf.getBeanDefinitionCount()).isEqualTo(1); @@ -1260,7 +1259,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testAutowireWithSatisfiedJavaBeanDependency() { + void autowireWithSatisfiedJavaBeanDependency() { MutablePropertyValues pvs = new MutablePropertyValues(); pvs.add("name", "Rod"); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); @@ -1276,7 +1275,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testAutowireWithSatisfiedConstructorDependency() { + void autowireWithSatisfiedConstructorDependency() { MutablePropertyValues pvs = new MutablePropertyValues(); pvs.add("name", "Rod"); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); @@ -1291,7 +1290,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testAutowireWithTwoMatchesForConstructorDependency() { + void autowireWithTwoMatchesForConstructorDependency() { RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("rod", bd); RootBeanDefinition bd2 = new RootBeanDefinition(TestBean.class); @@ -1303,7 +1302,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testAutowireWithUnsatisfiedConstructorDependency() { + void autowireWithUnsatisfiedConstructorDependency() { MutablePropertyValues pvs = new MutablePropertyValues(); pvs.addPropertyValue(new PropertyValue("name", "Rod")); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); @@ -1315,7 +1314,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testAutowireConstructor() { + void autowireConstructor() { RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("spouse", bd); ConstructorDependenciesBean bean = (ConstructorDependenciesBean) @@ -1326,7 +1325,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testAutowireBeanByName() { + void autowireBeanByName() { RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("spouse", bd); DependenciesBean bean = (DependenciesBean) @@ -1337,7 +1336,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testAutowireBeanByNameWithDependencyCheck() { + void autowireBeanByNameWithDependencyCheck() { RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("spous", bd); assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(() -> @@ -1345,7 +1344,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testAutowireBeanByNameWithNoDependencyCheck() { + void autowireBeanByNameWithNoDependencyCheck() { RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("spous", bd); DependenciesBean bean = (DependenciesBean) @@ -1354,7 +1353,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testDependsOnCycle() { + void dependsOnCycle() { RootBeanDefinition bd1 = new RootBeanDefinition(TestBean.class); bd1.setDependsOn("tb2"); lbf.registerBeanDefinition("tb1", bd1); @@ -1369,7 +1368,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testImplicitDependsOnCycle() { + void implicitDependsOnCycle() { RootBeanDefinition bd1 = new RootBeanDefinition(TestBean.class); bd1.setDependsOn("tb2"); lbf.registerBeanDefinition("tb1", bd1); @@ -1387,14 +1386,14 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testGetBeanByTypeWithNoneFound() { + void getBeanByTypeWithNoneFound() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() -> lbf.getBean(TestBean.class)); } @Test - public void testGetBeanByTypeDefinedInParent() { + void getBeanByTypeDefinedInParent() { DefaultListableBeanFactory parent = new DefaultListableBeanFactory(); RootBeanDefinition bd1 = new RootBeanDefinition(TestBean.class); parent.registerBeanDefinition("bd1", bd1); @@ -1404,7 +1403,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testGetBeanByTypeWithAmbiguity() { + void getBeanByTypeWithAmbiguity() { RootBeanDefinition bd1 = new RootBeanDefinition(TestBean.class); RootBeanDefinition bd2 = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("bd1", bd1); @@ -1414,7 +1413,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testGetBeanByTypeWithPrimary() { + void getBeanByTypeWithPrimary() { RootBeanDefinition bd1 = new RootBeanDefinition(TestBean.class); bd1.setLazyInit(true); RootBeanDefinition bd2 = new RootBeanDefinition(TestBean.class); @@ -1428,7 +1427,7 @@ public class DefaultListableBeanFactoryTests { @Test @SuppressWarnings("rawtypes") - public void testGetFactoryBeanByTypeWithPrimary() { + void getFactoryBeanByTypeWithPrimary() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition bd1 = new RootBeanDefinition(NullTestBeanFactoryBean.class); RootBeanDefinition bd2 = new RootBeanDefinition(NullTestBeanFactoryBean.class); @@ -1446,7 +1445,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testGetBeanByTypeWithMultiplePrimary() { + void getBeanByTypeWithMultiplePrimary() { RootBeanDefinition bd1 = new RootBeanDefinition(TestBean.class); bd1.setPrimary(true); RootBeanDefinition bd2 = new RootBeanDefinition(TestBean.class); @@ -1459,7 +1458,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testGetBeanByTypeWithPriority() { + void getBeanByTypeWithPriority() { lbf.setDependencyComparator(AnnotationAwareOrderComparator.INSTANCE); RootBeanDefinition bd1 = new RootBeanDefinition(HighPriorityTestBean.class); RootBeanDefinition bd2 = new RootBeanDefinition(LowPriorityTestBean.class); @@ -1473,7 +1472,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testMapInjectionWithPriority() { + void mapInjectionWithPriority() { lbf.setDependencyComparator(AnnotationAwareOrderComparator.INSTANCE); RootBeanDefinition bd1 = new RootBeanDefinition(HighPriorityTestBean.class); RootBeanDefinition bd2 = new RootBeanDefinition(LowPriorityTestBean.class); @@ -1489,7 +1488,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testGetBeanByTypeWithMultiplePriority() { + void getBeanByTypeWithMultiplePriority() { lbf.setDependencyComparator(AnnotationAwareOrderComparator.INSTANCE); RootBeanDefinition bd1 = new RootBeanDefinition(HighPriorityTestBean.class); RootBeanDefinition bd2 = new RootBeanDefinition(HighPriorityTestBean.class); @@ -1502,7 +1501,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testGetBeanByTypeWithPriorityAndNullInstance() { + void getBeanByTypeWithPriorityAndNullInstance() { lbf.setDependencyComparator(AnnotationAwareOrderComparator.INSTANCE); RootBeanDefinition bd1 = new RootBeanDefinition(HighPriorityTestBean.class); RootBeanDefinition bd2 = new RootBeanDefinition(NullTestBeanFactoryBean.class); @@ -1513,7 +1512,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testGetBeanByTypePrimaryHasPrecedenceOverPriority() { + void getBeanByTypePrimaryHasPrecedenceOverPriority() { lbf.setDependencyComparator(AnnotationAwareOrderComparator.INSTANCE); RootBeanDefinition bd1 = new RootBeanDefinition(HighPriorityTestBean.class); RootBeanDefinition bd2 = new RootBeanDefinition(TestBean.class); @@ -1525,7 +1524,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testGetBeanByTypeFiltersOutNonAutowireCandidates() { + void getBeanByTypeFiltersOutNonAutowireCandidates() { RootBeanDefinition bd1 = new RootBeanDefinition(TestBean.class); RootBeanDefinition bd2 = new RootBeanDefinition(TestBean.class); RootBeanDefinition na1 = new RootBeanDefinition(TestBean.class); @@ -1542,22 +1541,22 @@ public class DefaultListableBeanFactoryTests { } @Test - public void getBeanByTypeWithNullRequiredType() { + void getBeanByTypeWithNullRequiredType() { assertThatIllegalArgumentException().isThrownBy(() -> lbf.getBean((Class) null)); } @Test - public void getBeanProviderByTypeWithNullRequiredType() { + void getBeanProviderByTypeWithNullRequiredType() { assertThatIllegalArgumentException().isThrownBy(() -> lbf.getBeanProvider((Class) null)); } @Test - public void resolveNamedBeanByTypeWithNullRequiredType() { + void resolveNamedBeanByTypeWithNullRequiredType() { assertThatIllegalArgumentException().isThrownBy(() -> lbf.resolveNamedBean((Class) null)); } @Test - public void testGetBeanByTypeInstanceWithNoneFound() { + void getBeanByTypeInstanceWithNoneFound() { assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() -> lbf.getBean(ConstructorDependency.class)); assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() -> @@ -1573,7 +1572,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testGetBeanByTypeInstanceDefinedInParent() { + void getBeanByTypeInstanceDefinedInParent() { DefaultListableBeanFactory parent = new DefaultListableBeanFactory(); RootBeanDefinition bd1 = createConstructorDependencyBeanDefinition(99); parent.registerBeanDefinition("bd1", bd1); @@ -1602,7 +1601,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testGetBeanByTypeInstanceWithAmbiguity() { + void getBeanByTypeInstanceWithAmbiguity() { RootBeanDefinition bd1 = createConstructorDependencyBeanDefinition(99); RootBeanDefinition bd2 = new RootBeanDefinition(ConstructorDependency.class); bd2.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); @@ -1643,7 +1642,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testGetBeanByTypeInstanceWithPrimary() { + void getBeanByTypeInstanceWithPrimary() { RootBeanDefinition bd1 = createConstructorDependencyBeanDefinition(99); RootBeanDefinition bd2 = createConstructorDependencyBeanDefinition(43); bd2.setPrimary(true); @@ -1692,7 +1691,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testGetBeanByTypeInstanceWithMultiplePrimary() { + void getBeanByTypeInstanceWithMultiplePrimary() { RootBeanDefinition bd1 = createConstructorDependencyBeanDefinition(99); RootBeanDefinition bd2 = createConstructorDependencyBeanDefinition(43); bd1.setPrimary(true); @@ -1706,7 +1705,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testGetBeanByTypeInstanceFiltersOutNonAutowireCandidates() { + void getBeanByTypeInstanceFiltersOutNonAutowireCandidates() { RootBeanDefinition bd1 = createConstructorDependencyBeanDefinition(99); RootBeanDefinition bd2 = createConstructorDependencyBeanDefinition(43); RootBeanDefinition na1 = createConstructorDependencyBeanDefinition(21); @@ -1724,7 +1723,7 @@ public class DefaultListableBeanFactoryTests { @Test @SuppressWarnings("rawtypes") - public void testBeanProviderSerialization() throws Exception { + void beanProviderSerialization() throws Exception { lbf.setSerializationId("test"); ObjectProvider provider = lbf.getBeanProvider(ConstructorDependency.class); @@ -1738,7 +1737,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testGetBeanWithArgsNotCreatedForFactoryBeanChecking() { + void getBeanWithArgsNotCreatedForFactoryBeanChecking() { RootBeanDefinition bd1 = new RootBeanDefinition(ConstructorDependency.class); bd1.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); lbf.registerBeanDefinition("bd1", bd1); @@ -1766,7 +1765,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testAutowireBeanByType() { + void autowireBeanByType() { RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("test", bd); DependenciesBean bean = (DependenciesBean) @@ -1782,7 +1781,7 @@ public class DefaultListableBeanFactoryTests { * target="_blank">SPR-4040. */ @Test - public void testAutowireBeanWithFactoryBeanByType() { + void autowireBeanWithFactoryBeanByType() { RootBeanDefinition bd = new RootBeanDefinition(LazyInitFactory.class); lbf.registerBeanDefinition("factoryBean", bd); LazyInitFactory factoryBean = (LazyInitFactory) lbf.getBean("&factoryBean"); @@ -1794,7 +1793,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testAutowireBeanWithFactoryBeanByTypeWithPrimary() { + void autowireBeanWithFactoryBeanByTypeWithPrimary() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition bd1 = new RootBeanDefinition(LazyInitFactory.class); RootBeanDefinition bd2 = new RootBeanDefinition(LazyInitFactory.class); @@ -1812,7 +1811,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testGetTypeForAbstractFactoryBean() { + void getTypeForAbstractFactoryBean() { RootBeanDefinition bd = new RootBeanDefinition(FactoryBeanThatShouldntBeCalled.class); bd.setAbstract(true); lbf.registerBeanDefinition("factoryBean", bd); @@ -1820,7 +1819,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testGetBeanNamesForTypeBeforeFactoryBeanCreation() { + void getBeanNamesForTypeBeforeFactoryBeanCreation() { lbf.registerBeanDefinition("factoryBean", new RootBeanDefinition(FactoryBeanThatShouldntBeCalled.class)); assertThat(lbf.containsSingleton("factoryBean")).isFalse(); @@ -1842,7 +1841,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testGetBeanNamesForTypeAfterFactoryBeanCreation() { + void getBeanNamesForTypeAfterFactoryBeanCreation() { lbf.registerBeanDefinition("factoryBean", new RootBeanDefinition(FactoryBeanThatShouldntBeCalled.class)); lbf.getBean("&factoryBean"); @@ -1870,7 +1869,7 @@ public class DefaultListableBeanFactoryTests { * {@code set&FactoryBean(...)}. */ @Test - public void testAutowireBeanWithFactoryBeanByName() { + void autowireBeanWithFactoryBeanByName() { RootBeanDefinition bd = new RootBeanDefinition(LazyInitFactory.class); lbf.registerBeanDefinition("factoryBean", bd); LazyInitFactory factoryBean = (LazyInitFactory) lbf.getBean("&factoryBean"); @@ -1880,7 +1879,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testAutowireBeanByTypeWithTwoMatches() { + void autowireBeanByTypeWithTwoMatches() { RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); RootBeanDefinition bd2 = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("test", bd); @@ -1892,20 +1891,20 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testAutowireBeanByTypeWithDependencyCheck() { + void autowireBeanByTypeWithDependencyCheck() { assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(() -> lbf.autowire(DependenciesBean.class, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true)); } @Test - public void testAutowireBeanByTypeWithNoDependencyCheck() { + void autowireBeanByTypeWithNoDependencyCheck() { DependenciesBean bean = (DependenciesBean) lbf.autowire(DependenciesBean.class, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false); assertThat(bean.getSpouse()).isNull(); } @Test - public void testAutowireBeanByTypeWithTwoMatchesAndOnePrimary() { + void autowireBeanByTypeWithTwoMatchesAndOnePrimary() { RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); bd.setPrimary(true); RootBeanDefinition bd2 = new RootBeanDefinition(TestBean.class); @@ -1918,7 +1917,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testAutowireBeanByTypeWithTwoPrimaryCandidates() { + void autowireBeanByTypeWithTwoPrimaryCandidates() { RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); bd.setPrimary(true); RootBeanDefinition bd2 = new RootBeanDefinition(TestBean.class); @@ -1931,7 +1930,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testAutowireBeanByTypeWithTwoMatchesAndPriority() { + void autowireBeanByTypeWithTwoMatchesAndPriority() { lbf.setDependencyComparator(AnnotationAwareOrderComparator.INSTANCE); RootBeanDefinition bd = new RootBeanDefinition(HighPriorityTestBean.class); RootBeanDefinition bd2 = new RootBeanDefinition(LowPriorityTestBean.class); @@ -1944,7 +1943,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testAutowireBeanByTypeWithIdenticalPriorityCandidates() { + void autowireBeanByTypeWithIdenticalPriorityCandidates() { lbf.setDependencyComparator(AnnotationAwareOrderComparator.INSTANCE); RootBeanDefinition bd = new RootBeanDefinition(HighPriorityTestBean.class); RootBeanDefinition bd2 = new RootBeanDefinition(HighPriorityTestBean.class); @@ -1957,7 +1956,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testAutowireBeanByTypePrimaryTakesPrecedenceOverPriority() { + void autowireBeanByTypePrimaryTakesPrecedenceOverPriority() { lbf.setDependencyComparator(AnnotationAwareOrderComparator.INSTANCE); RootBeanDefinition bd = new RootBeanDefinition(HighPriorityTestBean.class); RootBeanDefinition bd2 = new RootBeanDefinition(TestBean.class); @@ -1971,7 +1970,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testAutowireExistingBeanByName() { + void autowireExistingBeanByName() { RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("spouse", bd); DependenciesBean existingBean = new DependenciesBean(); @@ -1982,7 +1981,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testAutowireExistingBeanByNameWithDependencyCheck() { + void autowireExistingBeanByNameWithDependencyCheck() { RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("spous", bd); DependenciesBean existingBean = new DependenciesBean(); @@ -1991,7 +1990,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testAutowireExistingBeanByNameWithNoDependencyCheck() { + void autowireExistingBeanByNameWithNoDependencyCheck() { RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("spous", bd); DependenciesBean existingBean = new DependenciesBean(); @@ -2000,7 +1999,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testAutowireExistingBeanByType() { + void autowireExistingBeanByType() { RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("test", bd); DependenciesBean existingBean = new DependenciesBean(); @@ -2010,27 +2009,27 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testAutowireExistingBeanByTypeWithDependencyCheck() { + void autowireExistingBeanByTypeWithDependencyCheck() { DependenciesBean existingBean = new DependenciesBean(); assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(() -> lbf.autowireBeanProperties(existingBean, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true)); } @Test - public void testAutowireExistingBeanByTypeWithNoDependencyCheck() { + void autowireExistingBeanByTypeWithNoDependencyCheck() { DependenciesBean existingBean = new DependenciesBean(); lbf.autowireBeanProperties(existingBean, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false); assertThat(existingBean.getSpouse()).isNull(); } @Test - public void testInvalidAutowireMode() { + void invalidAutowireMode() { assertThatIllegalArgumentException().isThrownBy(() -> lbf.autowireBeanProperties(new TestBean(), AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false)); } @Test - public void testApplyBeanPropertyValues() { + void applyBeanPropertyValues() { MutablePropertyValues pvs = new MutablePropertyValues(); pvs.add("age", "99"); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); @@ -2043,7 +2042,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testApplyBeanPropertyValuesWithIncompleteDefinition() { + void applyBeanPropertyValuesWithIncompleteDefinition() { MutablePropertyValues pvs = new MutablePropertyValues(); pvs.add("age", "99"); RootBeanDefinition bd = new RootBeanDefinition(); @@ -2058,14 +2057,14 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testCreateBean() { + void createBean() { TestBean tb = lbf.createBean(TestBean.class); assertThat(tb.getBeanFactory()).isSameAs(lbf); lbf.destroyBean(tb); } @Test - public void testCreateBeanWithDisposableBean() { + void createBeanWithDisposableBean() { DerivedTestBean tb = lbf.createBean(DerivedTestBean.class); assertThat(tb.getBeanFactory()).isSameAs(lbf); lbf.destroyBean(tb); @@ -2073,7 +2072,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testConfigureBean() { + void configureBean() { MutablePropertyValues pvs = new MutablePropertyValues(); pvs.add("age", "99"); RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); @@ -2088,7 +2087,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testConfigureBeanWithAutowiring() { + void configureBeanWithAutowiring() { RootBeanDefinition bd = new RootBeanDefinition(TestBean.class); lbf.registerBeanDefinition("spouse", bd); MutablePropertyValues pvs = new MutablePropertyValues(); @@ -2104,7 +2103,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testExtensiveCircularReference() { + void extensiveCircularReference() { for (int i = 0; i < 1000; i++) { MutablePropertyValues pvs = new MutablePropertyValues(); pvs.addPropertyValue(new PropertyValue("spouse", new RuntimeBeanReference("bean" + (i < 99 ? i + 1 : 0)))); @@ -2121,7 +2120,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testCircularReferenceThroughAutowiring() { + void circularReferenceThroughAutowiring() { RootBeanDefinition bd = new RootBeanDefinition(ConstructorDependencyBean.class); bd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR); lbf.registerBeanDefinition("test", bd); @@ -2130,7 +2129,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testCircularReferenceThroughFactoryBeanAutowiring() { + void circularReferenceThroughFactoryBeanAutowiring() { RootBeanDefinition bd = new RootBeanDefinition(ConstructorDependencyFactoryBean.class); bd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR); lbf.registerBeanDefinition("test", bd); @@ -2139,7 +2138,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testCircularReferenceThroughFactoryBeanTypeCheck() { + void circularReferenceThroughFactoryBeanTypeCheck() { RootBeanDefinition bd = new RootBeanDefinition(ConstructorDependencyFactoryBean.class); bd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR); lbf.registerBeanDefinition("test", bd); @@ -2148,7 +2147,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testAvoidCircularReferenceThroughAutowiring() { + void avoidCircularReferenceThroughAutowiring() { RootBeanDefinition bd = new RootBeanDefinition(ConstructorDependencyFactoryBean.class); bd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR); lbf.registerBeanDefinition("test", bd); @@ -2159,7 +2158,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testConstructorDependencyWithClassResolution() { + void constructorDependencyWithClassResolution() { RootBeanDefinition bd = new RootBeanDefinition(ConstructorDependencyWithClassResolution.class); bd.getConstructorArgumentValues().addGenericArgumentValue("java.lang.String"); lbf.registerBeanDefinition("test", bd); @@ -2167,7 +2166,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testConstructorDependencyWithUnresolvableClass() { + void constructorDependencyWithUnresolvableClass() { RootBeanDefinition bd = new RootBeanDefinition(ConstructorDependencyWithClassResolution.class); bd.getConstructorArgumentValues().addGenericArgumentValue("java.lang.Strin"); lbf.registerBeanDefinition("test", bd); @@ -2176,7 +2175,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testBeanDefinitionWithInterface() { + void beanDefinitionWithInterface() { lbf.registerBeanDefinition("test", new RootBeanDefinition(ITestBean.class)); assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> lbf.getBean("test")) @@ -2185,7 +2184,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testBeanDefinitionWithAbstractClass() { + void beanDefinitionWithAbstractClass() { lbf.registerBeanDefinition("test", new RootBeanDefinition(AbstractBeanFactory.class)); assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> lbf.getBean("test")) @@ -2194,13 +2193,13 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testPrototypeFactoryBeanNotEagerlyCalled() { + void prototypeFactoryBeanNotEagerlyCalled() { lbf.registerBeanDefinition("test", new RootBeanDefinition(FactoryBeanThatShouldntBeCalled.class)); lbf.preInstantiateSingletons(); } @Test - public void testLazyInitFlag() { + void lazyInitFlag() { DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); RootBeanDefinition bd1 = new RootBeanDefinition(TestBean.class); bd1.setLazyInit(true); @@ -2221,7 +2220,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testLazyInitFactory() { + void lazyInitFactory() { lbf.registerBeanDefinition("test", new RootBeanDefinition(LazyInitFactory.class)); lbf.preInstantiateSingletons(); LazyInitFactory factory = (LazyInitFactory) lbf.getBean("&test"); @@ -2229,7 +2228,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testSmartInitFactory() { + void smartInitFactory() { lbf.registerBeanDefinition("test", new RootBeanDefinition(EagerInitFactory.class)); lbf.preInstantiateSingletons(); EagerInitFactory factory = (EagerInitFactory) lbf.getBean("&test"); @@ -2237,14 +2236,14 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testPrototypeFactoryBeanNotEagerlyCalledInCaseOfBeanClassName() { + void prototypeFactoryBeanNotEagerlyCalledInCaseOfBeanClassName() { lbf.registerBeanDefinition("test", new RootBeanDefinition(FactoryBeanThatShouldntBeCalled.class.getName(), null, null)); lbf.preInstantiateSingletons(); } @Test - public void testPrototypeStringCreatedRepeatedly() { + void prototypeStringCreatedRepeatedly() { RootBeanDefinition stringDef = new RootBeanDefinition(String.class); stringDef.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); stringDef.getConstructorArgumentValues().addGenericArgumentValue(new TypedStringValue("value")); @@ -2257,7 +2256,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testPrototypeWithArrayConversionForConstructor() { + void prototypeWithArrayConversionForConstructor() { List list = new ManagedList<>(); list.add("myName"); list.add("myBeanName"); @@ -2275,7 +2274,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testPrototypeWithArrayConversionForFactoryMethod() { + void prototypeWithArrayConversionForFactoryMethod() { List list = new ManagedList<>(); list.add("myName"); list.add("myBeanName"); @@ -2295,7 +2294,7 @@ public class DefaultListableBeanFactoryTests { @Test @EnabledForTestGroups(TestGroup.PERFORMANCE) - public void testPrototypeCreationIsFastEnough() { + void prototypeCreationIsFastEnough() { Assume.notLogging(factoryLog); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); @@ -2313,7 +2312,7 @@ public class DefaultListableBeanFactoryTests { @Test @EnabledForTestGroups(TestGroup.PERFORMANCE) - public void testPrototypeCreationWithDependencyCheckIsFastEnough() { + void prototypeCreationWithDependencyCheckIsFastEnough() { Assume.notLogging(factoryLog); RootBeanDefinition rbd = new RootBeanDefinition(LifecycleBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); @@ -2334,7 +2333,7 @@ public class DefaultListableBeanFactoryTests { @Test @Disabled // TODO re-enable when ConstructorResolver TODO sorted out @EnabledForTestGroups(TestGroup.PERFORMANCE) - public void testPrototypeCreationWithConstructorArgumentsIsFastEnough() { + void prototypeCreationWithConstructorArgumentsIsFastEnough() { Assume.notLogging(factoryLog); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); @@ -2356,7 +2355,7 @@ public class DefaultListableBeanFactoryTests { @Test @EnabledForTestGroups(TestGroup.PERFORMANCE) - public void testPrototypeCreationWithResolvedConstructorArgumentsIsFastEnough() { + void prototypeCreationWithResolvedConstructorArgumentsIsFastEnough() { Assume.notLogging(factoryLog); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); @@ -2378,7 +2377,7 @@ public class DefaultListableBeanFactoryTests { @Test @EnabledForTestGroups(TestGroup.PERFORMANCE) - public void testPrototypeCreationWithPropertiesIsFastEnough() { + void prototypeCreationWithPropertiesIsFastEnough() { Assume.notLogging(factoryLog); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); @@ -2400,7 +2399,7 @@ public class DefaultListableBeanFactoryTests { @Test @EnabledForTestGroups(TestGroup.PERFORMANCE) - public void testPrototypeCreationWithResolvedPropertiesIsFastEnough() { + void prototypeCreationWithResolvedPropertiesIsFastEnough() { Assume.notLogging(factoryLog); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); @@ -2422,7 +2421,7 @@ public class DefaultListableBeanFactoryTests { @Test @EnabledForTestGroups(TestGroup.PERFORMANCE) - public void testSingletonLookupByNameIsFastEnough() { + void singletonLookupByNameIsFastEnough() { Assume.notLogging(factoryLog); lbf.registerBeanDefinition("test", new RootBeanDefinition(TestBean.class)); lbf.freezeConfiguration(); @@ -2438,7 +2437,7 @@ public class DefaultListableBeanFactoryTests { @Test @EnabledForTestGroups(TestGroup.PERFORMANCE) - public void testSingletonLookupByTypeIsFastEnough() { + void singletonLookupByTypeIsFastEnough() { Assume.notLogging(factoryLog); lbf.registerBeanDefinition("test", new RootBeanDefinition(TestBean.class)); lbf.freezeConfiguration(); @@ -2453,7 +2452,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testBeanPostProcessorWithWrappedObjectAndDisposableBean() { + void beanPostProcessorWithWrappedObjectAndDisposableBean() { RootBeanDefinition bd = new RootBeanDefinition(BeanWithDisposableBean.class); lbf.registerBeanDefinition("test", bd); lbf.addBeanPostProcessor(new BeanPostProcessor() { @@ -2469,7 +2468,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testBeanPostProcessorWithWrappedObjectAndCloseable() { + void beanPostProcessorWithWrappedObjectAndCloseable() { RootBeanDefinition bd = new RootBeanDefinition(BeanWithCloseable.class); lbf.registerBeanDefinition("test", bd); lbf.addBeanPostProcessor(new BeanPostProcessor() { @@ -2485,7 +2484,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testBeanPostProcessorWithWrappedObjectAndDestroyMethod() { + void beanPostProcessorWithWrappedObjectAndDestroyMethod() { RootBeanDefinition bd = new RootBeanDefinition(BeanWithDestroyMethod.class); bd.setDestroyMethodName("close"); lbf.registerBeanDefinition("test", bd); @@ -2503,7 +2502,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testDestroyMethodOnInnerBean() { + void destroyMethodOnInnerBean() { RootBeanDefinition innerBd = new RootBeanDefinition(BeanWithDestroyMethod.class); innerBd.setDestroyMethodName("close"); RootBeanDefinition bd = new RootBeanDefinition(BeanWithDestroyMethod.class); @@ -2518,7 +2517,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testDestroyMethodOnInnerBeanAsPrototype() { + void destroyMethodOnInnerBeanAsPrototype() { RootBeanDefinition innerBd = new RootBeanDefinition(BeanWithDestroyMethod.class); innerBd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); innerBd.setDestroyMethodName("close"); @@ -2534,12 +2533,12 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testFindTypeOfSingletonFactoryMethodOnBeanInstance() { + void findTypeOfSingletonFactoryMethodOnBeanInstance() { findTypeOfPrototypeFactoryMethodOnBeanInstance(true); } @Test - public void testFindTypeOfPrototypeFactoryMethodOnBeanInstance() { + void findTypeOfPrototypeFactoryMethodOnBeanInstance() { findTypeOfPrototypeFactoryMethodOnBeanInstance(false); } @@ -2625,7 +2624,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testScopingBeanToUnregisteredScopeResultsInAnException() { + void scopingBeanToUnregisteredScopeResultsInAnException() { BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(TestBean.class); AbstractBeanDefinition beanDefinition = builder.getBeanDefinition(); beanDefinition.setScope("he put himself so low could hardly look me in the face"); @@ -2637,7 +2636,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testExplicitScopeInheritanceForChildBeanDefinitions() { + void explicitScopeInheritanceForChildBeanDefinitions() { String theChildScope = "bonanza!"; RootBeanDefinition parent = new RootBeanDefinition(); @@ -2657,7 +2656,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testScopeInheritanceForChildBeanDefinitions() { + void scopeInheritanceForChildBeanDefinitions() { RootBeanDefinition parent = new RootBeanDefinition(); parent.setScope("bonanza!"); @@ -2674,12 +2673,12 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testFieldSettingWithInstantiationAwarePostProcessorNoShortCircuit() { + void fieldSettingWithInstantiationAwarePostProcessorNoShortCircuit() { doTestFieldSettingWithInstantiationAwarePostProcessor(false); } @Test - public void testFieldSettingWithInstantiationAwarePostProcessorWithShortCircuit() { + void fieldSettingWithInstantiationAwarePostProcessorWithShortCircuit() { doTestFieldSettingWithInstantiationAwarePostProcessor(true); } @@ -2720,7 +2719,7 @@ public class DefaultListableBeanFactoryTests { @Test @SuppressWarnings({ "unchecked", "rawtypes" }) - public void testInitSecurityAwarePrototypeBean() { + void initSecurityAwarePrototypeBean() { RootBeanDefinition bd = new RootBeanDefinition(TestSecuredBean.class); bd.setScope(ConfigurableBeanFactory.SCOPE_PROTOTYPE); bd.setInitMethodName("init"); @@ -2735,7 +2734,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testContainsBeanReturnsTrueEvenForAbstractBeanDefinition() { + void containsBeanReturnsTrueEvenForAbstractBeanDefinition() { lbf.registerBeanDefinition("abs", BeanDefinitionBuilder .rootBeanDefinition(TestBean.class).setAbstract(true).getBeanDefinition()); assertThat(lbf.containsBean("abs")).isEqualTo(true); @@ -2743,7 +2742,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void resolveEmbeddedValue() { + void resolveEmbeddedValue() { StringValueResolver r1 = mock(StringValueResolver.class); StringValueResolver r2 = mock(StringValueResolver.class); StringValueResolver r3 = mock(StringValueResolver.class); @@ -2762,7 +2761,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void populatedJavaUtilOptionalBean() { + void populatedJavaUtilOptionalBean() { RootBeanDefinition bd = new RootBeanDefinition(Optional.class); bd.setFactoryMethodName("of"); bd.getConstructorArgumentValues().addGenericArgumentValue("CONTENT"); @@ -2771,7 +2770,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void emptyJavaUtilOptionalBean() { + void emptyJavaUtilOptionalBean() { RootBeanDefinition bd = new RootBeanDefinition(Optional.class); bd.setFactoryMethodName("empty"); lbf.registerBeanDefinition("optionalBean", bd); @@ -2779,7 +2778,7 @@ public class DefaultListableBeanFactoryTests { } @Test - public void testNonPublicEnum() { + void nonPublicEnum() { RootBeanDefinition bd = new RootBeanDefinition(NonPublicEnumHolder.class); bd.getConstructorArgumentValues().addGenericArgumentValue("VALUE_1"); lbf.registerBeanDefinition("holderBean", bd); @@ -2800,7 +2799,7 @@ public class DefaultListableBeanFactoryTests { @Test @Timeout(1) @EnabledForTestGroups(TestGroup.PERFORMANCE) - public void testByTypeLookupIsFastEnough() { + void byTypeLookupIsFastEnough() { for (int i = 0; i < 1000; i++) { lbf.registerBeanDefinition("a" + i, new RootBeanDefinition(A.class)); } @@ -2816,7 +2815,7 @@ public class DefaultListableBeanFactoryTests { @Test @Timeout(1) @EnabledForTestGroups(TestGroup.PERFORMANCE) - public void testRegistrationOfManyBeanDefinitionsIsFastEnough() { + void registrationOfManyBeanDefinitionsIsFastEnough() { lbf.registerBeanDefinition("b", new RootBeanDefinition(B.class)); // lbf.getBean("b"); @@ -2828,7 +2827,7 @@ public class DefaultListableBeanFactoryTests { @Test @Timeout(1) @EnabledForTestGroups(TestGroup.PERFORMANCE) - public void testRegistrationOfManySingletonsIsFastEnough() { + void registrationOfManySingletonsIsFastEnough() { lbf.registerBeanDefinition("b", new RootBeanDefinition(B.class)); // lbf.getBean("b"); @@ -3255,7 +3254,7 @@ public class DefaultListableBeanFactoryTests { private String userName; - public void init() { + void init() { AccessControlContext acc = AccessController.getContext(); Subject subject = Subject.getSubject(acc); if (subject == null) {