Skip to content

Commit

Permalink
Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
snicoll committed Aug 3, 2023
1 parent eed1421 commit edb8a05
Showing 1 changed file with 28 additions and 0 deletions.
Expand Up @@ -2032,6 +2032,16 @@ void getBeanNamesForTypeWithPrototypeScopedFactoryBean() {
assertBeanNamesForType(FactoryBean.class, false, false);
}

@Test // gh-xxxx
void getBeanNamesForTypeWithFactoryBeanDefinedAsTargetType() {
RootBeanDefinition beanDefinition = new RootBeanDefinition(TestRepositoryFactoryBean.class);
beanDefinition.setTargetType(ResolvableType.forClassWithGenerics(TestRepositoryFactoryBean.class,
CityRepository.class, Object.class, Object.class));
lbf.registerBeanDefinition("factoryBean", beanDefinition);
assertBeanNamesForType(TestRepositoryFactoryBean.class, true, false, "&factoryBean");
assertBeanNamesForType(CityRepository.class, true, false, "factoryBean");
}

/**
* Verifies that a dependency on a {@link FactoryBean} can <strong>not</strong>
* be autowired <em>by name</em>, as &amp; is an illegal character in
Expand Down Expand Up @@ -3119,6 +3129,24 @@ public T call() {
}
}

public static class TestRepositoryFactoryBean<T extends Repository<S, ID>, S, ID extends Serializable>
extends RepositoryFactoryBeanSupport<T, S, ID> {


@Override
public T getObject() throws Exception {
throw new IllegalArgumentException("Should not be called");
}

@Override
public Class<?> getObjectType() {
throw new IllegalArgumentException("Should not be called");
}
}

public record City(String name) {}

public static class CityRepository implements Repository<City, Long> {}

public static class LazyInitFactory implements FactoryBean<Object> {

Expand Down

0 comments on commit edb8a05

Please sign in to comment.