Search in sources :

Example 1 with DefaultBeanDefinitionRegistry

use of cn.taketoday.beans.factory.support.DefaultBeanDefinitionRegistry in project today-framework by TAKETODAY.

the class AnnotationBeanNamePopulatorTests method generateBeanNameWithAnonymousComponentYieldsGeneratedBeanName.

@Test
public void generateBeanNameWithAnonymousComponentYieldsGeneratedBeanName() {
    BeanDefinitionRegistry registry = new DefaultBeanDefinitionRegistry();
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnonymousComponent.class);
    String beanName = this.beanNamePopulator.populateName(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();
    String expectedGeneratedBeanName = this.beanNamePopulator.buildDefaultBeanName(bd);
    assertThat(beanName).isEqualTo(expectedGeneratedBeanName);
}
Also used : AnnotatedBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedBeanDefinition) DefaultBeanDefinitionRegistry(cn.taketoday.beans.factory.support.DefaultBeanDefinitionRegistry) DefaultBeanDefinitionRegistry(cn.taketoday.beans.factory.support.DefaultBeanDefinitionRegistry) BeanDefinitionRegistry(cn.taketoday.beans.factory.support.BeanDefinitionRegistry) AnnotatedGenericBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedGenericBeanDefinition) Test(org.junit.jupiter.api.Test)

Example 2 with DefaultBeanDefinitionRegistry

use of cn.taketoday.beans.factory.support.DefaultBeanDefinitionRegistry in project today-framework by TAKETODAY.

the class AnnotationBeanNamePopulatorTests method generateBeanNameFromComposedControllerAnnotationWithBlankName.

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

Example 3 with DefaultBeanDefinitionRegistry

use of cn.taketoday.beans.factory.support.DefaultBeanDefinitionRegistry in project today-framework by TAKETODAY.

the class AnnotationBeanNamePopulatorTests method generateBeanNameWithNamedComponent.

@Test
public void generateBeanNameWithNamedComponent() {
    BeanDefinitionRegistry registry = new DefaultBeanDefinitionRegistry();
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComponentWithName.class);
    String beanName = this.beanNamePopulator.populateName(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 : AnnotatedBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedBeanDefinition) DefaultBeanDefinitionRegistry(cn.taketoday.beans.factory.support.DefaultBeanDefinitionRegistry) DefaultBeanDefinitionRegistry(cn.taketoday.beans.factory.support.DefaultBeanDefinitionRegistry) BeanDefinitionRegistry(cn.taketoday.beans.factory.support.BeanDefinitionRegistry) AnnotatedGenericBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedGenericBeanDefinition) Test(org.junit.jupiter.api.Test)

Example 4 with DefaultBeanDefinitionRegistry

use of cn.taketoday.beans.factory.support.DefaultBeanDefinitionRegistry in project today-framework by TAKETODAY.

the class AnnotationBeanNamePopulatorTests method generateBeanNameWithDefaultNamedComponent.

@Test
public void generateBeanNameWithDefaultNamedComponent() {
    BeanDefinitionRegistry registry = new DefaultBeanDefinitionRegistry();
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(DefaultNamedComponent.class);
    String beanName = this.beanNamePopulator.populateName(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("thoreau");
}
Also used : AnnotatedBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedBeanDefinition) DefaultBeanDefinitionRegistry(cn.taketoday.beans.factory.support.DefaultBeanDefinitionRegistry) DefaultBeanDefinitionRegistry(cn.taketoday.beans.factory.support.DefaultBeanDefinitionRegistry) BeanDefinitionRegistry(cn.taketoday.beans.factory.support.BeanDefinitionRegistry) AnnotatedGenericBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedGenericBeanDefinition) Test(org.junit.jupiter.api.Test)

Example 5 with DefaultBeanDefinitionRegistry

use of cn.taketoday.beans.factory.support.DefaultBeanDefinitionRegistry in project today-framework by TAKETODAY.

the class AnnotationBeanNamePopulatorTests method generateBeanNameFromComposedControllerAnnotationWithoutName.

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

Aggregations

AnnotatedBeanDefinition (cn.taketoday.beans.factory.annotation.AnnotatedBeanDefinition)9 AnnotatedGenericBeanDefinition (cn.taketoday.beans.factory.annotation.AnnotatedGenericBeanDefinition)9 BeanDefinitionRegistry (cn.taketoday.beans.factory.support.BeanDefinitionRegistry)9 DefaultBeanDefinitionRegistry (cn.taketoday.beans.factory.support.DefaultBeanDefinitionRegistry)9 Test (org.junit.jupiter.api.Test)9