use of org.springframework.beans.factory.support.RegisteredBean in project spring-framework by spring-projects.
the class AutowiredMethodArgumentsResolverTests method resolveRequiredWithSingleDependencyReturnsValue.
@Test
void resolveRequiredWithSingleDependencyReturnsValue() {
this.beanFactory.registerSingleton("test", "testValue");
RegisteredBean registeredBean = registerTestBean(this.beanFactory);
AutowiredMethodArgumentsResolver resolver = AutowiredMethodArgumentsResolver.forRequiredMethod("injectString", String.class);
AutowiredArguments resolved = resolver.resolve(registeredBean);
assertThat(resolved.toArray()).containsExactly("testValue");
}
use of org.springframework.beans.factory.support.RegisteredBean in project spring-framework by spring-projects.
the class AutowiredMethodArgumentsResolverTests method resolveNonRequiredWhenNoSuchBeanReturnsNull.
@Test
void resolveNonRequiredWhenNoSuchBeanReturnsNull() {
RegisteredBean registeredBean = registerTestBean(this.beanFactory);
AutowiredMethodArgumentsResolver resolver = AutowiredMethodArgumentsResolver.forMethod("injectString", String.class);
assertThat(resolver.resolve(registeredBean)).isNull();
}
use of org.springframework.beans.factory.support.RegisteredBean in project spring-framework by spring-projects.
the class BeanDefinitionMethodGeneratorFactoryTests method getBeanDefinitionMethodGeneratorWhenRegisteredBeanIsAotProcessorAndFilteresBeanBeanRegistrationExcludeFilterDoesNotFilterBean.
@Test
void getBeanDefinitionMethodGeneratorWhenRegisteredBeanIsAotProcessorAndFilteresBeanBeanRegistrationExcludeFilterDoesNotFilterBean() {
MockSpringFactoriesLoader springFactoriesLoader = new MockSpringFactoriesLoader();
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
beanFactory.registerBeanDefinition("test", BeanDefinitionBuilder.rootBeanDefinition(TestBeanRegistrationAotProcessorAndFilterBean.class).getBeanDefinition());
RegisteredBean registeredBean1 = RegisteredBean.of(beanFactory, "test");
BeanDefinitionMethodGeneratorFactory methodGeneratorFactory = new BeanDefinitionMethodGeneratorFactory(new AotFactoriesLoader(beanFactory, springFactoriesLoader));
assertThat(methodGeneratorFactory.getBeanDefinitionMethodGenerator(registeredBean1, null)).isNotNull();
}
use of org.springframework.beans.factory.support.RegisteredBean in project spring-framework by spring-projects.
the class BeanDefinitionMethodGeneratorFactoryTests method getBeanDefinitionMethodGeneratorAddsContributionsFromProcessors.
@Test
void getBeanDefinitionMethodGeneratorAddsContributionsFromProcessors() {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
BeanRegistrationAotContribution beanContribution = mock(BeanRegistrationAotContribution.class);
BeanRegistrationAotProcessor processorBean = registeredBean -> beanContribution;
beanFactory.registerSingleton("processorBean", processorBean);
MockSpringFactoriesLoader springFactoriesLoader = new MockSpringFactoriesLoader();
BeanRegistrationAotContribution loaderContribution = mock(BeanRegistrationAotContribution.class);
BeanRegistrationAotProcessor loaderProcessor = registeredBean -> loaderContribution;
springFactoriesLoader.addInstance(BeanRegistrationAotProcessor.class, loaderProcessor);
RegisteredBean registeredBean = registerTestBean(beanFactory);
BeanDefinitionMethodGeneratorFactory methodGeneratorFactory = new BeanDefinitionMethodGeneratorFactory(new AotFactoriesLoader(beanFactory, springFactoriesLoader));
BeanDefinitionMethodGenerator methodGenerator = methodGeneratorFactory.getBeanDefinitionMethodGenerator(registeredBean, null);
assertThat(methodGenerator).extracting("aotContributions").asList().containsExactly(beanContribution, loaderContribution);
}
use of org.springframework.beans.factory.support.RegisteredBean in project spring-framework by spring-projects.
the class BeanDefinitionMethodGeneratorFactoryTests method getBeanDefinitionMethodGeneratorWhenExcludedByBeanRegistrationExcludeFilterBeanReturnsNull.
@Test
void getBeanDefinitionMethodGeneratorWhenExcludedByBeanRegistrationExcludeFilterBeanReturnsNull() {
MockSpringFactoriesLoader springFactoriesLoader = new MockSpringFactoriesLoader();
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
RegisteredBean registeredBean = registerTestBean(beanFactory);
beanFactory.registerSingleton("filter", new MockBeanRegistrationExcludeFilter(true, 0));
BeanDefinitionMethodGeneratorFactory methodGeneratorFactory = new BeanDefinitionMethodGeneratorFactory(new AotFactoriesLoader(beanFactory, springFactoriesLoader));
assertThat(methodGeneratorFactory.getBeanDefinitionMethodGenerator(registeredBean, null)).isNull();
}
Aggregations