@@ -2023,6 +2023,30 @@ public void testAvoidCircularReferenceThroughAutowiring() {
2023
2023
lbf .preInstantiateSingletons ();
2024
2024
}
2025
2025
2026
+ @ Test
2027
+ public void testConstructorDependencyWithClassResolution () {
2028
+ DefaultListableBeanFactory lbf = new DefaultListableBeanFactory ();
2029
+ RootBeanDefinition bd = new RootBeanDefinition (ConstructorDependencyWithClassResolution .class );
2030
+ bd .getConstructorArgumentValues ().addGenericArgumentValue ("java.lang.String" );
2031
+ lbf .registerBeanDefinition ("test" , bd );
2032
+ lbf .preInstantiateSingletons ();
2033
+ }
2034
+
2035
+ @ Test
2036
+ public void testConstructorDependencyWithUnresolvableClass () {
2037
+ DefaultListableBeanFactory lbf = new DefaultListableBeanFactory ();
2038
+ RootBeanDefinition bd = new RootBeanDefinition (ConstructorDependencyWithClassResolution .class );
2039
+ bd .getConstructorArgumentValues ().addGenericArgumentValue ("java.lang.Strin" );
2040
+ lbf .registerBeanDefinition ("test" , bd );
2041
+ try {
2042
+ lbf .preInstantiateSingletons ();
2043
+ fail ("Should have thrown UnsatisfiedDependencyException" );
2044
+ }
2045
+ catch (UnsatisfiedDependencyException expected ) {
2046
+ assertTrue (expected .toString ().contains ("java.lang.Strin" ));
2047
+ }
2048
+ }
2049
+
2026
2050
@ Test
2027
2051
public void testBeanDefinitionWithInterface () {
2028
2052
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory ();
@@ -2033,7 +2057,7 @@ public void testBeanDefinitionWithInterface() {
2033
2057
}
2034
2058
catch (BeanCreationException ex ) {
2035
2059
assertEquals ("test" , ex .getBeanName ());
2036
- assertTrue (ex .getMessage ().toLowerCase ().indexOf ("interface" ) != - 1 );
2060
+ assertTrue (ex .getMessage ().toLowerCase ().contains ("interface" ));
2037
2061
}
2038
2062
}
2039
2063
@@ -2047,7 +2071,7 @@ public void testBeanDefinitionWithAbstractClass() {
2047
2071
}
2048
2072
catch (BeanCreationException ex ) {
2049
2073
assertEquals ("test" , ex .getBeanName ());
2050
- assertTrue (ex .getMessage ().toLowerCase ().indexOf ("abstract" ) != - 1 );
2074
+ assertTrue (ex .getMessage ().toLowerCase ().contains ("abstract" ));
2051
2075
}
2052
2076
}
2053
2077
@@ -2739,6 +2763,16 @@ public boolean isSingleton() {
2739
2763
}
2740
2764
2741
2765
2766
+ public static class ConstructorDependencyWithClassResolution {
2767
+
2768
+ public ConstructorDependencyWithClassResolution (Class <?> clazz ) {
2769
+ }
2770
+
2771
+ public ConstructorDependencyWithClassResolution () {
2772
+ }
2773
+ }
2774
+
2775
+
2742
2776
public static class BeanWithDisposableBean implements DisposableBean {
2743
2777
2744
2778
private static boolean closed ;
0 commit comments