Further tests for getBeanNamesForType(ResolvableType)
Issue: SPR-14097
This commit is contained in:
parent
8bfba6a07a
commit
edea66a967
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2015 the original author or authors.
|
* Copyright 2002-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -109,6 +109,7 @@ public interface ListableBeanFactory extends BeanFactory {
|
||||||
* @return the names of beans (or objects created by FactoryBeans) matching
|
* @return the names of beans (or objects created by FactoryBeans) matching
|
||||||
* the given object type (including subclasses), or an empty array if none
|
* the given object type (including subclasses), or an empty array if none
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
|
* @see #isTypeMatch(String, ResolvableType)
|
||||||
* @see FactoryBean#getObjectType
|
* @see FactoryBean#getObjectType
|
||||||
* @see BeanFactoryUtils#beanNamesForTypeIncludingAncestors(ListableBeanFactory, ResolvableType)
|
* @see BeanFactoryUtils#beanNamesForTypeIncludingAncestors(ListableBeanFactory, ResolvableType)
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||||
import org.springframework.beans.factory.support.GenericBeanDefinition;
|
import org.springframework.beans.factory.support.GenericBeanDefinition;
|
||||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
|
import org.springframework.core.ResolvableType;
|
||||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.tests.sample.beans.ITestBean;
|
import org.springframework.tests.sample.beans.ITestBean;
|
||||||
|
|
@ -1633,6 +1634,8 @@ public class AutowiredAnnotationBeanPostProcessorTests {
|
||||||
assertSame(1, bean.stringRepositoryMap.size());
|
assertSame(1, bean.stringRepositoryMap.size());
|
||||||
assertSame(repo, bean.repositoryMap.get("repo"));
|
assertSame(repo, bean.repositoryMap.get("repo"));
|
||||||
assertSame(repo, bean.stringRepositoryMap.get("repo"));
|
assertSame(repo, bean.stringRepositoryMap.get("repo"));
|
||||||
|
|
||||||
|
assertArrayEquals(new String[] {"repo"}, bf.getBeanNamesForType(ResolvableType.forClassWithGenerics(Repository.class, String.class)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -2018,6 +2021,9 @@ public class AutowiredAnnotationBeanPostProcessorTests {
|
||||||
GenericInterface1Impl bean1 = (GenericInterface1Impl) bf.getBean("bean1");
|
GenericInterface1Impl bean1 = (GenericInterface1Impl) bf.getBean("bean1");
|
||||||
GenericInterface2Impl bean2 = (GenericInterface2Impl) bf.getBean("bean2");
|
GenericInterface2Impl bean2 = (GenericInterface2Impl) bf.getBean("bean2");
|
||||||
assertSame(bean2, bean1.gi2);
|
assertSame(bean2, bean1.gi2);
|
||||||
|
|
||||||
|
assertArrayEquals(new String[] {"bean1"}, bf.getBeanNamesForType(ResolvableType.forClassWithGenerics(GenericInterface1.class, String.class)));
|
||||||
|
assertArrayEquals(new String[] {"bean2"}, bf.getBeanNamesForType(ResolvableType.forClassWithGenerics(GenericInterface2.class, String.class)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -3076,7 +3082,7 @@ public class AutowiredAnnotationBeanPostProcessorTests {
|
||||||
|
|
||||||
public interface GenericInterface1<T> {
|
public interface GenericInterface1<T> {
|
||||||
|
|
||||||
public String doSomethingGeneric(T o);
|
String doSomethingGeneric(T o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue