Browse Source

Polish

pull/31932/head
Stéphane Nicoll 2 years ago
parent
commit
7d44a4dcad
  1. 27
      spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java
  2. 42
      spring-beans/src/test/java/org/springframework/beans/BeanWrapperAutoGrowingTests.java
  3. 36
      spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java
  4. 19
      spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java
  5. 4
      spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java
  6. 10
      spring-beans/src/test/java/org/springframework/beans/CachedIntrospectionResultsTests.java
  7. 4
      spring-beans/src/test/java/org/springframework/beans/ConcurrentBeanWrapperTests.java
  8. 4
      spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java
  9. 18
      spring-beans/src/test/java/org/springframework/beans/PropertyAccessorUtilsTests.java
  10. 28
      spring-beans/src/test/java/org/springframework/beans/PropertyMatchesTests.java
  11. 10
      spring-beans/src/test/java/org/springframework/beans/SimplePropertyDescriptorTests.java
  12. 42
      spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java
  13. 8
      spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java
  14. 18
      spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanLookupTests.java
  15. 16
      spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java
  16. 12
      spring-beans/src/test/java/org/springframework/beans/factory/Spr5475Tests.java
  17. 14
      spring-beans/src/test/java/org/springframework/beans/factory/annotation/AnnotationBeanWiringInfoResolverTests.java
  18. 151
      spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java
  19. 6
      spring-beans/src/test/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurerTests.java
  20. 109
      spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java
  21. 24
      spring-beans/src/test/java/org/springframework/beans/factory/annotation/LookupAnnotationTests.java
  22. 22
      spring-beans/src/test/java/org/springframework/beans/factory/annotation/ParameterResolutionTests.java
  23. 4
      spring-beans/src/test/java/org/springframework/beans/factory/aot/BeanDefinitionPropertiesCodeGeneratorTests.java
  24. 6
      spring-beans/src/test/java/org/springframework/beans/factory/aot/DefaultBeanRegistrationCodeFragmentsTests.java
  25. 10
      spring-beans/src/test/java/org/springframework/beans/factory/config/CustomEditorConfigurerTests.java
  26. 18
      spring-beans/src/test/java/org/springframework/beans/factory/config/CustomScopeConfigurerTests.java
  27. 4
      spring-beans/src/test/java/org/springframework/beans/factory/config/DeprecatedBeanWarnerTests.java
  28. 24
      spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java
  29. 18
      spring-beans/src/test/java/org/springframework/beans/factory/config/MethodInvokingFactoryBeanTests.java
  30. 26
      spring-beans/src/test/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java
  31. 18
      spring-beans/src/test/java/org/springframework/beans/factory/config/PropertiesFactoryBeanTests.java
  32. 16
      spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java
  33. 77
      spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java
  34. 26
      spring-beans/src/test/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBeanTests.java
  35. 8
      spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java
  36. 20
      spring-beans/src/test/java/org/springframework/beans/factory/config/YamlMapFactoryBeanTests.java
  37. 4
      spring-beans/src/test/java/org/springframework/beans/factory/config/YamlProcessorTests.java
  38. 6
      spring-beans/src/test/java/org/springframework/beans/factory/parsing/ConstructorArgumentEntryTests.java
  39. 8
      spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java
  40. 8
      spring-beans/src/test/java/org/springframework/beans/factory/parsing/FailFastProblemReporterTests.java
  41. 8
      spring-beans/src/test/java/org/springframework/beans/factory/parsing/NullSourceExtractorTests.java
  42. 10
      spring-beans/src/test/java/org/springframework/beans/factory/parsing/ParseStateTests.java
  43. 8
      spring-beans/src/test/java/org/springframework/beans/factory/parsing/PassThroughSourceExtractorTests.java
  44. 10
      spring-beans/src/test/java/org/springframework/beans/factory/parsing/PropertyEntryTests.java
  45. 6
      spring-beans/src/test/java/org/springframework/beans/factory/support/AutowireUtilsTests.java
  46. 18
      spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionTests.java
  47. 9
      spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java
  48. 4
      spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactorySupplierTests.java
  49. 4
      spring-beans/src/test/java/org/springframework/beans/factory/support/ConstructorResolverAotTests.java
  50. 14
      spring-beans/src/test/java/org/springframework/beans/factory/support/DefinitionMetadataEqualsHashCodeTests.java
  51. 20
      spring-beans/src/test/java/org/springframework/beans/factory/support/LookupMethodTests.java
  52. 16
      spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedMapTests.java
  53. 10
      spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedPropertiesTests.java
  54. 20
      spring-beans/src/test/java/org/springframework/beans/factory/support/QualifierAnnotationAutowireBeanFactoryTests.java
  55. 14
      spring-beans/src/test/java/org/springframework/beans/factory/support/Spr8954Tests.java
  56. 16
      spring-beans/src/test/java/org/springframework/beans/factory/wiring/BeanConfigurerSupportTests.java
  57. 22
      spring-beans/src/test/java/org/springframework/beans/factory/wiring/BeanWiringInfoTests.java
  58. 4
      spring-beans/src/test/java/org/springframework/beans/factory/wiring/ClassNameBeanWiringInfoResolverTests.java
  59. 24
      spring-beans/src/test/java/org/springframework/beans/factory/xml/AutowireWithExclusionTests.java
  60. 8
      spring-beans/src/test/java/org/springframework/beans/factory/xml/BeanNameGenerationTests.java
  61. 59
      spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionMergingTests.java
  62. 14
      spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionsWithDefaultTypesTests.java
  63. 18
      spring-beans/src/test/java/org/springframework/beans/factory/xml/DefaultLifecycleMethodsTests.java
  64. 10
      spring-beans/src/test/java/org/springframework/beans/factory/xml/DelegatingEntityResolverTests.java
  65. 13
      spring-beans/src/test/java/org/springframework/beans/factory/xml/EventPublicationTests.java
  66. 40
      spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethodTests.java
  67. 12
      spring-beans/src/test/java/org/springframework/beans/factory/xml/MetadataAttachmentTests.java
  68. 18
      spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests.java
  69. 8
      spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementTests.java
  70. 12
      spring-beans/src/test/java/org/springframework/beans/factory/xml/ProfileXmlBeanDefinitionTests.java
  71. 10
      spring-beans/src/test/java/org/springframework/beans/factory/xml/SchemaValidationTests.java
  72. 20
      spring-beans/src/test/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandlerTests.java
  73. 12
      spring-beans/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerTests.java
  74. 4
      spring-beans/src/test/java/org/springframework/beans/factory/xml/UtilNamespaceHandlerTests.java
  75. 116
      spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanCollectionTests.java
  76. 28
      spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlListableBeanFactoryTests.java
  77. 16
      spring-beans/src/test/java/org/springframework/beans/factory/xml/support/DefaultNamespaceHandlerResolverTests.java
  78. 6
      spring-beans/src/test/java/org/springframework/beans/propertyeditors/BeanInfoTests.java
  79. 8
      spring-beans/src/test/java/org/springframework/beans/propertyeditors/ByteArrayPropertyEditorTests.java
  80. 8
      spring-beans/src/test/java/org/springframework/beans/propertyeditors/CharArrayPropertyEditorTests.java
  81. 24
      spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomCollectionEditorTests.java
  82. 13
      spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java
  83. 16
      spring-beans/src/test/java/org/springframework/beans/propertyeditors/FileEditorTests.java
  84. 12
      spring-beans/src/test/java/org/springframework/beans/propertyeditors/InputStreamEditorTests.java
  85. 20
      spring-beans/src/test/java/org/springframework/beans/propertyeditors/PathEditorTests.java
  86. 24
      spring-beans/src/test/java/org/springframework/beans/propertyeditors/PropertiesEditorTests.java
  87. 12
      spring-beans/src/test/java/org/springframework/beans/propertyeditors/ReaderEditorTests.java
  88. 22
      spring-beans/src/test/java/org/springframework/beans/propertyeditors/ResourceBundleEditorTests.java
  89. 28
      spring-beans/src/test/java/org/springframework/beans/propertyeditors/URIEditorTests.java
  90. 18
      spring-beans/src/test/java/org/springframework/beans/propertyeditors/URLEditorTests.java
  91. 4
      spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java
  92. 12
      spring-beans/src/test/java/org/springframework/beans/support/PropertyComparatorTests.java
  93. 40
      spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/factory/StringFactoryBean.java

27
spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -294,7 +294,7 @@ abstract class AbstractPropertyAccessorTests { @@ -294,7 +294,7 @@ abstract class AbstractPropertyAccessorTests {
}
@Test
void setNestedPropertyPolymorphic() throws Exception {
void setNestedPropertyPolymorphic() {
ITestBean target = new TestBean("rod", 31);
ITestBean kerry = new Employee();
@ -316,7 +316,7 @@ abstract class AbstractPropertyAccessorTests { @@ -316,7 +316,7 @@ abstract class AbstractPropertyAccessorTests {
}
@Test
void setAnotherNestedProperty() throws Exception {
void setAnotherNestedProperty() {
ITestBean target = new TestBean("rod", 31);
ITestBean kerry = new TestBean("kerry", 0);
@ -386,7 +386,7 @@ abstract class AbstractPropertyAccessorTests { @@ -386,7 +386,7 @@ abstract class AbstractPropertyAccessorTests {
}
@Test
void setAnotherPropertyIntermediatePropertyIsNull() throws Exception {
void setAnotherPropertyIntermediatePropertyIsNull() {
ITestBean target = new TestBean("rod", 31);
AbstractPropertyAccessor accessor = createAccessor(target);
assertThatExceptionOfType(NullValueInNestedPathException.class).isThrownBy(() ->
@ -406,7 +406,6 @@ abstract class AbstractPropertyAccessorTests { @@ -406,7 +406,6 @@ abstract class AbstractPropertyAccessorTests {
}
@Test
@SuppressWarnings("unchecked")
void setPropertyIntermediateListIsNullWithAutoGrow() {
Foo target = new Foo();
AbstractPropertyAccessor accessor = createAccessor(target);
@ -553,7 +552,7 @@ abstract class AbstractPropertyAccessorTests { @@ -553,7 +552,7 @@ abstract class AbstractPropertyAccessorTests {
}
@Test
void setStringPropertyWithCustomEditor() throws Exception {
void setStringPropertyWithCustomEditor() {
TestBean target = new TestBean();
AbstractPropertyAccessor accessor = createAccessor(target);
accessor.registerCustomEditor(String.class, "name", new PropertyEditorSupport() {
@ -724,7 +723,7 @@ abstract class AbstractPropertyAccessorTests { @@ -724,7 +723,7 @@ abstract class AbstractPropertyAccessorTests {
}
@Test
void setPropertiesProperty() throws Exception {
void setPropertiesProperty() {
PropsTester target = new PropsTester();
AbstractPropertyAccessor accessor = createAccessor(target);
accessor.setPropertyValue("name", "ptest");
@ -742,7 +741,7 @@ abstract class AbstractPropertyAccessorTests { @@ -742,7 +741,7 @@ abstract class AbstractPropertyAccessorTests {
}
@Test
void setStringArrayProperty() throws Exception {
void setStringArrayProperty() {
PropsTester target = new PropsTester();
AbstractPropertyAccessor accessor = createAccessor(target);
@ -767,7 +766,7 @@ abstract class AbstractPropertyAccessorTests { @@ -767,7 +766,7 @@ abstract class AbstractPropertyAccessorTests {
}
@Test
void setStringArrayPropertyWithCustomStringEditor() throws Exception {
void setStringArrayPropertyWithCustomStringEditor() {
PropsTester target = new PropsTester();
AbstractPropertyAccessor accessor = createAccessor(target);
accessor.registerCustomEditor(String.class, "stringArray", new PropertyEditorSupport() {
@ -796,7 +795,7 @@ abstract class AbstractPropertyAccessorTests { @@ -796,7 +795,7 @@ abstract class AbstractPropertyAccessorTests {
}
@Test
void setStringArrayPropertyWithStringSplitting() throws Exception {
void setStringArrayPropertyWithStringSplitting() {
PropsTester target = new PropsTester();
AbstractPropertyAccessor accessor = createAccessor(target);
accessor.useConfigValueEditors();
@ -805,7 +804,7 @@ abstract class AbstractPropertyAccessorTests { @@ -805,7 +804,7 @@ abstract class AbstractPropertyAccessorTests {
}
@Test
void setStringArrayPropertyWithCustomStringDelimiter() throws Exception {
void setStringArrayPropertyWithCustomStringDelimiter() {
PropsTester target = new PropsTester();
AbstractPropertyAccessor accessor = createAccessor(target);
accessor.registerCustomEditor(String[].class, "stringArray", new StringArrayPropertyEditor("-"));
@ -814,7 +813,7 @@ abstract class AbstractPropertyAccessorTests { @@ -814,7 +813,7 @@ abstract class AbstractPropertyAccessorTests {
}
@Test
void setStringArrayWithAutoGrow() throws Exception {
void setStringArrayWithAutoGrow() {
StringArrayBean target = new StringArrayBean();
AbstractPropertyAccessor accessor = createAccessor(target);
accessor.setAutoGrowNestedPaths(true);
@ -888,7 +887,7 @@ abstract class AbstractPropertyAccessorTests { @@ -888,7 +887,7 @@ abstract class AbstractPropertyAccessorTests {
}
@Test
void setIntArrayPropertyWithStringSplitting() throws Exception {
void setIntArrayPropertyWithStringSplitting() {
PropsTester target = new PropsTester();
AbstractPropertyAccessor accessor = createAccessor(target);
accessor.useConfigValueEditors();
@ -943,7 +942,7 @@ abstract class AbstractPropertyAccessorTests { @@ -943,7 +942,7 @@ abstract class AbstractPropertyAccessorTests {
}
@Test
void setPrimitiveArrayPropertyWithAutoGrow() throws Exception {
void setPrimitiveArrayPropertyWithAutoGrow() {
PrimitiveArrayBean target = new PrimitiveArrayBean();
AbstractPropertyAccessor accessor = createAccessor(target);
accessor.setAutoGrowNestedPaths(true);

42
spring-beans/src/test/java/org/springframework/beans/BeanWrapperAutoGrowingTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Juergen Hoeller
* @author Sam Brannen
*/
public class BeanWrapperAutoGrowingTests {
class BeanWrapperAutoGrowingTests {
private final Bean bean = new Bean();
@ -38,43 +38,43 @@ public class BeanWrapperAutoGrowingTests { @@ -38,43 +38,43 @@ public class BeanWrapperAutoGrowingTests {
@BeforeEach
public void setup() {
void setup() {
wrapper.setAutoGrowNestedPaths(true);
}
@Test
public void getPropertyValueNullValueInNestedPath() {
void getPropertyValueNullValueInNestedPath() {
assertThat(wrapper.getPropertyValue("nested.prop")).isNull();
}
@Test
public void setPropertyValueNullValueInNestedPath() {
void setPropertyValueNullValueInNestedPath() {
wrapper.setPropertyValue("nested.prop", "test");
assertThat(bean.getNested().getProp()).isEqualTo("test");
}
@Test
public void getPropertyValueNullValueInNestedPathNoDefaultConstructor() {
void getPropertyValueNullValueInNestedPathNoDefaultConstructor() {
assertThatExceptionOfType(NullValueInNestedPathException.class).isThrownBy(() ->
wrapper.getPropertyValue("nestedNoConstructor.prop"));
}
@Test
public void getPropertyValueAutoGrowArray() {
void getPropertyValueAutoGrowArray() {
assertNotNull(wrapper.getPropertyValue("array[0]"));
assertThat(bean.getArray()).hasSize(1);
assertThat(bean.getArray()[0]).isInstanceOf(Bean.class);
}
@Test
public void setPropertyValueAutoGrowArray() {
void setPropertyValueAutoGrowArray() {
wrapper.setPropertyValue("array[0].prop", "test");
assertThat(bean.getArray()[0].getProp()).isEqualTo("test");
}
@Test
public void getPropertyValueAutoGrowArrayBySeveralElements() {
void getPropertyValueAutoGrowArrayBySeveralElements() {
assertNotNull(wrapper.getPropertyValue("array[4]"));
assertThat(bean.getArray()).hasSize(5);
assertThat(bean.getArray()[0]).isInstanceOf(Bean.class);
@ -89,21 +89,21 @@ public class BeanWrapperAutoGrowingTests { @@ -89,21 +89,21 @@ public class BeanWrapperAutoGrowingTests {
}
@Test
public void getPropertyValueAutoGrow2dArray() {
void getPropertyValueAutoGrow2dArray() {
assertThat(wrapper.getPropertyValue("multiArray[0][0]")).isNotNull();
assertThat(bean.getMultiArray()[0]).hasSize(1);
assertThat(bean.getMultiArray()[0][0]).isInstanceOf(Bean.class);
}
@Test
public void getPropertyValueAutoGrow3dArray() {
void getPropertyValueAutoGrow3dArray() {
assertThat(wrapper.getPropertyValue("threeDimensionalArray[1][2][3]")).isNotNull();
assertThat(bean.getThreeDimensionalArray()[1]).hasNumberOfRows(3);
assertThat(bean.getThreeDimensionalArray()[1][2][3]).isInstanceOf(Bean.class);
}
@Test
public void setPropertyValueAutoGrow2dArray() {
void setPropertyValueAutoGrow2dArray() {
Bean newBean = new Bean();
newBean.setProp("enigma");
wrapper.setPropertyValue("multiArray[2][3]", newBean);
@ -113,7 +113,7 @@ public class BeanWrapperAutoGrowingTests { @@ -113,7 +113,7 @@ public class BeanWrapperAutoGrowingTests {
}
@Test
public void setPropertyValueAutoGrow3dArray() {
void setPropertyValueAutoGrow3dArray() {
Bean newBean = new Bean();
newBean.setProp("enigma");
wrapper.setPropertyValue("threeDimensionalArray[2][3][4]", newBean);
@ -123,20 +123,20 @@ public class BeanWrapperAutoGrowingTests { @@ -123,20 +123,20 @@ public class BeanWrapperAutoGrowingTests {
}
@Test
public void getPropertyValueAutoGrowList() {
void getPropertyValueAutoGrowList() {
assertNotNull(wrapper.getPropertyValue("list[0]"));
assertThat(bean.getList()).hasSize(1);
assertThat(bean.getList()).element(0).isInstanceOf(Bean.class);
}
@Test
public void setPropertyValueAutoGrowList() {
void setPropertyValueAutoGrowList() {
wrapper.setPropertyValue("list[0].prop", "test");
assertThat(bean.getList().get(0).getProp()).isEqualTo("test");
}
@Test
public void getPropertyValueAutoGrowListBySeveralElements() {
void getPropertyValueAutoGrowListBySeveralElements() {
assertNotNull(wrapper.getPropertyValue("list[4]"));
assertThat(bean.getList()).hasSize(5);
assertThat(bean.getList()).element(0).isInstanceOf(Bean.class);
@ -151,7 +151,7 @@ public class BeanWrapperAutoGrowingTests { @@ -151,7 +151,7 @@ public class BeanWrapperAutoGrowingTests {
}
@Test
public void getPropertyValueAutoGrowListFailsAgainstLimit() {
void getPropertyValueAutoGrowListFailsAgainstLimit() {
wrapper.setAutoGrowCollectionLimit(2);
assertThatExceptionOfType(InvalidPropertyException.class).isThrownBy(() ->
wrapper.getPropertyValue("list[4]"))
@ -159,26 +159,26 @@ public class BeanWrapperAutoGrowingTests { @@ -159,26 +159,26 @@ public class BeanWrapperAutoGrowingTests {
}
@Test
public void getPropertyValueAutoGrowMultiDimensionalList() {
void getPropertyValueAutoGrowMultiDimensionalList() {
assertNotNull(wrapper.getPropertyValue("multiList[0][0]"));
assertThat(bean.getMultiList()).element(0).asList().hasSize(1);
assertThat(bean.getMultiList().get(0)).element(0).isInstanceOf(Bean.class);
}
@Test
public void getPropertyValueAutoGrowListNotParameterized() {
void getPropertyValueAutoGrowListNotParameterized() {
assertThatExceptionOfType(InvalidPropertyException.class).isThrownBy(() ->
wrapper.getPropertyValue("listNotParameterized[0]"));
}
@Test
public void setPropertyValueAutoGrowMap() {
void setPropertyValueAutoGrowMap() {
wrapper.setPropertyValue("map[A]", new Bean());
assertThat(bean.getMap().get("A")).isInstanceOf(Bean.class);
}
@Test
public void setNestedPropertyValueAutoGrowMap() {
void setNestedPropertyValueAutoGrowMap() {
wrapper.setPropertyValue("map[A].nested", new Bean());
assertThat(bean.getMap().get("A").getNested()).isInstanceOf(Bean.class);
}

36
spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Juergen Hoeller
* @author Chris Beams
*/
public class BeanWrapperEnumTests {
class BeanWrapperEnumTests {
@Test
public void testCustomEnum() {
void testCustomEnum() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("customEnum", "VALUE_1");
@ -42,7 +42,7 @@ public class BeanWrapperEnumTests { @@ -42,7 +42,7 @@ public class BeanWrapperEnumTests {
}
@Test
public void testCustomEnumWithNull() {
void testCustomEnumWithNull() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("customEnum", null);
@ -50,7 +50,7 @@ public class BeanWrapperEnumTests { @@ -50,7 +50,7 @@ public class BeanWrapperEnumTests {
}
@Test
public void testCustomEnumWithEmptyString() {
void testCustomEnumWithEmptyString() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("customEnum", "");
@ -58,7 +58,7 @@ public class BeanWrapperEnumTests { @@ -58,7 +58,7 @@ public class BeanWrapperEnumTests {
}
@Test
public void testCustomEnumArrayWithSingleValue() {
void testCustomEnumArrayWithSingleValue() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("customEnumArray", "VALUE_1");
@ -67,7 +67,7 @@ public class BeanWrapperEnumTests { @@ -67,7 +67,7 @@ public class BeanWrapperEnumTests {
}
@Test
public void testCustomEnumArrayWithMultipleValues() {
void testCustomEnumArrayWithMultipleValues() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("customEnumArray", new String[] {"VALUE_1", "VALUE_2"});
@ -77,7 +77,7 @@ public class BeanWrapperEnumTests { @@ -77,7 +77,7 @@ public class BeanWrapperEnumTests {
}
@Test
public void testCustomEnumArrayWithMultipleValuesAsCsv() {
void testCustomEnumArrayWithMultipleValuesAsCsv() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("customEnumArray", "VALUE_1,VALUE_2");
@ -87,7 +87,7 @@ public class BeanWrapperEnumTests { @@ -87,7 +87,7 @@ public class BeanWrapperEnumTests {
}
@Test
public void testCustomEnumSetWithSingleValue() {
void testCustomEnumSetWithSingleValue() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("customEnumSet", "VALUE_1");
@ -96,7 +96,7 @@ public class BeanWrapperEnumTests { @@ -96,7 +96,7 @@ public class BeanWrapperEnumTests {
}
@Test
public void testCustomEnumSetWithMultipleValues() {
void testCustomEnumSetWithMultipleValues() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("customEnumSet", new String[] {"VALUE_1", "VALUE_2"});
@ -106,7 +106,7 @@ public class BeanWrapperEnumTests { @@ -106,7 +106,7 @@ public class BeanWrapperEnumTests {
}
@Test
public void testCustomEnumSetWithMultipleValuesAsCsv() {
void testCustomEnumSetWithMultipleValuesAsCsv() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("customEnumSet", "VALUE_1,VALUE_2");
@ -116,7 +116,7 @@ public class BeanWrapperEnumTests { @@ -116,7 +116,7 @@ public class BeanWrapperEnumTests {
}
@Test
public void testCustomEnumSetWithGetterSetterMismatch() {
void testCustomEnumSetWithGetterSetterMismatch() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("customEnumSetMismatch", new String[] {"VALUE_1", "VALUE_2"});
@ -126,7 +126,7 @@ public class BeanWrapperEnumTests { @@ -126,7 +126,7 @@ public class BeanWrapperEnumTests {
}
@Test
public void testStandardEnumSetWithMultipleValues() {
void testStandardEnumSetWithMultipleValues() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setConversionService(new DefaultConversionService());
@ -138,7 +138,7 @@ public class BeanWrapperEnumTests { @@ -138,7 +138,7 @@ public class BeanWrapperEnumTests {
}
@Test
public void testStandardEnumSetWithAutoGrowing() {
void testStandardEnumSetWithAutoGrowing() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setAutoGrowNestedPaths(true);
@ -148,7 +148,7 @@ public class BeanWrapperEnumTests { @@ -148,7 +148,7 @@ public class BeanWrapperEnumTests {
}
@Test
public void testStandardEnumMapWithMultipleValues() {
void testStandardEnumMapWithMultipleValues() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setConversionService(new DefaultConversionService());
@ -163,7 +163,7 @@ public class BeanWrapperEnumTests { @@ -163,7 +163,7 @@ public class BeanWrapperEnumTests {
}
@Test
public void testStandardEnumMapWithAutoGrowing() {
void testStandardEnumMapWithAutoGrowing() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setAutoGrowNestedPaths(true);
@ -174,7 +174,7 @@ public class BeanWrapperEnumTests { @@ -174,7 +174,7 @@ public class BeanWrapperEnumTests {
}
@Test
public void testNonPublicEnum() {
void testNonPublicEnum() {
NonPublicEnumHolder holder = new NonPublicEnumHolder();
BeanWrapper bw = new BeanWrapperImpl(holder);
bw.setPropertyValue("nonPublicEnum", "VALUE_1");
@ -184,7 +184,7 @@ public class BeanWrapperEnumTests { @@ -184,7 +184,7 @@ public class BeanWrapperEnumTests {
enum NonPublicEnum {
VALUE_1, VALUE_2;
VALUE_1, VALUE_2
}

19
spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -201,7 +201,7 @@ class BeanWrapperGenericsTests { @@ -201,7 +201,7 @@ class BeanWrapperGenericsTests {
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("listOfLists[0][0]", 5);
assertThat(bw.getPropertyValue("listOfLists[0][0]")).isEqualTo(5);
assertThat(gb.getListOfLists().get(0)).element(0).isEqualTo(5);
assertThat(gb.getListOfLists()).singleElement().asList().containsExactly(5);
}
@Test
@ -213,7 +213,7 @@ class BeanWrapperGenericsTests { @@ -213,7 +213,7 @@ class BeanWrapperGenericsTests {
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("listOfLists[0][0]", "5");
assertThat(bw.getPropertyValue("listOfLists[0][0]")).isEqualTo(5);
assertThat(gb.getListOfLists().get(0)).element(0).isEqualTo(5);
assertThat(gb.getListOfLists()).singleElement().asList().containsExactly(5);
}
@Test
@ -298,7 +298,7 @@ class BeanWrapperGenericsTests { @@ -298,7 +298,7 @@ class BeanWrapperGenericsTests {
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("mapOfLists[1][0]", 5);
assertThat(bw.getPropertyValue("mapOfLists[1][0]")).isEqualTo(5);
assertThat(gb.getMapOfLists().get(1)).element(0).isEqualTo(5);
assertThat(gb.getMapOfLists().get(1)).containsExactly(5);
}
@Test
@ -310,7 +310,7 @@ class BeanWrapperGenericsTests { @@ -310,7 +310,7 @@ class BeanWrapperGenericsTests {
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("mapOfLists[1][0]", "5");
assertThat(bw.getPropertyValue("mapOfLists[1][0]")).isEqualTo(5);
assertThat(gb.getMapOfLists().get(1)).element(0).isEqualTo(5);
assertThat(gb.getMapOfLists().get(1)).containsExactly(5);
}
@Test
@ -516,8 +516,7 @@ class BeanWrapperGenericsTests { @@ -516,8 +516,7 @@ class BeanWrapperGenericsTests {
bw.setPropertyValue("genericProperty", "10");
bw.setPropertyValue("genericListProperty", new String[] {"20", "30"});
assertThat(gb.getGenericProperty()).isEqualTo(10);
assertThat(gb.getGenericListProperty()).element(0).isEqualTo(20);
assertThat(gb.getGenericListProperty()).element(1).isEqualTo(30);
assertThat(gb.getGenericListProperty()).containsExactly(20, 30);
}
@Test
@ -526,9 +525,9 @@ class BeanWrapperGenericsTests { @@ -526,9 +525,9 @@ class BeanWrapperGenericsTests {
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("genericProperty", "10");
bw.setPropertyValue("genericListProperty", new String[] {"20", "30"});
assertThat(gb.getGenericProperty()).element(0).isEqualTo(10);
assertThat(gb.getGenericListProperty().get(0)).element(0).isEqualTo(20);
assertThat(gb.getGenericListProperty().get(1)).element(0).isEqualTo(30);
assertThat(gb.getGenericProperty()).containsExactly(10);
assertThat(gb.getGenericListProperty().get(0)).containsExactly(20);
assertThat(gb.getGenericListProperty().get(1)).containsExactly(30);
}
@Test

4
spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -428,7 +428,7 @@ class BeanWrapperTests extends AbstractPropertyAccessorTests { @@ -428,7 +428,7 @@ class BeanWrapperTests extends AbstractPropertyAccessorTests {
}
@Override
public void close() throws Exception {
public void close() {
}
}

10
spring-beans/src/test/java/org/springframework/beans/CachedIntrospectionResultsTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -32,10 +32,10 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -32,10 +32,10 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Chris Beams
* @author Arjen Poutsma
*/
public class CachedIntrospectionResultsTests {
class CachedIntrospectionResultsTests {
@Test
public void acceptAndClearClassLoader() throws Exception {
void acceptAndClearClassLoader() throws Exception {
BeanWrapper bw = new BeanWrapperImpl(TestBean.class);
assertThat(bw.isWritableProperty("name")).isTrue();
assertThat(bw.isWritableProperty("age")).isTrue();
@ -56,7 +56,7 @@ public class CachedIntrospectionResultsTests { @@ -56,7 +56,7 @@ public class CachedIntrospectionResultsTests {
}
@Test
public void clearClassLoaderForSystemClassLoader() throws Exception {
void clearClassLoaderForSystemClassLoader() {
BeanUtils.getPropertyDescriptors(ArrayList.class);
assertThat(CachedIntrospectionResults.strongClassCache.containsKey(ArrayList.class)).isTrue();
CachedIntrospectionResults.clearClassLoader(ArrayList.class.getClassLoader());
@ -64,7 +64,7 @@ public class CachedIntrospectionResultsTests { @@ -64,7 +64,7 @@ public class CachedIntrospectionResultsTests {
}
@Test
public void shouldUseExtendedBeanInfoWhenApplicable() throws NoSuchMethodException, SecurityException {
void shouldUseExtendedBeanInfoWhenApplicable() throws NoSuchMethodException, SecurityException {
// given a class with a non-void returning setter method
@SuppressWarnings("unused")
class C {

4
spring-beans/src/test/java/org/springframework/beans/ConcurrentBeanWrapperTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -97,7 +97,7 @@ class ConcurrentBeanWrapperTests { @@ -97,7 +97,7 @@ class ConcurrentBeanWrapperTests {
// ByteArrayOutputStream does not throw
// any IOException
}
String value = new String(buffer.toByteArray());
String value = buffer.toString();
BeanWrapperImpl wrapper = new BeanWrapperImpl(bean);
wrapper.setPropertyValue("properties", value);

4
spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -558,7 +558,7 @@ class ExtendedBeanInfoTests { @@ -558,7 +558,7 @@ class ExtendedBeanInfoTests {
* @see #cornerSpr9702()
*/
@Test
void cornerSpr10111() throws Exception {
void cornerSpr10111() {
assertThatNoException().isThrownBy(() -> new ExtendedBeanInfo(Introspector.getBeanInfo(BigDecimal.class)));
}

18
spring-beans/src/test/java/org/springframework/beans/PropertyAccessorUtilsTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -26,17 +26,17 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -26,17 +26,17 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Juergen Hoeller
* @author Chris Beams
*/
public class PropertyAccessorUtilsTests {
class PropertyAccessorUtilsTests {
@Test
public void getPropertyName() {
void getPropertyName() {
assertThat(PropertyAccessorUtils.getPropertyName("")).isEmpty();
assertThat(PropertyAccessorUtils.getPropertyName("[user]")).isEmpty();
assertThat(PropertyAccessorUtils.getPropertyName("user")).isEqualTo("user");
}
@Test
public void isNestedOrIndexedProperty() {
void isNestedOrIndexedProperty() {
assertThat(PropertyAccessorUtils.isNestedOrIndexedProperty(null)).isFalse();
assertThat(PropertyAccessorUtils.isNestedOrIndexedProperty("")).isFalse();
assertThat(PropertyAccessorUtils.isNestedOrIndexedProperty("user")).isFalse();
@ -46,19 +46,19 @@ public class PropertyAccessorUtilsTests { @@ -46,19 +46,19 @@ public class PropertyAccessorUtilsTests {
}
@Test
public void getFirstNestedPropertySeparatorIndex() {
void getFirstNestedPropertySeparatorIndex() {
assertThat(PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex("[user]")).isEqualTo(-1);
assertThat(PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex("user.name")).isEqualTo(4);
}
@Test
public void getLastNestedPropertySeparatorIndex() {
void getLastNestedPropertySeparatorIndex() {
assertThat(PropertyAccessorUtils.getLastNestedPropertySeparatorIndex("[user]")).isEqualTo(-1);
assertThat(PropertyAccessorUtils.getLastNestedPropertySeparatorIndex("user.address.street")).isEqualTo(12);
}
@Test
public void matchesProperty() {
void matchesProperty() {
assertThat(PropertyAccessorUtils.matchesProperty("user", "email")).isFalse();
assertThat(PropertyAccessorUtils.matchesProperty("username", "user")).isFalse();
assertThat(PropertyAccessorUtils.matchesProperty("admin[user]", "user")).isFalse();
@ -68,7 +68,7 @@ public class PropertyAccessorUtilsTests { @@ -68,7 +68,7 @@ public class PropertyAccessorUtilsTests {
}
@Test
public void canonicalPropertyName() {
void canonicalPropertyName() {
assertThat(PropertyAccessorUtils.canonicalPropertyName(null)).isEmpty();
assertThat(PropertyAccessorUtils.canonicalPropertyName("map")).isEqualTo("map");
assertThat(PropertyAccessorUtils.canonicalPropertyName("map[key1]")).isEqualTo("map[key1]");
@ -82,7 +82,7 @@ public class PropertyAccessorUtilsTests { @@ -82,7 +82,7 @@ public class PropertyAccessorUtilsTests {
}
@Test
public void canonicalPropertyNames() {
void canonicalPropertyNames() {
assertThat(PropertyAccessorUtils.canonicalPropertyNames(null)).isNull();
String[] original =

28
spring-beans/src/test/java/org/springframework/beans/PropertyMatchesTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -30,28 +30,28 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -30,28 +30,28 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Stephane Nicoll
*/
public class PropertyMatchesTests {
class PropertyMatchesTests {
@Test
public void simpleBeanPropertyTypo() {
void simpleBeanPropertyTypo() {
PropertyMatches matches = PropertyMatches.forProperty("naem", SampleBeanProperties.class);
assertThat(matches.getPossibleMatches()).contains("name");
}
@Test
public void complexBeanPropertyTypo() {
void complexBeanPropertyTypo() {
PropertyMatches matches = PropertyMatches.forProperty("desriptn", SampleBeanProperties.class);
assertThat(matches.getPossibleMatches()).isEmpty();
}
@Test
public void unknownBeanProperty() {
void unknownBeanProperty() {
PropertyMatches matches = PropertyMatches.forProperty("unknown", SampleBeanProperties.class);
assertThat(matches.getPossibleMatches()).isEmpty();
}
@Test
public void severalMatchesBeanProperty() {
void severalMatchesBeanProperty() {
PropertyMatches matches = PropertyMatches.forProperty("counter", SampleBeanProperties.class);
assertThat(matches.getPossibleMatches()).contains("counter1");
assertThat(matches.getPossibleMatches()).contains("counter2");
@ -59,7 +59,7 @@ public class PropertyMatchesTests { @@ -59,7 +59,7 @@ public class PropertyMatchesTests {
}
@Test
public void simpleBeanPropertyErrorMessage() {
void simpleBeanPropertyErrorMessage() {
PropertyMatches matches = PropertyMatches.forProperty("naem", SampleBeanProperties.class);
String msg = matches.buildErrorMessage();
assertThat(msg).contains("naem");
@ -69,7 +69,7 @@ public class PropertyMatchesTests { @@ -69,7 +69,7 @@ public class PropertyMatchesTests {
}
@Test
public void complexBeanPropertyErrorMessage() {
void complexBeanPropertyErrorMessage() {
PropertyMatches matches = PropertyMatches.forProperty("counter", SampleBeanProperties.class);
String msg = matches.buildErrorMessage();
assertThat(msg).contains("counter");
@ -79,25 +79,25 @@ public class PropertyMatchesTests { @@ -79,25 +79,25 @@ public class PropertyMatchesTests {
}
@Test
public void simpleFieldPropertyTypo() {
void simpleFieldPropertyTypo() {
PropertyMatches matches = PropertyMatches.forField("naem", SampleFieldProperties.class);
assertThat(matches.getPossibleMatches()).contains("name");
}
@Test
public void complexFieldPropertyTypo() {
void complexFieldPropertyTypo() {
PropertyMatches matches = PropertyMatches.forField("desriptn", SampleFieldProperties.class);
assertThat(matches.getPossibleMatches()).isEmpty();
}
@Test
public void unknownFieldProperty() {
void unknownFieldProperty() {
PropertyMatches matches = PropertyMatches.forField("unknown", SampleFieldProperties.class);
assertThat(matches.getPossibleMatches()).isEmpty();
}
@Test
public void severalMatchesFieldProperty() {
void severalMatchesFieldProperty() {
PropertyMatches matches = PropertyMatches.forField("counter", SampleFieldProperties.class);
assertThat(matches.getPossibleMatches()).contains("counter1");
assertThat(matches.getPossibleMatches()).contains("counter2");
@ -105,7 +105,7 @@ public class PropertyMatchesTests { @@ -105,7 +105,7 @@ public class PropertyMatchesTests {
}
@Test
public void simpleFieldPropertyErrorMessage() {
void simpleFieldPropertyErrorMessage() {
PropertyMatches matches = PropertyMatches.forField("naem", SampleFieldProperties.class);
String msg = matches.buildErrorMessage();
assertThat(msg).contains("naem");
@ -115,7 +115,7 @@ public class PropertyMatchesTests { @@ -115,7 +115,7 @@ public class PropertyMatchesTests {
}
@Test
public void complexFieldPropertyErrorMessage() {
void complexFieldPropertyErrorMessage() {
PropertyMatches matches = PropertyMatches.forField("counter", SampleFieldProperties.class);
String msg = matches.buildErrorMessage();
assertThat(msg).contains("counter");

10
spring-beans/src/test/java/org/springframework/beans/SimplePropertyDescriptorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -30,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -30,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Chris Beams
* @see ExtendedBeanInfoTests
*/
public class SimplePropertyDescriptorTests {
class SimplePropertyDescriptorTests {
@Test
public void toStringOutput() throws IntrospectionException, SecurityException, NoSuchMethodException {
void toStringOutput() throws IntrospectionException, SecurityException, NoSuchMethodException {
{
Object pd = new ExtendedBeanInfo.SimplePropertyDescriptor("foo", null, null);
assertThat(pd.toString()).contains(
@ -71,7 +71,7 @@ public class SimplePropertyDescriptorTests { @@ -71,7 +71,7 @@ public class SimplePropertyDescriptorTests {
}
@Test
public void nonIndexedEquality() throws IntrospectionException, SecurityException, NoSuchMethodException {
void nonIndexedEquality() throws IntrospectionException, SecurityException, NoSuchMethodException {
Object pd1 = new ExtendedBeanInfo.SimplePropertyDescriptor("foo", null, null);
assertThat(pd1).isEqualTo(pd1);
@ -108,7 +108,7 @@ public class SimplePropertyDescriptorTests { @@ -108,7 +108,7 @@ public class SimplePropertyDescriptorTests {
}
@Test
public void indexedEquality() throws IntrospectionException, SecurityException, NoSuchMethodException {
void indexedEquality() throws IntrospectionException, SecurityException, NoSuchMethodException {
Object pd1 = new ExtendedBeanInfo.SimpleIndexedPropertyDescriptor("foo", null, null, null, null);
assertThat(pd1).isEqualTo(pd1);

42
spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -49,7 +49,7 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie @@ -49,7 +49,7 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
* @author Sam Brannen
* @since 04.07.2003
*/
public class BeanFactoryUtilsTests {
class BeanFactoryUtilsTests {
private static final Class<?> CLASS = BeanFactoryUtilsTests.class;
private static final Resource ROOT_CONTEXT = qualifiedResource(CLASS, "root.xml");
@ -63,7 +63,7 @@ public class BeanFactoryUtilsTests { @@ -63,7 +63,7 @@ public class BeanFactoryUtilsTests {
@BeforeEach
public void setup() {
void setup() {
// Interesting hierarchical factory to test counts.
DefaultListableBeanFactory grandParent = new DefaultListableBeanFactory();
@ -81,7 +81,7 @@ public class BeanFactoryUtilsTests { @@ -81,7 +81,7 @@ public class BeanFactoryUtilsTests {
@Test
public void testHierarchicalCountBeansWithNonHierarchicalFactory() {
void testHierarchicalCountBeansWithNonHierarchicalFactory() {
StaticListableBeanFactory lbf = new StaticListableBeanFactory();
lbf.addBean("t1", new TestBean());
lbf.addBean("t2", new TestBean());
@ -92,7 +92,7 @@ public class BeanFactoryUtilsTests { @@ -92,7 +92,7 @@ public class BeanFactoryUtilsTests {
* Check that override doesn't count as two separate beans.
*/
@Test
public void testHierarchicalCountBeansWithOverride() {
void testHierarchicalCountBeansWithOverride() {
// Leaf count
assertThat(this.listableBeanFactory.getBeanDefinitionCount()).isEqualTo(1);
// Count minus duplicate
@ -101,14 +101,14 @@ public class BeanFactoryUtilsTests { @@ -101,14 +101,14 @@ public class BeanFactoryUtilsTests {
}
@Test
public void testHierarchicalNamesWithNoMatch() {
void testHierarchicalNamesWithNoMatch() {
List<String> names = Arrays.asList(
BeanFactoryUtils.beanNamesForTypeIncludingAncestors(this.listableBeanFactory, NoOp.class));
assertThat(names).isEmpty();
}
@Test
public void testHierarchicalNamesWithMatchOnlyInRoot() {
void testHierarchicalNamesWithMatchOnlyInRoot() {
List<String> names = Arrays.asList(
BeanFactoryUtils.beanNamesForTypeIncludingAncestors(this.listableBeanFactory, IndexedTestBean.class));
assertThat(names).hasSize(1);
@ -118,7 +118,7 @@ public class BeanFactoryUtilsTests { @@ -118,7 +118,7 @@ public class BeanFactoryUtilsTests {
}
@Test
public void testGetBeanNamesForTypeWithOverride() {
void testGetBeanNamesForTypeWithOverride() {
List<String> names = Arrays.asList(
BeanFactoryUtils.beanNamesForTypeIncludingAncestors(this.listableBeanFactory, ITestBean.class));
// includes 2 TestBeans from FactoryBeans (DummyFactory definitions)
@ -130,7 +130,7 @@ public class BeanFactoryUtilsTests { @@ -130,7 +130,7 @@ public class BeanFactoryUtilsTests {
}
@Test
public void testNoBeansOfType() {
void testNoBeansOfType() {
StaticListableBeanFactory lbf = new StaticListableBeanFactory();
lbf.addBean("foo", new Object());
Map<String, ?> beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(lbf, ITestBean.class, true, false);
@ -138,7 +138,7 @@ public class BeanFactoryUtilsTests { @@ -138,7 +138,7 @@ public class BeanFactoryUtilsTests {
}
@Test
public void testFindsBeansOfTypeWithStaticFactory() {
void testFindsBeansOfTypeWithStaticFactory() {
StaticListableBeanFactory lbf = new StaticListableBeanFactory();
TestBean t1 = new TestBean();
TestBean t2 = new TestBean();
@ -169,7 +169,7 @@ public class BeanFactoryUtilsTests { @@ -169,7 +169,7 @@ public class BeanFactoryUtilsTests {
}
@Test
public void testFindsBeansOfTypeWithDefaultFactory() {
void testFindsBeansOfTypeWithDefaultFactory() {
Object test3 = this.listableBeanFactory.getBean("test3");
Object test = this.listableBeanFactory.getBean("test");
@ -232,7 +232,7 @@ public class BeanFactoryUtilsTests { @@ -232,7 +232,7 @@ public class BeanFactoryUtilsTests {
}
@Test
public void testHierarchicalResolutionWithOverride() {
void testHierarchicalResolutionWithOverride() {
Object test3 = this.listableBeanFactory.getBean("test3");
Object test = this.listableBeanFactory.getBean("test");
@ -271,14 +271,14 @@ public class BeanFactoryUtilsTests { @@ -271,14 +271,14 @@ public class BeanFactoryUtilsTests {
}
@Test
public void testHierarchicalNamesForAnnotationWithNoMatch() {
void testHierarchicalNamesForAnnotationWithNoMatch() {
List<String> names = Arrays.asList(
BeanFactoryUtils.beanNamesForAnnotationIncludingAncestors(this.listableBeanFactory, Override.class));
assertThat(names).isEmpty();
}
@Test
public void testHierarchicalNamesForAnnotationWithMatchOnlyInRoot() {
void testHierarchicalNamesForAnnotationWithMatchOnlyInRoot() {
List<String> names = Arrays.asList(
BeanFactoryUtils.beanNamesForAnnotationIncludingAncestors(this.listableBeanFactory, TestAnnotation.class));
assertThat(names).hasSize(1);
@ -288,7 +288,7 @@ public class BeanFactoryUtilsTests { @@ -288,7 +288,7 @@ public class BeanFactoryUtilsTests {
}
@Test
public void testGetBeanNamesForAnnotationWithOverride() {
void testGetBeanNamesForAnnotationWithOverride() {
AnnotatedBean annotatedBean = new AnnotatedBean();
this.listableBeanFactory.registerSingleton("anotherAnnotatedBean", annotatedBean);
List<String> names = Arrays.asList(
@ -299,31 +299,31 @@ public class BeanFactoryUtilsTests { @@ -299,31 +299,31 @@ public class BeanFactoryUtilsTests {
}
@Test
public void testADependencies() {
void testADependencies() {
String[] deps = this.dependentBeansFactory.getDependentBeans("a");
assertThat(ObjectUtils.isEmpty(deps)).isTrue();
}
@Test
public void testBDependencies() {
void testBDependencies() {
String[] deps = this.dependentBeansFactory.getDependentBeans("b");
assertThat(Arrays.equals(new String[] { "c" }, deps)).isTrue();
}
@Test
public void testCDependencies() {
void testCDependencies() {
String[] deps = this.dependentBeansFactory.getDependentBeans("c");
assertThat(Arrays.equals(new String[] { "int", "long" }, deps)).isTrue();
}
@Test
public void testIntDependencies() {
void testIntDependencies() {
String[] deps = this.dependentBeansFactory.getDependentBeans("int");
assertThat(Arrays.equals(new String[] { "buffer" }, deps)).isTrue();
}
@Test
public void findAnnotationOnBean() {
void findAnnotationOnBean() {
this.listableBeanFactory.registerSingleton("controllerAdvice", new ControllerAdviceClass());
this.listableBeanFactory.registerSingleton("restControllerAdvice", new RestControllerAdviceClass());
testFindAnnotationOnBean(this.listableBeanFactory);
@ -350,7 +350,7 @@ public class BeanFactoryUtilsTests { @@ -350,7 +350,7 @@ public class BeanFactoryUtilsTests {
}
@Test
public void isSingletonAndIsPrototypeWithStaticFactory() {
void isSingletonAndIsPrototypeWithStaticFactory() {
StaticListableBeanFactory lbf = new StaticListableBeanFactory();
TestBean bean = new TestBean();
DummyFactory fb1 = new DummyFactory();

8
spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -1240,7 +1240,7 @@ class DefaultListableBeanFactoryTests { @@ -1240,7 +1240,7 @@ class DefaultListableBeanFactoryTests {
}
@Test
void arrayPropertyWithOptionalAutowiring() throws MalformedURLException {
void arrayPropertyWithOptionalAutowiring() {
RootBeanDefinition rbd = new RootBeanDefinition(ArrayBean.class);
rbd.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE);
lbf.registerBeanDefinition("arrayBean", rbd);
@ -3211,7 +3211,7 @@ class DefaultListableBeanFactoryTests { @@ -3211,7 +3211,7 @@ class DefaultListableBeanFactoryTests {
extends RepositoryFactoryBeanSupport<T, S, ID> {
@Override
public T getObject() throws Exception {
public T getObject() {
throw new IllegalArgumentException("Should not be called");
}
@ -3460,7 +3460,7 @@ class DefaultListableBeanFactoryTests { @@ -3460,7 +3460,7 @@ class DefaultListableBeanFactoryTests {
enum NonPublicEnum {
VALUE_1, VALUE_2;
VALUE_1, VALUE_2
}

18
spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanLookupTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -32,42 +32,42 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -32,42 +32,42 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Chris Beams
*/
public class FactoryBeanLookupTests {
class FactoryBeanLookupTests {
private BeanFactory beanFactory;
@BeforeEach
public void setUp() {
void setUp() {
beanFactory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory).loadBeanDefinitions(
new ClassPathResource("FactoryBeanLookupTests-context.xml", this.getClass()));
}
@Test
public void factoryBeanLookupByNameDereferencing() {
void factoryBeanLookupByNameDereferencing() {
Object fooFactory = beanFactory.getBean("&fooFactory");
assertThat(fooFactory).isInstanceOf(FooFactoryBean.class);
}
@Test
public void factoryBeanLookupByType() {
void factoryBeanLookupByType() {
FooFactoryBean fooFactory = beanFactory.getBean(FooFactoryBean.class);
assertThat(fooFactory).isNotNull();
}
@Test
public void factoryBeanLookupByTypeAndNameDereference() {
void factoryBeanLookupByTypeAndNameDereference() {
FooFactoryBean fooFactory = beanFactory.getBean("&fooFactory", FooFactoryBean.class);
assertThat(fooFactory).isNotNull();
}
@Test
public void factoryBeanObjectLookupByName() {
void factoryBeanObjectLookupByName() {
Object fooFactory = beanFactory.getBean("fooFactory");
assertThat(fooFactory).isInstanceOf(Foo.class);
}
@Test
public void factoryBeanObjectLookupByNameAndType() {
void factoryBeanObjectLookupByNameAndType() {
Foo foo = beanFactory.getBean("fooFactory", Foo.class);
assertThat(foo).isNotNull();
}
@ -75,7 +75,7 @@ public class FactoryBeanLookupTests { @@ -75,7 +75,7 @@ public class FactoryBeanLookupTests {
class FooFactoryBean extends AbstractFactoryBean<Foo> {
@Override
protected Foo createInstance() throws Exception {
protected Foo createInstance() {
return new Foo();
}

16
spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -38,7 +38,7 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie @@ -38,7 +38,7 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
* @author Juergen Hoeller
* @author Chris Beams
*/
public class FactoryBeanTests {
class FactoryBeanTests {
private static final Class<?> CLASS = FactoryBeanTests.class;
private static final Resource RETURNS_NULL_CONTEXT = qualifiedResource(CLASS, "returnsNull.xml");
@ -48,7 +48,7 @@ public class FactoryBeanTests { @@ -48,7 +48,7 @@ public class FactoryBeanTests {
@Test
public void testFactoryBeanReturnsNull() throws Exception {
void testFactoryBeanReturnsNull() {
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(factory).loadBeanDefinitions(RETURNS_NULL_CONTEXT);
@ -56,7 +56,7 @@ public class FactoryBeanTests { @@ -56,7 +56,7 @@ public class FactoryBeanTests {
}
@Test
public void testFactoryBeansWithAutowiring() throws Exception {
void testFactoryBeansWithAutowiring() {
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(factory).loadBeanDefinitions(WITH_AUTOWIRING_CONTEXT);
@ -77,7 +77,7 @@ public class FactoryBeanTests { @@ -77,7 +77,7 @@ public class FactoryBeanTests {
}
@Test
public void testFactoryBeansWithIntermediateFactoryBeanAutowiringFailure() throws Exception {
void testFactoryBeansWithIntermediateFactoryBeanAutowiringFailure() {
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(factory).loadBeanDefinitions(WITH_AUTOWIRING_CONTEXT);
@ -92,21 +92,21 @@ public class FactoryBeanTests { @@ -92,21 +92,21 @@ public class FactoryBeanTests {
}
@Test
public void testAbstractFactoryBeanViaAnnotation() throws Exception {
void testAbstractFactoryBeanViaAnnotation() {
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(factory).loadBeanDefinitions(ABSTRACT_CONTEXT);
factory.getBeansWithAnnotation(Component.class);
}
@Test
public void testAbstractFactoryBeanViaType() throws Exception {
void testAbstractFactoryBeanViaType() {
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(factory).loadBeanDefinitions(ABSTRACT_CONTEXT);
factory.getBeansOfType(AbstractFactoryBean.class);
}
@Test
public void testCircularReferenceWithPostProcessor() {
void testCircularReferenceWithPostProcessor() {
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(factory).loadBeanDefinitions(CIRCULAR_CONTEXT);

12
spring-beans/src/test/java/org/springframework/beans/factory/Spr5475Tests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -33,10 +33,10 @@ import static org.springframework.beans.factory.support.BeanDefinitionBuilder.ro @@ -33,10 +33,10 @@ import static org.springframework.beans.factory.support.BeanDefinitionBuilder.ro
* @author Chris Beams
* @author Juergen Hoeller
*/
public class Spr5475Tests {
class Spr5475Tests {
@Test
public void noArgFactoryMethodInvokedWithOneArg() {
void noArgFactoryMethodInvokedWithOneArg() {
assertExceptionMessageForMisconfiguredFactoryMethod(
rootBeanDefinition(Foo.class)
.setFactoryMethod("noArgFactory")
@ -47,7 +47,7 @@ public class Spr5475Tests { @@ -47,7 +47,7 @@ public class Spr5475Tests {
}
@Test
public void noArgFactoryMethodInvokedWithTwoArgs() {
void noArgFactoryMethodInvokedWithTwoArgs() {
assertExceptionMessageForMisconfiguredFactoryMethod(
rootBeanDefinition(Foo.class)
.setFactoryMethod("noArgFactory")
@ -59,7 +59,7 @@ public class Spr5475Tests { @@ -59,7 +59,7 @@ public class Spr5475Tests {
}
@Test
public void noArgFactoryMethodInvokedWithTwoArgsAndTypesSpecified() {
void noArgFactoryMethodInvokedWithTwoArgsAndTypesSpecified() {
RootBeanDefinition def = new RootBeanDefinition(Foo.class);
def.setFactoryMethodName("noArgFactory");
ConstructorArgumentValues cav = new ConstructorArgumentValues();
@ -82,7 +82,7 @@ public class Spr5475Tests { @@ -82,7 +82,7 @@ public class Spr5475Tests {
}
@Test
public void singleArgFactoryMethodInvokedWithNoArgs() {
void singleArgFactoryMethodInvokedWithNoArgs() {
// calling a factory method that accepts arguments without any arguments emits an exception unlike cases
// where a no-arg factory method is called with arguments. Adding this test just to document the difference
assertExceptionMessageForMisconfiguredFactoryMethod(

14
spring-beans/src/test/java/org/springframework/beans/factory/annotation/AnnotationBeanWiringInfoResolverTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -27,30 +27,30 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException @@ -27,30 +27,30 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Rick Evans
* @author Chris Beams
*/
public class AnnotationBeanWiringInfoResolverTests {
class AnnotationBeanWiringInfoResolverTests {
@Test
public void testResolveWiringInfo() throws Exception {
void testResolveWiringInfo() {
assertThatIllegalArgumentException().isThrownBy(() ->
new AnnotationBeanWiringInfoResolver().resolveWiringInfo(null));
}
@Test
public void testResolveWiringInfoWithAnInstanceOfANonAnnotatedClass() {
void testResolveWiringInfoWithAnInstanceOfANonAnnotatedClass() {
AnnotationBeanWiringInfoResolver resolver = new AnnotationBeanWiringInfoResolver();
BeanWiringInfo info = resolver.resolveWiringInfo("java.lang.String is not @Configurable");
assertThat(info).as("Must be returning null for a non-@Configurable class instance").isNull();
}
@Test
public void testResolveWiringInfoWithAnInstanceOfAnAnnotatedClass() {
void testResolveWiringInfoWithAnInstanceOfAnAnnotatedClass() {
AnnotationBeanWiringInfoResolver resolver = new AnnotationBeanWiringInfoResolver();
BeanWiringInfo info = resolver.resolveWiringInfo(new Soap());
assertThat(info).as("Must *not* be returning null for a non-@Configurable class instance").isNotNull();
}
@Test
public void testResolveWiringInfoWithAnInstanceOfAnAnnotatedClassWithAutowiringTurnedOffExplicitly() {
void testResolveWiringInfoWithAnInstanceOfAnAnnotatedClassWithAutowiringTurnedOffExplicitly() {
AnnotationBeanWiringInfoResolver resolver = new AnnotationBeanWiringInfoResolver();
BeanWiringInfo info = resolver.resolveWiringInfo(new WirelessSoap());
assertThat(info).as("Must *not* be returning null for an @Configurable class instance even when autowiring is NO").isNotNull();
@ -59,7 +59,7 @@ public class AnnotationBeanWiringInfoResolverTests { @@ -59,7 +59,7 @@ public class AnnotationBeanWiringInfoResolverTests {
}
@Test
public void testResolveWiringInfoWithAnInstanceOfAnAnnotatedClassWithAutowiringTurnedOffExplicitlyAndCustomBeanName() {
void testResolveWiringInfoWithAnInstanceOfAnAnnotatedClassWithAutowiringTurnedOffExplicitlyAndCustomBeanName() {
AnnotationBeanWiringInfoResolver resolver = new AnnotationBeanWiringInfoResolver();
BeanWiringInfo info = resolver.resolveWiringInfo(new NamedWirelessSoap());
assertThat(info).as("Must *not* be returning null for an @Configurable class instance even when autowiring is NO").isNotNull();

151
spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -21,7 +21,6 @@ import java.lang.annotation.ElementType; @@ -21,7 +21,6 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Arrays;
@ -89,7 +88,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -89,7 +88,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Chris Beams
* @author Stephane Nicoll
*/
public class AutowiredAnnotationBeanPostProcessorTests {
class AutowiredAnnotationBeanPostProcessorTests {
private DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
@ -711,15 +710,9 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -711,15 +710,9 @@ public class AutowiredAnnotationBeanPostProcessorTests {
assertThat(bean.getTestBean3()).isSameAs(tb);
assertThat(bean.getTestBean4()).isSameAs(tb);
assertThat(bean.getIndexedTestBean()).isSameAs(itb);
assertThat(bean.getNestedTestBeans()).hasSize(2);
assertThat(bean.getNestedTestBeans()).element(0).isSameAs(ntb2);
assertThat(bean.getNestedTestBeans()).element(1).isSameAs(ntb1);
assertThat(bean.nestedTestBeansSetter).hasSize(2);
assertThat(bean.nestedTestBeansSetter).element(0).isSameAs(ntb2);
assertThat(bean.nestedTestBeansSetter).element(1).isSameAs(ntb1);
assertThat(bean.nestedTestBeansField).hasSize(2);
assertThat(bean.nestedTestBeansField).element(0).isSameAs(ntb2);
assertThat(bean.nestedTestBeansField).element(1).isSameAs(ntb1);
assertThat(bean.getNestedTestBeans()).containsExactly(ntb2, ntb1);
assertThat(bean.nestedTestBeansSetter).containsExactly(ntb2, ntb1);
assertThat(bean.nestedTestBeansField).containsExactly(ntb2, ntb1);
}
@Test
@ -744,15 +737,9 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -744,15 +737,9 @@ public class AutowiredAnnotationBeanPostProcessorTests {
assertThat(bean.getTestBean3()).isSameAs(tb);
assertThat(bean.getTestBean4()).isSameAs(tb);
assertThat(bean.getIndexedTestBean()).isSameAs(itb);
assertThat(bean.getNestedTestBeans()).hasSize(2);
assertThat(bean.getNestedTestBeans()).element(0).isSameAs(ntb2);
assertThat(bean.getNestedTestBeans()).element(1).isSameAs(ntb1);
assertThat(bean.nestedTestBeansSetter).hasSize(2);
assertThat(bean.nestedTestBeansSetter).element(0).isSameAs(ntb2);
assertThat(bean.nestedTestBeansSetter).element(1).isSameAs(ntb1);
assertThat(bean.nestedTestBeansField).hasSize(2);
assertThat(bean.nestedTestBeansField).element(0).isSameAs(ntb2);
assertThat(bean.nestedTestBeansField).element(1).isSameAs(ntb1);
assertThat(bean.getNestedTestBeans()).containsExactly(ntb2, ntb1);
assertThat(bean.nestedTestBeansSetter).containsExactly(ntb2, ntb1);
assertThat(bean.nestedTestBeansField).containsExactly(ntb2, ntb1);
}
@Test
@ -1112,9 +1099,7 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -1112,9 +1099,7 @@ public class AutowiredAnnotationBeanPostProcessorTests {
ConstructorsCollectionResourceInjectionBean bean = bf.getBean("annotatedBean", ConstructorsCollectionResourceInjectionBean.class);
assertThat(bean.getTestBean3()).isNull();
assertThat(bean.getTestBean4()).isSameAs(tb);
assertThat(bean.getNestedTestBeans()).hasSize(2);
assertThat(bean.getNestedTestBeans()).element(0).isSameAs(ntb2);
assertThat(bean.getNestedTestBeans()).element(1).isSameAs(ntb1);
assertThat(bean.getNestedTestBeans()).containsExactly(ntb2, ntb1);
}
@Test
@ -1129,9 +1114,7 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -1129,9 +1114,7 @@ public class AutowiredAnnotationBeanPostProcessorTests {
SingleConstructorVarargBean bean = bf.getBean("annotatedBean", SingleConstructorVarargBean.class);
assertThat(bean.getTestBean()).isSameAs(tb);
assertThat(bean.getNestedTestBeans()).hasSize(2);
assertThat(bean.getNestedTestBeans()).element(0).isSameAs(ntb2);
assertThat(bean.getNestedTestBeans()).element(1).isSameAs(ntb1);
assertThat(bean.getNestedTestBeans()).containsExactly(ntb2, ntb1);
}
@Test
@ -1158,9 +1141,7 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -1158,9 +1141,7 @@ public class AutowiredAnnotationBeanPostProcessorTests {
SingleConstructorRequiredCollectionBean bean = bf.getBean("annotatedBean", SingleConstructorRequiredCollectionBean.class);
assertThat(bean.getTestBean()).isSameAs(tb);
assertThat(bean.getNestedTestBeans()).hasSize(2);
assertThat(bean.getNestedTestBeans()).element(0).isSameAs(ntb2);
assertThat(bean.getNestedTestBeans()).element(1).isSameAs(ntb1);
assertThat(bean.getNestedTestBeans()).containsExactly(ntb2, ntb1);
}
@Test
@ -1187,9 +1168,7 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -1187,9 +1168,7 @@ public class AutowiredAnnotationBeanPostProcessorTests {
SingleConstructorOptionalCollectionBean bean = bf.getBean("annotatedBean", SingleConstructorOptionalCollectionBean.class);
assertThat(bean.getTestBean()).isSameAs(tb);
assertThat(bean.getNestedTestBeans()).hasSize(2);
assertThat(bean.getNestedTestBeans()).element(0).isSameAs(ntb2);
assertThat(bean.getNestedTestBeans()).element(1).isSameAs(ntb1);
assertThat(bean.getNestedTestBeans()).containsExactly(ntb2, ntb1);
}
@Test
@ -1500,8 +1479,7 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -1500,8 +1479,7 @@ public class AutowiredAnnotationBeanPostProcessorTests {
SelfInjectionBean bean = bf.getBean("annotatedBean", SelfInjectionBean.class);
SelfInjectionBean bean2 = bf.getBean("annotatedBean2", SelfInjectionBean.class);
assertThat(bean.reference).isSameAs(bean2);
assertThat(bean.referenceCollection).hasSize(1);
assertThat(bean.referenceCollection).element(0).isSameAs(bean2);
assertThat(bean.referenceCollection).containsExactly(bean2);
}
@Test
@ -1986,10 +1964,8 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -1986,10 +1964,8 @@ public class AutowiredAnnotationBeanPostProcessorTests {
assertThat(bean.integerArray).hasSize(1);
assertThat(bean.stringArray[0]).isSameAs(sv);
assertThat(bean.integerArray[0]).isSameAs(iv);
assertThat(bean.stringList).hasSize(1);
assertThat(bean.integerList).hasSize(1);
assertThat(bean.stringList).element(0).isSameAs(sv);
assertThat(bean.integerList).element(0).isSameAs(iv);
assertThat(bean.stringList).containsExactly(sv);
assertThat(bean.integerList).containsExactly(iv);
assertThat(bean.stringMap).hasSize(1);
assertThat(bean.integerMap).hasSize(1);
assertThat(bean.stringMap.get("stringValue")).isSameAs(sv);
@ -2000,10 +1976,8 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -2000,10 +1976,8 @@ public class AutowiredAnnotationBeanPostProcessorTests {
assertThat(bean.integerRepositoryArray).hasSize(1);
assertThat(bean.stringRepositoryArray[0]).isSameAs(sr);
assertThat(bean.integerRepositoryArray[0]).isSameAs(ir);
assertThat(bean.stringRepositoryList).hasSize(1);
assertThat(bean.integerRepositoryList).hasSize(1);
assertThat(bean.stringRepositoryList).element(0).isSameAs(sr);
assertThat(bean.integerRepositoryList).element(0).isSameAs(ir);
assertThat(bean.stringRepositoryList).containsExactly(sr);
assertThat(bean.integerRepositoryList).containsExactly(ir);
assertThat(bean.stringRepositoryMap).hasSize(1);
assertThat(bean.integerRepositoryMap).hasSize(1);
assertThat(bean.stringRepositoryMap.get("stringRepo")).isSameAs(sr);
@ -2032,10 +2006,8 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -2032,10 +2006,8 @@ public class AutowiredAnnotationBeanPostProcessorTests {
assertThat(bean.integerArray).hasSize(1);
assertThat(bean.stringArray[0]).isSameAs(sv);
assertThat(bean.integerArray[0]).isSameAs(iv);
assertThat(bean.stringList).hasSize(1);
assertThat(bean.integerList).hasSize(1);
assertThat(bean.stringList).element(0).isSameAs(sv);
assertThat(bean.integerList).element(0).isSameAs(iv);
assertThat(bean.stringList).containsExactly(sv);
assertThat(bean.integerList).containsExactly(iv);
assertThat(bean.stringMap).hasSize(1);
assertThat(bean.integerMap).hasSize(1);
assertThat(bean.stringMap.get("stringValue")).isSameAs(sv);
@ -2046,10 +2018,8 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -2046,10 +2018,8 @@ public class AutowiredAnnotationBeanPostProcessorTests {
assertThat(bean.integerRepositoryArray).hasSize(1);
assertThat(bean.stringRepositoryArray[0]).isSameAs(sr);
assertThat(bean.integerRepositoryArray[0]).isSameAs(ir);
assertThat(bean.stringRepositoryList).hasSize(1);
assertThat(bean.integerRepositoryList).hasSize(1);
assertThat(bean.stringRepositoryList).element(0).isSameAs(sr);
assertThat(bean.integerRepositoryList).element(0).isSameAs(ir);
assertThat(bean.stringRepositoryList).containsExactly(sr);
assertThat(bean.integerRepositoryList).containsExactly(ir);
assertThat(bean.stringRepositoryMap).hasSize(1);
assertThat(bean.integerRepositoryMap).hasSize(1);
assertThat(bean.stringRepositoryMap.get("stringRepo")).isSameAs(sr);
@ -2074,10 +2044,8 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -2074,10 +2044,8 @@ public class AutowiredAnnotationBeanPostProcessorTests {
assertThat(bean.integerRepositoryArray).hasSize(1);
assertThat(bean.stringRepositoryArray[0]).isSameAs(sr);
assertThat(bean.integerRepositoryArray[0]).isSameAs(ir);
assertThat(bean.stringRepositoryList).hasSize(1);
assertThat(bean.integerRepositoryList).hasSize(1);
assertThat(bean.stringRepositoryList).element(0).isSameAs(sr);
assertThat(bean.integerRepositoryList).element(0).isSameAs(ir);
assertThat(bean.stringRepositoryList).containsExactly(sr);
assertThat(bean.integerRepositoryList).containsExactly(ir);
assertThat(bean.stringRepositoryMap).hasSize(1);
assertThat(bean.integerRepositoryMap).hasSize(1);
assertThat(bean.stringRepositoryMap.get("stringRepo")).isSameAs(sr);
@ -2141,9 +2109,8 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -2141,9 +2109,8 @@ public class AutowiredAnnotationBeanPostProcessorTests {
assertThat(bean.stringRepositoryArray).hasSize(1);
assertThat(bean.repositoryArray[0]).isSameAs(repo);
assertThat(bean.stringRepositoryArray[0]).isSameAs(repo);
assertThat(bean.repositoryList).hasSize(1);
assertThat(bean.repositoryList).containsExactly(repo);
assertThat(bean.stringRepositoryList).hasSize(1);
assertThat(bean.repositoryList).element(0).isSameAs(repo);
assertThat(bean.stringRepositoryList).element(0).isSameAs(repo);
assertThat(bean.repositoryMap).hasSize(1);
assertThat(bean.stringRepositoryMap).hasSize(1);
@ -2201,7 +2168,6 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -2201,7 +2168,6 @@ public class AutowiredAnnotationBeanPostProcessorTests {
assertThat(bean.stringRepositoryArray[0]).isSameAs(repo);
assertThat(bean.repositoryList).hasSize(1);
assertThat(bean.stringRepositoryList).hasSize(1);
assertThat(bean.repositoryList).element(0).isSameAs(repo);
assertThat(bean.stringRepositoryList).element(0).isSameAs(repo);
assertThat(bean.repositoryMap).hasSize(1);
assertThat(bean.stringRepositoryMap).hasSize(1);
@ -2230,9 +2196,8 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -2230,9 +2196,8 @@ public class AutowiredAnnotationBeanPostProcessorTests {
assertThat(bean.stringRepositoryArray).hasSize(1);
assertThat(bean.repositoryArray[0]).isSameAs(repo);
assertThat(bean.stringRepositoryArray[0]).isSameAs(repo);
assertThat(bean.repositoryList).hasSize(1);
assertThat(bean.repositoryList).containsExactly(repo);
assertThat(bean.stringRepositoryList).hasSize(1);
assertThat(bean.repositoryList).element(0).isSameAs(repo);
assertThat(bean.stringRepositoryList).element(0).isSameAs(repo);
assertThat(bean.repositoryMap).hasSize(1);
assertThat(bean.stringRepositoryMap).hasSize(1);
@ -2270,10 +2235,8 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -2270,10 +2235,8 @@ public class AutowiredAnnotationBeanPostProcessorTests {
assertThat(bean.integerArray).hasSize(1);
assertThat(bean.stringArray[0]).isSameAs(sv);
assertThat(bean.integerArray[0]).isSameAs(iv);
assertThat(bean.stringList).hasSize(1);
assertThat(bean.integerList).hasSize(1);
assertThat(bean.stringList).element(0).isSameAs(sv);
assertThat(bean.integerList).element(0).isSameAs(iv);
assertThat(bean.stringList).containsExactly(sv);
assertThat(bean.integerList).containsExactly(iv);
assertThat(bean.stringMap).hasSize(1);
assertThat(bean.integerMap).hasSize(1);
assertThat(bean.stringMap.get("stringValue")).isSameAs(sv);
@ -2284,10 +2247,8 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -2284,10 +2247,8 @@ public class AutowiredAnnotationBeanPostProcessorTests {
assertThat(bean.integerRepositoryArray).hasSize(1);
assertThat(bean.stringRepositoryArray[0]).isSameAs(sr);
assertThat(bean.integerRepositoryArray[0]).isSameAs(ir);
assertThat(bean.stringRepositoryList).hasSize(1);
assertThat(bean.integerRepositoryList).hasSize(1);
assertThat(bean.stringRepositoryList).element(0).isSameAs(sr);
assertThat(bean.integerRepositoryList).element(0).isSameAs(ir);
assertThat(bean.stringRepositoryList).containsExactly(sr);
assertThat(bean.integerRepositoryList).containsExactly(ir);
assertThat(bean.stringRepositoryMap).hasSize(1);
assertThat(bean.integerRepositoryMap).hasSize(1);
assertThat(bean.stringRepositoryMap.get("stringRepo")).isSameAs(sr);
@ -2316,10 +2277,8 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -2316,10 +2277,8 @@ public class AutowiredAnnotationBeanPostProcessorTests {
assertThat(bean.integerArray).hasSize(1);
assertThat(bean.stringArray[0]).isSameAs(sv);
assertThat(bean.integerArray[0]).isSameAs(iv);
assertThat(bean.stringList).hasSize(1);
assertThat(bean.integerList).hasSize(1);
assertThat(bean.stringList).element(0).isSameAs(sv);
assertThat(bean.integerList).element(0).isSameAs(iv);
assertThat(bean.stringList).containsExactly(sv);
assertThat(bean.integerList).containsExactly(iv);
assertThat(bean.stringMap).hasSize(1);
assertThat(bean.integerMap).hasSize(1);
assertThat(bean.stringMap.get("stringValue")).isSameAs(sv);
@ -2330,10 +2289,8 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -2330,10 +2289,8 @@ public class AutowiredAnnotationBeanPostProcessorTests {
assertThat(bean.integerRepositoryArray).hasSize(1);
assertThat(bean.stringRepositoryArray[0]).isSameAs(sr);
assertThat(bean.integerRepositoryArray[0]).isSameAs(ir);
assertThat(bean.stringRepositoryList).hasSize(1);
assertThat(bean.integerRepositoryList).hasSize(1);
assertThat(bean.stringRepositoryList).element(0).isSameAs(sr);
assertThat(bean.integerRepositoryList).element(0).isSameAs(ir);
assertThat(bean.stringRepositoryList).containsExactly(sr);
assertThat(bean.integerRepositoryList).containsExactly(ir);
assertThat(bean.stringRepositoryMap).hasSize(1);
assertThat(bean.integerRepositoryMap).hasSize(1);
assertThat(bean.stringRepositoryMap.get("stringRepo")).isSameAs(sr);
@ -2357,10 +2314,8 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -2357,10 +2314,8 @@ public class AutowiredAnnotationBeanPostProcessorTests {
assertThat(bean.integerRepositoryArray).hasSize(1);
assertThat(bean.stringRepositoryArray[0]).isSameAs(sr);
assertThat(bean.integerRepositoryArray[0]).isSameAs(ir);
assertThat(bean.stringRepositoryList).hasSize(1);
assertThat(bean.integerRepositoryList).hasSize(1);
assertThat(bean.stringRepositoryList).element(0).isSameAs(sr);
assertThat(bean.integerRepositoryList).element(0).isSameAs(ir);
assertThat(bean.stringRepositoryList).containsExactly(sr);
assertThat(bean.integerRepositoryList).containsExactly(ir);
assertThat(bean.stringRepositoryMap).hasSize(1);
assertThat(bean.integerRepositoryMap).hasSize(1);
assertThat(bean.stringRepositoryMap.get("stringRepo")).isSameAs(sr);
@ -2383,10 +2338,8 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -2383,10 +2338,8 @@ public class AutowiredAnnotationBeanPostProcessorTests {
assertThat(bean.integerRepositoryArray).hasSize(1);
assertThat(bean.stringRepositoryArray[0]).isSameAs(gr);
assertThat(bean.integerRepositoryArray[0]).isSameAs(gr);
assertThat(bean.stringRepositoryList).hasSize(1);
assertThat(bean.integerRepositoryList).hasSize(1);
assertThat(bean.stringRepositoryList).element(0).isSameAs(gr);
assertThat(bean.integerRepositoryList).element(0).isSameAs(gr);
assertThat(bean.stringRepositoryList).containsExactly(gr);
assertThat(bean.integerRepositoryList).containsExactly(gr);
assertThat(bean.stringRepositoryMap).hasSize(1);
assertThat(bean.integerRepositoryMap).hasSize(1);
assertThat(bean.stringRepositoryMap.get("genericRepo")).isSameAs(gr);
@ -2408,10 +2361,8 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -2408,10 +2361,8 @@ public class AutowiredAnnotationBeanPostProcessorTests {
assertThat(bean.integerRepositoryArray).hasSize(1);
assertThat(bean.stringRepositoryArray[0]).isSameAs(ngr);
assertThat(bean.integerRepositoryArray[0]).isSameAs(ngr);
assertThat(bean.stringRepositoryList).hasSize(1);
assertThat(bean.integerRepositoryList).hasSize(1);
assertThat(bean.stringRepositoryList).element(0).isSameAs(ngr);
assertThat(bean.integerRepositoryList).element(0).isSameAs(ngr);
assertThat(bean.stringRepositoryList).containsExactly(ngr);
assertThat(bean.integerRepositoryList).containsExactly(ngr);
assertThat(bean.stringRepositoryMap).hasSize(1);
assertThat(bean.integerRepositoryMap).hasSize(1);
assertThat(bean.stringRepositoryMap.get("simpleRepo")).isSameAs(ngr);
@ -2436,10 +2387,8 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -2436,10 +2387,8 @@ public class AutowiredAnnotationBeanPostProcessorTests {
assertThat(bean.integerRepositoryArray).hasSize(1);
assertThat(bean.stringRepositoryArray[0]).isSameAs(sr);
assertThat(bean.integerRepositoryArray[0]).isSameAs(gr);
assertThat(bean.stringRepositoryList).hasSize(1);
assertThat(bean.integerRepositoryList).hasSize(1);
assertThat(bean.stringRepositoryList).element(0).isSameAs(sr);
assertThat(bean.integerRepositoryList).element(0).isSameAs(gr);
assertThat(bean.stringRepositoryList).containsExactly(sr);
assertThat(bean.integerRepositoryList).containsExactly(gr);
assertThat(bean.stringRepositoryMap).hasSize(1);
assertThat(bean.integerRepositoryMap).hasSize(1);
assertThat(bean.stringRepositoryMap.get("stringRepo")).isSameAs(sr);
@ -2463,10 +2412,8 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -2463,10 +2412,8 @@ public class AutowiredAnnotationBeanPostProcessorTests {
assertThat(bean.integerRepositoryArray).hasSize(1);
assertThat(bean.stringRepositoryArray[0]).isSameAs(sr);
assertThat(bean.integerRepositoryArray[0]).isSameAs(ngr);
assertThat(bean.stringRepositoryList).hasSize(1);
assertThat(bean.integerRepositoryList).hasSize(1);
assertThat(bean.stringRepositoryList).element(0).isSameAs(sr);
assertThat(bean.integerRepositoryList).element(0).isSameAs(ngr);
assertThat(bean.stringRepositoryList).containsExactly(sr);
assertThat(bean.integerRepositoryList).containsExactly(ngr);
assertThat(bean.stringRepositoryMap).hasSize(1);
assertThat(bean.integerRepositoryMap).hasSize(1);
assertThat(bean.stringRepositoryMap.get("stringRepo")).isSameAs(sr);
@ -2602,7 +2549,7 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -2602,7 +2549,7 @@ public class AutowiredAnnotationBeanPostProcessorTests {
}
@Test
public void mixedNullableArgMethodInjection(){
void mixedNullableArgMethodInjection(){
bf.registerSingleton("nonNullBean", "Test");
bf.registerBeanDefinition("mixedNullableInjectionBean",
new RootBeanDefinition(MixedNullableInjectionBean.class));
@ -2612,7 +2559,7 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -2612,7 +2559,7 @@ public class AutowiredAnnotationBeanPostProcessorTests {
}
@Test
public void mixedOptionalArgMethodInjection(){
void mixedOptionalArgMethodInjection(){
bf.registerSingleton("nonNullBean", "Test");
bf.registerBeanDefinition("mixedOptionalInjectionBean",
new RootBeanDefinition(MixedOptionalInjectionBean.class));
@ -3463,7 +3410,7 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -3463,7 +3410,7 @@ public class AutowiredAnnotationBeanPostProcessorTests {
public static class StringFactoryBean implements FactoryBean<String> {
@Override
public String getObject() throws Exception {
public String getObject() {
return "";
}
@ -3998,7 +3945,7 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -3998,7 +3945,7 @@ public class AutowiredAnnotationBeanPostProcessorTests {
@SuppressWarnings("unchecked")
public <T> T createMock(Class<T> toMock) {
return (T) Proxy.newProxyInstance(AutowiredAnnotationBeanPostProcessorTests.class.getClassLoader(), new Class<?>[] {toMock},
(InvocationHandler) (proxy, method, args) -> {
(proxy, method, args) -> {
throw new UnsupportedOperationException("mocked!");
});
}
@ -4146,7 +4093,7 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -4146,7 +4093,7 @@ public class AutowiredAnnotationBeanPostProcessorTests {
public static class MyCallable implements Callable<Thread> {
@Override
public Thread call() throws Exception {
public Thread call() {
return null;
}
}
@ -4155,7 +4102,7 @@ public class AutowiredAnnotationBeanPostProcessorTests { @@ -4155,7 +4102,7 @@ public class AutowiredAnnotationBeanPostProcessorTests {
public static class SecondCallable implements Callable<Thread>{
@Override
public Thread call() throws Exception {
public Thread call() {
return null;
}
}

6
spring-beans/src/test/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurerTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -34,10 +34,10 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie @@ -34,10 +34,10 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
* @author Juergen Hoeller
* @author Chris Beams
*/
public class CustomAutowireConfigurerTests {
class CustomAutowireConfigurerTests {
@Test
public void testCustomResolver() {
void testCustomResolver() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
qualifiedResource(CustomAutowireConfigurerTests.class, "context.xml"));

109
spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -33,6 +33,7 @@ import org.junit.jupiter.api.Test; @@ -33,6 +33,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessorTests.StringFactoryBean;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.AutowireCandidateQualifier;
@ -55,7 +56,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -55,7 +56,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Juergen Hoeller
* @since 3.0
*/
public class InjectAnnotationBeanPostProcessorTests {
class InjectAnnotationBeanPostProcessorTests {
private DefaultListableBeanFactory bf;
@ -63,7 +64,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -63,7 +64,7 @@ public class InjectAnnotationBeanPostProcessorTests {
@BeforeEach
public void setup() {
void setup() {
bf = new DefaultListableBeanFactory();
bf.registerResolvableDependency(BeanFactory.class, bf);
bpp = new AutowiredAnnotationBeanPostProcessor();
@ -73,13 +74,13 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -73,13 +74,13 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@AfterEach
public void close() {
void close() {
bf.destroySingletons();
}
@Test
public void testIncompleteBeanDefinition() {
void testIncompleteBeanDefinition() {
bf.registerBeanDefinition("testBean", new GenericBeanDefinition());
try {
bf.getBean("testBean");
@ -90,7 +91,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -90,7 +91,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testResourceInjection() {
void testResourceInjection() {
RootBeanDefinition bd = new RootBeanDefinition(ResourceInjectionBean.class);
bd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
bf.registerBeanDefinition("annotatedBean", bd);
@ -107,7 +108,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -107,7 +108,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testExtendedResourceInjection() {
void testExtendedResourceInjection() {
RootBeanDefinition bd = new RootBeanDefinition(TypedExtendedResourceInjectionBean.class);
bd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
bf.registerBeanDefinition("annotatedBean", bd);
@ -134,7 +135,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -134,7 +135,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testExtendedResourceInjectionWithOverriding() {
void testExtendedResourceInjectionWithOverriding() {
RootBeanDefinition annotatedBd = new RootBeanDefinition(TypedExtendedResourceInjectionBean.class);
TestBean tb2 = new TestBean();
annotatedBd.getPropertyValues().add("testBean2", tb2);
@ -154,7 +155,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -154,7 +155,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testConstructorResourceInjection() {
void testConstructorResourceInjection() {
RootBeanDefinition bd = new RootBeanDefinition(ConstructorResourceInjectionBean.class);
bd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
bf.registerBeanDefinition("annotatedBean", bd);
@ -181,7 +182,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -181,7 +182,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testConstructorResourceInjectionWithMultipleCandidatesAsCollection() {
void testConstructorResourceInjectionWithMultipleCandidatesAsCollection() {
bf.registerBeanDefinition("annotatedBean",
new RootBeanDefinition(ConstructorsCollectionResourceInjectionBean.class));
TestBean tb = new TestBean();
@ -200,7 +201,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -200,7 +201,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testConstructorResourceInjectionWithMultipleCandidatesAndFallback() {
void testConstructorResourceInjectionWithMultipleCandidatesAndFallback() {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ConstructorsResourceInjectionBean.class));
TestBean tb = new TestBean();
bf.registerSingleton("testBean", tb);
@ -211,7 +212,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -211,7 +212,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testConstructorInjectionWithMap() {
void testConstructorInjectionWithMap() {
RootBeanDefinition bd = new RootBeanDefinition(MapConstructorInjectionBean.class);
bd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
bf.registerBeanDefinition("annotatedBean", bd);
@ -236,7 +237,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -236,7 +237,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testFieldInjectionWithMap() {
void testFieldInjectionWithMap() {
RootBeanDefinition bd = new RootBeanDefinition(MapFieldInjectionBean.class);
bd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
bf.registerBeanDefinition("annotatedBean", bd);
@ -261,7 +262,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -261,7 +262,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testMethodInjectionWithMap() {
void testMethodInjectionWithMap() {
RootBeanDefinition bd = new RootBeanDefinition(MapMethodInjectionBean.class);
bd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
bf.registerBeanDefinition("annotatedBean", bd);
@ -282,7 +283,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -282,7 +283,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testMethodInjectionWithMapAndMultipleMatches() {
void testMethodInjectionWithMapAndMultipleMatches() {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(MapMethodInjectionBean.class));
bf.registerBeanDefinition("testBean1", new RootBeanDefinition(TestBean.class));
bf.registerBeanDefinition("testBean2", new RootBeanDefinition(TestBean.class));
@ -291,7 +292,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -291,7 +292,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testMethodInjectionWithMapAndMultipleMatchesButOnlyOneAutowireCandidate() {
void testMethodInjectionWithMapAndMultipleMatchesButOnlyOneAutowireCandidate() {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(MapMethodInjectionBean.class));
bf.registerBeanDefinition("testBean1", new RootBeanDefinition(TestBean.class));
RootBeanDefinition rbd2 = new RootBeanDefinition(TestBean.class);
@ -307,7 +308,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -307,7 +308,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testObjectFactoryInjection() {
void testObjectFactoryInjection() {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ObjectFactoryQualifierFieldInjectionBean.class));
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
bd.addQualifier(new AutowireCandidateQualifier(Qualifier.class, "testBean"));
@ -319,7 +320,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -319,7 +320,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testObjectFactoryQualifierInjection() {
void testObjectFactoryQualifierInjection() {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ObjectFactoryQualifierFieldInjectionBean.class));
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
bd.addQualifier(new AutowireCandidateQualifier(Qualifier.class, "testBean"));
@ -330,7 +331,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -330,7 +331,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testObjectFactoryFieldInjectionIntoPrototypeBean() {
void testObjectFactoryFieldInjectionIntoPrototypeBean() {
RootBeanDefinition annotatedBeanDefinition = new RootBeanDefinition(ObjectFactoryQualifierFieldInjectionBean.class);
annotatedBeanDefinition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
bf.registerBeanDefinition("annotatedBean", annotatedBeanDefinition);
@ -347,7 +348,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -347,7 +348,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testObjectFactoryMethodInjectionIntoPrototypeBean() {
void testObjectFactoryMethodInjectionIntoPrototypeBean() {
RootBeanDefinition annotatedBeanDefinition = new RootBeanDefinition(ObjectFactoryQualifierMethodInjectionBean.class);
annotatedBeanDefinition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
bf.registerBeanDefinition("annotatedBean", annotatedBeanDefinition);
@ -364,7 +365,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -364,7 +365,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testObjectFactoryWithBeanField() throws Exception {
void testObjectFactoryWithBeanField() throws Exception {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ObjectFactoryFieldInjectionBean.class));
bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
bf.setSerializationId("test");
@ -376,7 +377,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -376,7 +377,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testObjectFactoryWithBeanMethod() throws Exception {
void testObjectFactoryWithBeanMethod() throws Exception {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ObjectFactoryMethodInjectionBean.class));
bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
bf.setSerializationId("test");
@ -388,7 +389,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -388,7 +389,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testObjectFactoryWithTypedListField() throws Exception {
void testObjectFactoryWithTypedListField() throws Exception {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ObjectFactoryListFieldInjectionBean.class));
bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
bf.setSerializationId("test");
@ -400,7 +401,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -400,7 +401,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testObjectFactoryWithTypedListMethod() throws Exception {
void testObjectFactoryWithTypedListMethod() throws Exception {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ObjectFactoryListMethodInjectionBean.class));
bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
bf.setSerializationId("test");
@ -412,7 +413,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -412,7 +413,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testObjectFactoryWithTypedMapField() throws Exception {
void testObjectFactoryWithTypedMapField() throws Exception {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ObjectFactoryMapFieldInjectionBean.class));
bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
bf.setSerializationId("test");
@ -424,7 +425,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -424,7 +425,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testObjectFactoryWithTypedMapMethod() throws Exception {
void testObjectFactoryWithTypedMapMethod() throws Exception {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ObjectFactoryMapMethodInjectionBean.class));
bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
bf.setSerializationId("test");
@ -441,7 +442,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -441,7 +442,7 @@ public class InjectAnnotationBeanPostProcessorTests {
* specifically addressing SPR-4040.
*/
@Test
public void testBeanAutowiredWithFactoryBean() {
void testBeanAutowiredWithFactoryBean() {
bf.registerBeanDefinition("factoryBeanDependentBean", new RootBeanDefinition(FactoryBeanDependentBean.class));
bf.registerSingleton("stringFactoryBean", new StringFactoryBean());
@ -454,7 +455,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -454,7 +455,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testNullableFieldInjectionWithBeanAvailable() {
void testNullableFieldInjectionWithBeanAvailable() {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(NullableFieldInjectionBean.class));
bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
@ -463,7 +464,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -463,7 +464,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testNullableFieldInjectionWithBeanNotAvailable() {
void testNullableFieldInjectionWithBeanNotAvailable() {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(NullableFieldInjectionBean.class));
NullableFieldInjectionBean bean = (NullableFieldInjectionBean) bf.getBean("annotatedBean");
@ -471,7 +472,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -471,7 +472,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testNullableMethodInjectionWithBeanAvailable() {
void testNullableMethodInjectionWithBeanAvailable() {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(NullableMethodInjectionBean.class));
bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
@ -480,7 +481,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -480,7 +481,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testNullableMethodInjectionWithBeanNotAvailable() {
void testNullableMethodInjectionWithBeanNotAvailable() {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(NullableMethodInjectionBean.class));
NullableMethodInjectionBean bean = (NullableMethodInjectionBean) bf.getBean("annotatedBean");
@ -488,7 +489,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -488,7 +489,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testOptionalFieldInjectionWithBeanAvailable() {
void testOptionalFieldInjectionWithBeanAvailable() {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(OptionalFieldInjectionBean.class));
bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
@ -498,7 +499,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -498,7 +499,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testOptionalFieldInjectionWithBeanNotAvailable() {
void testOptionalFieldInjectionWithBeanNotAvailable() {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(OptionalFieldInjectionBean.class));
OptionalFieldInjectionBean bean = (OptionalFieldInjectionBean) bf.getBean("annotatedBean");
@ -506,7 +507,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -506,7 +507,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testOptionalMethodInjectionWithBeanAvailable() {
void testOptionalMethodInjectionWithBeanAvailable() {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(OptionalMethodInjectionBean.class));
bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
@ -516,7 +517,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -516,7 +517,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testOptionalMethodInjectionWithBeanNotAvailable() {
void testOptionalMethodInjectionWithBeanNotAvailable() {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(OptionalMethodInjectionBean.class));
OptionalMethodInjectionBean bean = (OptionalMethodInjectionBean) bf.getBean("annotatedBean");
@ -524,7 +525,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -524,7 +525,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testOptionalListFieldInjectionWithBeanAvailable() {
void testOptionalListFieldInjectionWithBeanAvailable() {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(OptionalListFieldInjectionBean.class));
bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
@ -534,7 +535,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -534,7 +535,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testOptionalListFieldInjectionWithBeanNotAvailable() {
void testOptionalListFieldInjectionWithBeanNotAvailable() {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(OptionalListFieldInjectionBean.class));
OptionalListFieldInjectionBean bean = (OptionalListFieldInjectionBean) bf.getBean("annotatedBean");
@ -542,7 +543,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -542,7 +543,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testOptionalListMethodInjectionWithBeanAvailable() {
void testOptionalListMethodInjectionWithBeanAvailable() {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(OptionalListMethodInjectionBean.class));
bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
@ -552,7 +553,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -552,7 +553,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testOptionalListMethodInjectionWithBeanNotAvailable() {
void testOptionalListMethodInjectionWithBeanNotAvailable() {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(OptionalListMethodInjectionBean.class));
OptionalListMethodInjectionBean bean = (OptionalListMethodInjectionBean) bf.getBean("annotatedBean");
@ -560,7 +561,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -560,7 +561,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testProviderOfOptionalFieldInjectionWithBeanAvailable() {
void testProviderOfOptionalFieldInjectionWithBeanAvailable() {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ProviderOfOptionalFieldInjectionBean.class));
bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
@ -570,7 +571,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -570,7 +571,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testProviderOfOptionalFieldInjectionWithBeanNotAvailable() {
void testProviderOfOptionalFieldInjectionWithBeanNotAvailable() {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ProviderOfOptionalFieldInjectionBean.class));
ProviderOfOptionalFieldInjectionBean bean = (ProviderOfOptionalFieldInjectionBean) bf.getBean("annotatedBean");
@ -578,7 +579,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -578,7 +579,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testProviderOfOptionalMethodInjectionWithBeanAvailable() {
void testProviderOfOptionalMethodInjectionWithBeanAvailable() {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ProviderOfOptionalMethodInjectionBean.class));
bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
@ -588,7 +589,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -588,7 +589,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testProviderOfOptionalMethodInjectionWithBeanNotAvailable() {
void testProviderOfOptionalMethodInjectionWithBeanNotAvailable() {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ProviderOfOptionalMethodInjectionBean.class));
ProviderOfOptionalMethodInjectionBean bean = (ProviderOfOptionalMethodInjectionBean) bf.getBean("annotatedBean");
@ -596,7 +597,7 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -596,7 +597,7 @@ public class InjectAnnotationBeanPostProcessorTests {
}
@Test
public void testAnnotatedDefaultConstructor() {
void testAnnotatedDefaultConstructor() {
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(AnnotatedDefaultConstructorBean.class));
assertThat(bf.getBean("annotatedBean")).isNotNull();
@ -644,7 +645,6 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -644,7 +645,6 @@ public class InjectAnnotationBeanPostProcessorTests {
@Override
@Inject
@SuppressWarnings("deprecation")
public void setTestBean2(TestBean testBean2) {
super.setTestBean2(testBean2);
}
@ -1108,25 +1108,6 @@ public class InjectAnnotationBeanPostProcessorTests { @@ -1108,25 +1108,6 @@ public class InjectAnnotationBeanPostProcessorTests {
}
public static class StringFactoryBean implements FactoryBean<String> {
@Override
public String getObject() {
return "";
}
@Override
public Class<String> getObjectType() {
return String.class;
}
@Override
public boolean isSingleton() {
return true;
}
}
@Retention(RetentionPolicy.RUNTIME)
public @interface Nullable {}

24
spring-beans/src/test/java/org/springframework/beans/factory/annotation/LookupAnnotationTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -31,13 +31,13 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -31,13 +31,13 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Karl Pietrzak
* @author Juergen Hoeller
*/
public class LookupAnnotationTests {
class LookupAnnotationTests {
private DefaultListableBeanFactory beanFactory;
@BeforeEach
public void setup() {
void setup() {
beanFactory = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor aabpp = new AutowiredAnnotationBeanPostProcessor();
aabpp.setBeanFactory(beanFactory);
@ -51,7 +51,7 @@ public class LookupAnnotationTests { @@ -51,7 +51,7 @@ public class LookupAnnotationTests {
@Test
public void testWithoutConstructorArg() {
void testWithoutConstructorArg() {
AbstractBean bean = (AbstractBean) beanFactory.getBean("abstractBean");
Object expected = bean.get();
assertThat(expected.getClass()).isEqualTo(TestBean.class);
@ -59,7 +59,7 @@ public class LookupAnnotationTests { @@ -59,7 +59,7 @@ public class LookupAnnotationTests {
}
@Test
public void testWithOverloadedArg() {
void testWithOverloadedArg() {
AbstractBean bean = (AbstractBean) beanFactory.getBean("abstractBean");
TestBean expected = bean.get("haha");
assertThat(expected.getClass()).isEqualTo(TestBean.class);
@ -68,7 +68,7 @@ public class LookupAnnotationTests { @@ -68,7 +68,7 @@ public class LookupAnnotationTests {
}
@Test
public void testWithOneConstructorArg() {
void testWithOneConstructorArg() {
AbstractBean bean = (AbstractBean) beanFactory.getBean("abstractBean");
TestBean expected = bean.getOneArgument("haha");
assertThat(expected.getClass()).isEqualTo(TestBean.class);
@ -77,7 +77,7 @@ public class LookupAnnotationTests { @@ -77,7 +77,7 @@ public class LookupAnnotationTests {
}
@Test
public void testWithTwoConstructorArg() {
void testWithTwoConstructorArg() {
AbstractBean bean = (AbstractBean) beanFactory.getBean("abstractBean");
TestBean expected = bean.getTwoArguments("haha", 72);
assertThat(expected.getClass()).isEqualTo(TestBean.class);
@ -87,7 +87,7 @@ public class LookupAnnotationTests { @@ -87,7 +87,7 @@ public class LookupAnnotationTests {
}
@Test
public void testWithThreeArgsShouldFail() {
void testWithThreeArgsShouldFail() {
AbstractBean bean = (AbstractBean) beanFactory.getBean("abstractBean");
assertThatExceptionOfType(AbstractMethodError.class).as("TestBean has no three arg constructor").isThrownBy(() ->
bean.getThreeArguments("name", 1, 2));
@ -95,7 +95,7 @@ public class LookupAnnotationTests { @@ -95,7 +95,7 @@ public class LookupAnnotationTests {
}
@Test
public void testWithEarlyInjection() {
void testWithEarlyInjection() {
AbstractBean bean = beanFactory.getBean("beanConsumer", BeanConsumer.class).abstractBean;
Object expected = bean.get();
assertThat(expected.getClass()).isEqualTo(TestBean.class);
@ -115,7 +115,7 @@ public class LookupAnnotationTests { @@ -115,7 +115,7 @@ public class LookupAnnotationTests {
}
@Test
public void testWithGenericBean() {
void testWithGenericBean() {
beanFactory.registerBeanDefinition("numberBean", new RootBeanDefinition(NumberBean.class));
beanFactory.registerBeanDefinition("doubleStore", new RootBeanDefinition(DoubleStore.class));
beanFactory.registerBeanDefinition("floatStore", new RootBeanDefinition(FloatStore.class));
@ -126,7 +126,7 @@ public class LookupAnnotationTests { @@ -126,7 +126,7 @@ public class LookupAnnotationTests {
}
@Test
public void testSingletonWithoutMetadataCaching() {
void testSingletonWithoutMetadataCaching() {
beanFactory.setCacheBeanMetadata(false);
beanFactory.registerBeanDefinition("numberBean", new RootBeanDefinition(NumberBean.class));
@ -139,7 +139,7 @@ public class LookupAnnotationTests { @@ -139,7 +139,7 @@ public class LookupAnnotationTests {
}
@Test
public void testPrototypeWithoutMetadataCaching() {
void testPrototypeWithoutMetadataCaching() {
beanFactory.setCacheBeanMetadata(false);
beanFactory.registerBeanDefinition("numberBean", new RootBeanDefinition(NumberBean.class, BeanDefinition.SCOPE_PROTOTYPE, null));

22
spring-beans/src/test/java/org/springframework/beans/factory/annotation/ParameterResolutionTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -41,29 +41,29 @@ import static org.mockito.Mockito.mock; @@ -41,29 +41,29 @@ import static org.mockito.Mockito.mock;
* @author Juergen Hoeller
* @author Loïc Ledoyen
*/
public class ParameterResolutionTests {
class ParameterResolutionTests {
@Test
public void isAutowirablePreconditions() {
void isAutowirablePreconditions() {
assertThatIllegalArgumentException().isThrownBy(() ->
ParameterResolutionDelegate.isAutowirable(null, 0))
.withMessageContaining("Parameter must not be null");
}
@Test
public void annotatedParametersInMethodAreCandidatesForAutowiring() throws Exception {
void annotatedParametersInMethodAreCandidatesForAutowiring() throws Exception {
Method method = getClass().getDeclaredMethod("autowirableMethod", String.class, String.class, String.class, String.class);
assertAutowirableParameters(method);
}
@Test
public void annotatedParametersInTopLevelClassConstructorAreCandidatesForAutowiring() throws Exception {
void annotatedParametersInTopLevelClassConstructorAreCandidatesForAutowiring() throws Exception {
Constructor<?> constructor = AutowirableClass.class.getConstructor(String.class, String.class, String.class, String.class);
assertAutowirableParameters(constructor);
}
@Test
public void annotatedParametersInInnerClassConstructorAreCandidatesForAutowiring() throws Exception {
void annotatedParametersInInnerClassConstructorAreCandidatesForAutowiring() throws Exception {
Class<?> innerClass = AutowirableClass.InnerAutowirableClass.class;
assertThat(ClassUtils.isInnerClass(innerClass)).isTrue();
Constructor<?> constructor = innerClass.getConstructor(AutowirableClass.class, String.class, String.class);
@ -81,7 +81,7 @@ public class ParameterResolutionTests { @@ -81,7 +81,7 @@ public class ParameterResolutionTests {
}
@Test
public void nonAnnotatedParametersInTopLevelClassConstructorAreNotCandidatesForAutowiring() throws Exception {
void nonAnnotatedParametersInTopLevelClassConstructorAreNotCandidatesForAutowiring() throws Exception {
Constructor<?> notAutowirableConstructor = AutowirableClass.class.getConstructor(String.class);
Parameter[] parameters = notAutowirableConstructor.getParameters();
@ -92,21 +92,21 @@ public class ParameterResolutionTests { @@ -92,21 +92,21 @@ public class ParameterResolutionTests {
}
@Test
public void resolveDependencyPreconditionsForParameter() {
void resolveDependencyPreconditionsForParameter() {
assertThatIllegalArgumentException()
.isThrownBy(() -> ParameterResolutionDelegate.resolveDependency(null, 0, null, mock()))
.withMessageContaining("Parameter must not be null");
}
@Test
public void resolveDependencyPreconditionsForContainingClass() throws Exception {
void resolveDependencyPreconditionsForContainingClass() {
assertThatIllegalArgumentException().isThrownBy(() ->
ParameterResolutionDelegate.resolveDependency(getParameter(), 0, null, null))
.withMessageContaining("Containing class must not be null");
}
@Test
public void resolveDependencyPreconditionsForBeanFactory() throws Exception {
void resolveDependencyPreconditionsForBeanFactory() {
assertThatIllegalArgumentException().isThrownBy(() ->
ParameterResolutionDelegate.resolveDependency(getParameter(), 0, getClass(), null))
.withMessageContaining("AutowireCapableBeanFactory must not be null");
@ -118,7 +118,7 @@ public class ParameterResolutionTests { @@ -118,7 +118,7 @@ public class ParameterResolutionTests {
}
@Test
public void resolveDependencyForAnnotatedParametersInTopLevelClassConstructor() throws Exception {
void resolveDependencyForAnnotatedParametersInTopLevelClassConstructor() throws Exception {
Constructor<?> constructor = AutowirableClass.class.getConstructor(String.class, String.class, String.class, String.class);
AutowireCapableBeanFactory beanFactory = mock();

4
spring-beans/src/test/java/org/springframework/beans/factory/aot/BeanDefinitionPropertiesCodeGeneratorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -692,7 +692,7 @@ class BeanDefinitionPropertiesCodeGeneratorTests { @@ -692,7 +692,7 @@ class BeanDefinitionPropertiesCodeGeneratorTests {
@Nullable
@Override
public String getObject() throws Exception {
public String getObject() {
return getPrefix() + " " + getName();
}

6
spring-beans/src/test/java/org/springframework/beans/factory/aot/DefaultBeanRegistrationCodeFragmentsTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -26,11 +26,11 @@ import org.junit.jupiter.api.Test; @@ -26,11 +26,11 @@ import org.junit.jupiter.api.Test;
import org.springframework.aot.generate.GenerationContext;
import org.springframework.aot.test.generate.TestGenerationContext;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.annotation.InjectAnnotationBeanPostProcessorTests.StringFactoryBean;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RegisteredBean;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.testfixture.beans.factory.DummyFactory;
import org.springframework.beans.testfixture.beans.factory.StringFactoryBean;
import org.springframework.beans.testfixture.beans.factory.aot.GenericFactoryBean;
import org.springframework.beans.testfixture.beans.factory.aot.MockBeanRegistrationCode;
import org.springframework.beans.testfixture.beans.factory.aot.MockBeanRegistrationsCode;
@ -275,7 +275,7 @@ class DefaultBeanRegistrationCodeFragmentsTests { @@ -275,7 +275,7 @@ class DefaultBeanRegistrationCodeFragmentsTests {
static class PrivilegedTestBeanFactoryBean implements FactoryBean<SimpleBean> {
@Override
public SimpleBean getObject() throws Exception {
public SimpleBean getObject() {
return new SimpleBean();
}

10
spring-beans/src/test/java/org/springframework/beans/factory/config/CustomEditorConfigurerTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -41,10 +41,10 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -41,10 +41,10 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Chris Beams
* @since 31.07.2004
*/
public class CustomEditorConfigurerTests {
class CustomEditorConfigurerTests {
@Test
public void testCustomEditorConfigurerWithPropertyEditorRegistrar() throws ParseException {
void testCustomEditorConfigurerWithPropertyEditorRegistrar() throws ParseException {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
CustomEditorConfigurer cec = new CustomEditorConfigurer();
final DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.GERMAN);
@ -70,7 +70,7 @@ public class CustomEditorConfigurerTests { @@ -70,7 +70,7 @@ public class CustomEditorConfigurerTests {
}
@Test
public void testCustomEditorConfigurerWithEditorAsClass() throws ParseException {
void testCustomEditorConfigurerWithEditorAsClass() throws ParseException {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
CustomEditorConfigurer cec = new CustomEditorConfigurer();
Map<Class<?>, Class<? extends PropertyEditor>> editors = new HashMap<>();
@ -90,7 +90,7 @@ public class CustomEditorConfigurerTests { @@ -90,7 +90,7 @@ public class CustomEditorConfigurerTests {
}
@Test
public void testCustomEditorConfigurerWithRequiredTypeArray() throws ParseException {
void testCustomEditorConfigurerWithRequiredTypeArray() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
CustomEditorConfigurer cec = new CustomEditorConfigurer();
Map<Class<?>, Class<? extends PropertyEditor>> editors = new HashMap<>();

18
spring-beans/src/test/java/org/springframework/beans/factory/config/CustomScopeConfigurerTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -35,7 +35,7 @@ import static org.mockito.Mockito.mock; @@ -35,7 +35,7 @@ import static org.mockito.Mockito.mock;
* @author Juergen Hoeller
* @author Chris Beams
*/
public class CustomScopeConfigurerTests {
class CustomScopeConfigurerTests {
private static final String FOO_SCOPE = "fooScope";
@ -43,13 +43,13 @@ public class CustomScopeConfigurerTests { @@ -43,13 +43,13 @@ public class CustomScopeConfigurerTests {
@Test
public void testWithNoScopes() {
void testWithNoScopes() {
CustomScopeConfigurer figurer = new CustomScopeConfigurer();
figurer.postProcessBeanFactory(factory);
}
@Test
public void testSunnyDayWithBonaFideScopeInstance() {
void testSunnyDayWithBonaFideScopeInstance() {
Scope scope = mock();
factory.registerScope(FOO_SCOPE, scope);
Map<String, Object> scopes = new HashMap<>();
@ -60,7 +60,7 @@ public class CustomScopeConfigurerTests { @@ -60,7 +60,7 @@ public class CustomScopeConfigurerTests {
}
@Test
public void testSunnyDayWithBonaFideScopeClass() {
void testSunnyDayWithBonaFideScopeClass() {
Map<String, Object> scopes = new HashMap<>();
scopes.put(FOO_SCOPE, NoOpScope.class);
CustomScopeConfigurer figurer = new CustomScopeConfigurer();
@ -70,7 +70,7 @@ public class CustomScopeConfigurerTests { @@ -70,7 +70,7 @@ public class CustomScopeConfigurerTests {
}
@Test
public void testSunnyDayWithBonaFideScopeClassName() {
void testSunnyDayWithBonaFideScopeClassName() {
Map<String, Object> scopes = new HashMap<>();
scopes.put(FOO_SCOPE, NoOpScope.class.getName());
CustomScopeConfigurer figurer = new CustomScopeConfigurer();
@ -80,7 +80,7 @@ public class CustomScopeConfigurerTests { @@ -80,7 +80,7 @@ public class CustomScopeConfigurerTests {
}
@Test
public void testWhereScopeMapHasNullScopeValueInEntrySet() {
void testWhereScopeMapHasNullScopeValueInEntrySet() {
Map<String, Object> scopes = new HashMap<>();
scopes.put(FOO_SCOPE, null);
CustomScopeConfigurer figurer = new CustomScopeConfigurer();
@ -90,7 +90,7 @@ public class CustomScopeConfigurerTests { @@ -90,7 +90,7 @@ public class CustomScopeConfigurerTests {
}
@Test
public void testWhereScopeMapHasNonScopeInstanceInEntrySet() {
void testWhereScopeMapHasNonScopeInstanceInEntrySet() {
Map<String, Object> scopes = new HashMap<>();
scopes.put(FOO_SCOPE, this); // <-- not a valid value...
CustomScopeConfigurer figurer = new CustomScopeConfigurer();
@ -101,7 +101,7 @@ public class CustomScopeConfigurerTests { @@ -101,7 +101,7 @@ public class CustomScopeConfigurerTests {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testWhereScopeMapHasNonStringTypedScopeNameInKeySet() {
void testWhereScopeMapHasNonStringTypedScopeNameInKeySet() {
Map scopes = new HashMap();
scopes.put(this, new NoOpScope()); // <-- not a valid value (the key)...
CustomScopeConfigurer figurer = new CustomScopeConfigurer();

4
spring-beans/src/test/java/org/springframework/beans/factory/config/DeprecatedBeanWarnerTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -26,7 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -26,7 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Arjen Poutsma
*/
public class DeprecatedBeanWarnerTests {
class DeprecatedBeanWarnerTests {
private String beanName;

24
spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -34,10 +34,10 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie @@ -34,10 +34,10 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
* @author Chris Beams
* @since 31.07.2004
*/
public class FieldRetrievingFactoryBeanTests {
class FieldRetrievingFactoryBeanTests {
@Test
public void testStaticField() throws Exception {
void testStaticField() throws Exception {
FieldRetrievingFactoryBean fr = new FieldRetrievingFactoryBean();
fr.setStaticField("java.sql.Connection.TRANSACTION_SERIALIZABLE");
fr.afterPropertiesSet();
@ -45,7 +45,7 @@ public class FieldRetrievingFactoryBeanTests { @@ -45,7 +45,7 @@ public class FieldRetrievingFactoryBeanTests {
}
@Test
public void testStaticFieldWithWhitespace() throws Exception {
void testStaticFieldWithWhitespace() throws Exception {
FieldRetrievingFactoryBean fr = new FieldRetrievingFactoryBean();
fr.setStaticField(" java.sql.Connection.TRANSACTION_SERIALIZABLE ");
fr.afterPropertiesSet();
@ -53,7 +53,7 @@ public class FieldRetrievingFactoryBeanTests { @@ -53,7 +53,7 @@ public class FieldRetrievingFactoryBeanTests {
}
@Test
public void testStaticFieldViaClassAndFieldName() throws Exception {
void testStaticFieldViaClassAndFieldName() throws Exception {
FieldRetrievingFactoryBean fr = new FieldRetrievingFactoryBean();
fr.setTargetClass(Connection.class);
fr.setTargetField("TRANSACTION_SERIALIZABLE");
@ -62,7 +62,7 @@ public class FieldRetrievingFactoryBeanTests { @@ -62,7 +62,7 @@ public class FieldRetrievingFactoryBeanTests {
}
@Test
public void testNonStaticField() throws Exception {
void testNonStaticField() throws Exception {
FieldRetrievingFactoryBean fr = new FieldRetrievingFactoryBean();
PublicFieldHolder target = new PublicFieldHolder();
fr.setTargetObject(target);
@ -72,7 +72,7 @@ public class FieldRetrievingFactoryBeanTests { @@ -72,7 +72,7 @@ public class FieldRetrievingFactoryBeanTests {
}
@Test
public void testNothingButBeanName() throws Exception {
void testNothingButBeanName() throws Exception {
FieldRetrievingFactoryBean fr = new FieldRetrievingFactoryBean();
fr.setBeanName("java.sql.Connection.TRANSACTION_SERIALIZABLE");
fr.afterPropertiesSet();
@ -80,7 +80,7 @@ public class FieldRetrievingFactoryBeanTests { @@ -80,7 +80,7 @@ public class FieldRetrievingFactoryBeanTests {
}
@Test
public void testJustTargetField() throws Exception {
void testJustTargetField() throws Exception {
FieldRetrievingFactoryBean fr = new FieldRetrievingFactoryBean();
fr.setTargetField("TRANSACTION_SERIALIZABLE");
try {
@ -91,7 +91,7 @@ public class FieldRetrievingFactoryBeanTests { @@ -91,7 +91,7 @@ public class FieldRetrievingFactoryBeanTests {
}
@Test
public void testJustTargetClass() throws Exception {
void testJustTargetClass() throws Exception {
FieldRetrievingFactoryBean fr = new FieldRetrievingFactoryBean();
fr.setTargetClass(Connection.class);
try {
@ -102,7 +102,7 @@ public class FieldRetrievingFactoryBeanTests { @@ -102,7 +102,7 @@ public class FieldRetrievingFactoryBeanTests {
}
@Test
public void testJustTargetObject() throws Exception {
void testJustTargetObject() throws Exception {
FieldRetrievingFactoryBean fr = new FieldRetrievingFactoryBean();
fr.setTargetObject(new PublicFieldHolder());
try {
@ -113,7 +113,7 @@ public class FieldRetrievingFactoryBeanTests { @@ -113,7 +113,7 @@ public class FieldRetrievingFactoryBeanTests {
}
@Test
public void testWithConstantOnClassWithPackageLevelVisibility() throws Exception {
void testWithConstantOnClassWithPackageLevelVisibility() throws Exception {
FieldRetrievingFactoryBean fr = new FieldRetrievingFactoryBean();
fr.setBeanName("org.springframework.beans.testfixture.beans.PackageLevelVisibleBean.CONSTANT");
fr.afterPropertiesSet();
@ -121,7 +121,7 @@ public class FieldRetrievingFactoryBeanTests { @@ -121,7 +121,7 @@ public class FieldRetrievingFactoryBeanTests {
}
@Test
public void testBeanNameSyntaxWithBeanFactory() throws Exception {
void testBeanNameSyntaxWithBeanFactory() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
qualifiedResource(FieldRetrievingFactoryBeanTests.class, "context.xml"));

18
spring-beans/src/test/java/org/springframework/beans/factory/config/MethodInvokingFactoryBeanTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -38,10 +38,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException @@ -38,10 +38,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Chris Beams
* @since 21.11.2003
*/
public class MethodInvokingFactoryBeanTests {
class MethodInvokingFactoryBeanTests {
@Test
public void testParameterValidation() throws Exception {
void testParameterValidation() throws Exception {
// assert that only static OR non-static are set, but not both or none
MethodInvokingFactoryBean mcfb = new MethodInvokingFactoryBean();
@ -91,7 +91,7 @@ public class MethodInvokingFactoryBeanTests { @@ -91,7 +91,7 @@ public class MethodInvokingFactoryBeanTests {
}
@Test
public void testGetObjectType() throws Exception {
void testGetObjectType() throws Exception {
TestClass1 tc1 = new TestClass1();
MethodInvokingFactoryBean mcfb = new MethodInvokingFactoryBean();
mcfb = new MethodInvokingFactoryBean();
@ -127,7 +127,7 @@ public class MethodInvokingFactoryBeanTests { @@ -127,7 +127,7 @@ public class MethodInvokingFactoryBeanTests {
}
@Test
public void testGetObject() throws Exception {
void testGetObject() throws Exception {
// singleton, non-static
TestClass1 tc1 = new TestClass1();
MethodInvokingFactoryBean mcfb = new MethodInvokingFactoryBean();
@ -190,7 +190,7 @@ public class MethodInvokingFactoryBeanTests { @@ -190,7 +190,7 @@ public class MethodInvokingFactoryBeanTests {
}
@Test
public void testArgumentConversion() throws Exception {
void testArgumentConversion() throws Exception {
MethodInvokingFactoryBean mcfb = new MethodInvokingFactoryBean();
mcfb.setTargetClass(TestClass1.class);
mcfb.setTargetMethod("supertypes");
@ -224,7 +224,7 @@ public class MethodInvokingFactoryBeanTests { @@ -224,7 +224,7 @@ public class MethodInvokingFactoryBeanTests {
}
@Test
public void testInvokeWithNullArgument() throws Exception {
void testInvokeWithNullArgument() throws Exception {
MethodInvoker methodInvoker = new MethodInvoker();
methodInvoker.setTargetClass(TestClass1.class);
methodInvoker.setTargetMethod("nullArgument");
@ -234,7 +234,7 @@ public class MethodInvokingFactoryBeanTests { @@ -234,7 +234,7 @@ public class MethodInvokingFactoryBeanTests {
}
@Test
public void testInvokeWithIntArgument() throws Exception {
void testInvokeWithIntArgument() throws Exception {
ArgumentConvertingMethodInvoker methodInvoker = new ArgumentConvertingMethodInvoker();
methodInvoker.setTargetClass(TestClass1.class);
methodInvoker.setTargetMethod("intArgument");
@ -251,7 +251,7 @@ public class MethodInvokingFactoryBeanTests { @@ -251,7 +251,7 @@ public class MethodInvokingFactoryBeanTests {
}
@Test
public void testInvokeWithIntArguments() throws Exception {
void testInvokeWithIntArguments() throws Exception {
MethodInvokingBean methodInvoker = new MethodInvokingBean();
methodInvoker.setTargetClass(TestClass1.class);
methodInvoker.setTargetMethod("intArguments");

26
spring-beans/src/test/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -41,13 +41,13 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie @@ -41,13 +41,13 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
* @author Rick Evans
* @author Chris Beams
*/
public class ObjectFactoryCreatingFactoryBeanTests {
class ObjectFactoryCreatingFactoryBeanTests {
private DefaultListableBeanFactory beanFactory;
@BeforeEach
public void setup() {
void setup() {
this.beanFactory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
qualifiedResource(ObjectFactoryCreatingFactoryBeanTests.class, "context.xml"));
@ -55,13 +55,13 @@ public class ObjectFactoryCreatingFactoryBeanTests { @@ -55,13 +55,13 @@ public class ObjectFactoryCreatingFactoryBeanTests {
}
@AfterEach
public void close() {
void close() {
this.beanFactory.setSerializationId(null);
}
@Test
public void testFactoryOperation() {
void testFactoryOperation() {
FactoryTestBean testBean = beanFactory.getBean("factoryTestBean", FactoryTestBean.class);
ObjectFactory<?> objectFactory = testBean.getObjectFactory();
@ -71,7 +71,7 @@ public class ObjectFactoryCreatingFactoryBeanTests { @@ -71,7 +71,7 @@ public class ObjectFactoryCreatingFactoryBeanTests {
}
@Test
public void testFactorySerialization() throws Exception {
void testFactorySerialization() throws Exception {
FactoryTestBean testBean = beanFactory.getBean("factoryTestBean", FactoryTestBean.class);
ObjectFactory<?> objectFactory = testBean.getObjectFactory();
@ -83,7 +83,7 @@ public class ObjectFactoryCreatingFactoryBeanTests { @@ -83,7 +83,7 @@ public class ObjectFactoryCreatingFactoryBeanTests {
}
@Test
public void testProviderOperation() {
void testProviderOperation() {
ProviderTestBean testBean = beanFactory.getBean("providerTestBean", ProviderTestBean.class);
Provider<?> provider = testBean.getProvider();
@ -93,7 +93,7 @@ public class ObjectFactoryCreatingFactoryBeanTests { @@ -93,7 +93,7 @@ public class ObjectFactoryCreatingFactoryBeanTests {
}
@Test
public void testProviderSerialization() throws Exception {
void testProviderSerialization() throws Exception {
ProviderTestBean testBean = beanFactory.getBean("providerTestBean", ProviderTestBean.class);
Provider<?> provider = testBean.getProvider();
@ -105,7 +105,7 @@ public class ObjectFactoryCreatingFactoryBeanTests { @@ -105,7 +105,7 @@ public class ObjectFactoryCreatingFactoryBeanTests {
}
@Test
public void testDoesNotComplainWhenTargetBeanNameRefersToSingleton() throws Exception {
void testDoesNotComplainWhenTargetBeanNameRefersToSingleton() throws Exception {
final String targetBeanName = "singleton";
final String expectedSingleton = "Alicia Keys";
@ -122,14 +122,14 @@ public class ObjectFactoryCreatingFactoryBeanTests { @@ -122,14 +122,14 @@ public class ObjectFactoryCreatingFactoryBeanTests {
}
@Test
public void testWhenTargetBeanNameIsNull() throws Exception {
void testWhenTargetBeanNameIsNull() {
assertThatIllegalArgumentException().as(
"'targetBeanName' property not set").isThrownBy(
new ObjectFactoryCreatingFactoryBean()::afterPropertiesSet);
}
@Test
public void testWhenTargetBeanNameIsEmptyString() throws Exception {
void testWhenTargetBeanNameIsEmptyString() {
ObjectFactoryCreatingFactoryBean factory = new ObjectFactoryCreatingFactoryBean();
factory.setTargetBeanName("");
assertThatIllegalArgumentException().as(
@ -138,7 +138,7 @@ public class ObjectFactoryCreatingFactoryBeanTests { @@ -138,7 +138,7 @@ public class ObjectFactoryCreatingFactoryBeanTests {
}
@Test
public void testWhenTargetBeanNameIsWhitespacedString() throws Exception {
void testWhenTargetBeanNameIsWhitespacedString() {
ObjectFactoryCreatingFactoryBean factory = new ObjectFactoryCreatingFactoryBean();
factory.setTargetBeanName(" \t");
assertThatIllegalArgumentException().as(
@ -147,7 +147,7 @@ public class ObjectFactoryCreatingFactoryBeanTests { @@ -147,7 +147,7 @@ public class ObjectFactoryCreatingFactoryBeanTests {
}
@Test
public void testEnsureOFBFBReportsThatItActuallyCreatesObjectFactoryInstances() {
void testEnsureOFBFBReportsThatItActuallyCreatesObjectFactoryInstances() {
assertThat(new ObjectFactoryCreatingFactoryBean().getObjectType()).as("Must be reporting that it creates ObjectFactory instances (as per class contract).").isEqualTo(ObjectFactory.class);
}

18
spring-beans/src/test/java/org/springframework/beans/factory/config/PropertiesFactoryBeanTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -32,14 +32,14 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie @@ -32,14 +32,14 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
* @author Chris Beams
* @since 01.11.2003
*/
public class PropertiesFactoryBeanTests {
class PropertiesFactoryBeanTests {
private static final Class<?> CLASS = PropertiesFactoryBeanTests.class;
private static final Resource TEST_PROPS = qualifiedResource(CLASS, "test.properties");
private static final Resource TEST_PROPS_XML = qualifiedResource(CLASS, "test.properties.xml");
@Test
public void testWithPropertiesFile() throws Exception {
void testWithPropertiesFile() throws Exception {
PropertiesFactoryBean pfb = new PropertiesFactoryBean();
pfb.setLocation(TEST_PROPS);
pfb.afterPropertiesSet();
@ -48,7 +48,7 @@ public class PropertiesFactoryBeanTests { @@ -48,7 +48,7 @@ public class PropertiesFactoryBeanTests {
}
@Test
public void testWithPropertiesXmlFile() throws Exception {
void testWithPropertiesXmlFile() throws Exception {
PropertiesFactoryBean pfb = new PropertiesFactoryBean();
pfb.setLocation(TEST_PROPS_XML);
pfb.afterPropertiesSet();
@ -57,7 +57,7 @@ public class PropertiesFactoryBeanTests { @@ -57,7 +57,7 @@ public class PropertiesFactoryBeanTests {
}
@Test
public void testWithLocalProperties() throws Exception {
void testWithLocalProperties() throws Exception {
PropertiesFactoryBean pfb = new PropertiesFactoryBean();
Properties localProps = new Properties();
localProps.setProperty("key2", "value2");
@ -68,7 +68,7 @@ public class PropertiesFactoryBeanTests { @@ -68,7 +68,7 @@ public class PropertiesFactoryBeanTests {
}
@Test
public void testWithPropertiesFileAndLocalProperties() throws Exception {
void testWithPropertiesFileAndLocalProperties() throws Exception {
PropertiesFactoryBean pfb = new PropertiesFactoryBean();
pfb.setLocation(TEST_PROPS);
Properties localProps = new Properties();
@ -82,7 +82,7 @@ public class PropertiesFactoryBeanTests { @@ -82,7 +82,7 @@ public class PropertiesFactoryBeanTests {
}
@Test
public void testWithPropertiesFileAndMultipleLocalProperties() throws Exception {
void testWithPropertiesFileAndMultipleLocalProperties() throws Exception {
PropertiesFactoryBean pfb = new PropertiesFactoryBean();
pfb.setLocation(TEST_PROPS);
@ -111,7 +111,7 @@ public class PropertiesFactoryBeanTests { @@ -111,7 +111,7 @@ public class PropertiesFactoryBeanTests {
}
@Test
public void testWithPropertiesFileAndLocalPropertiesAndLocalOverride() throws Exception {
void testWithPropertiesFileAndLocalPropertiesAndLocalOverride() throws Exception {
PropertiesFactoryBean pfb = new PropertiesFactoryBean();
pfb.setLocation(TEST_PROPS);
Properties localProps = new Properties();
@ -126,7 +126,7 @@ public class PropertiesFactoryBeanTests { @@ -126,7 +126,7 @@ public class PropertiesFactoryBeanTests {
}
@Test
public void testWithPrototype() throws Exception {
void testWithPrototype() throws Exception {
PropertiesFactoryBean pfb = new PropertiesFactoryBean();
pfb.setSingleton(false);
pfb.setLocation(TEST_PROPS);

16
spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -34,13 +34,13 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie @@ -34,13 +34,13 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
* @author Chris Beams
* @since 04.10.2004
*/
public class PropertyPathFactoryBeanTests {
class PropertyPathFactoryBeanTests {
private static final Resource CONTEXT = qualifiedResource(PropertyPathFactoryBeanTests.class, "context.xml");
@Test
public void testPropertyPathFactoryBeanWithSingletonResult() {
void testPropertyPathFactoryBeanWithSingletonResult() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONTEXT);
assertThat(xbf.getBean("propertyPath1")).isEqualTo(12);
@ -55,7 +55,7 @@ public class PropertyPathFactoryBeanTests { @@ -55,7 +55,7 @@ public class PropertyPathFactoryBeanTests {
}
@Test
public void testPropertyPathFactoryBeanWithPrototypeResult() {
void testPropertyPathFactoryBeanWithPrototypeResult() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONTEXT);
assertThat(xbf.getType("tb.spouse")).isNull();
@ -75,7 +75,7 @@ public class PropertyPathFactoryBeanTests { @@ -75,7 +75,7 @@ public class PropertyPathFactoryBeanTests {
}
@Test
public void testPropertyPathFactoryBeanWithNullResult() {
void testPropertyPathFactoryBeanWithNullResult() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONTEXT);
assertThat(xbf.getType("tb.spouse.spouse")).isNull();
@ -83,7 +83,7 @@ public class PropertyPathFactoryBeanTests { @@ -83,7 +83,7 @@ public class PropertyPathFactoryBeanTests {
}
@Test
public void testPropertyPathFactoryBeanAsInnerBean() {
void testPropertyPathFactoryBeanAsInnerBean() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONTEXT);
TestBean spouse = (TestBean) xbf.getBean("otb.spouse");
@ -94,14 +94,14 @@ public class PropertyPathFactoryBeanTests { @@ -94,14 +94,14 @@ public class PropertyPathFactoryBeanTests {
}
@Test
public void testPropertyPathFactoryBeanAsNullReference() {
void testPropertyPathFactoryBeanAsNullReference() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONTEXT);
assertThat(xbf.getBean("tbWithNullReference", TestBean.class).getSpouse()).isNull();
}
@Test
public void testPropertyPathFactoryBeanAsInnerNull() {
void testPropertyPathFactoryBeanAsInnerNull() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONTEXT);
assertThat(xbf.getBean("tbWithInnerNull", TestBean.class).getSpouse()).isNull();

77
spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -23,7 +23,6 @@ import java.util.Map; @@ -23,7 +23,6 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.prefs.AbstractPreferences;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
import java.util.prefs.PreferencesFactory;
@ -61,7 +60,7 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie @@ -61,7 +60,7 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
* @see PropertyPlaceholderConfigurerTests
*/
@SuppressWarnings("deprecation")
public class PropertyResourceConfigurerTests {
class PropertyResourceConfigurerTests {
static {
System.setProperty("java.util.prefs.PreferencesFactory", MockPreferencesFactory.class.getName());
@ -76,7 +75,7 @@ public class PropertyResourceConfigurerTests { @@ -76,7 +75,7 @@ public class PropertyResourceConfigurerTests {
@Test
public void testPropertyOverrideConfigurer() {
void testPropertyOverrideConfigurer() {
BeanDefinition def1 = BeanDefinitionBuilder.genericBeanDefinition(TestBean.class).getBeanDefinition();
factory.registerBeanDefinition("tb1", def1);
@ -116,7 +115,7 @@ public class PropertyResourceConfigurerTests { @@ -116,7 +115,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyOverrideConfigurerWithNestedProperty() {
void testPropertyOverrideConfigurerWithNestedProperty() {
BeanDefinition def = BeanDefinitionBuilder.genericBeanDefinition(IndexedTestBean.class).getBeanDefinition();
factory.registerBeanDefinition("tb", def);
@ -134,7 +133,7 @@ public class PropertyResourceConfigurerTests { @@ -134,7 +133,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyOverrideConfigurerWithNestedPropertyAndDotInBeanName() {
void testPropertyOverrideConfigurerWithNestedPropertyAndDotInBeanName() {
BeanDefinition def = BeanDefinitionBuilder.genericBeanDefinition(IndexedTestBean.class).getBeanDefinition();
factory.registerBeanDefinition("my.tb", def);
@ -153,7 +152,7 @@ public class PropertyResourceConfigurerTests { @@ -153,7 +152,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyOverrideConfigurerWithNestedMapPropertyAndDotInMapKey() {
void testPropertyOverrideConfigurerWithNestedMapPropertyAndDotInMapKey() {
BeanDefinition def = BeanDefinitionBuilder.genericBeanDefinition(IndexedTestBean.class).getBeanDefinition();
factory.registerBeanDefinition("tb", def);
@ -171,7 +170,7 @@ public class PropertyResourceConfigurerTests { @@ -171,7 +170,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyOverrideConfigurerWithHeldProperties() {
void testPropertyOverrideConfigurerWithHeldProperties() {
BeanDefinition def = BeanDefinitionBuilder.genericBeanDefinition(PropertiesHolder.class).getBeanDefinition();
factory.registerBeanDefinition("tb", def);
@ -187,7 +186,7 @@ public class PropertyResourceConfigurerTests { @@ -187,7 +186,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyOverrideConfigurerWithPropertiesFile() {
void testPropertyOverrideConfigurerWithPropertiesFile() {
BeanDefinition def = BeanDefinitionBuilder.genericBeanDefinition(IndexedTestBean.class).getBeanDefinition();
factory.registerBeanDefinition("tb", def);
@ -201,7 +200,7 @@ public class PropertyResourceConfigurerTests { @@ -201,7 +200,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyOverrideConfigurerWithInvalidPropertiesFile() {
void testPropertyOverrideConfigurerWithInvalidPropertiesFile() {
BeanDefinition def = BeanDefinitionBuilder.genericBeanDefinition(IndexedTestBean.class).getBeanDefinition();
factory.registerBeanDefinition("tb", def);
@ -216,7 +215,7 @@ public class PropertyResourceConfigurerTests { @@ -216,7 +215,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyOverrideConfigurerWithPropertiesXmlFile() {
void testPropertyOverrideConfigurerWithPropertiesXmlFile() {
BeanDefinition def = BeanDefinitionBuilder.genericBeanDefinition(IndexedTestBean.class).getBeanDefinition();
factory.registerBeanDefinition("tb", def);
@ -230,7 +229,7 @@ public class PropertyResourceConfigurerTests { @@ -230,7 +229,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyOverrideConfigurerWithConvertProperties() {
void testPropertyOverrideConfigurerWithConvertProperties() {
BeanDefinition def = BeanDefinitionBuilder.genericBeanDefinition(IndexedTestBean.class).getBeanDefinition();
factory.registerBeanDefinition("tb", def);
@ -247,7 +246,7 @@ public class PropertyResourceConfigurerTests { @@ -247,7 +246,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyOverrideConfigurerWithInvalidKey() {
void testPropertyOverrideConfigurerWithInvalidKey() {
factory.registerBeanDefinition("tb1", genericBeanDefinition(TestBean.class).getBeanDefinition());
factory.registerBeanDefinition("tb2", genericBeanDefinition(TestBean.class).getBeanDefinition());
@ -282,7 +281,7 @@ public class PropertyResourceConfigurerTests { @@ -282,7 +281,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyOverrideConfigurerWithIgnoreInvalidKeys() {
void testPropertyOverrideConfigurerWithIgnoreInvalidKeys() {
factory.registerBeanDefinition("tb1", genericBeanDefinition(TestBean.class).getBeanDefinition());
factory.registerBeanDefinition("tb2", genericBeanDefinition(TestBean.class).getBeanDefinition());
@ -315,12 +314,12 @@ public class PropertyResourceConfigurerTests { @@ -315,12 +314,12 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyPlaceholderConfigurer() {
void testPropertyPlaceholderConfigurer() {
doTestPropertyPlaceholderConfigurer(false);
}
@Test
public void testPropertyPlaceholderConfigurerWithParentChildSeparation() {
void testPropertyPlaceholderConfigurerWithParentChildSeparation() {
doTestPropertyPlaceholderConfigurer(true);
}
@ -427,7 +426,7 @@ public class PropertyResourceConfigurerTests { @@ -427,7 +426,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyPlaceholderConfigurerWithSystemPropertyFallback() {
void testPropertyPlaceholderConfigurerWithSystemPropertyFallback() {
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
.addPropertyValue("country", "${os.name}").getBeanDefinition());
@ -439,7 +438,7 @@ public class PropertyResourceConfigurerTests { @@ -439,7 +438,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyPlaceholderConfigurerWithSystemPropertyNotUsed() {
void testPropertyPlaceholderConfigurerWithSystemPropertyNotUsed() {
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
.addPropertyValue("country", "${os.name}").getBeanDefinition());
@ -454,7 +453,7 @@ public class PropertyResourceConfigurerTests { @@ -454,7 +453,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyPlaceholderConfigurerWithOverridingSystemProperty() {
void testPropertyPlaceholderConfigurerWithOverridingSystemProperty() {
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
.addPropertyValue("country", "${os.name}").getBeanDefinition());
@ -470,7 +469,7 @@ public class PropertyResourceConfigurerTests { @@ -470,7 +469,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyPlaceholderConfigurerWithUnresolvableSystemProperty() {
void testPropertyPlaceholderConfigurerWithUnresolvableSystemProperty() {
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
.addPropertyValue("touchy", "${user.dir}").getBeanDefinition());
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
@ -481,7 +480,7 @@ public class PropertyResourceConfigurerTests { @@ -481,7 +480,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyPlaceholderConfigurerWithUnresolvablePlaceholder() {
void testPropertyPlaceholderConfigurerWithUnresolvablePlaceholder() {
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
.addPropertyValue("name", "${ref}").getBeanDefinition());
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
@ -491,7 +490,7 @@ public class PropertyResourceConfigurerTests { @@ -491,7 +490,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyPlaceholderConfigurerWithIgnoreUnresolvablePlaceholder() {
void testPropertyPlaceholderConfigurerWithIgnoreUnresolvablePlaceholder() {
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
.addPropertyValue("name", "${ref}").getBeanDefinition());
@ -504,7 +503,7 @@ public class PropertyResourceConfigurerTests { @@ -504,7 +503,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyPlaceholderConfigurerWithEmptyStringAsNull() {
void testPropertyPlaceholderConfigurerWithEmptyStringAsNull() {
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
.addPropertyValue("name", "").getBeanDefinition());
@ -517,7 +516,7 @@ public class PropertyResourceConfigurerTests { @@ -517,7 +516,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyPlaceholderConfigurerWithEmptyStringInPlaceholderAsNull() {
void testPropertyPlaceholderConfigurerWithEmptyStringInPlaceholderAsNull() {
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
.addPropertyValue("name", "${ref}").getBeanDefinition());
@ -533,7 +532,7 @@ public class PropertyResourceConfigurerTests { @@ -533,7 +532,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyPlaceholderConfigurerWithNestedPlaceholderInKey() {
void testPropertyPlaceholderConfigurerWithNestedPlaceholderInKey() {
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
.addPropertyValue("name", "${my${key}key}").getBeanDefinition());
@ -549,7 +548,7 @@ public class PropertyResourceConfigurerTests { @@ -549,7 +548,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyPlaceholderConfigurerWithPlaceholderInAlias() {
void testPropertyPlaceholderConfigurerWithPlaceholderInAlias() {
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class).getBeanDefinition());
factory.registerAlias("tb", "${alias}");
@ -565,7 +564,7 @@ public class PropertyResourceConfigurerTests { @@ -565,7 +564,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyPlaceholderConfigurerWithSelfReferencingPlaceholderInAlias() {
void testPropertyPlaceholderConfigurerWithSelfReferencingPlaceholderInAlias() {
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class).getBeanDefinition());
factory.registerAlias("tb", "${alias}");
@ -581,7 +580,7 @@ public class PropertyResourceConfigurerTests { @@ -581,7 +580,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyPlaceholderConfigurerWithCircularReference() {
void testPropertyPlaceholderConfigurerWithCircularReference() {
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
.addPropertyValue("age", "${age}")
.addPropertyValue("name", "name${var}")
@ -598,7 +597,7 @@ public class PropertyResourceConfigurerTests { @@ -598,7 +597,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyPlaceholderConfigurerWithDefaultProperties() {
void testPropertyPlaceholderConfigurerWithDefaultProperties() {
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
.addPropertyValue("touchy", "${test}").getBeanDefinition());
@ -613,7 +612,7 @@ public class PropertyResourceConfigurerTests { @@ -613,7 +612,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyPlaceholderConfigurerWithInlineDefault() {
void testPropertyPlaceholderConfigurerWithInlineDefault() {
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
.addPropertyValue("touchy", "${test:mytest}").getBeanDefinition());
@ -625,7 +624,7 @@ public class PropertyResourceConfigurerTests { @@ -625,7 +624,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPropertyPlaceholderConfigurerWithAliases() {
void testPropertyPlaceholderConfigurerWithAliases() {
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
.addPropertyValue("touchy", "${test}").getBeanDefinition());
@ -649,7 +648,7 @@ public class PropertyResourceConfigurerTests { @@ -649,7 +648,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPreferencesPlaceholderConfigurer() {
void testPreferencesPlaceholderConfigurer() {
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
.addPropertyValue("name", "${myName}")
.addPropertyValue("age", "${myAge}")
@ -676,7 +675,7 @@ public class PropertyResourceConfigurerTests { @@ -676,7 +675,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPreferencesPlaceholderConfigurerWithCustomTreePaths() {
void testPreferencesPlaceholderConfigurerWithCustomTreePaths() {
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
.addPropertyValue("name", "${myName}")
.addPropertyValue("age", "${myAge}")
@ -705,7 +704,7 @@ public class PropertyResourceConfigurerTests { @@ -705,7 +704,7 @@ public class PropertyResourceConfigurerTests {
}
@Test
public void testPreferencesPlaceholderConfigurerWithPathInPlaceholder() {
void testPreferencesPlaceholderConfigurerWithPathInPlaceholder() {
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
.addPropertyValue("name", "${mypath/myName}")
.addPropertyValue("age", "${myAge}")
@ -812,16 +811,16 @@ public class PropertyResourceConfigurerTests { @@ -812,16 +811,16 @@ public class PropertyResourceConfigurerTests {
}
@Override
protected void removeNodeSpi() throws BackingStoreException {
protected void removeNodeSpi() {
}
@Override
protected String[] keysSpi() throws BackingStoreException {
protected String[] keysSpi() {
return StringUtils.toStringArray(values.keySet());
}
@Override
protected String[] childrenNamesSpi() throws BackingStoreException {
protected String[] childrenNamesSpi() {
return StringUtils.toStringArray(children.keySet());
}
@ -836,11 +835,11 @@ public class PropertyResourceConfigurerTests { @@ -836,11 +835,11 @@ public class PropertyResourceConfigurerTests {
}
@Override
protected void syncSpi() throws BackingStoreException {
protected void syncSpi() {
}
@Override
protected void flushSpi() throws BackingStoreException {
protected void flushSpi() {
}
}

26
spring-beans/src/test/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBeanTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -40,17 +40,17 @@ import static org.springframework.beans.factory.support.BeanDefinitionBuilder.ge @@ -40,17 +40,17 @@ import static org.springframework.beans.factory.support.BeanDefinitionBuilder.ge
* @author Rick Evans
* @author Chris Beams
*/
public class ServiceLocatorFactoryBeanTests {
class ServiceLocatorFactoryBeanTests {
private DefaultListableBeanFactory bf;
@BeforeEach
public void setUp() {
void setUp() {
bf = new DefaultListableBeanFactory();
}
@Test
public void testNoArgGetter() {
void testNoArgGetter() {
bf.registerBeanDefinition("testService", genericBeanDefinition(TestService.class).getBeanDefinition());
bf.registerBeanDefinition("factory",
genericBeanDefinition(ServiceLocatorFactoryBean.class)
@ -63,7 +63,7 @@ public class ServiceLocatorFactoryBeanTests { @@ -63,7 +63,7 @@ public class ServiceLocatorFactoryBeanTests {
}
@Test
public void testErrorOnTooManyOrTooFew() throws Exception {
void testErrorOnTooManyOrTooFew() {
bf.registerBeanDefinition("testService", genericBeanDefinition(TestService.class).getBeanDefinition());
bf.registerBeanDefinition("testServiceInstance2", genericBeanDefinition(TestService.class).getBeanDefinition());
bf.registerBeanDefinition("factory",
@ -87,7 +87,7 @@ public class ServiceLocatorFactoryBeanTests { @@ -87,7 +87,7 @@ public class ServiceLocatorFactoryBeanTests {
}
@Test
public void testErrorOnTooManyOrTooFewWithCustomServiceLocatorException() {
void testErrorOnTooManyOrTooFewWithCustomServiceLocatorException() {
bf.registerBeanDefinition("testService", genericBeanDefinition(TestService.class).getBeanDefinition());
bf.registerBeanDefinition("testServiceInstance2", genericBeanDefinition(TestService.class).getBeanDefinition());
bf.registerBeanDefinition("factory",
@ -116,7 +116,7 @@ public class ServiceLocatorFactoryBeanTests { @@ -116,7 +116,7 @@ public class ServiceLocatorFactoryBeanTests {
}
@Test
public void testStringArgGetter() throws Exception {
void testStringArgGetter() throws Exception {
bf.registerBeanDefinition("testService", genericBeanDefinition(TestService.class).getBeanDefinition());
bf.registerBeanDefinition("factory",
genericBeanDefinition(ServiceLocatorFactoryBean.class)
@ -205,13 +205,13 @@ public class ServiceLocatorFactoryBeanTests { @@ -205,13 +205,13 @@ public class ServiceLocatorFactoryBeanTests {
}
@Test
public void testNoServiceLocatorInterfaceSupplied() throws Exception {
void testNoServiceLocatorInterfaceSupplied() {
assertThatIllegalArgumentException().isThrownBy(
new ServiceLocatorFactoryBean()::afterPropertiesSet);
}
@Test
public void testWhenServiceLocatorInterfaceIsNotAnInterfaceType() throws Exception {
void testWhenServiceLocatorInterfaceIsNotAnInterfaceType() {
ServiceLocatorFactoryBean factory = new ServiceLocatorFactoryBean();
factory.setServiceLocatorInterface(getClass());
assertThatIllegalArgumentException().isThrownBy(
@ -220,7 +220,7 @@ public class ServiceLocatorFactoryBeanTests { @@ -220,7 +220,7 @@ public class ServiceLocatorFactoryBeanTests {
}
@Test
public void testWhenServiceLocatorExceptionClassToExceptionTypeWithOnlyNoArgCtor() throws Exception {
void testWhenServiceLocatorExceptionClassToExceptionTypeWithOnlyNoArgCtor() {
ServiceLocatorFactoryBean factory = new ServiceLocatorFactoryBean();
assertThatIllegalArgumentException().isThrownBy(() ->
factory.setServiceLocatorExceptionClass(ExceptionClassWithOnlyZeroArgCtor.class));
@ -229,7 +229,7 @@ public class ServiceLocatorFactoryBeanTests { @@ -229,7 +229,7 @@ public class ServiceLocatorFactoryBeanTests {
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testWhenServiceLocatorExceptionClassIsNotAnExceptionSubclass() throws Exception {
public void testWhenServiceLocatorExceptionClassIsNotAnExceptionSubclass() {
ServiceLocatorFactoryBean factory = new ServiceLocatorFactoryBean();
assertThatIllegalArgumentException().isThrownBy(() ->
factory.setServiceLocatorExceptionClass((Class) getClass()));
@ -237,7 +237,7 @@ public class ServiceLocatorFactoryBeanTests { @@ -237,7 +237,7 @@ public class ServiceLocatorFactoryBeanTests {
}
@Test
public void testWhenServiceLocatorMethodCalledWithTooManyParameters() throws Exception {
void testWhenServiceLocatorMethodCalledWithTooManyParameters() {
ServiceLocatorFactoryBean factory = new ServiceLocatorFactoryBean();
factory.setServiceLocatorInterface(ServiceLocatorInterfaceWithExtraNonCompliantMethod.class);
factory.afterPropertiesSet();
@ -247,7 +247,7 @@ public class ServiceLocatorFactoryBeanTests { @@ -247,7 +247,7 @@ public class ServiceLocatorFactoryBeanTests {
}
@Test
public void testRequiresListableBeanFactoryAndChokesOnAnythingElse() throws Exception {
void testRequiresListableBeanFactoryAndChokesOnAnythingElse() {
BeanFactory beanFactory = mock();
try {
ServiceLocatorFactoryBean factory = new ServiceLocatorFactoryBean();

8
spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -37,13 +37,13 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie @@ -37,13 +37,13 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
* @author Juergen Hoeller
* @author Chris Beams
*/
public class SimpleScopeTests {
class SimpleScopeTests {
private DefaultListableBeanFactory beanFactory;
@BeforeEach
public void setup() {
void setup() {
beanFactory = new DefaultListableBeanFactory();
Scope scope = new NoOpScope() {
private int index;
@ -73,7 +73,7 @@ public class SimpleScopeTests { @@ -73,7 +73,7 @@ public class SimpleScopeTests {
@Test
public void testCanGetScopedObject() {
void testCanGetScopedObject() {
TestBean tb1 = (TestBean) beanFactory.getBean("usesScope");
TestBean tb2 = (TestBean) beanFactory.getBean("usesScope");
assertThat(tb2).isNotSameAs(tb1);

20
spring-beans/src/test/java/org/springframework/beans/factory/config/YamlMapFactoryBeanTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -38,20 +38,20 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; @@ -38,20 +38,20 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
* @author Dave Syer
* @author Juergen Hoeller
*/
public class YamlMapFactoryBeanTests {
class YamlMapFactoryBeanTests {
private final YamlMapFactoryBean factory = new YamlMapFactoryBean();
@Test
public void testSetIgnoreResourceNotFound() {
void testSetIgnoreResourceNotFound() {
this.factory.setResolutionMethod(YamlMapFactoryBean.ResolutionMethod.OVERRIDE_AND_IGNORE);
this.factory.setResources(new FileSystemResource("non-exsitent-file.yml"));
assertThat(this.factory.getObject()).isEmpty();
}
@Test
public void testSetBarfOnResourceNotFound() {
void testSetBarfOnResourceNotFound() {
assertThatIllegalStateException().isThrownBy(() -> {
this.factory.setResources(new FileSystemResource("non-exsitent-file.yml"));
this.factory.getObject().size();
@ -59,14 +59,14 @@ public class YamlMapFactoryBeanTests { @@ -59,14 +59,14 @@ public class YamlMapFactoryBeanTests {
}
@Test
public void testGetObject() {
void testGetObject() {
this.factory.setResources(new ByteArrayResource("foo: bar".getBytes()));
assertThat(this.factory.getObject()).hasSize(1);
}
@SuppressWarnings("unchecked")
@Test
public void testOverrideAndRemoveDefaults() {
void testOverrideAndRemoveDefaults() {
this.factory.setResources(new ByteArrayResource("foo:\n bar: spam".getBytes()),
new ByteArrayResource("foo:\n spam: bar".getBytes()));
@ -75,7 +75,7 @@ public class YamlMapFactoryBeanTests { @@ -75,7 +75,7 @@ public class YamlMapFactoryBeanTests {
}
@Test
public void testFirstFound() {
void testFirstFound() {
this.factory.setResolutionMethod(YamlProcessor.ResolutionMethod.FIRST_FOUND);
this.factory.setResources(new AbstractResource() {
@Override
@ -92,7 +92,7 @@ public class YamlMapFactoryBeanTests { @@ -92,7 +92,7 @@ public class YamlMapFactoryBeanTests {
}
@Test
public void testMapWithPeriodsInKey() {
void testMapWithPeriodsInKey() {
this.factory.setResources(new ByteArrayResource("foo:\n ? key1.key2\n : value".getBytes()));
Map<String, Object> map = this.factory.getObject();
@ -107,7 +107,7 @@ public class YamlMapFactoryBeanTests { @@ -107,7 +107,7 @@ public class YamlMapFactoryBeanTests {
}
@Test
public void testMapWithIntegerValue() {
void testMapWithIntegerValue() {
this.factory.setResources(new ByteArrayResource("foo:\n ? key1.key2\n : 3".getBytes()));
Map<String, Object> map = this.factory.getObject();
@ -122,7 +122,7 @@ public class YamlMapFactoryBeanTests { @@ -122,7 +122,7 @@ public class YamlMapFactoryBeanTests {
}
@Test
public void testDuplicateKey() {
void testDuplicateKey() {
this.factory.setResources(new ByteArrayResource("mymap:\n foo: bar\nmymap:\n bar: foo".getBytes()));
assertThatExceptionOfType(DuplicateKeyException.class).isThrownBy(() ->
this.factory.getObject().get("mymap"));

4
spring-beans/src/test/java/org/springframework/beans/factory/config/YamlProcessorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -142,7 +142,7 @@ class YamlProcessorTests { @@ -142,7 +142,7 @@ class YamlProcessorTests {
@Test
@SuppressWarnings("unchecked")
void standardTypesSupportedByDefault() throws Exception {
void standardTypesSupportedByDefault() {
setYaml("value: !!set\n ? first\n ? second");
this.processor.process((properties, map) -> {
assertThat(properties).containsExactly(entry("value[0]", "first"), entry("value[1]", "second"));

6
spring-beans/src/test/java/org/springframework/beans/factory/parsing/ConstructorArgumentEntryTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -26,10 +26,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException @@ -26,10 +26,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Rick Evans
* @author Chris Beams
*/
public class ConstructorArgumentEntryTests {
class ConstructorArgumentEntryTests {
@Test
public void testCtorBailsOnNegativeCtorIndexArgument() {
void testCtorBailsOnNegativeCtorIndexArgument() {
assertThatIllegalArgumentException().isThrownBy(() ->
new ConstructorArgumentEntry(-1));
}

8
spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -34,7 +34,7 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie @@ -34,7 +34,7 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
* @author Chris Beams
* @since 2.0
*/
public class CustomProblemReporterTests {
class CustomProblemReporterTests {
private CollatingProblemReporter problemReporter;
@ -44,7 +44,7 @@ public class CustomProblemReporterTests { @@ -44,7 +44,7 @@ public class CustomProblemReporterTests {
@BeforeEach
public void setup() {
void setup() {
this.problemReporter = new CollatingProblemReporter();
this.beanFactory = new DefaultListableBeanFactory();
this.reader = new XmlBeanDefinitionReader(this.beanFactory);
@ -53,7 +53,7 @@ public class CustomProblemReporterTests { @@ -53,7 +53,7 @@ public class CustomProblemReporterTests {
@Test
public void testErrorsAreCollated() {
void testErrorsAreCollated() {
this.reader.loadBeanDefinitions(qualifiedResource(CustomProblemReporterTests.class, "context.xml"));
assertThat(this.problemReporter.getErrors()).as("Incorrect number of errors collated").hasSize(4);

8
spring-beans/src/test/java/org/springframework/beans/factory/parsing/FailFastProblemReporterTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -32,10 +32,10 @@ import static org.mockito.Mockito.verify; @@ -32,10 +32,10 @@ import static org.mockito.Mockito.verify;
* @author Juergen Hoeller
* @author Chris Beams
*/
public class FailFastProblemReporterTests {
class FailFastProblemReporterTests {
@Test
public void testError() throws Exception {
void testError() {
FailFastProblemReporter reporter = new FailFastProblemReporter();
assertThatExceptionOfType(BeanDefinitionParsingException.class).isThrownBy(() ->
reporter.error(new Problem("VGER", new Location(new DescriptiveResource("here")),
@ -43,7 +43,7 @@ public class FailFastProblemReporterTests { @@ -43,7 +43,7 @@ public class FailFastProblemReporterTests {
}
@Test
public void testWarn() throws Exception {
void testWarn() {
Problem problem = new Problem("VGER", new Location(new DescriptiveResource("here")),
null, new IllegalArgumentException());

8
spring-beans/src/test/java/org/springframework/beans/factory/parsing/NullSourceExtractorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -24,17 +24,17 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -24,17 +24,17 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Rick Evans
* @author Chris Beams
*/
public class NullSourceExtractorTests {
class NullSourceExtractorTests {
@Test
public void testPassThroughContract() throws Exception {
void testPassThroughContract() {
Object source = new Object();
Object extractedSource = new NullSourceExtractor().extractSource(source, null);
assertThat(extractedSource).as("The contract of NullSourceExtractor states that the extraction *always* return null").isNull();
}
@Test
public void testPassThroughContractEvenWithNull() throws Exception {
void testPassThroughContractEvenWithNull() {
Object extractedSource = new NullSourceExtractor().extractSource(null, null);
assertThat(extractedSource).as("The contract of NullSourceExtractor states that the extraction *always* return null").isNull();
}

10
spring-beans/src/test/java/org/springframework/beans/factory/parsing/ParseStateTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -25,10 +25,10 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -25,10 +25,10 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Chris Beams
* @since 2.0
*/
public class ParseStateTests {
class ParseStateTests {
@Test
public void testSimple() throws Exception {
void testSimple() {
MockEntry entry = new MockEntry();
ParseState parseState = new ParseState();
@ -39,7 +39,7 @@ public class ParseStateTests { @@ -39,7 +39,7 @@ public class ParseStateTests {
}
@Test
public void testNesting() throws Exception {
void testNesting() {
MockEntry one = new MockEntry();
MockEntry two = new MockEntry();
MockEntry three = new MockEntry();
@ -59,7 +59,7 @@ public class ParseStateTests { @@ -59,7 +59,7 @@ public class ParseStateTests {
}
@Test
public void testSnapshot() throws Exception {
void testSnapshot() {
MockEntry entry = new MockEntry();
ParseState original = new ParseState();

8
spring-beans/src/test/java/org/springframework/beans/factory/parsing/PassThroughSourceExtractorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -26,10 +26,10 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -26,10 +26,10 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Rick Evans
* @author Chris Beams
*/
public class PassThroughSourceExtractorTests {
class PassThroughSourceExtractorTests {
@Test
public void testPassThroughContract() throws Exception {
void testPassThroughContract() {
Object source = new Object();
Object extractedSource = new PassThroughSourceExtractor().extractSource(source, null);
assertThat(extractedSource).as("The contract of PassThroughSourceExtractor states that the supplied " +
@ -37,7 +37,7 @@ public class PassThroughSourceExtractorTests { @@ -37,7 +37,7 @@ public class PassThroughSourceExtractorTests {
}
@Test
public void testPassThroughContractEvenWithNull() throws Exception {
void testPassThroughContractEvenWithNull() {
Object extractedSource = new PassThroughSourceExtractor().extractSource(null, null);
assertThat(extractedSource).as("The contract of PassThroughSourceExtractor states that the supplied " +
"source object *must* be returned as-is (even if null)").isNull();

10
spring-beans/src/test/java/org/springframework/beans/factory/parsing/PropertyEntryTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -26,22 +26,22 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException @@ -26,22 +26,22 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Rick Evans
* @author Chris Beams
*/
public class PropertyEntryTests {
class PropertyEntryTests {
@Test
public void testCtorBailsOnNullPropertyNameArgument() throws Exception {
void testCtorBailsOnNullPropertyNameArgument() {
assertThatIllegalArgumentException().isThrownBy(() ->
new PropertyEntry(null));
}
@Test
public void testCtorBailsOnEmptyPropertyNameArgument() throws Exception {
void testCtorBailsOnEmptyPropertyNameArgument() {
assertThatIllegalArgumentException().isThrownBy(() ->
new PropertyEntry(""));
}
@Test
public void testCtorBailsOnWhitespacedPropertyNameArgument() throws Exception {
void testCtorBailsOnWhitespacedPropertyNameArgument() {
assertThatIllegalArgumentException().isThrownBy(() ->
new PropertyEntry("\t "));
}

6
spring-beans/src/test/java/org/springframework/beans/factory/support/AutowireUtilsTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -33,10 +33,10 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -33,10 +33,10 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Sam Brannen
* @author Loïc Ledoyen
*/
public class AutowireUtilsTests {
class AutowireUtilsTests {
@Test
public void genericMethodReturnTypes() {
void genericMethodReturnTypes() {
Method notParameterized = ReflectionUtils.findMethod(MyTypeWithMethods.class, "notParameterized");
Object actual = AutowireUtils.resolveReturnTypeForFactoryMethod(notParameterized, new Object[0], getClass().getClassLoader());
assertThat(actual).isEqualTo(String.class);

18
spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -26,10 +26,10 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -26,10 +26,10 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Juergen Hoeller
*/
public class BeanDefinitionTests {
class BeanDefinitionTests {
@Test
public void beanDefinitionEquality() {
void beanDefinitionEquality() {
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
bd.setAbstract(true);
bd.setLazyInit(true);
@ -46,7 +46,7 @@ public class BeanDefinitionTests { @@ -46,7 +46,7 @@ public class BeanDefinitionTests {
}
@Test
public void beanDefinitionEqualityWithPropertyValues() {
void beanDefinitionEqualityWithPropertyValues() {
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
bd.getPropertyValues().add("name", "myName");
bd.getPropertyValues().add("age", "99");
@ -64,7 +64,7 @@ public class BeanDefinitionTests { @@ -64,7 +64,7 @@ public class BeanDefinitionTests {
}
@Test
public void beanDefinitionEqualityWithConstructorArguments() {
void beanDefinitionEqualityWithConstructorArguments() {
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
bd.getConstructorArgumentValues().addGenericArgumentValue("test");
bd.getConstructorArgumentValues().addIndexedArgumentValue(1, 5);
@ -82,7 +82,7 @@ public class BeanDefinitionTests { @@ -82,7 +82,7 @@ public class BeanDefinitionTests {
}
@Test
public void beanDefinitionEqualityWithTypedConstructorArguments() {
void beanDefinitionEqualityWithTypedConstructorArguments() {
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
bd.getConstructorArgumentValues().addGenericArgumentValue("test", "int");
bd.getConstructorArgumentValues().addIndexedArgumentValue(1, 5, "long");
@ -101,7 +101,7 @@ public class BeanDefinitionTests { @@ -101,7 +101,7 @@ public class BeanDefinitionTests {
}
@Test
public void genericBeanDefinitionEquality() {
void genericBeanDefinitionEquality() {
GenericBeanDefinition bd = new GenericBeanDefinition();
bd.setParentName("parent");
bd.setScope("request");
@ -130,7 +130,7 @@ public class BeanDefinitionTests { @@ -130,7 +130,7 @@ public class BeanDefinitionTests {
}
@Test
public void beanDefinitionHolderEquality() {
void beanDefinitionHolderEquality() {
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
bd.setAbstract(true);
bd.setLazyInit(true);
@ -149,7 +149,7 @@ public class BeanDefinitionTests { @@ -149,7 +149,7 @@ public class BeanDefinitionTests {
}
@Test
public void beanDefinitionMerging() {
void beanDefinitionMerging() {
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
bd.getConstructorArgumentValues().addGenericArgumentValue("test");
bd.getConstructorArgumentValues().addIndexedArgumentValue(1, 5);

9
spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -564,8 +564,7 @@ class BeanFactoryGenericsTests { @@ -564,8 +564,7 @@ class BeanFactoryGenericsTests {
new ClassPathResource("genericBeanTests.xml", getClass()));
GenericIntegerBean gb = (GenericIntegerBean) bf.getBean("integerBean");
assertThat(gb.getGenericProperty()).isEqualTo(10);
assertThat(gb.getGenericListProperty()).element(0).isEqualTo(20);
assertThat(gb.getGenericListProperty()).element(1).isEqualTo(30);
assertThat(gb.getGenericListProperty()).containsExactly(20, 30);
}
@Test
@ -575,8 +574,8 @@ class BeanFactoryGenericsTests { @@ -575,8 +574,8 @@ class BeanFactoryGenericsTests {
new ClassPathResource("genericBeanTests.xml", getClass()));
GenericSetOfIntegerBean gb = (GenericSetOfIntegerBean) bf.getBean("setOfIntegerBean");
assertThat(gb.getGenericProperty()).element(0).isEqualTo(10);
assertThat(gb.getGenericListProperty().get(0)).element(0).isEqualTo(20);
assertThat(gb.getGenericListProperty().get(1)).element(0).isEqualTo(30);
assertThat(gb.getGenericListProperty().get(0)).containsExactly(20);
assertThat(gb.getGenericListProperty().get(1)).containsExactly(30);
}
@Test

4
spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactorySupplierTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Phillip Webb
* @author Juergen Hoeller
*/
public class BeanFactorySupplierTests {
class BeanFactorySupplierTests {
@Test
void getBeanWhenUsingRegularSupplier() {

4
spring-beans/src/test/java/org/springframework/beans/factory/support/ConstructorResolverAotTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -441,7 +441,7 @@ class ConstructorResolverAotTests { @@ -441,7 +441,7 @@ class ConstructorResolverAotTests {
}
@Test
void beanDefinitionWithMultiConstructorSimilarArgumentsAndNullValueForSpecificArgument() throws NoSuchMethodException {
void beanDefinitionWithMultiConstructorSimilarArgumentsAndNullValueForSpecificArgument() {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
BeanDefinition beanDefinition = BeanDefinitionBuilder
.rootBeanDefinition(MultiConstructorSimilarArgumentsSample.class)

14
spring-beans/src/test/java/org/springframework/beans/factory/support/DefinitionMetadataEqualsHashCodeTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Sam Brannen
*/
@SuppressWarnings("serial")
public class DefinitionMetadataEqualsHashCodeTests {
class DefinitionMetadataEqualsHashCodeTests {
@Test
public void rootBeanDefinition() {
void rootBeanDefinition() {
RootBeanDefinition master = new RootBeanDefinition(TestBean.class);
RootBeanDefinition equal = new RootBeanDefinition(TestBean.class);
RootBeanDefinition notEqual = new RootBeanDefinition(String.class);
@ -53,7 +53,7 @@ public class DefinitionMetadataEqualsHashCodeTests { @@ -53,7 +53,7 @@ public class DefinitionMetadataEqualsHashCodeTests {
* @see <a href="https://jira.spring.io/browse/SPR-11420">SPR-11420</a>
*/
@Test
public void rootBeanDefinitionAndMethodOverridesWithDifferentOverloadedValues() {
void rootBeanDefinitionAndMethodOverridesWithDifferentOverloadedValues() {
RootBeanDefinition master = new RootBeanDefinition(TestBean.class);
RootBeanDefinition equal = new RootBeanDefinition(TestBean.class);
@ -73,7 +73,7 @@ public class DefinitionMetadataEqualsHashCodeTests { @@ -73,7 +73,7 @@ public class DefinitionMetadataEqualsHashCodeTests {
}
@Test
public void childBeanDefinition() {
void childBeanDefinition() {
ChildBeanDefinition master = new ChildBeanDefinition("foo");
ChildBeanDefinition equal = new ChildBeanDefinition("foo");
ChildBeanDefinition notEqual = new ChildBeanDefinition("bar");
@ -88,7 +88,7 @@ public class DefinitionMetadataEqualsHashCodeTests { @@ -88,7 +88,7 @@ public class DefinitionMetadataEqualsHashCodeTests {
}
@Test
public void runtimeBeanReference() {
void runtimeBeanReference() {
RuntimeBeanReference master = new RuntimeBeanReference("name");
RuntimeBeanReference equal = new RuntimeBeanReference("name");
RuntimeBeanReference notEqual = new RuntimeBeanReference("someOtherName");
@ -104,7 +104,7 @@ public class DefinitionMetadataEqualsHashCodeTests { @@ -104,7 +104,7 @@ public class DefinitionMetadataEqualsHashCodeTests {
definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);
// definition.getConstructorArgumentValues().addGenericArgumentValue("foo");
definition.setDependencyCheck(AbstractBeanDefinition.DEPENDENCY_CHECK_OBJECTS);
definition.setDependsOn(new String[] { "foo", "bar" });
definition.setDependsOn("foo", "bar");
definition.setDestroyMethodName("destroy");
definition.setEnforceDestroyMethod(false);
definition.setEnforceInitMethod(true);

20
spring-beans/src/test/java/org/springframework/beans/factory/support/LookupMethodTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -30,13 +30,13 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -30,13 +30,13 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Karl Pietrzak
* @author Juergen Hoeller
*/
public class LookupMethodTests {
class LookupMethodTests {
private DefaultListableBeanFactory beanFactory;
@BeforeEach
public void setup() {
void setup() {
beanFactory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
reader.loadBeanDefinitions(new ClassPathResource("lookupMethodTests.xml", getClass()));
@ -44,7 +44,7 @@ public class LookupMethodTests { @@ -44,7 +44,7 @@ public class LookupMethodTests {
@Test
public void testWithoutConstructorArg() {
void testWithoutConstructorArg() {
AbstractBean bean = (AbstractBean) beanFactory.getBean("abstractBean");
assertThat(bean).isNotNull();
Object expected = bean.get();
@ -52,7 +52,7 @@ public class LookupMethodTests { @@ -52,7 +52,7 @@ public class LookupMethodTests {
}
@Test
public void testWithOverloadedArg() {
void testWithOverloadedArg() {
AbstractBean bean = (AbstractBean) beanFactory.getBean("abstractBean");
assertThat(bean).isNotNull();
TestBean expected = bean.get("haha");
@ -61,7 +61,7 @@ public class LookupMethodTests { @@ -61,7 +61,7 @@ public class LookupMethodTests {
}
@Test
public void testWithOneConstructorArg() {
void testWithOneConstructorArg() {
AbstractBean bean = (AbstractBean) beanFactory.getBean("abstractBean");
assertThat(bean).isNotNull();
TestBean expected = bean.getOneArgument("haha");
@ -70,7 +70,7 @@ public class LookupMethodTests { @@ -70,7 +70,7 @@ public class LookupMethodTests {
}
@Test
public void testWithTwoConstructorArg() {
void testWithTwoConstructorArg() {
AbstractBean bean = (AbstractBean) beanFactory.getBean("abstractBean");
assertThat(bean).isNotNull();
TestBean expected = bean.getTwoArguments("haha", 72);
@ -80,7 +80,7 @@ public class LookupMethodTests { @@ -80,7 +80,7 @@ public class LookupMethodTests {
}
@Test
public void testWithThreeArgsShouldFail() {
void testWithThreeArgsShouldFail() {
AbstractBean bean = (AbstractBean) beanFactory.getBean("abstractBean");
assertThat(bean).isNotNull();
assertThatExceptionOfType(AbstractMethodError.class).as("does not have a three arg constructor")
@ -88,7 +88,7 @@ public class LookupMethodTests { @@ -88,7 +88,7 @@ public class LookupMethodTests {
}
@Test
public void testWithOverriddenLookupMethod() {
void testWithOverriddenLookupMethod() {
AbstractBean bean = (AbstractBean) beanFactory.getBean("extendedBean");
assertThat(bean).isNotNull();
TestBean expected = bean.getOneArgument("haha");
@ -98,7 +98,7 @@ public class LookupMethodTests { @@ -98,7 +98,7 @@ public class LookupMethodTests {
}
@Test
public void testWithGenericBean() {
void testWithGenericBean() {
RootBeanDefinition bd = new RootBeanDefinition(NumberBean.class);
bd.getMethodOverrides().addOverride(new LookupOverride("getDoubleStore", null));
bd.getMethodOverrides().addOverride(new LookupOverride("getFloatStore", null));

16
spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedMapTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -30,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; @@ -30,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
* @author Sam Brannen
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public class ManagedMapTests {
class ManagedMapTests {
@Test
public void mergeSunnyDay() {
void mergeSunnyDay() {
ManagedMap parent = ManagedMap.ofEntries(Map.entry("one", "one"),
Map.entry("two", "two"));
ManagedMap child = ManagedMap.ofEntries(Map.entry("tree", "three"));
@ -43,14 +43,14 @@ public class ManagedMapTests { @@ -43,14 +43,14 @@ public class ManagedMapTests {
}
@Test
public void mergeWithNullParent() {
void mergeWithNullParent() {
ManagedMap child = new ManagedMap();
child.setMergeEnabled(true);
assertThat(child.merge(null)).isSameAs(child);
}
@Test
public void mergeWithNonCompatibleParentType() {
void mergeWithNonCompatibleParentType() {
ManagedMap map = new ManagedMap();
map.setMergeEnabled(true);
assertThatIllegalArgumentException().isThrownBy(() ->
@ -58,13 +58,13 @@ public class ManagedMapTests { @@ -58,13 +58,13 @@ public class ManagedMapTests {
}
@Test
public void mergeNotAllowedWhenMergeNotEnabled() {
void mergeNotAllowedWhenMergeNotEnabled() {
assertThatIllegalStateException().isThrownBy(() ->
new ManagedMap().merge(null));
}
@Test
public void mergeEmptyChild() {
void mergeEmptyChild() {
ManagedMap parent = ManagedMap.ofEntries(Map.entry("one", "one"),
Map.entry("two", "two"));
ManagedMap child = new ManagedMap();
@ -74,7 +74,7 @@ public class ManagedMapTests { @@ -74,7 +74,7 @@ public class ManagedMapTests {
}
@Test
public void mergeChildValuesOverrideTheParents() {
void mergeChildValuesOverrideTheParents() {
ManagedMap parent = ManagedMap.ofEntries(Map.entry("one", "one"),
Map.entry("two", "two"));
ManagedMap child = ManagedMap.ofEntries(Map.entry("one", "fork"));

10
spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedPropertiesTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; @@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
* @author Sam Brannen
*/
@SuppressWarnings("rawtypes")
public class ManagedPropertiesTests {
class ManagedPropertiesTests {
@Test
@SuppressWarnings("unchecked")
@ -46,14 +46,14 @@ public class ManagedPropertiesTests { @@ -46,14 +46,14 @@ public class ManagedPropertiesTests {
}
@Test
public void mergeWithNullParent() {
void mergeWithNullParent() {
ManagedProperties child = new ManagedProperties();
child.setMergeEnabled(true);
assertThat(child.merge(null)).isSameAs(child);
}
@Test
public void mergeWithNonCompatibleParentType() {
void mergeWithNonCompatibleParentType() {
ManagedProperties map = new ManagedProperties();
map.setMergeEnabled(true);
assertThatIllegalArgumentException().isThrownBy(() ->
@ -61,7 +61,7 @@ public class ManagedPropertiesTests { @@ -61,7 +61,7 @@ public class ManagedPropertiesTests {
}
@Test
public void mergeNotAllowedWhenMergeNotEnabled() {
void mergeNotAllowedWhenMergeNotEnabled() {
ManagedProperties map = new ManagedProperties();
assertThatIllegalStateException().isThrownBy(() ->
map.merge(null));

20
spring-beans/src/test/java/org/springframework/beans/factory/support/QualifierAnnotationAutowireBeanFactoryTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Mark Fisher
* @author Juergen Hoeller
*/
public class QualifierAnnotationAutowireBeanFactoryTests {
class QualifierAnnotationAutowireBeanFactoryTests {
private static final String JUERGEN = "juergen";
@ -45,7 +45,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests { @@ -45,7 +45,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests {
@Test
public void testAutowireCandidateDefaultWithIrrelevantDescriptor() throws Exception {
void testAutowireCandidateDefaultWithIrrelevantDescriptor() throws Exception {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
ConstructorArgumentValues cavs = new ConstructorArgumentValues();
cavs.addGenericArgumentValue(JUERGEN);
@ -59,7 +59,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests { @@ -59,7 +59,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests {
}
@Test
public void testAutowireCandidateExplicitlyFalseWithIrrelevantDescriptor() throws Exception {
void testAutowireCandidateExplicitlyFalseWithIrrelevantDescriptor() throws Exception {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
ConstructorArgumentValues cavs = new ConstructorArgumentValues();
cavs.addGenericArgumentValue(JUERGEN);
@ -75,7 +75,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests { @@ -75,7 +75,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests {
@Disabled
@Test
public void testAutowireCandidateWithFieldDescriptor() throws Exception {
void testAutowireCandidateWithFieldDescriptor() throws Exception {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
ConstructorArgumentValues cavs1 = new ConstructorArgumentValues();
cavs1.addGenericArgumentValue(JUERGEN);
@ -99,7 +99,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests { @@ -99,7 +99,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests {
}
@Test
public void testAutowireCandidateExplicitlyFalseWithFieldDescriptor() throws Exception {
void testAutowireCandidateExplicitlyFalseWithFieldDescriptor() throws Exception {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
ConstructorArgumentValues cavs = new ConstructorArgumentValues();
cavs.addGenericArgumentValue(JUERGEN);
@ -117,7 +117,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests { @@ -117,7 +117,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests {
}
@Test
public void testAutowireCandidateWithShortClassName() throws Exception {
void testAutowireCandidateWithShortClassName() throws Exception {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
ConstructorArgumentValues cavs = new ConstructorArgumentValues();
cavs.addGenericArgumentValue(JUERGEN);
@ -135,7 +135,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests { @@ -135,7 +135,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests {
@Disabled
@Test
public void testAutowireCandidateWithConstructorDescriptor() throws Exception {
void testAutowireCandidateWithConstructorDescriptor() throws Exception {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
ConstructorArgumentValues cavs1 = new ConstructorArgumentValues();
cavs1.addGenericArgumentValue(JUERGEN);
@ -157,7 +157,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests { @@ -157,7 +157,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests {
@Disabled
@Test
public void testAutowireCandidateWithMethodDescriptor() throws Exception {
void testAutowireCandidateWithMethodDescriptor() throws Exception {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
ConstructorArgumentValues cavs1 = new ConstructorArgumentValues();
cavs1.addGenericArgumentValue(JUERGEN);
@ -187,7 +187,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests { @@ -187,7 +187,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests {
}
@Test
public void testAutowireCandidateWithMultipleCandidatesDescriptor() throws Exception {
void testAutowireCandidateWithMultipleCandidatesDescriptor() throws Exception {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
ConstructorArgumentValues cavs1 = new ConstructorArgumentValues();
cavs1.addGenericArgumentValue(JUERGEN);

14
spring-beans/src/test/java/org/springframework/beans/factory/support/Spr8954Tests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -40,19 +40,19 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -40,19 +40,19 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Chris Beams
* @author Oliver Gierke
*/
public class Spr8954Tests {
class Spr8954Tests {
private DefaultListableBeanFactory bf;
@BeforeEach
public void setUp() {
void setUp() {
bf = new DefaultListableBeanFactory();
bf.registerBeanDefinition("foo", new RootBeanDefinition(FooFactoryBean.class));
bf.addBeanPostProcessor(new PredictingBPP());
}
@Test
public void repro() {
void repro() {
assertThat(bf.getBean("foo")).isInstanceOf(Foo.class);
assertThat(bf.getBean("&foo")).isInstanceOf(FooFactoryBean.class);
assertThat(bf.isTypeMatch("&foo", FactoryBean.class)).isTrue();
@ -66,7 +66,7 @@ public class Spr8954Tests { @@ -66,7 +66,7 @@ public class Spr8954Tests {
}
@Test
public void findsBeansByTypeIfNotInstantiated() {
void findsBeansByTypeIfNotInstantiated() {
assertThat(bf.isTypeMatch("&foo", FactoryBean.class)).isTrue();
@SuppressWarnings("rawtypes")
@ -81,7 +81,7 @@ public class Spr8954Tests { @@ -81,7 +81,7 @@ public class Spr8954Tests {
* SPR-10517
*/
@Test
public void findsFactoryBeanNameByTypeWithoutInstantiation() {
void findsFactoryBeanNameByTypeWithoutInstantiation() {
String[] names = bf.getBeanNamesForType(AnInterface.class, false, false);
assertThat(Arrays.asList(names)).contains("&foo");
@ -93,7 +93,7 @@ public class Spr8954Tests { @@ -93,7 +93,7 @@ public class Spr8954Tests {
static class FooFactoryBean implements FactoryBean<Foo>, AnInterface {
@Override
public Foo getObject() throws Exception {
public Foo getObject() {
return new Foo();
}

16
spring-beans/src/test/java/org/springframework/beans/factory/wiring/BeanConfigurerSupportTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -33,16 +33,16 @@ import static org.mockito.Mockito.verify; @@ -33,16 +33,16 @@ import static org.mockito.Mockito.verify;
* @author Juergen Hoeller
* @author Sam Brannen
*/
public class BeanConfigurerSupportTests {
class BeanConfigurerSupportTests {
@Test
public void supplyIncompatibleBeanFactoryImplementation() {
void supplyIncompatibleBeanFactoryImplementation() {
assertThatIllegalArgumentException().isThrownBy(() ->
new StubBeanConfigurerSupport().setBeanFactory(mock()));
}
@Test
public void configureBeanDoesNothingIfBeanWiringInfoResolverResolvesToNull() throws Exception {
void configureBeanDoesNothingIfBeanWiringInfoResolverResolvesToNull() {
TestBean beanInstance = new TestBean();
BeanWiringInfoResolver resolver = mock();
@ -56,7 +56,7 @@ public class BeanConfigurerSupportTests { @@ -56,7 +56,7 @@ public class BeanConfigurerSupportTests {
}
@Test
public void configureBeanDoesNothingIfNoBeanFactoryHasBeenSet() throws Exception {
void configureBeanDoesNothingIfNoBeanFactoryHasBeenSet() {
TestBean beanInstance = new TestBean();
BeanConfigurerSupport configurer = new StubBeanConfigurerSupport();
configurer.configureBean(beanInstance);
@ -64,7 +64,7 @@ public class BeanConfigurerSupportTests { @@ -64,7 +64,7 @@ public class BeanConfigurerSupportTests {
}
@Test
public void configureBeanReallyDoesDefaultToUsingTheFullyQualifiedClassNameOfTheSuppliedBeanInstance() throws Exception {
void configureBeanReallyDoesDefaultToUsingTheFullyQualifiedClassNameOfTheSuppliedBeanInstance() {
TestBean beanInstance = new TestBean();
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(TestBean.class);
builder.addPropertyValue("name", "Harriet Wheeler");
@ -80,7 +80,7 @@ public class BeanConfigurerSupportTests { @@ -80,7 +80,7 @@ public class BeanConfigurerSupportTests {
}
@Test
public void configureBeanPerformsAutowiringByNameIfAppropriateBeanWiringInfoResolverIsPluggedIn() throws Exception {
void configureBeanPerformsAutowiringByNameIfAppropriateBeanWiringInfoResolverIsPluggedIn() {
TestBean beanInstance = new TestBean();
// spouse for autowiring by name...
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(TestBean.class);
@ -100,7 +100,7 @@ public class BeanConfigurerSupportTests { @@ -100,7 +100,7 @@ public class BeanConfigurerSupportTests {
}
@Test
public void configureBeanPerformsAutowiringByTypeIfAppropriateBeanWiringInfoResolverIsPluggedIn() throws Exception {
void configureBeanPerformsAutowiringByTypeIfAppropriateBeanWiringInfoResolverIsPluggedIn() {
TestBean beanInstance = new TestBean();
// spouse for autowiring by type...
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(TestBean.class);

22
spring-beans/src/test/java/org/springframework/beans/factory/wiring/BeanWiringInfoTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -27,58 +27,58 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException @@ -27,58 +27,58 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Rick Evans
* @author Sam Brannen
*/
public class BeanWiringInfoTests {
class BeanWiringInfoTests {
@Test
public void ctorWithNullBeanName() throws Exception {
void ctorWithNullBeanName() {
assertThatIllegalArgumentException().isThrownBy(() ->
new BeanWiringInfo(null));
}
@Test
public void ctorWithWhitespacedBeanName() throws Exception {
void ctorWithWhitespacedBeanName() {
assertThatIllegalArgumentException().isThrownBy(() ->
new BeanWiringInfo(" \t"));
}
@Test
public void ctorWithEmptyBeanName() throws Exception {
void ctorWithEmptyBeanName() {
assertThatIllegalArgumentException().isThrownBy(() ->
new BeanWiringInfo(""));
}
@Test
public void ctorWithNegativeIllegalAutowiringValue() throws Exception {
void ctorWithNegativeIllegalAutowiringValue() {
assertThatIllegalArgumentException().isThrownBy(() ->
new BeanWiringInfo(-1, true));
}
@Test
public void ctorWithPositiveOutOfRangeAutowiringValue() throws Exception {
void ctorWithPositiveOutOfRangeAutowiringValue() {
assertThatIllegalArgumentException().isThrownBy(() ->
new BeanWiringInfo(123871, true));
}
@Test
public void usingAutowireCtorIndicatesAutowiring() throws Exception {
void usingAutowireCtorIndicatesAutowiring() {
BeanWiringInfo info = new BeanWiringInfo(BeanWiringInfo.AUTOWIRE_BY_NAME, true);
assertThat(info.indicatesAutowiring()).isTrue();
}
@Test
public void usingBeanNameCtorDoesNotIndicateAutowiring() throws Exception {
void usingBeanNameCtorDoesNotIndicateAutowiring() {
BeanWiringInfo info = new BeanWiringInfo("fooService");
assertThat(info.indicatesAutowiring()).isFalse();
}
@Test
public void noDependencyCheckValueIsPreserved() throws Exception {
void noDependencyCheckValueIsPreserved() {
BeanWiringInfo info = new BeanWiringInfo(BeanWiringInfo.AUTOWIRE_BY_NAME, true);
assertThat(info.getDependencyCheck()).isTrue();
}
@Test
public void dependencyCheckValueIsPreserved() throws Exception {
void dependencyCheckValueIsPreserved() {
BeanWiringInfo info = new BeanWiringInfo(BeanWiringInfo.AUTOWIRE_BY_TYPE, false);
assertThat(info.getDependencyCheck()).isFalse();
}

4
spring-beans/src/test/java/org/springframework/beans/factory/wiring/ClassNameBeanWiringInfoResolverTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -29,7 +29,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException @@ -29,7 +29,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
class ClassNameBeanWiringInfoResolverTests {
@Test
void resolveWiringInfoWithNullBeanInstance() throws Exception {
void resolveWiringInfoWithNullBeanInstance() {
assertThatIllegalArgumentException().isThrownBy(() ->
new ClassNameBeanWiringInfoResolver().resolveWiringInfo(null));
}

24
spring-beans/src/test/java/org/springframework/beans/factory/xml/AutowireWithExclusionTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Rob Harrop
* @author Juergen Hoeller
*/
public class AutowireWithExclusionTests {
class AutowireWithExclusionTests {
@Test
public void byTypeAutowireWithAutoSelfExclusion() throws Exception {
void byTypeAutowireWithAutoSelfExclusion() {
CountingFactory.reset();
DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-with-exclusion.xml");
beanFactory.preInstantiateSingletons();
@ -45,7 +45,7 @@ public class AutowireWithExclusionTests { @@ -45,7 +45,7 @@ public class AutowireWithExclusionTests {
}
@Test
public void byTypeAutowireWithExclusion() throws Exception {
void byTypeAutowireWithExclusion() {
CountingFactory.reset();
DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-with-exclusion.xml");
beanFactory.preInstantiateSingletons();
@ -55,7 +55,7 @@ public class AutowireWithExclusionTests { @@ -55,7 +55,7 @@ public class AutowireWithExclusionTests {
}
@Test
public void byTypeAutowireWithExclusionInParentFactory() throws Exception {
void byTypeAutowireWithExclusionInParentFactory() {
CountingFactory.reset();
DefaultListableBeanFactory parent = getBeanFactory("autowire-with-exclusion.xml");
parent.preInstantiateSingletons();
@ -70,7 +70,7 @@ public class AutowireWithExclusionTests { @@ -70,7 +70,7 @@ public class AutowireWithExclusionTests {
}
@Test
public void byTypeAutowireWithPrimaryInParentFactory() throws Exception {
void byTypeAutowireWithPrimaryInParentFactory() {
CountingFactory.reset();
DefaultListableBeanFactory parent = getBeanFactory("autowire-with-exclusion.xml");
parent.getBeanDefinition("props1").setPrimary(true);
@ -89,7 +89,7 @@ public class AutowireWithExclusionTests { @@ -89,7 +89,7 @@ public class AutowireWithExclusionTests {
}
@Test
public void byTypeAutowireWithPrimaryOverridingParentFactory() throws Exception {
void byTypeAutowireWithPrimaryOverridingParentFactory() {
CountingFactory.reset();
DefaultListableBeanFactory parent = getBeanFactory("autowire-with-exclusion.xml");
parent.preInstantiateSingletons();
@ -108,7 +108,7 @@ public class AutowireWithExclusionTests { @@ -108,7 +108,7 @@ public class AutowireWithExclusionTests {
}
@Test
public void byTypeAutowireWithPrimaryInParentAndChild() throws Exception {
void byTypeAutowireWithPrimaryInParentAndChild() {
CountingFactory.reset();
DefaultListableBeanFactory parent = getBeanFactory("autowire-with-exclusion.xml");
parent.getBeanDefinition("props1").setPrimary(true);
@ -128,7 +128,7 @@ public class AutowireWithExclusionTests { @@ -128,7 +128,7 @@ public class AutowireWithExclusionTests {
}
@Test
public void byTypeAutowireWithInclusion() throws Exception {
void byTypeAutowireWithInclusion() {
CountingFactory.reset();
DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-with-inclusion.xml");
beanFactory.preInstantiateSingletons();
@ -138,7 +138,7 @@ public class AutowireWithExclusionTests { @@ -138,7 +138,7 @@ public class AutowireWithExclusionTests {
}
@Test
public void byTypeAutowireWithSelectiveInclusion() throws Exception {
void byTypeAutowireWithSelectiveInclusion() {
CountingFactory.reset();
DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-with-selective-inclusion.xml");
beanFactory.preInstantiateSingletons();
@ -148,7 +148,7 @@ public class AutowireWithExclusionTests { @@ -148,7 +148,7 @@ public class AutowireWithExclusionTests {
}
@Test
public void constructorAutowireWithAutoSelfExclusion() throws Exception {
void constructorAutowireWithAutoSelfExclusion() {
DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-constructor-with-exclusion.xml");
TestBean rob = (TestBean) beanFactory.getBean("rob");
TestBean sally = (TestBean) beanFactory.getBean("sally");
@ -161,7 +161,7 @@ public class AutowireWithExclusionTests { @@ -161,7 +161,7 @@ public class AutowireWithExclusionTests {
}
@Test
public void constructorAutowireWithExclusion() throws Exception {
void constructorAutowireWithExclusion() {
DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-constructor-with-exclusion.xml");
TestBean rob = (TestBean) beanFactory.getBean("rob");
assertThat(rob.getSomeProperties().getProperty("name")).isEqualTo("props1");

8
spring-beans/src/test/java/org/springframework/beans/factory/xml/BeanNameGenerationTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -29,13 +29,13 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -29,13 +29,13 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Rob Harrop
* @author Juergen Hoeller
*/
public class BeanNameGenerationTests {
class BeanNameGenerationTests {
private DefaultListableBeanFactory beanFactory;
@BeforeEach
public void setUp() {
void setUp() {
this.beanFactory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
@ -43,7 +43,7 @@ public class BeanNameGenerationTests { @@ -43,7 +43,7 @@ public class BeanNameGenerationTests {
}
@Test
public void naming() {
void naming() {
String className = GeneratedNameBean.class.getName();
String targetName = className + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR + "0";

59
spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionMergingTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,6 +22,7 @@ import java.util.Map; @@ -22,6 +22,7 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -30,6 +31,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; @@ -30,6 +31,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.io.ClassPathResource;
import static java.util.Map.entry;
import static org.assertj.core.api.Assertions.assertThat;
/**
@ -39,29 +41,27 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -39,29 +41,27 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Rick Evans
*/
@SuppressWarnings("rawtypes")
public class CollectionMergingTests {
class CollectionMergingTests {
private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
@BeforeEach
public void setUp() throws Exception {
void setUp() {
BeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
reader.loadBeanDefinitions(new ClassPathResource("collectionMerging.xml", getClass()));
}
@Test
public void mergeList() throws Exception {
void mergeList() {
TestBean bean = (TestBean) this.beanFactory.getBean("childWithList");
List<?> list = bean.getSomeList();
assertThat(list).as("Incorrect size").hasSize(3);
assertThat(list).element(0).isEqualTo("Rob Harrop");
assertThat(list).element(1).isEqualTo("Rod Johnson");
assertThat(list).element(2).isEqualTo("Juergen Hoeller");
assertThat(list).asInstanceOf(InstanceOfAssertFactories.list(String.class))
.containsExactly("Rob Harrop", "Rod Johnson", "Juergen Hoeller");
}
@Test
public void mergeListWithInnerBeanAsListElement() throws Exception {
void mergeListWithInnerBeanAsListElement() {
TestBean bean = (TestBean) this.beanFactory.getBean("childWithListOfRefs");
List<?> list = bean.getSomeList();
assertThat(list).isNotNull();
@ -70,16 +70,15 @@ public class CollectionMergingTests { @@ -70,16 +70,15 @@ public class CollectionMergingTests {
}
@Test
public void mergeSet() {
void mergeSet() {
TestBean bean = (TestBean) this.beanFactory.getBean("childWithSet");
Set<?> set = bean.getSomeSet();
assertThat(set).as("Incorrect size").hasSize(2);
assertThat(set.contains("Rob Harrop")).isTrue();
assertThat(set.contains("Sally Greenwood")).isTrue();
assertThat(set).asInstanceOf(InstanceOfAssertFactories.collection(String.class))
.containsOnly("Rob Harrop", "Sally Greenwood");
}
@Test
public void mergeSetWithInnerBeanAsSetElement() throws Exception {
void mergeSetWithInnerBeanAsSetElement() {
TestBean bean = (TestBean) this.beanFactory.getBean("childWithSetOfRefs");
Set<?> set = bean.getSomeSet();
assertThat(set).isNotNull();
@ -92,17 +91,15 @@ public class CollectionMergingTests { @@ -92,17 +91,15 @@ public class CollectionMergingTests {
}
@Test
public void mergeMap() throws Exception {
void mergeMap() {
TestBean bean = (TestBean) this.beanFactory.getBean("childWithMap");
Map<?, ?> map = bean.getSomeMap();
assertThat(map).as("Incorrect size").hasSize(3);
assertThat(map.get("Rob")).isEqualTo("Sally");
assertThat(map.get("Rod")).isEqualTo("Kerry");
assertThat(map.get("Juergen")).isEqualTo("Eva");
assertThat(map).asInstanceOf(InstanceOfAssertFactories.map(String.class,String.class))
.containsOnly(entry("Rob", "Sally"), entry("Rod", "Kerry"), entry("Juergen", "Eva"));
}
@Test
public void mergeMapWithInnerBeanAsMapEntryValue() throws Exception {
void mergeMapWithInnerBeanAsMapEntryValue() {
TestBean bean = (TestBean) this.beanFactory.getBean("childWithMapOfRefs");
Map<?, ?> map = bean.getSomeMap();
assertThat(map).isNotNull();
@ -113,7 +110,7 @@ public class CollectionMergingTests { @@ -113,7 +110,7 @@ public class CollectionMergingTests {
}
@Test
public void mergeProperties() throws Exception {
void mergeProperties() {
TestBean bean = (TestBean) this.beanFactory.getBean("childWithProps");
Properties props = bean.getSomeProperties();
assertThat(props).as("Incorrect size").hasSize(3);
@ -123,17 +120,15 @@ public class CollectionMergingTests { @@ -123,17 +120,15 @@ public class CollectionMergingTests {
}
@Test
public void mergeListInConstructor() throws Exception {
void mergeListInConstructor() {
TestBean bean = (TestBean) this.beanFactory.getBean("childWithListInConstructor");
List<?> list = bean.getSomeList();
assertThat(list).as("Incorrect size").hasSize(3);
assertThat(list).element(0).isEqualTo("Rob Harrop");
assertThat(list).element(1).isEqualTo("Rod Johnson");
assertThat(list).element(2).isEqualTo("Juergen Hoeller");
assertThat(list).asInstanceOf(InstanceOfAssertFactories.list(String.class))
.containsExactly("Rob Harrop", "Rod Johnson", "Juergen Hoeller");
}
@Test
public void mergeListWithInnerBeanAsListElementInConstructor() throws Exception {
void mergeListWithInnerBeanAsListElementInConstructor() {
TestBean bean = (TestBean) this.beanFactory.getBean("childWithListOfRefsInConstructor");
List<?> list = bean.getSomeList();
assertThat(list).isNotNull();
@ -143,7 +138,7 @@ public class CollectionMergingTests { @@ -143,7 +138,7 @@ public class CollectionMergingTests {
}
@Test
public void mergeSetInConstructor() {
void mergeSetInConstructor() {
TestBean bean = (TestBean) this.beanFactory.getBean("childWithSetInConstructor");
Set<?> set = bean.getSomeSet();
assertThat(set).as("Incorrect size").hasSize(2);
@ -152,7 +147,7 @@ public class CollectionMergingTests { @@ -152,7 +147,7 @@ public class CollectionMergingTests {
}
@Test
public void mergeSetWithInnerBeanAsSetElementInConstructor() throws Exception {
void mergeSetWithInnerBeanAsSetElementInConstructor() {
TestBean bean = (TestBean) this.beanFactory.getBean("childWithSetOfRefsInConstructor");
Set<?> set = bean.getSomeSet();
assertThat(set).isNotNull();
@ -165,7 +160,7 @@ public class CollectionMergingTests { @@ -165,7 +160,7 @@ public class CollectionMergingTests {
}
@Test
public void mergeMapInConstructor() throws Exception {
void mergeMapInConstructor() {
TestBean bean = (TestBean) this.beanFactory.getBean("childWithMapInConstructor");
Map<?, ?> map = bean.getSomeMap();
assertThat(map).as("Incorrect size").hasSize(3);
@ -175,7 +170,7 @@ public class CollectionMergingTests { @@ -175,7 +170,7 @@ public class CollectionMergingTests {
}
@Test
public void mergeMapWithInnerBeanAsMapEntryValueInConstructor() throws Exception {
void mergeMapWithInnerBeanAsMapEntryValueInConstructor() {
TestBean bean = (TestBean) this.beanFactory.getBean("childWithMapOfRefsInConstructor");
Map<?, ?> map = bean.getSomeMap();
assertThat(map).isNotNull();
@ -185,7 +180,7 @@ public class CollectionMergingTests { @@ -185,7 +180,7 @@ public class CollectionMergingTests {
}
@Test
public void mergePropertiesInConstructor() throws Exception {
void mergePropertiesInConstructor() {
TestBean bean = (TestBean) this.beanFactory.getBean("childWithPropsInConstructor");
Properties props = bean.getSomeProperties();
assertThat(props).as("Incorrect size").hasSize(3);

14
spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionsWithDefaultTypesTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Rob Harrop
* @author Juergen Hoeller
*/
public class CollectionsWithDefaultTypesTests {
class CollectionsWithDefaultTypesTests {
private final DefaultListableBeanFactory beanFactory;
@ -42,7 +42,7 @@ public class CollectionsWithDefaultTypesTests { @@ -42,7 +42,7 @@ public class CollectionsWithDefaultTypesTests {
}
@Test
public void testListHasDefaultType() throws Exception {
void testListHasDefaultType() {
TestBean bean = (TestBean) this.beanFactory.getBean("testBean");
for (Object o : bean.getSomeList()) {
assertThat(o.getClass()).as("Value type is incorrect").isEqualTo(Integer.class);
@ -50,7 +50,7 @@ public class CollectionsWithDefaultTypesTests { @@ -50,7 +50,7 @@ public class CollectionsWithDefaultTypesTests {
}
@Test
public void testSetHasDefaultType() throws Exception {
void testSetHasDefaultType() {
TestBean bean = (TestBean) this.beanFactory.getBean("testBean");
for (Object o : bean.getSomeSet()) {
assertThat(o.getClass()).as("Value type is incorrect").isEqualTo(Integer.class);
@ -58,13 +58,13 @@ public class CollectionsWithDefaultTypesTests { @@ -58,13 +58,13 @@ public class CollectionsWithDefaultTypesTests {
}
@Test
public void testMapHasDefaultKeyAndValueType() throws Exception {
void testMapHasDefaultKeyAndValueType() {
TestBean bean = (TestBean) this.beanFactory.getBean("testBean");
assertMap(bean.getSomeMap());
}
@Test
public void testMapWithNestedElementsHasDefaultKeyAndValueType() throws Exception {
void testMapWithNestedElementsHasDefaultKeyAndValueType() {
TestBean bean = (TestBean) this.beanFactory.getBean("testBean2");
assertMap(bean.getSomeMap());
}
@ -79,7 +79,7 @@ public class CollectionsWithDefaultTypesTests { @@ -79,7 +79,7 @@ public class CollectionsWithDefaultTypesTests {
@Test
@SuppressWarnings("rawtypes")
public void testBuildCollectionFromMixtureOfReferencesAndValues() throws Exception {
public void testBuildCollectionFromMixtureOfReferencesAndValues() {
MixedCollectionBean jumble = (MixedCollectionBean) this.beanFactory.getBean("jumble");
assertThat(jumble.getJumble()).as("Expected 3 elements, not " + jumble.getJumble().size()).hasSize(3);
List l = (List) jumble.getJumble();

18
spring-beans/src/test/java/org/springframework/beans/factory/xml/DefaultLifecycleMethodsTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -28,20 +28,20 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -28,20 +28,20 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Rob Harrop
* @author Juergen Hoeller
*/
public class DefaultLifecycleMethodsTests {
class DefaultLifecycleMethodsTests {
private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
@BeforeEach
public void setup() throws Exception {
void setup() {
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
new ClassPathResource("defaultLifecycleMethods.xml", getClass()));
}
@Test
public void lifecycleMethodsInvoked() {
void lifecycleMethodsInvoked() {
LifecycleAwareBean bean = (LifecycleAwareBean) this.beanFactory.getBean("lifecycleAware");
assertThat(bean.isInitCalled()).as("Bean not initialized").isTrue();
assertThat(bean.isCustomInitCalled()).as("Custom init method called incorrectly").isFalse();
@ -52,7 +52,7 @@ public class DefaultLifecycleMethodsTests { @@ -52,7 +52,7 @@ public class DefaultLifecycleMethodsTests {
}
@Test
public void lifecycleMethodsDisabled() throws Exception {
void lifecycleMethodsDisabled() {
LifecycleAwareBean bean = (LifecycleAwareBean) this.beanFactory.getBean("lifecycleMethodsDisabled");
assertThat(bean.isInitCalled()).as("Bean init method called incorrectly").isFalse();
assertThat(bean.isCustomInitCalled()).as("Custom init method called incorrectly").isFalse();
@ -62,7 +62,7 @@ public class DefaultLifecycleMethodsTests { @@ -62,7 +62,7 @@ public class DefaultLifecycleMethodsTests {
}
@Test
public void ignoreDefaultLifecycleMethods() throws Exception {
void ignoreDefaultLifecycleMethods() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(
"ignoreDefaultLifecycleMethods.xml", getClass()));
@ -71,7 +71,7 @@ public class DefaultLifecycleMethodsTests { @@ -71,7 +71,7 @@ public class DefaultLifecycleMethodsTests {
}
@Test
public void overrideDefaultLifecycleMethods() throws Exception {
void overrideDefaultLifecycleMethods() {
LifecycleAwareBean bean = (LifecycleAwareBean) this.beanFactory.getBean("overrideLifecycleMethods");
assertThat(bean.isInitCalled()).as("Default init method called incorrectly").isFalse();
assertThat(bean.isCustomInitCalled()).as("Custom init method not called").isTrue();
@ -81,7 +81,7 @@ public class DefaultLifecycleMethodsTests { @@ -81,7 +81,7 @@ public class DefaultLifecycleMethodsTests {
}
@Test
public void childWithDefaultLifecycleMethods() throws Exception {
void childWithDefaultLifecycleMethods() {
LifecycleAwareBean bean = (LifecycleAwareBean) this.beanFactory.getBean("childWithDefaultLifecycleMethods");
assertThat(bean.isInitCalled()).as("Bean not initialized").isTrue();
assertThat(bean.isCustomInitCalled()).as("Custom init method called incorrectly").isFalse();
@ -92,7 +92,7 @@ public class DefaultLifecycleMethodsTests { @@ -92,7 +92,7 @@ public class DefaultLifecycleMethodsTests {
}
@Test
public void childWithLifecycleMethodsDisabled() throws Exception {
void childWithLifecycleMethodsDisabled() {
LifecycleAwareBean bean = (LifecycleAwareBean) this.beanFactory.getBean("childWithLifecycleMethodsDisabled");
assertThat(bean.isInitCalled()).as("Bean init method called incorrectly").isFalse();
assertThat(bean.isCustomInitCalled()).as("Custom init method called incorrectly").isFalse();

10
spring-beans/src/test/java/org/springframework/beans/factory/xml/DelegatingEntityResolverTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -28,22 +28,22 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException @@ -28,22 +28,22 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Rick Evans
* @author Chris Beams
*/
public class DelegatingEntityResolverTests {
class DelegatingEntityResolverTests {
@Test
public void testCtorWhereDtdEntityResolverIsNull() throws Exception {
void testCtorWhereDtdEntityResolverIsNull() {
assertThatIllegalArgumentException().isThrownBy(() ->
new DelegatingEntityResolver(null, new NoOpEntityResolver()));
}
@Test
public void testCtorWhereSchemaEntityResolverIsNull() throws Exception {
void testCtorWhereSchemaEntityResolverIsNull() {
assertThatIllegalArgumentException().isThrownBy(() ->
new DelegatingEntityResolver(new NoOpEntityResolver(), null));
}
@Test
public void testCtorWhereEntityResolversAreBothNull() throws Exception {
void testCtorWhereEntityResolversAreBothNull() {
assertThatIllegalArgumentException().isThrownBy(() ->
new DelegatingEntityResolver(null, null));
}

13
spring-beans/src/test/java/org/springframework/beans/factory/xml/EventPublicationTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -40,7 +40,6 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -40,7 +40,6 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Rob Harrop
* @author Juergen Hoeller
*/
@SuppressWarnings("rawtypes")
class EventPublicationTests {
private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
@ -50,7 +49,7 @@ class EventPublicationTests { @@ -50,7 +49,7 @@ class EventPublicationTests {
@BeforeEach
void setUp() throws Exception {
void setUp() {
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
reader.setEventListener(this.eventListener);
reader.setSourceExtractor(new PassThroughSourceExtractor());
@ -58,7 +57,7 @@ class EventPublicationTests { @@ -58,7 +57,7 @@ class EventPublicationTests {
}
@Test
void defaultsEventReceived() throws Exception {
void defaultsEventReceived() {
List<DefaultsDefinition> defaultsList = this.eventListener.getDefaults();
assertThat(defaultsList).isNotEmpty();
assertThat(defaultsList).element(0).isInstanceOf(DocumentDefaultsDefinition.class);
@ -72,7 +71,7 @@ class EventPublicationTests { @@ -72,7 +71,7 @@ class EventPublicationTests {
}
@Test
void beanEventReceived() throws Exception {
void beanEventReceived() {
ComponentDefinition componentDefinition1 = this.eventListener.getComponentDefinition("testBean");
assertThat(componentDefinition1).isInstanceOf(BeanComponentDefinition.class);
assertThat(componentDefinition1.getBeanDefinitions()).hasSize(1);
@ -98,7 +97,7 @@ class EventPublicationTests { @@ -98,7 +97,7 @@ class EventPublicationTests {
}
@Test
void aliasEventReceived() throws Exception {
void aliasEventReceived() {
List<AliasDefinition> aliases = this.eventListener.getAliases("testBean");
assertThat(aliases).hasSize(2);
AliasDefinition aliasDefinition1 = aliases.get(0);
@ -110,7 +109,7 @@ class EventPublicationTests { @@ -110,7 +109,7 @@ class EventPublicationTests {
}
@Test
void importEventReceived() throws Exception {
void importEventReceived() {
List<ImportDefinition> imports = this.eventListener.getImports();
assertThat(imports).hasSize(1);
ImportDefinition importDefinition = imports.get(0);

40
spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethodTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -36,10 +36,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -36,10 +36,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Juergen Hoeller
* @author Chris Beams
*/
public class FactoryMethodTests {
class FactoryMethodTests {
@Test
public void testFactoryMethodsSingletonOnTargetClass() {
void testFactoryMethodsSingletonOnTargetClass() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(new ClassPathResource("factory-methods.xml", getClass()));
@ -73,7 +73,7 @@ public class FactoryMethodTests { @@ -73,7 +73,7 @@ public class FactoryMethodTests {
}
@Test
public void testFactoryMethodsWithInvalidDestroyMethod() {
void testFactoryMethodsWithInvalidDestroyMethod() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(new ClassPathResource("factory-methods.xml", getClass()));
@ -82,7 +82,7 @@ public class FactoryMethodTests { @@ -82,7 +82,7 @@ public class FactoryMethodTests {
}
@Test
public void testFactoryMethodsWithNullInstance() {
void testFactoryMethodsWithNullInstance() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(new ClassPathResource("factory-methods.xml", getClass()));
@ -93,7 +93,7 @@ public class FactoryMethodTests { @@ -93,7 +93,7 @@ public class FactoryMethodTests {
}
@Test
public void testFactoryMethodsWithNullValue() {
void testFactoryMethodsWithNullValue() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(new ClassPathResource("factory-methods.xml", getClass()));
@ -115,7 +115,7 @@ public class FactoryMethodTests { @@ -115,7 +115,7 @@ public class FactoryMethodTests {
}
@Test
public void testFactoryMethodsWithAutowire() {
void testFactoryMethodsWithAutowire() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(new ClassPathResource("factory-methods.xml", getClass()));
@ -127,7 +127,7 @@ public class FactoryMethodTests { @@ -127,7 +127,7 @@ public class FactoryMethodTests {
}
@Test
public void testProtectedFactoryMethod() {
void testProtectedFactoryMethod() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(new ClassPathResource("factory-methods.xml", getClass()));
@ -137,7 +137,7 @@ public class FactoryMethodTests { @@ -137,7 +137,7 @@ public class FactoryMethodTests {
}
@Test
public void testPrivateFactoryMethod() {
void testPrivateFactoryMethod() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(new ClassPathResource("factory-methods.xml", getClass()));
@ -147,7 +147,7 @@ public class FactoryMethodTests { @@ -147,7 +147,7 @@ public class FactoryMethodTests {
}
@Test
public void testFactoryMethodsPrototypeOnTargetClass() {
void testFactoryMethodsPrototypeOnTargetClass() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(new ClassPathResource("factory-methods.xml", getClass()));
@ -191,7 +191,7 @@ public class FactoryMethodTests { @@ -191,7 +191,7 @@ public class FactoryMethodTests {
* Tests where the static factory method is on a different class.
*/
@Test
public void testFactoryMethodsOnExternalClass() {
void testFactoryMethodsOnExternalClass() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(new ClassPathResource("factory-methods.xml", getClass()));
@ -217,7 +217,7 @@ public class FactoryMethodTests { @@ -217,7 +217,7 @@ public class FactoryMethodTests {
}
@Test
public void testInstanceFactoryMethodWithoutArgs() {
void testInstanceFactoryMethodWithoutArgs() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(new ClassPathResource("factory-methods.xml", getClass()));
@ -235,7 +235,7 @@ public class FactoryMethodTests { @@ -235,7 +235,7 @@ public class FactoryMethodTests {
}
@Test
public void testFactoryMethodNoMatchingStaticMethod() {
void testFactoryMethodNoMatchingStaticMethod() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(new ClassPathResource("factory-methods.xml", getClass()));
@ -244,7 +244,7 @@ public class FactoryMethodTests { @@ -244,7 +244,7 @@ public class FactoryMethodTests {
}
@Test
public void testNonExistingFactoryMethod() {
void testNonExistingFactoryMethod() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(new ClassPathResource("factory-methods.xml", getClass()));
@ -254,7 +254,7 @@ public class FactoryMethodTests { @@ -254,7 +254,7 @@ public class FactoryMethodTests {
}
@Test
public void testFactoryMethodArgumentsForNonExistingMethod() {
void testFactoryMethodArgumentsForNonExistingMethod() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(new ClassPathResource("factory-methods.xml", getClass()));
@ -264,7 +264,7 @@ public class FactoryMethodTests { @@ -264,7 +264,7 @@ public class FactoryMethodTests {
}
@Test
public void testCanSpecifyFactoryMethodArgumentsOnFactoryMethodPrototype() {
void testCanSpecifyFactoryMethodArgumentsOnFactoryMethodPrototype() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(new ClassPathResource("factory-methods.xml", getClass()));
@ -300,7 +300,7 @@ public class FactoryMethodTests { @@ -300,7 +300,7 @@ public class FactoryMethodTests {
}
@Test
public void testCanSpecifyFactoryMethodArgumentsOnSingleton() {
void testCanSpecifyFactoryMethodArgumentsOnSingleton() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(new ClassPathResource("factory-methods.xml", getClass()));
@ -315,7 +315,7 @@ public class FactoryMethodTests { @@ -315,7 +315,7 @@ public class FactoryMethodTests {
}
@Test
public void testCannotSpecifyFactoryMethodArgumentsOnSingletonAfterCreation() {
void testCannotSpecifyFactoryMethodArgumentsOnSingletonAfterCreation() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(new ClassPathResource("factory-methods.xml", getClass()));
@ -329,7 +329,7 @@ public class FactoryMethodTests { @@ -329,7 +329,7 @@ public class FactoryMethodTests {
}
@Test
public void testFactoryMethodWithDifferentReturnType() {
void testFactoryMethodWithDifferentReturnType() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(new ClassPathResource("factory-methods.xml", getClass()));
@ -352,7 +352,7 @@ public class FactoryMethodTests { @@ -352,7 +352,7 @@ public class FactoryMethodTests {
}
@Test
public void testFactoryMethodForJavaMailSession() {
void testFactoryMethodForJavaMailSession() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(new ClassPathResource("factory-methods.xml", getClass()));

12
spring-beans/src/test/java/org/springframework/beans/factory/xml/MetadataAttachmentTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -29,33 +29,33 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -29,33 +29,33 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Rob Harrop
*/
public class MetadataAttachmentTests {
class MetadataAttachmentTests {
private DefaultListableBeanFactory beanFactory;
@BeforeEach
public void setUp() throws Exception {
void setUp() {
this.beanFactory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
new ClassPathResource("withMeta.xml", getClass()));
}
@Test
public void metadataAttachment() throws Exception {
void metadataAttachment() {
BeanDefinition beanDefinition1 = this.beanFactory.getMergedBeanDefinition("testBean1");
assertThat(beanDefinition1.getAttribute("foo")).isEqualTo("bar");
}
@Test
public void metadataIsInherited() throws Exception {
void metadataIsInherited() {
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("testBean2");
assertThat(beanDefinition.getAttribute("foo")).as("Metadata not inherited").isEqualTo("bar");
assertThat(beanDefinition.getAttribute("abc")).as("Child metdata not attached").isEqualTo("123");
}
@Test
public void propertyMetadata() throws Exception {
void propertyMetadata() {
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("testBean3");
PropertyValue pv = beanDefinition.getPropertyValues().getPropertyValue("name");
assertThat(pv.getAttribute("surname")).isEqualTo("Harrop");

18
spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -30,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -30,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Chris Beams
*/
public class NestedBeansElementAttributeRecursionTests {
class NestedBeansElementAttributeRecursionTests {
@Test
public void defaultLazyInit() {
void defaultLazyInit() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
new ClassPathResource("NestedBeansElementAttributeRecursionTests-lazy-context.xml", this.getClass()));
@ -42,7 +42,7 @@ public class NestedBeansElementAttributeRecursionTests { @@ -42,7 +42,7 @@ public class NestedBeansElementAttributeRecursionTests {
}
@Test
public void defaultLazyInitWithNonValidatingParser() {
void defaultLazyInitWithNonValidatingParser() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(bf);
xmlBeanDefinitionReader.setValidating(false);
@ -67,7 +67,7 @@ public class NestedBeansElementAttributeRecursionTests { @@ -67,7 +67,7 @@ public class NestedBeansElementAttributeRecursionTests {
}
@Test
public void defaultMerge() {
void defaultMerge() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
new ClassPathResource("NestedBeansElementAttributeRecursionTests-merge-context.xml", this.getClass()));
@ -76,7 +76,7 @@ public class NestedBeansElementAttributeRecursionTests { @@ -76,7 +76,7 @@ public class NestedBeansElementAttributeRecursionTests {
}
@Test
public void defaultMergeWithNonValidatingParser() {
void defaultMergeWithNonValidatingParser() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(bf);
xmlBeanDefinitionReader.setValidating(false);
@ -106,7 +106,7 @@ public class NestedBeansElementAttributeRecursionTests { @@ -106,7 +106,7 @@ public class NestedBeansElementAttributeRecursionTests {
}
@Test
public void defaultAutowireCandidates() {
void defaultAutowireCandidates() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
new ClassPathResource("NestedBeansElementAttributeRecursionTests-autowire-candidates-context.xml", this.getClass()));
@ -115,7 +115,7 @@ public class NestedBeansElementAttributeRecursionTests { @@ -115,7 +115,7 @@ public class NestedBeansElementAttributeRecursionTests {
}
@Test
public void defaultAutowireCandidatesWithNonValidatingParser() {
void defaultAutowireCandidatesWithNonValidatingParser() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(bf);
xmlBeanDefinitionReader.setValidating(false);
@ -146,7 +146,7 @@ public class NestedBeansElementAttributeRecursionTests { @@ -146,7 +146,7 @@ public class NestedBeansElementAttributeRecursionTests {
}
@Test
public void initMethod() {
void initMethod() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
new ClassPathResource("NestedBeansElementAttributeRecursionTests-init-destroy-context.xml", this.getClass()));

8
spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -32,12 +32,12 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -32,12 +32,12 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Chris Beams
*/
public class NestedBeansElementTests {
class NestedBeansElementTests {
private final Resource XML =
new ClassPathResource("NestedBeansElementTests-context.xml", this.getClass());
@Test
public void getBean_withoutActiveProfile() {
void getBean_withoutActiveProfile() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(XML);
@ -46,7 +46,7 @@ public class NestedBeansElementTests { @@ -46,7 +46,7 @@ public class NestedBeansElementTests {
}
@Test
public void getBean_withActiveProfile() {
void getBean_withActiveProfile() {
ConfigurableEnvironment env = new StandardEnvironment();
env.setActiveProfiles("dev");

12
spring-beans/src/test/java/org/springframework/beans/factory/xml/ProfileXmlBeanDefinitionTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException @@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Sam Brannen
* @since 3.1
*/
public class ProfileXmlBeanDefinitionTests {
class ProfileXmlBeanDefinitionTests {
private static final String PROD_ELIGIBLE_XML = "ProfileXmlBeanDefinitionTests-prodProfile.xml";
private static final String DEV_ELIGIBLE_XML = "ProfileXmlBeanDefinitionTests-devProfile.xml";
@ -61,13 +61,13 @@ public class ProfileXmlBeanDefinitionTests { @@ -61,13 +61,13 @@ public class ProfileXmlBeanDefinitionTests {
private static final String TARGET_BEAN = "foo";
@Test
public void testProfileValidation() {
void testProfileValidation() {
assertThatIllegalArgumentException().isThrownBy(() ->
beanFactoryFor(PROD_ELIGIBLE_XML, NULL_ACTIVE));
}
@Test
public void testProfilePermutations() {
void testProfilePermutations() {
assertThat(beanFactoryFor(PROD_ELIGIBLE_XML, NONE_ACTIVE)).isNot(containingTarget());
assertThat(beanFactoryFor(PROD_ELIGIBLE_XML, DEV_ACTIVE)).isNot(containingTarget());
assertThat(beanFactoryFor(PROD_ELIGIBLE_XML, PROD_ACTIVE)).is(containingTarget());
@ -116,7 +116,7 @@ public class ProfileXmlBeanDefinitionTests { @@ -116,7 +116,7 @@ public class ProfileXmlBeanDefinitionTests {
}
@Test
public void testDefaultProfile() {
void testDefaultProfile() {
{
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
@ -140,7 +140,7 @@ public class ProfileXmlBeanDefinitionTests { @@ -140,7 +140,7 @@ public class ProfileXmlBeanDefinitionTests {
}
@Test
public void testDefaultAndNonDefaultProfile() {
void testDefaultAndNonDefaultProfile() {
assertThat(beanFactoryFor(DEFAULT_ELIGIBLE_XML, NONE_ACTIVE)).is(containingTarget());
assertThat(beanFactoryFor(DEFAULT_ELIGIBLE_XML, "other")).isNot(containingTarget());

10
spring-beans/src/test/java/org/springframework/beans/factory/xml/SchemaValidationTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -30,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -30,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* @author Rob Harrop
*/
public class SchemaValidationTests {
class SchemaValidationTests {
@Test
public void withAutodetection() throws Exception {
void withAutodetection() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(bf);
assertThatExceptionOfType(BeansException.class).isThrownBy(() ->
@ -42,7 +42,7 @@ public class SchemaValidationTests { @@ -42,7 +42,7 @@ public class SchemaValidationTests {
}
@Test
public void withExplicitValidationMode() throws Exception {
void withExplicitValidationMode() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(bf);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
@ -52,7 +52,7 @@ public class SchemaValidationTests { @@ -52,7 +52,7 @@ public class SchemaValidationTests {
}
@Test
public void loadDefinitions() throws Exception {
void loadDefinitions() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(bf);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);

20
spring-beans/src/test/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandlerTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -30,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -30,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* @author Costin Leau
*/
public class SimpleConstructorNamespaceHandlerTests {
class SimpleConstructorNamespaceHandlerTests {
@Test
public void simpleValue() throws Exception {
void simpleValue() {
DefaultListableBeanFactory beanFactory = createFactory("simpleConstructorNamespaceHandlerTests.xml");
String name = "simple";
// beanFactory.getBean("simple1", DummyBean.class);
@ -42,7 +42,7 @@ public class SimpleConstructorNamespaceHandlerTests { @@ -42,7 +42,7 @@ public class SimpleConstructorNamespaceHandlerTests {
}
@Test
public void simpleRef() throws Exception {
void simpleRef() {
DefaultListableBeanFactory beanFactory = createFactory("simpleConstructorNamespaceHandlerTests.xml");
String name = "simple-ref";
// beanFactory.getBean("name-value1", TestBean.class);
@ -51,7 +51,7 @@ public class SimpleConstructorNamespaceHandlerTests { @@ -51,7 +51,7 @@ public class SimpleConstructorNamespaceHandlerTests {
}
@Test
public void nameValue() throws Exception {
void nameValue() {
DefaultListableBeanFactory beanFactory = createFactory("simpleConstructorNamespaceHandlerTests.xml");
String name = "name-value";
// beanFactory.getBean("name-value1", TestBean.class);
@ -61,7 +61,7 @@ public class SimpleConstructorNamespaceHandlerTests { @@ -61,7 +61,7 @@ public class SimpleConstructorNamespaceHandlerTests {
}
@Test
public void nameRef() throws Exception {
void nameRef() {
DefaultListableBeanFactory beanFactory = createFactory("simpleConstructorNamespaceHandlerTests.xml");
TestBean nameValue = beanFactory.getBean("name-value", TestBean.class);
DummyBean nameRef = beanFactory.getBean("name-ref", DummyBean.class);
@ -71,7 +71,7 @@ public class SimpleConstructorNamespaceHandlerTests { @@ -71,7 +71,7 @@ public class SimpleConstructorNamespaceHandlerTests {
}
@Test
public void typeIndexedValue() throws Exception {
void typeIndexedValue() {
DefaultListableBeanFactory beanFactory = createFactory("simpleConstructorNamespaceHandlerTests.xml");
DummyBean typeRef = beanFactory.getBean("indexed-value", DummyBean.class);
@ -81,7 +81,7 @@ public class SimpleConstructorNamespaceHandlerTests { @@ -81,7 +81,7 @@ public class SimpleConstructorNamespaceHandlerTests {
}
@Test
public void typeIndexedRef() throws Exception {
void typeIndexedRef() {
DefaultListableBeanFactory beanFactory = createFactory("simpleConstructorNamespaceHandlerTests.xml");
DummyBean typeRef = beanFactory.getBean("indexed-ref", DummyBean.class);
@ -90,7 +90,7 @@ public class SimpleConstructorNamespaceHandlerTests { @@ -90,7 +90,7 @@ public class SimpleConstructorNamespaceHandlerTests {
}
@Test
public void ambiguousConstructor() throws Exception {
void ambiguousConstructor() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() ->
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
@ -98,7 +98,7 @@ public class SimpleConstructorNamespaceHandlerTests { @@ -98,7 +98,7 @@ public class SimpleConstructorNamespaceHandlerTests {
}
@Test
public void constructorWithNameEndingInRef() throws Exception {
void constructorWithNameEndingInRef() {
DefaultListableBeanFactory beanFactory = createFactory("simpleConstructorNamespaceHandlerTests.xml");
DummyBean derivedBean = beanFactory.getBean("beanWithRefConstructorArg", DummyBean.class);
assertThat(derivedBean.getAge()).isEqualTo(10);

12
spring-beans/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -32,10 +32,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -32,10 +32,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Juergen Hoeller
* @author Arjen Poutsma
*/
public class SimplePropertyNamespaceHandlerTests {
class SimplePropertyNamespaceHandlerTests {
@Test
public void simpleBeanConfigured() throws Exception {
void simpleBeanConfigured() {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(
new ClassPathResource("simplePropertyNamespaceHandlerTests.xml", getClass()));
@ -47,7 +47,7 @@ public class SimplePropertyNamespaceHandlerTests { @@ -47,7 +47,7 @@ public class SimplePropertyNamespaceHandlerTests {
}
@Test
public void innerBeanConfigured() throws Exception {
void innerBeanConfigured() {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(
new ClassPathResource("simplePropertyNamespaceHandlerTests.xml", getClass()));
@ -59,7 +59,7 @@ public class SimplePropertyNamespaceHandlerTests { @@ -59,7 +59,7 @@ public class SimplePropertyNamespaceHandlerTests {
}
@Test
public void withPropertyDefinedTwice() throws Exception {
void withPropertyDefinedTwice() {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() ->
new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(
@ -67,7 +67,7 @@ public class SimplePropertyNamespaceHandlerTests { @@ -67,7 +67,7 @@ public class SimplePropertyNamespaceHandlerTests {
}
@Test
public void propertyWithNameEndingInRef() throws Exception {
void propertyWithNameEndingInRef() {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(
new ClassPathResource("simplePropertyNamespaceHandlerTests.xml", getClass()));

4
spring-beans/src/test/java/org/springframework/beans/factory/xml/UtilNamespaceHandlerTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -46,7 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -46,7 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Mark Fisher
*/
@SuppressWarnings("rawtypes")
public class UtilNamespaceHandlerTests {
class UtilNamespaceHandlerTests {
private DefaultListableBeanFactory beanFactory;

116
spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanCollectionTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -42,6 +42,7 @@ import org.springframework.beans.testfixture.beans.HasMap; @@ -42,6 +42,7 @@ import org.springframework.beans.testfixture.beans.HasMap;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.io.ClassPathResource;
import static java.util.Map.entry;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
@ -53,20 +54,20 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -53,20 +54,20 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @since 19.12.2004
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public class XmlBeanCollectionTests {
class XmlBeanCollectionTests {
private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
@BeforeEach
public void loadBeans() {
void loadBeans() {
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
new ClassPathResource("collections.xml", getClass()));
}
@Test
public void testCollectionFactoryDefaults() throws Exception {
void testCollectionFactoryDefaults() throws Exception {
ListFactoryBean listFactory = new ListFactoryBean();
listFactory.setSourceList(new LinkedList());
listFactory.afterPropertiesSet();
@ -84,7 +85,7 @@ public class XmlBeanCollectionTests { @@ -84,7 +85,7 @@ public class XmlBeanCollectionTests {
}
@Test
public void testRefSubelement() {
void testRefSubelement() {
//assertTrue("5 beans in reftypes, not " + this.beanFactory.getBeanDefinitionCount(), this.beanFactory.getBeanDefinitionCount() == 5);
TestBean jen = (TestBean) this.beanFactory.getBean("jenny");
TestBean dave = (TestBean) this.beanFactory.getBean("david");
@ -92,25 +93,25 @@ public class XmlBeanCollectionTests { @@ -92,25 +93,25 @@ public class XmlBeanCollectionTests {
}
@Test
public void testPropertyWithLiteralValueSubelement() {
void testPropertyWithLiteralValueSubelement() {
TestBean verbose = (TestBean) this.beanFactory.getBean("verbose");
assertThat(verbose.getName()).isEqualTo("verbose");
}
@Test
public void testPropertyWithIdRefLocalAttrSubelement() {
void testPropertyWithIdRefLocalAttrSubelement() {
TestBean verbose = (TestBean) this.beanFactory.getBean("verbose2");
assertThat(verbose.getName()).isEqualTo("verbose");
}
@Test
public void testPropertyWithIdRefBeanAttrSubelement() {
void testPropertyWithIdRefBeanAttrSubelement() {
TestBean verbose = (TestBean) this.beanFactory.getBean("verbose3");
assertThat(verbose.getName()).isEqualTo("verbose");
}
@Test
public void testRefSubelementsBuildCollection() {
void testRefSubelementsBuildCollection() {
TestBean jen = (TestBean) this.beanFactory.getBean("jenny");
TestBean dave = (TestBean) this.beanFactory.getBean("david");
TestBean rod = (TestBean) this.beanFactory.getBean("rod");
@ -127,7 +128,7 @@ public class XmlBeanCollectionTests { @@ -127,7 +128,7 @@ public class XmlBeanCollectionTests {
}
@Test
public void testRefSubelementsBuildCollectionWithPrototypes() {
void testRefSubelementsBuildCollectionWithPrototypes() {
TestBean jen = (TestBean) this.beanFactory.getBean("pJenny");
TestBean dave = (TestBean) this.beanFactory.getBean("pDavid");
TestBean rod = (TestBean) this.beanFactory.getBean("pRod");
@ -150,7 +151,7 @@ public class XmlBeanCollectionTests { @@ -150,7 +151,7 @@ public class XmlBeanCollectionTests {
}
@Test
public void testRefSubelementsBuildCollectionFromSingleElement() {
void testRefSubelementsBuildCollectionFromSingleElement() {
TestBean loner = (TestBean) this.beanFactory.getBean("loner");
TestBean dave = (TestBean) this.beanFactory.getBean("david");
assertThat(loner.getFriends().size()).isEqualTo(1);
@ -158,7 +159,7 @@ public class XmlBeanCollectionTests { @@ -158,7 +159,7 @@ public class XmlBeanCollectionTests {
}
@Test
public void testBuildCollectionFromMixtureOfReferencesAndValues() {
void testBuildCollectionFromMixtureOfReferencesAndValues() {
MixedCollectionBean jumble = (MixedCollectionBean) this.beanFactory.getBean("jumble");
assertThat(jumble.getJumble().size()).as("Expected 5 elements, not " + jumble.getJumble().size()).isEqualTo(5);
List l = (List) jumble.getJumble();
@ -172,7 +173,7 @@ public class XmlBeanCollectionTests { @@ -172,7 +173,7 @@ public class XmlBeanCollectionTests {
}
@Test
public void testInvalidBeanNameReference() {
void testInvalidBeanNameReference() {
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
this.beanFactory.getBean("jumble2"))
.withCauseInstanceOf(BeanDefinitionStoreException.class)
@ -180,13 +181,13 @@ public class XmlBeanCollectionTests { @@ -180,13 +181,13 @@ public class XmlBeanCollectionTests {
}
@Test
public void testEmptyMap() {
void testEmptyMap() {
HasMap hasMap = (HasMap) this.beanFactory.getBean("emptyMap");
assertThat(hasMap.getMap().size()).isEqualTo(0);
}
@Test
public void testMapWithLiteralsOnly() {
void testMapWithLiteralsOnly() {
HasMap hasMap = (HasMap) this.beanFactory.getBean("literalMap");
assertThat(hasMap.getMap().size()).isEqualTo(3);
assertThat(hasMap.getMap().get("foo").equals("bar")).isTrue();
@ -195,7 +196,7 @@ public class XmlBeanCollectionTests { @@ -195,7 +196,7 @@ public class XmlBeanCollectionTests {
}
@Test
public void testMapWithLiteralsAndReferences() {
void testMapWithLiteralsAndReferences() {
HasMap hasMap = (HasMap) this.beanFactory.getBean("mixedMap");
assertThat(hasMap.getMap().size()).isEqualTo(5);
assertThat(hasMap.getMap().get("foo")).isEqualTo(10);
@ -209,7 +210,7 @@ public class XmlBeanCollectionTests { @@ -209,7 +210,7 @@ public class XmlBeanCollectionTests {
}
@Test
public void testMapWithLiteralsAndPrototypeReferences() {
void testMapWithLiteralsAndPrototypeReferences() {
TestBean jenny = (TestBean) this.beanFactory.getBean("pJenny");
HasMap hasMap = (HasMap) this.beanFactory.getBean("pMixedMap");
assertThat(hasMap.getMap().size()).isEqualTo(2);
@ -225,7 +226,7 @@ public class XmlBeanCollectionTests { @@ -225,7 +226,7 @@ public class XmlBeanCollectionTests {
}
@Test
public void testMapWithLiteralsReferencesAndList() {
void testMapWithLiteralsReferencesAndList() {
HasMap hasMap = (HasMap) this.beanFactory.getBean("mixedMapWithList");
assertThat(hasMap.getMap().size()).isEqualTo(4);
assertThat(hasMap.getMap().get(null).equals("bar")).isTrue();
@ -262,13 +263,13 @@ public class XmlBeanCollectionTests { @@ -262,13 +263,13 @@ public class XmlBeanCollectionTests {
}
@Test
public void testEmptySet() {
void testEmptySet() {
HasMap hasMap = (HasMap) this.beanFactory.getBean("emptySet");
assertThat(hasMap.getSet().size()).isEqualTo(0);
}
@Test
public void testPopulatedSet() {
void testPopulatedSet() {
HasMap hasMap = (HasMap) this.beanFactory.getBean("set");
assertThat(hasMap.getSet().size()).isEqualTo(3);
assertThat(hasMap.getSet().contains("bar")).isTrue();
@ -282,7 +283,7 @@ public class XmlBeanCollectionTests { @@ -282,7 +283,7 @@ public class XmlBeanCollectionTests {
}
@Test
public void testPopulatedConcurrentSet() {
void testPopulatedConcurrentSet() {
HasMap hasMap = (HasMap) this.beanFactory.getBean("concurrentSet");
assertThat(hasMap.getConcurrentSet().size()).isEqualTo(3);
assertThat(hasMap.getConcurrentSet().contains("bar")).isTrue();
@ -292,7 +293,7 @@ public class XmlBeanCollectionTests { @@ -292,7 +293,7 @@ public class XmlBeanCollectionTests {
}
@Test
public void testPopulatedIdentityMap() {
void testPopulatedIdentityMap() {
HasMap hasMap = (HasMap) this.beanFactory.getBean("identityMap");
assertThat(hasMap.getIdentityMap().size()).isEqualTo(2);
HashSet set = new HashSet(hasMap.getIdentityMap().keySet());
@ -301,14 +302,14 @@ public class XmlBeanCollectionTests { @@ -301,14 +302,14 @@ public class XmlBeanCollectionTests {
}
@Test
public void testEmptyProps() {
void testEmptyProps() {
HasMap hasMap = (HasMap) this.beanFactory.getBean("emptyProps");
assertThat(hasMap.getProps().size()).isEqualTo(0);
assertThat(Properties.class).isEqualTo(hasMap.getProps().getClass());
}
@Test
public void testPopulatedProps() {
void testPopulatedProps() {
HasMap hasMap = (HasMap) this.beanFactory.getBean("props");
assertThat(hasMap.getProps().size()).isEqualTo(2);
assertThat(hasMap.getProps().get("foo").equals("bar")).isTrue();
@ -316,7 +317,7 @@ public class XmlBeanCollectionTests { @@ -316,7 +317,7 @@ public class XmlBeanCollectionTests {
}
@Test
public void testObjectArray() {
void testObjectArray() {
HasMap hasMap = (HasMap) this.beanFactory.getBean("objectArray");
assertThat(hasMap.getObjectArray().length).isEqualTo(2);
assertThat(hasMap.getObjectArray()[0].equals("one")).isTrue();
@ -324,7 +325,7 @@ public class XmlBeanCollectionTests { @@ -324,7 +325,7 @@ public class XmlBeanCollectionTests {
}
@Test
public void testIntegerArray() {
void testIntegerArray() {
HasMap hasMap = (HasMap) this.beanFactory.getBean("integerArray");
assertThat(hasMap.getIntegerArray().length).isEqualTo(3);
assertThat(hasMap.getIntegerArray()[0]).isEqualTo(0);
@ -333,7 +334,7 @@ public class XmlBeanCollectionTests { @@ -333,7 +334,7 @@ public class XmlBeanCollectionTests {
}
@Test
public void testClassArray() {
void testClassArray() {
HasMap hasMap = (HasMap) this.beanFactory.getBean("classArray");
assertThat(hasMap.getClassArray().length).isEqualTo(2);
assertThat(hasMap.getClassArray()[0].equals(String.class)).isTrue();
@ -341,7 +342,7 @@ public class XmlBeanCollectionTests { @@ -341,7 +342,7 @@ public class XmlBeanCollectionTests {
}
@Test
public void testClassList() {
void testClassList() {
HasMap hasMap = (HasMap) this.beanFactory.getBean("classList");
assertThat(hasMap.getClassList().size()).isEqualTo(2);
assertThat(hasMap.getClassList().get(0).equals(String.class)).isTrue();
@ -349,7 +350,7 @@ public class XmlBeanCollectionTests { @@ -349,7 +350,7 @@ public class XmlBeanCollectionTests {
}
@Test
public void testProps() {
void testProps() {
HasMap hasMap = (HasMap) this.beanFactory.getBean("props");
assertThat(hasMap.getProps()).hasSize(2);
assertThat(hasMap.getProps().getProperty("foo")).isEqualTo("bar");
@ -362,76 +363,55 @@ public class XmlBeanCollectionTests { @@ -362,76 +363,55 @@ public class XmlBeanCollectionTests {
}
@Test
public void testListFactory() {
void testListFactory() {
List list = (List) this.beanFactory.getBean("listFactory");
assertThat(list).isInstanceOf(LinkedList.class);
assertThat(list.size()).isEqualTo(2);
assertThat(list).element(0).isEqualTo("bar");
assertThat(list).element(1).isEqualTo("jenny");
assertThat(list).isInstanceOf(LinkedList.class).containsExactly("bar", "jenny");
}
@Test
public void testPrototypeListFactory() {
void testPrototypeListFactory() {
List list = (List) this.beanFactory.getBean("pListFactory");
assertThat(list).isInstanceOf(LinkedList.class);
assertThat(list.size()).isEqualTo(2);
assertThat(list).element(0).isEqualTo("bar");
assertThat(list).element(1).isEqualTo("jenny");
assertThat(list).isInstanceOf(LinkedList.class).containsExactly("bar", "jenny");
}
@Test
public void testSetFactory() {
void testSetFactory() {
Set set = (Set) this.beanFactory.getBean("setFactory");
assertThat(set).isInstanceOf(TreeSet.class);
assertThat(set.size()).isEqualTo(2);
assertThat(set).contains("bar");
assertThat(set).contains("jenny");
assertThat(set).isInstanceOf(TreeSet.class).containsOnly("bar", "jenny");
}
@Test
public void testPrototypeSetFactory() {
void testPrototypeSetFactory() {
Set set = (Set) this.beanFactory.getBean("pSetFactory");
assertThat(set).isInstanceOf(TreeSet.class);
assertThat(set.size()).isEqualTo(2);
assertThat(set).contains("bar");
assertThat(set).contains("jenny");
assertThat(set).isInstanceOf(TreeSet.class).containsOnly("bar", "jenny");
}
@Test
public void testMapFactory() {
void testMapFactory() {
Map map = (Map) this.beanFactory.getBean("mapFactory");
assertThat(map).isInstanceOf(TreeMap.class);
assertThat(map.size()).isEqualTo(2);
assertThat(map.get("foo")).isEqualTo("bar");
assertThat(map.get("jen")).isEqualTo("jenny");
assertThat(map).isInstanceOf(TreeMap.class).containsOnly(
entry("foo", "bar"), entry("jen", "jenny"));
}
@Test
public void testPrototypeMapFactory() {
void testPrototypeMapFactory() {
Map map = (Map) this.beanFactory.getBean("pMapFactory");
assertThat(map).isInstanceOf(TreeMap.class);
assertThat(map.size()).isEqualTo(2);
assertThat(map.get("foo")).isEqualTo("bar");
assertThat(map.get("jen")).isEqualTo("jenny");
assertThat(map).isInstanceOf(TreeMap.class).containsOnly(
entry("foo", "bar"), entry("jen", "jenny"));
}
@Test
public void testChoiceBetweenSetAndMap() {
void testChoiceBetweenSetAndMap() {
MapAndSet sam = (MapAndSet) this.beanFactory.getBean("setAndMap");
assertThat(sam.getObject() instanceof Map).as("Didn't choose constructor with Map argument").isTrue();
Map map = (Map) sam.getObject();
assertThat(map).hasSize(3);
assertThat(map.get("key1")).isEqualTo("val1");
assertThat(map.get("key2")).isEqualTo("val2");
assertThat(map.get("key3")).isEqualTo("val3");
assertThat(map).containsOnly(entry("key1", "val1"), entry("key2", "val2"), entry("key3", "val3"));
}
@Test
public void testEnumSetFactory() {
void testEnumSetFactory() {
Set set = (Set) this.beanFactory.getBean("enumSetFactory");
assertThat(set.size()).isEqualTo(2);
assertThat(set).contains("ONE");
assertThat(set).contains("TWO");
assertThat(set).containsOnly("ONE", "TWO");
}

28
spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlListableBeanFactoryTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -44,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -44,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 09.11.2003
*/
@SuppressWarnings({"rawtypes", "unchecked"})
public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTests {
class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTests {
private DefaultListableBeanFactory parent;
@ -52,7 +52,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest @@ -52,7 +52,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
@BeforeEach
public void setup() {
void setup() {
parent = new DefaultListableBeanFactory();
Map map = new HashMap();
@ -105,24 +105,24 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest @@ -105,24 +105,24 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
}
@Test
public void beanCount() {
void beanCount() {
assertTestBeanCount(13);
}
@Test
public void lifecycleMethods() {
void lifecycleMethods() {
LifecycleBean bean = (LifecycleBean) getBeanFactory().getBean("lifecycle");
bean.businessMethod();
}
@Test
public void protectedLifecycleMethods() {
void protectedLifecycleMethods() {
ProtectedLifecycleBean bean = (ProtectedLifecycleBean) getBeanFactory().getBean("protectedLifecycle");
bean.businessMethod();
}
@Test
public void descriptionButNoProperties() {
void descriptionButNoProperties() {
TestBean validEmpty = (TestBean) getBeanFactory().getBean("validEmptyWithDescription");
assertThat(validEmpty.getAge()).isZero();
}
@ -131,7 +131,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest @@ -131,7 +131,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
* Test that properties with name as well as id creating an alias up front.
*/
@Test
public void autoAliasing() {
void autoAliasing() {
List beanNames = Arrays.asList(getListableBeanFactory().getBeanDefinitionNames());
TestBean tb1 = (TestBean) getBeanFactory().getBean("aliased");
@ -191,7 +191,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest @@ -191,7 +191,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
}
@Test
public void factoryNesting() {
void factoryNesting() {
ITestBean father = (ITestBean) getBeanFactory().getBean("father");
assertThat(father).as("Bean from root context").isNotNull();
@ -204,7 +204,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest @@ -204,7 +204,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
}
@Test
public void factoryReferences() {
void factoryReferences() {
DummyFactory factory = (DummyFactory) getBeanFactory().getBean("&singletonFactory");
DummyReferencer ref = (DummyReferencer) getBeanFactory().getBean("factoryReferencer");
@ -217,7 +217,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest @@ -217,7 +217,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
}
@Test
public void prototypeReferences() {
void prototypeReferences() {
// check that not broken by circular reference resolution mechanism
DummyReferencer ref1 = (DummyReferencer) getBeanFactory().getBean("prototypeReferencer");
assertThat(ref1.getTestBean1()).as("Not referencing same bean twice").isNotSameAs(ref1.getTestBean2());
@ -230,7 +230,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest @@ -230,7 +230,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
}
@Test
public void beanPostProcessor() {
void beanPostProcessor() {
TestBean kerry = (TestBean) getBeanFactory().getBean("kerry");
TestBean kathy = (TestBean) getBeanFactory().getBean("kathy");
DummyFactory factory = (DummyFactory) getBeanFactory().getBean("&singletonFactory");
@ -242,7 +242,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest @@ -242,7 +242,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
}
@Test
public void emptyValues() {
void emptyValues() {
TestBean rod = (TestBean) getBeanFactory().getBean("rod");
TestBean kerry = (TestBean) getBeanFactory().getBean("kerry");
assertThat(rod.getTouchy()).as("Touchy is empty").isEqualTo("");
@ -250,7 +250,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest @@ -250,7 +250,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
}
@Test
public void commentsAndCdataInValue() {
void commentsAndCdataInValue() {
TestBean bean = (TestBean) getBeanFactory().getBean("commentsInValue");
assertThat(bean.getName()).as("Failed to handle comments and CDATA properly").isEqualTo("this is a <!--comment-->");
}

16
spring-beans/src/test/java/org/springframework/beans/factory/xml/support/DefaultNamespaceHandlerResolverTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException @@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Rob Harrop
* @author Rick Evans
*/
public class DefaultNamespaceHandlerResolverTests {
class DefaultNamespaceHandlerResolverTests {
@Test
public void testResolvedMappedHandler() {
void testResolvedMappedHandler() {
DefaultNamespaceHandlerResolver resolver = new DefaultNamespaceHandlerResolver(getClass().getClassLoader());
NamespaceHandler handler = resolver.resolve("http://www.springframework.org/schema/util");
assertThat(handler).as("Handler should not be null.").isNotNull();
@ -42,7 +42,7 @@ public class DefaultNamespaceHandlerResolverTests { @@ -42,7 +42,7 @@ public class DefaultNamespaceHandlerResolverTests {
}
@Test
public void testResolvedMappedHandlerWithNoArgCtor() {
void testResolvedMappedHandlerWithNoArgCtor() {
DefaultNamespaceHandlerResolver resolver = new DefaultNamespaceHandlerResolver();
NamespaceHandler handler = resolver.resolve("http://www.springframework.org/schema/util");
assertThat(handler).as("Handler should not be null.").isNotNull();
@ -50,25 +50,25 @@ public class DefaultNamespaceHandlerResolverTests { @@ -50,25 +50,25 @@ public class DefaultNamespaceHandlerResolverTests {
}
@Test
public void testNonExistentHandlerClass() {
void testNonExistentHandlerClass() {
String mappingPath = "org/springframework/beans/factory/xml/support/nonExistent.properties";
new DefaultNamespaceHandlerResolver(getClass().getClassLoader(), mappingPath);
}
@Test
public void testCtorWithNullClassLoaderArgument() {
void testCtorWithNullClassLoaderArgument() {
// simply must not bail...
new DefaultNamespaceHandlerResolver(null);
}
@Test
public void testCtorWithNullClassLoaderArgumentAndNullMappingLocationArgument() {
void testCtorWithNullClassLoaderArgumentAndNullMappingLocationArgument() {
assertThatIllegalArgumentException().isThrownBy(() ->
new DefaultNamespaceHandlerResolver(null, null));
}
@Test
public void testCtorWithNonExistentMappingLocationArgument() {
void testCtorWithNonExistentMappingLocationArgument() {
// simply must not bail; we don't want non-existent resources to result in an Exception
new DefaultNamespaceHandlerResolver(null, "738trbc bobabloobop871");
}

6
spring-beans/src/test/java/org/springframework/beans/propertyeditors/BeanInfoTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -33,10 +33,10 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -33,10 +33,10 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Juergen Hoeller
* @since 06.03.2006
*/
public class BeanInfoTests {
class BeanInfoTests {
@Test
public void testComplexObject() {
void testComplexObject() {
ValueBean bean = new ValueBean();
BeanWrapper bw = new BeanWrapperImpl(bean);
Integer value = 1;

8
spring-beans/src/test/java/org/springframework/beans/propertyeditors/ByteArrayPropertyEditorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -27,12 +27,12 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -27,12 +27,12 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Rick Evans
*/
public class ByteArrayPropertyEditorTests {
class ByteArrayPropertyEditorTests {
private final PropertyEditor byteEditor = new ByteArrayPropertyEditor();
@Test
public void sunnyDaySetAsText() throws Exception {
void sunnyDaySetAsText() {
final String text = "Hideous towns make me throw... up";
byteEditor.setAsText(text);
@ -46,7 +46,7 @@ public class ByteArrayPropertyEditorTests { @@ -46,7 +46,7 @@ public class ByteArrayPropertyEditorTests {
}
@Test
public void getAsTextReturnsEmptyStringIfValueIsNull() throws Exception {
void getAsTextReturnsEmptyStringIfValueIsNull() {
assertThat(byteEditor.getAsText()).isEmpty();
byteEditor.setAsText(null);

8
spring-beans/src/test/java/org/springframework/beans/propertyeditors/CharArrayPropertyEditorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -27,12 +27,12 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -27,12 +27,12 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Rick Evans
*/
public class CharArrayPropertyEditorTests {
class CharArrayPropertyEditorTests {
private final PropertyEditor charEditor = new CharArrayPropertyEditor();
@Test
public void sunnyDaySetAsText() throws Exception {
void sunnyDaySetAsText() {
final String text = "Hideous towns make me throw... up";
charEditor.setAsText(text);
@ -46,7 +46,7 @@ public class CharArrayPropertyEditorTests { @@ -46,7 +46,7 @@ public class CharArrayPropertyEditorTests {
}
@Test
public void getAsTextReturnsEmptyStringIfValueIsNull() throws Exception {
void getAsTextReturnsEmptyStringIfValueIsNull() {
assertThat(charEditor.getAsText()).isEmpty();
charEditor.setAsText(null);

24
spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomCollectionEditorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException @@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Rick Evans
* @author Chris Beams
*/
public class CustomCollectionEditorTests {
class CustomCollectionEditorTests {
@Test
public void testCtorWithNullCollectionType() {
void testCtorWithNullCollectionType() {
assertThatIllegalArgumentException().isThrownBy(() ->
new CustomCollectionEditor(null));
}
@ -47,38 +47,34 @@ public class CustomCollectionEditorTests { @@ -47,38 +47,34 @@ public class CustomCollectionEditorTests {
}
@Test
public void testWithCollectionTypeThatDoesNotExposeAPublicNoArgCtor() {
void testWithCollectionTypeThatDoesNotExposeAPublicNoArgCtor() {
CustomCollectionEditor editor = new CustomCollectionEditor(CollectionTypeWithNoNoArgCtor.class);
assertThatIllegalArgumentException().isThrownBy(() ->
editor.setValue("1"));
}
@Test
public void testSunnyDaySetValue() {
void testSunnyDaySetValue() {
CustomCollectionEditor editor = new CustomCollectionEditor(ArrayList.class);
editor.setValue(new int[] {0, 1, 2});
Object value = editor.getValue();
assertThat(value).isNotNull();
assertThat(value).isInstanceOf(ArrayList.class);
List<?> list = (List<?>) value;
assertThat(list).as("There must be 3 elements in the converted collection").hasSize(3);
assertThat(list).element(0).isEqualTo(0);
assertThat(list).element(1).isEqualTo(1);
assertThat(list).element(2).isEqualTo(2);
assertThat(value).asList().containsExactly(0, 1, 2);
}
@Test
public void testWhenTargetTypeIsExactlyTheCollectionInterfaceUsesFallbackCollectionType() {
void testWhenTargetTypeIsExactlyTheCollectionInterfaceUsesFallbackCollectionType() {
CustomCollectionEditor editor = new CustomCollectionEditor(Collection.class);
editor.setValue("0, 1, 2");
Collection<?> value = (Collection<?>) editor.getValue();
assertThat(value).isNotNull();
assertThat(value).as("There must be 1 element in the converted collection").hasSize(1);
assertThat(value).element(0).isEqualTo("0, 1, 2");
assertThat(value).singleElement().isEqualTo("0, 1, 2");
}
@Test
public void testSunnyDaySetAsTextYieldsSingleValue() {
void testSunnyDaySetAsTextYieldsSingleValue() {
CustomCollectionEditor editor = new CustomCollectionEditor(ArrayList.class);
editor.setValue("0, 1, 2");
Object value = editor.getValue();
@ -86,7 +82,7 @@ public class CustomCollectionEditorTests { @@ -86,7 +82,7 @@ public class CustomCollectionEditorTests {
assertThat(value).isInstanceOf(ArrayList.class);
List<?> list = (List<?>) value;
assertThat(list).as("There must be 1 element in the converted collection").hasSize(1);
assertThat(list).element(0).isEqualTo("0, 1, 2");
assertThat(list).singleElement().isEqualTo("0, 1, 2");
}

13
spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -18,7 +18,6 @@ package org.springframework.beans.propertyeditors; @@ -18,7 +18,6 @@ package org.springframework.beans.propertyeditors;
import java.beans.PropertyEditor;
import java.beans.PropertyEditorSupport;
import java.beans.PropertyVetoException;
import java.io.File;
import java.math.BigDecimal;
import java.math.BigInteger;
@ -1319,7 +1318,6 @@ class CustomEditorTests { @@ -1319,7 +1318,6 @@ class CustomEditorTests {
}
@Test
@SuppressWarnings("unchecked")
void indexedPropertiesWithListPropertyEditor() {
IndexedTestBean bean = new IndexedTestBean();
BeanWrapper bw = new BeanWrapperImpl(bean);
@ -1334,11 +1332,11 @@ class CustomEditorTests { @@ -1334,11 +1332,11 @@ class CustomEditorTests {
bw.setPropertyValue("list", "1");
assertThat(((TestBean) bean.getList().get(0)).getName()).isEqualTo("list1");
bw.setPropertyValue("list[0]", "test");
assertThat(bean.getList()).element(0).isEqualTo("test");
assertThat(bean.getList()).singleElement().isEqualTo("test");
}
@Test
void conversionToOldCollections() throws PropertyVetoException {
void conversionToOldCollections() {
OldCollectionsBean tb = new OldCollectionsBean();
BeanWrapper bw = new BeanWrapperImpl(tb);
bw.registerCustomEditor(Vector.class, new CustomCollectionEditor(Vector.class));
@ -1355,7 +1353,6 @@ class CustomEditorTests { @@ -1355,7 +1353,6 @@ class CustomEditorTests {
}
@Test
@SuppressWarnings("unchecked")
void uninitializedArrayPropertyWithCustomEditor() {
IndexedTestBean bean = new IndexedTestBean(false);
BeanWrapper bw = new BeanWrapperImpl(bean);
@ -1372,7 +1369,7 @@ class CustomEditorTests { @@ -1372,7 +1369,7 @@ class CustomEditorTests {
}
@Test
void arrayToArrayConversion() throws PropertyVetoException {
void arrayToArrayConversion() {
IndexedTestBean tb = new IndexedTestBean();
BeanWrapper bw = new BeanWrapperImpl(tb);
bw.registerCustomEditor(TestBean.class, new PropertyEditorSupport() {
@ -1388,7 +1385,7 @@ class CustomEditorTests { @@ -1388,7 +1385,7 @@ class CustomEditorTests {
}
@Test
void arrayToStringConversion() throws PropertyVetoException {
void arrayToStringConversion() {
TestBean tb = new TestBean();
BeanWrapper bw = new BeanWrapperImpl(tb);
bw.registerCustomEditor(String.class, new PropertyEditorSupport() {

16
spring-beans/src/test/java/org/springframework/beans/propertyeditors/FileEditorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException @@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Chris Beams
* @author Juergen Hoeller
*/
public class FileEditorTests {
class FileEditorTests {
@Test
public void testClasspathFileName() {
void testClasspathFileName() {
PropertyEditor fileEditor = new FileEditor();
fileEditor.setAsText("classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) + "/" +
ClassUtils.getShortName(getClass()) + ".class");
@ -45,14 +45,14 @@ public class FileEditorTests { @@ -45,14 +45,14 @@ public class FileEditorTests {
}
@Test
public void testWithNonExistentResource() {
void testWithNonExistentResource() {
PropertyEditor propertyEditor = new FileEditor();
assertThatIllegalArgumentException().isThrownBy(() ->
propertyEditor.setAsText("classpath:no_way_this_file_is_found.doc"));
}
@Test
public void testWithNonExistentFile() {
void testWithNonExistentFile() {
PropertyEditor fileEditor = new FileEditor();
fileEditor.setAsText("file:no_way_this_file_is_found.doc");
Object value = fileEditor.getValue();
@ -62,7 +62,7 @@ public class FileEditorTests { @@ -62,7 +62,7 @@ public class FileEditorTests {
}
@Test
public void testAbsoluteFileName() {
void testAbsoluteFileName() {
PropertyEditor fileEditor = new FileEditor();
fileEditor.setAsText("/no_way_this_file_is_found.doc");
Object value = fileEditor.getValue();
@ -72,7 +72,7 @@ public class FileEditorTests { @@ -72,7 +72,7 @@ public class FileEditorTests {
}
@Test
public void testUnqualifiedFileNameFound() {
void testUnqualifiedFileNameFound() {
PropertyEditor fileEditor = new FileEditor();
String fileName = ClassUtils.classPackageAsResourcePath(getClass()) + "/" +
ClassUtils.getShortName(getClass()) + ".class";
@ -86,7 +86,7 @@ public class FileEditorTests { @@ -86,7 +86,7 @@ public class FileEditorTests {
}
@Test
public void testUnqualifiedFileNameNotFound() {
void testUnqualifiedFileNameNotFound() {
PropertyEditor fileEditor = new FileEditor();
String fileName = ClassUtils.classPackageAsResourcePath(getClass()) + "/" +
ClassUtils.getShortName(getClass()) + ".clazz";

12
spring-beans/src/test/java/org/springframework/beans/propertyeditors/InputStreamEditorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -32,16 +32,16 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException @@ -32,16 +32,16 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Rick Evans
* @author Chris Beams
*/
public class InputStreamEditorTests {
class InputStreamEditorTests {
@Test
public void testCtorWithNullResourceEditor() {
void testCtorWithNullResourceEditor() {
assertThatIllegalArgumentException().isThrownBy(() ->
new InputStreamEditor(null));
}
@Test
public void testSunnyDay() throws IOException {
void testSunnyDay() throws IOException {
InputStream stream = null;
try {
String resource = "classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) +
@ -62,14 +62,14 @@ public class InputStreamEditorTests { @@ -62,14 +62,14 @@ public class InputStreamEditorTests {
}
@Test
public void testWhenResourceDoesNotExist() {
void testWhenResourceDoesNotExist() {
InputStreamEditor editor = new InputStreamEditor();
assertThatIllegalArgumentException().isThrownBy(() ->
editor.setAsText("classpath:bingo!"));
}
@Test
public void testGetAsTextReturnsNullByDefault() {
void testGetAsTextReturnsNullByDefault() {
assertThat(new InputStreamEditor().getAsText()).isNull();
String resource = "classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) +
"/" + ClassUtils.getShortName(getClass()) + ".class";

20
spring-beans/src/test/java/org/springframework/beans/propertyeditors/PathEditorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException @@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Juergen Hoeller
* @since 4.3.2
*/
public class PathEditorTests {
class PathEditorTests {
@Test
public void testClasspathPathName() {
void testClasspathPathName() {
PropertyEditor pathEditor = new PathEditor();
pathEditor.setAsText("classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) + "/" +
ClassUtils.getShortName(getClass()) + ".class");
@ -45,14 +45,14 @@ public class PathEditorTests { @@ -45,14 +45,14 @@ public class PathEditorTests {
}
@Test
public void testWithNonExistentResource() {
void testWithNonExistentResource() {
PropertyEditor propertyEditor = new PathEditor();
assertThatIllegalArgumentException().isThrownBy(() ->
propertyEditor.setAsText("classpath:/no_way_this_file_is_found.doc"));
}
@Test
public void testWithNonExistentPath() {
void testWithNonExistentPath() {
PropertyEditor pathEditor = new PathEditor();
pathEditor.setAsText("file:/no_way_this_file_is_found.doc");
Object value = pathEditor.getValue();
@ -62,7 +62,7 @@ public class PathEditorTests { @@ -62,7 +62,7 @@ public class PathEditorTests {
}
@Test
public void testAbsolutePath() {
void testAbsolutePath() {
PropertyEditor pathEditor = new PathEditor();
pathEditor.setAsText("/no_way_this_file_is_found.doc");
Object value = pathEditor.getValue();
@ -72,7 +72,7 @@ public class PathEditorTests { @@ -72,7 +72,7 @@ public class PathEditorTests {
}
@Test
public void testWindowsAbsolutePath() {
void testWindowsAbsolutePath() {
PropertyEditor pathEditor = new PathEditor();
pathEditor.setAsText("C:\\no_way_this_file_is_found.doc");
Object value = pathEditor.getValue();
@ -82,7 +82,7 @@ public class PathEditorTests { @@ -82,7 +82,7 @@ public class PathEditorTests {
}
@Test
public void testWindowsAbsoluteFilePath() {
void testWindowsAbsoluteFilePath() {
PropertyEditor pathEditor = new PathEditor();
try {
pathEditor.setAsText("file://C:\\no_way_this_file_is_found.doc");
@ -99,7 +99,7 @@ public class PathEditorTests { @@ -99,7 +99,7 @@ public class PathEditorTests {
}
@Test
public void testUnqualifiedPathNameFound() {
void testUnqualifiedPathNameFound() {
PropertyEditor pathEditor = new PathEditor();
String fileName = ClassUtils.classPackageAsResourcePath(getClass()) + "/" +
ClassUtils.getShortName(getClass()) + ".class";
@ -117,7 +117,7 @@ public class PathEditorTests { @@ -117,7 +117,7 @@ public class PathEditorTests {
}
@Test
public void testUnqualifiedPathNameNotFound() {
void testUnqualifiedPathNameNotFound() {
PropertyEditor pathEditor = new PathEditor();
String fileName = ClassUtils.classPackageAsResourcePath(getClass()) + "/" +
ClassUtils.getShortName(getClass()) + ".clazz";

24
spring-beans/src/test/java/org/springframework/beans/propertyeditors/PropertiesEditorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -32,10 +32,10 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -32,10 +32,10 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Juergen Hoeller
* @author Rick Evans
*/
public class PropertiesEditorTests {
class PropertiesEditorTests {
@Test
public void oneProperty() {
void oneProperty() {
String s = "foo=bar";
PropertiesEditor pe= new PropertiesEditor();
pe.setAsText(s);
@ -45,7 +45,7 @@ public class PropertiesEditorTests { @@ -45,7 +45,7 @@ public class PropertiesEditorTests {
}
@Test
public void twoProperties() {
void twoProperties() {
String s = "foo=bar with whitespace\n" +
"me=mi";
PropertiesEditor pe= new PropertiesEditor();
@ -57,7 +57,7 @@ public class PropertiesEditorTests { @@ -57,7 +57,7 @@ public class PropertiesEditorTests {
}
@Test
public void handlesEqualsInValue() {
void handlesEqualsInValue() {
String s = """
foo=bar
me=mi
@ -72,7 +72,7 @@ public class PropertiesEditorTests { @@ -72,7 +72,7 @@ public class PropertiesEditorTests {
}
@Test
public void handlesEmptyProperty() {
void handlesEmptyProperty() {
String s = "foo=bar\nme=mi\nx=";
PropertiesEditor pe= new PropertiesEditor();
pe.setAsText(s);
@ -84,7 +84,7 @@ public class PropertiesEditorTests { @@ -84,7 +84,7 @@ public class PropertiesEditorTests {
}
@Test
public void handlesEmptyPropertyWithoutEquals() {
void handlesEmptyPropertyWithoutEquals() {
String s = "foo\nme=mi\nx=x";
PropertiesEditor pe= new PropertiesEditor();
pe.setAsText(s);
@ -98,7 +98,7 @@ public class PropertiesEditorTests { @@ -98,7 +98,7 @@ public class PropertiesEditorTests {
* Comments begin with #
*/
@Test
public void ignoresCommentLinesAndEmptyLines() {
void ignoresCommentLinesAndEmptyLines() {
String s = """
#Ignore this comment
foo=bar
@ -122,7 +122,7 @@ public class PropertiesEditorTests { @@ -122,7 +122,7 @@ public class PropertiesEditorTests {
* still ignored: The standard syntax doesn't allow this on JDK 1.3.
*/
@Test
public void ignoresLeadingSpacesAndTabs() {
void ignoresLeadingSpacesAndTabs() {
String s = " #Ignore this comment\n" +
"\t\tfoo=bar\n" +
"\t#Another comment more junk \n" +
@ -138,7 +138,7 @@ public class PropertiesEditorTests { @@ -138,7 +138,7 @@ public class PropertiesEditorTests {
}
@Test
public void nullValue() {
void nullValue() {
PropertiesEditor pe= new PropertiesEditor();
pe.setAsText(null);
Properties p = (Properties) pe.getValue();
@ -146,7 +146,7 @@ public class PropertiesEditorTests { @@ -146,7 +146,7 @@ public class PropertiesEditorTests {
}
@Test
public void emptyString() {
void emptyString() {
PropertiesEditor pe = new PropertiesEditor();
pe.setAsText("");
Properties p = (Properties) pe.getValue();
@ -154,7 +154,7 @@ public class PropertiesEditorTests { @@ -154,7 +154,7 @@ public class PropertiesEditorTests {
}
@Test
public void usingMapAsValueSource() {
void usingMapAsValueSource() {
Map<String, String> map = new HashMap<>();
map.put("one", "1");
map.put("two", "2");

12
spring-beans/src/test/java/org/springframework/beans/propertyeditors/ReaderEditorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -32,16 +32,16 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException @@ -32,16 +32,16 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Juergen Hoeller
* @since 4.2
*/
public class ReaderEditorTests {
class ReaderEditorTests {
@Test
public void testCtorWithNullResourceEditor() {
void testCtorWithNullResourceEditor() {
assertThatIllegalArgumentException().isThrownBy(() ->
new ReaderEditor(null));
}
@Test
public void testSunnyDay() throws IOException {
void testSunnyDay() throws IOException {
Reader reader = null;
try {
String resource = "classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) +
@ -62,7 +62,7 @@ public class ReaderEditorTests { @@ -62,7 +62,7 @@ public class ReaderEditorTests {
}
@Test
public void testWhenResourceDoesNotExist() {
void testWhenResourceDoesNotExist() {
String resource = "classpath:bingo!";
ReaderEditor editor = new ReaderEditor();
assertThatIllegalArgumentException().isThrownBy(() ->
@ -70,7 +70,7 @@ public class ReaderEditorTests { @@ -70,7 +70,7 @@ public class ReaderEditorTests {
}
@Test
public void testGetAsTextReturnsNullByDefault() {
void testGetAsTextReturnsNullByDefault() {
assertThat(new ReaderEditor().getAsText()).isNull();
String resource = "classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) +
"/" + ClassUtils.getShortName(getClass()) + ".class";

22
spring-beans/src/test/java/org/springframework/beans/propertyeditors/ResourceBundleEditorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -29,7 +29,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException @@ -29,7 +29,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Rick Evans
* @author Chris Beams
*/
public class ResourceBundleEditorTests {
class ResourceBundleEditorTests {
private static final String BASE_NAME = ResourceBundleEditorTests.class.getName();
@ -37,7 +37,7 @@ public class ResourceBundleEditorTests { @@ -37,7 +37,7 @@ public class ResourceBundleEditorTests {
@Test
public void testSetAsTextWithJustBaseName() {
void testSetAsTextWithJustBaseName() {
ResourceBundleEditor editor = new ResourceBundleEditor();
editor.setAsText(BASE_NAME);
Object value = editor.getValue();
@ -49,7 +49,7 @@ public class ResourceBundleEditorTests { @@ -49,7 +49,7 @@ public class ResourceBundleEditorTests {
}
@Test
public void testSetAsTextWithBaseNameThatEndsInDefaultSeparator() {
void testSetAsTextWithBaseNameThatEndsInDefaultSeparator() {
ResourceBundleEditor editor = new ResourceBundleEditor();
editor.setAsText(BASE_NAME + "_");
Object value = editor.getValue();
@ -61,7 +61,7 @@ public class ResourceBundleEditorTests { @@ -61,7 +61,7 @@ public class ResourceBundleEditorTests {
}
@Test
public void testSetAsTextWithBaseNameAndLanguageCode() {
void testSetAsTextWithBaseNameAndLanguageCode() {
ResourceBundleEditor editor = new ResourceBundleEditor();
editor.setAsText(BASE_NAME + "Lang" + "_en");
Object value = editor.getValue();
@ -73,7 +73,7 @@ public class ResourceBundleEditorTests { @@ -73,7 +73,7 @@ public class ResourceBundleEditorTests {
}
@Test
public void testSetAsTextWithBaseNameLanguageAndCountryCode() {
void testSetAsTextWithBaseNameLanguageAndCountryCode() {
ResourceBundleEditor editor = new ResourceBundleEditor();
editor.setAsText(BASE_NAME + "LangCountry" + "_en_GB");
Object value = editor.getValue();
@ -85,7 +85,7 @@ public class ResourceBundleEditorTests { @@ -85,7 +85,7 @@ public class ResourceBundleEditorTests {
}
@Test
public void testSetAsTextWithTheKitchenSink() {
void testSetAsTextWithTheKitchenSink() {
ResourceBundleEditor editor = new ResourceBundleEditor();
editor.setAsText(BASE_NAME + "LangCountryDialect" + "_en_GB_GLASGOW");
Object value = editor.getValue();
@ -97,28 +97,28 @@ public class ResourceBundleEditorTests { @@ -97,28 +97,28 @@ public class ResourceBundleEditorTests {
}
@Test
public void testSetAsTextWithNull() {
void testSetAsTextWithNull() {
ResourceBundleEditor editor = new ResourceBundleEditor();
assertThatIllegalArgumentException().isThrownBy(() ->
editor.setAsText(null));
}
@Test
public void testSetAsTextWithEmptyString() {
void testSetAsTextWithEmptyString() {
ResourceBundleEditor editor = new ResourceBundleEditor();
assertThatIllegalArgumentException().isThrownBy(() ->
editor.setAsText(""));
}
@Test
public void testSetAsTextWithWhiteSpaceString() {
void testSetAsTextWithWhiteSpaceString() {
ResourceBundleEditor editor = new ResourceBundleEditor();
assertThatIllegalArgumentException().isThrownBy(() ->
editor.setAsText(" "));
}
@Test
public void testSetAsTextWithJustSeparatorString() {
void testSetAsTextWithJustSeparatorString() {
ResourceBundleEditor editor = new ResourceBundleEditor();
assertThatIllegalArgumentException().isThrownBy(() ->
editor.setAsText("_"));

28
spring-beans/src/test/java/org/springframework/beans/propertyeditors/URIEditorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -29,30 +29,30 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -29,30 +29,30 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Juergen Hoeller
* @author Arjen Poutsma
*/
public class URIEditorTests {
class URIEditorTests {
@Test
public void standardURI() {
void standardURI() {
doTestURI("mailto:juergen.hoeller@interface21.com");
}
@Test
public void withNonExistentResource() {
void withNonExistentResource() {
doTestURI("gonna:/freak/in/the/morning/freak/in/the.evening");
}
@Test
public void standardURL() {
void standardURL() {
doTestURI("https://www.springframework.org");
}
@Test
public void standardURLWithFragment() {
void standardURLWithFragment() {
doTestURI("https://www.springframework.org#1");
}
@Test
public void standardURLWithWhitespace() {
void standardURLWithWhitespace() {
PropertyEditor uriEditor = new URIEditor();
uriEditor.setAsText(" https://www.springframework.org ");
Object value = uriEditor.getValue();
@ -62,7 +62,7 @@ public class URIEditorTests { @@ -62,7 +62,7 @@ public class URIEditorTests {
}
@Test
public void classpathURL() {
void classpathURL() {
PropertyEditor uriEditor = new URIEditor(getClass().getClassLoader());
uriEditor.setAsText("classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) +
"/" + ClassUtils.getShortName(getClass()) + ".class");
@ -74,7 +74,7 @@ public class URIEditorTests { @@ -74,7 +74,7 @@ public class URIEditorTests {
}
@Test
public void classpathURLWithWhitespace() {
void classpathURLWithWhitespace() {
PropertyEditor uriEditor = new URIEditor(getClass().getClassLoader());
uriEditor.setAsText(" classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) +
"/" + ClassUtils.getShortName(getClass()) + ".class ");
@ -86,7 +86,7 @@ public class URIEditorTests { @@ -86,7 +86,7 @@ public class URIEditorTests {
}
@Test
public void classpathURLAsIs() {
void classpathURLAsIs() {
PropertyEditor uriEditor = new URIEditor();
uriEditor.setAsText("classpath:test.txt");
Object value = uriEditor.getValue();
@ -97,7 +97,7 @@ public class URIEditorTests { @@ -97,7 +97,7 @@ public class URIEditorTests {
}
@Test
public void setAsTextWithNull() {
void setAsTextWithNull() {
PropertyEditor uriEditor = new URIEditor();
uriEditor.setAsText(null);
assertThat(uriEditor.getValue()).isNull();
@ -105,13 +105,13 @@ public class URIEditorTests { @@ -105,13 +105,13 @@ public class URIEditorTests {
}
@Test
public void getAsTextReturnsEmptyStringIfValueNotSet() {
void getAsTextReturnsEmptyStringIfValueNotSet() {
PropertyEditor uriEditor = new URIEditor();
assertThat(uriEditor.getAsText()).isEmpty();
}
@Test
public void encodeURI() {
void encodeURI() {
PropertyEditor uriEditor = new URIEditor();
uriEditor.setAsText("https://example.com/spaces and \u20AC");
Object value = uriEditor.getValue();
@ -122,7 +122,7 @@ public class URIEditorTests { @@ -122,7 +122,7 @@ public class URIEditorTests {
}
@Test
public void encodeAlreadyEncodedURI() {
void encodeAlreadyEncodedURI() {
PropertyEditor uriEditor = new URIEditor(false);
uriEditor.setAsText("https://example.com/spaces%20and%20%E2%82%AC");
Object value = uriEditor.getValue();

18
spring-beans/src/test/java/org/springframework/beans/propertyeditors/URLEditorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -30,16 +30,16 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException @@ -30,16 +30,16 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Rick Evans
* @author Chris Beams
*/
public class URLEditorTests {
class URLEditorTests {
@Test
public void testCtorWithNullResourceEditor() {
void testCtorWithNullResourceEditor() {
assertThatIllegalArgumentException().isThrownBy(() ->
new URLEditor(null));
}
@Test
public void testStandardURI() {
void testStandardURI() {
PropertyEditor urlEditor = new URLEditor();
urlEditor.setAsText("mailto:juergen.hoeller@interface21.com");
Object value = urlEditor.getValue();
@ -49,7 +49,7 @@ public class URLEditorTests { @@ -49,7 +49,7 @@ public class URLEditorTests {
}
@Test
public void testStandardURL() {
void testStandardURL() {
PropertyEditor urlEditor = new URLEditor();
urlEditor.setAsText("https://www.springframework.org");
Object value = urlEditor.getValue();
@ -59,7 +59,7 @@ public class URLEditorTests { @@ -59,7 +59,7 @@ public class URLEditorTests {
}
@Test
public void testClasspathURL() {
void testClasspathURL() {
PropertyEditor urlEditor = new URLEditor();
urlEditor.setAsText("classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) +
"/" + ClassUtils.getShortName(getClass()) + ".class");
@ -71,14 +71,14 @@ public class URLEditorTests { @@ -71,14 +71,14 @@ public class URLEditorTests {
}
@Test
public void testWithNonExistentResource() {
void testWithNonExistentResource() {
PropertyEditor urlEditor = new URLEditor();
assertThatIllegalArgumentException().isThrownBy(() ->
urlEditor.setAsText("gonna:/freak/in/the/morning/freak/in/the.evening"));
}
@Test
public void testSetAsTextWithNull() {
void testSetAsTextWithNull() {
PropertyEditor urlEditor = new URLEditor();
urlEditor.setAsText(null);
assertThat(urlEditor.getValue()).isNull();
@ -86,7 +86,7 @@ public class URLEditorTests { @@ -86,7 +86,7 @@ public class URLEditorTests {
}
@Test
public void testGetAsTextReturnsEmptyStringIfValueNotSet() {
void testGetAsTextReturnsEmptyStringIfValueNotSet() {
PropertyEditor urlEditor = new URLEditor();
assertThat(urlEditor.getAsText()).isEmpty();
}

4
spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Chris Beams
* @since 20.05.2003
*/
public class PagedListHolderTests {
class PagedListHolderTests {
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })

12
spring-beans/src/test/java/org/springframework/beans/support/PropertyComparatorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -28,10 +28,10 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -28,10 +28,10 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Keith Donald
* @author Chris Beams
*/
public class PropertyComparatorTests {
class PropertyComparatorTests {
@Test
public void testPropertyComparator() {
void testPropertyComparator() {
Dog dog = new Dog();
dog.setNickName("mace");
@ -45,7 +45,7 @@ public class PropertyComparatorTests { @@ -45,7 +45,7 @@ public class PropertyComparatorTests {
}
@Test
public void testPropertyComparatorNulls() {
void testPropertyComparatorNulls() {
Dog dog = new Dog();
Dog dog2 = new Dog();
PropertyComparator<Dog> c = new PropertyComparator<>("nickName", false, true);
@ -53,7 +53,7 @@ public class PropertyComparatorTests { @@ -53,7 +53,7 @@ public class PropertyComparatorTests {
}
@Test
public void testChainedComparators() {
void testChainedComparators() {
Comparator<Dog> c = new PropertyComparator<>("lastName", false, true);
Dog dog1 = new Dog();
@ -74,7 +74,7 @@ public class PropertyComparatorTests { @@ -74,7 +74,7 @@ public class PropertyComparatorTests {
}
@Test
public void testChainedComparatorsReversed() {
void testChainedComparatorsReversed() {
Comparator<Dog> c = (new PropertyComparator<Dog>("lastName", false, true)).
thenComparing(new PropertyComparator<>("firstName", false, true));

40
spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/beans/factory/StringFactoryBean.java

@ -0,0 +1,40 @@ @@ -0,0 +1,40 @@
/*
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.beans.testfixture.beans.factory;
import org.springframework.beans.factory.FactoryBean;
public class StringFactoryBean implements FactoryBean<String> {
@Override
public String getObject() {
return "";
}
@Override
public Class<String> getObjectType() {
return String.class;
}
@Override
public boolean isSingleton() {
return true;
}
}
Loading…
Cancel
Save