@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2019 the original author or authors .
* Copyright 2002 - 202 1 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 @@ public class LookupMethodTests {
@@ -36,7 +36,7 @@ public class LookupMethodTests {
@BeforeEach
public void setU p ( ) {
public void setu p ( ) {
beanFactory = new DefaultListableBeanFactory ( ) ;
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader ( beanFactory ) ;
reader . loadBeanDefinitions ( new ClassPathResource ( "lookupMethodTests.xml" , getClass ( ) ) ) ;
@ -83,8 +83,8 @@ public class LookupMethodTests {
@@ -83,8 +83,8 @@ public class LookupMethodTests {
public void testWithThreeArgsShouldFail ( ) {
AbstractBean bean = ( AbstractBean ) beanFactory . getBean ( "abstractBean" ) ;
assertThat ( bean ) . isNotNull ( ) ;
assertThatExceptionOfType ( AbstractMethodError . class ) . as ( "does not have a three arg constructor" ) . isThrownBy ( ( ) - >
bean . getThreeArguments ( "name" , 1 , 2 ) ) ;
assertThatExceptionOfType ( AbstractMethodError . class ) . as ( "does not have a three arg constructor" )
. isThrownBy ( ( ) - > bean . getThreeArguments ( "name" , 1 , 2 ) ) ;
}
@Test
@ -97,6 +97,21 @@ public class LookupMethodTests {
@@ -97,6 +97,21 @@ public class LookupMethodTests {
assertThat ( expected . isJedi ( ) ) . isTrue ( ) ;
}
@Test
public void testWithGenericBean ( ) {
RootBeanDefinition bd = new RootBeanDefinition ( NumberBean . class ) ;
bd . getMethodOverrides ( ) . addOverride ( new LookupOverride ( "getDoubleStore" , null ) ) ;
bd . getMethodOverrides ( ) . addOverride ( new LookupOverride ( "getFloatStore" , null ) ) ;
beanFactory . registerBeanDefinition ( "numberBean" , bd ) ;
beanFactory . registerBeanDefinition ( "doubleStore" , new RootBeanDefinition ( DoubleStore . class ) ) ;
beanFactory . registerBeanDefinition ( "floatStore" , new RootBeanDefinition ( FloatStore . class ) ) ;
NumberBean bean = ( NumberBean ) beanFactory . getBean ( "numberBean" ) ;
assertThat ( bean ) . isNotNull ( ) ;
assertThat ( beanFactory . getBean ( DoubleStore . class ) ) . isSameAs ( bean . getDoubleStore ( ) ) ;
assertThat ( beanFactory . getBean ( FloatStore . class ) ) . isSameAs ( bean . getFloatStore ( ) ) ;
}
public static abstract class AbstractBean {
@ -111,4 +126,24 @@ public class LookupMethodTests {
@@ -111,4 +126,24 @@ public class LookupMethodTests {
public abstract TestBean getThreeArguments ( String name , int age , int anotherArg ) ;
}
public static class NumberStore < T extends Number > {
}
public static class DoubleStore extends NumberStore < Double > {
}
public static class FloatStore extends NumberStore < Float > {
}
public static abstract class NumberBean {
public abstract NumberStore < Double > getDoubleStore ( ) ;
public abstract NumberStore < Float > getFloatStore ( ) ;
}
}