Search in sources :

Example 1 with AnnotatedGenericBeanDefinition

use of cn.taketoday.beans.factory.annotation.AnnotatedGenericBeanDefinition in project today-infrastructure by TAKETODAY.

the class AnnotationBeanNameGeneratorTests method generateBeanNameFromComposedControllerAnnotationWithBlankName.

@Test
public void generateBeanNameFromComposedControllerAnnotationWithBlankName() {
    // SPR-11360
    BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComposedControllerAnnotationWithBlankName.class);
    String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
    String expectedGeneratedBeanName = this.beanNameGenerator.buildDefaultBeanName(bd);
    assertThat(beanName).isEqualTo(expectedGeneratedBeanName);
}
Also used : SimpleBeanDefinitionRegistry(cn.taketoday.beans.factory.support.SimpleBeanDefinitionRegistry) AnnotatedBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedBeanDefinition) SimpleBeanDefinitionRegistry(cn.taketoday.beans.factory.support.SimpleBeanDefinitionRegistry) BeanDefinitionRegistry(cn.taketoday.beans.factory.support.BeanDefinitionRegistry) AnnotatedGenericBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedGenericBeanDefinition) Test(org.junit.jupiter.api.Test)

Example 2 with AnnotatedGenericBeanDefinition

use of cn.taketoday.beans.factory.annotation.AnnotatedGenericBeanDefinition in project today-infrastructure by TAKETODAY.

the class AnnotationBeanNameGeneratorTests method generateBeanNameWithNamedComponent.

@Test
public void generateBeanNameWithNamedComponent() {
    BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComponentWithName.class);
    String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
    assertThat(beanName).as("The generated beanName must *never* be null.").isNotNull();
    assertThat(StringUtils.hasText(beanName)).as("The generated beanName must *never* be blank.").isTrue();
    assertThat(beanName).isEqualTo("walden");
}
Also used : SimpleBeanDefinitionRegistry(cn.taketoday.beans.factory.support.SimpleBeanDefinitionRegistry) AnnotatedBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedBeanDefinition) SimpleBeanDefinitionRegistry(cn.taketoday.beans.factory.support.SimpleBeanDefinitionRegistry) BeanDefinitionRegistry(cn.taketoday.beans.factory.support.BeanDefinitionRegistry) AnnotatedGenericBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedGenericBeanDefinition) Test(org.junit.jupiter.api.Test)

Example 3 with AnnotatedGenericBeanDefinition

use of cn.taketoday.beans.factory.annotation.AnnotatedGenericBeanDefinition in project today-infrastructure by TAKETODAY.

the class AnnotationBeanNameGeneratorTests method generateBeanNameFromMetaComponentWithStringValue.

@Test
public void generateBeanNameFromMetaComponentWithStringValue() {
    BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComponentFromStringMeta.class);
    String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
    assertThat(beanName).isEqualTo("henry");
}
Also used : SimpleBeanDefinitionRegistry(cn.taketoday.beans.factory.support.SimpleBeanDefinitionRegistry) AnnotatedBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedBeanDefinition) SimpleBeanDefinitionRegistry(cn.taketoday.beans.factory.support.SimpleBeanDefinitionRegistry) BeanDefinitionRegistry(cn.taketoday.beans.factory.support.BeanDefinitionRegistry) AnnotatedGenericBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedGenericBeanDefinition) Test(org.junit.jupiter.api.Test)

Example 4 with AnnotatedGenericBeanDefinition

use of cn.taketoday.beans.factory.annotation.AnnotatedGenericBeanDefinition in project today-infrastructure by TAKETODAY.

the class AnnotationScopeMetadataResolverTests method resolveScopeMetadataShouldApplyScopedProxyModeToPrototype.

@Test
public void resolveScopeMetadataShouldApplyScopedProxyModeToPrototype() {
    this.scopeMetadataResolver = new AnnotationScopeMetadataResolver(INTERFACES);
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnnotatedWithPrototypeScope.class);
    ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
    Assertions.assertThat(scopeMetadata).as("resolveScopeMetadata(..) must *never* return null.").isNotNull();
    Assertions.assertThat(scopeMetadata.getScopeName()).isEqualTo(BeanDefinition.SCOPE_PROTOTYPE);
    Assertions.assertThat(scopeMetadata.getScopedProxyMode()).isEqualTo(INTERFACES);
}
Also used : AnnotatedBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedBeanDefinition) ScopeMetadata(cn.taketoday.context.loader.ScopeMetadata) AnnotatedGenericBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedGenericBeanDefinition) Test(org.junit.jupiter.api.Test)

Example 5 with AnnotatedGenericBeanDefinition

use of cn.taketoday.beans.factory.annotation.AnnotatedGenericBeanDefinition in project today-infrastructure by TAKETODAY.

the class AnnotationScopeMetadataResolverTests method customRequestScope.

@Test
public void customRequestScope() {
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnnotatedWithCustomRequestScope.class);
    ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
    Assertions.assertThat(scopeMetadata).as("resolveScopeMetadata(..) must *never* return null.").isNotNull();
    Assertions.assertThat(scopeMetadata.getScopeName()).isEqualTo("request");
    Assertions.assertThat(scopeMetadata.getScopedProxyMode()).isEqualTo(NO);
}
Also used : AnnotatedBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedBeanDefinition) ScopeMetadata(cn.taketoday.context.loader.ScopeMetadata) AnnotatedGenericBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedGenericBeanDefinition) Test(org.junit.jupiter.api.Test)

Aggregations

AnnotatedGenericBeanDefinition (cn.taketoday.beans.factory.annotation.AnnotatedGenericBeanDefinition)45 AnnotatedBeanDefinition (cn.taketoday.beans.factory.annotation.AnnotatedBeanDefinition)41 Test (org.junit.jupiter.api.Test)41 BeanDefinitionRegistry (cn.taketoday.beans.factory.support.BeanDefinitionRegistry)27 SimpleBeanDefinitionRegistry (cn.taketoday.beans.factory.support.SimpleBeanDefinitionRegistry)18 ScopeMetadata (cn.taketoday.context.loader.ScopeMetadata)16 DefaultBeanDefinitionRegistry (cn.taketoday.beans.factory.support.DefaultBeanDefinitionRegistry)9 MetadataReader (cn.taketoday.core.type.classreading.MetadataReader)6 MetadataReaderFactory (cn.taketoday.core.type.classreading.MetadataReaderFactory)6 SimpleMetadataReaderFactory (cn.taketoday.core.type.classreading.SimpleMetadataReaderFactory)4 BeanDefinitionHolder (cn.taketoday.beans.factory.config.BeanDefinitionHolder)2 AutowireCandidateQualifier (cn.taketoday.beans.factory.support.AutowireCandidateQualifier)2 AnnotationMetadata (cn.taketoday.core.type.AnnotationMetadata)2