Search in sources :

Example 1 with SimpleBeanDefinitionRegistry

use of cn.taketoday.beans.factory.support.SimpleBeanDefinitionRegistry 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 SimpleBeanDefinitionRegistry

use of cn.taketoday.beans.factory.support.SimpleBeanDefinitionRegistry 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 SimpleBeanDefinitionRegistry

use of cn.taketoday.beans.factory.support.SimpleBeanDefinitionRegistry 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 SimpleBeanDefinitionRegistry

use of cn.taketoday.beans.factory.support.SimpleBeanDefinitionRegistry in project today-infrastructure by TAKETODAY.

the class XmlBeanDefinitionReaderTests method withOpenInputStream.

@Test
public void withOpenInputStream() {
    SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    Resource resource = new InputStreamResource(getClass().getResourceAsStream("test.xml"));
    assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() -> new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource));
}
Also used : SimpleBeanDefinitionRegistry(cn.taketoday.beans.factory.support.SimpleBeanDefinitionRegistry) BeanDefinitionStoreException(cn.taketoday.beans.factory.BeanDefinitionStoreException) Resource(cn.taketoday.core.io.Resource) ClassPathResource(cn.taketoday.core.io.ClassPathResource) InputStreamResource(cn.taketoday.core.io.InputStreamResource) InputStreamResource(cn.taketoday.core.io.InputStreamResource) Test(org.junit.jupiter.api.Test)

Example 5 with SimpleBeanDefinitionRegistry

use of cn.taketoday.beans.factory.support.SimpleBeanDefinitionRegistry in project today-infrastructure by TAKETODAY.

the class XmlBeanDefinitionReaderTests method withImport.

@Test
public void withImport() {
    SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    Resource resource = new ClassPathResource("import.xml", getClass());
    new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
    testBeanDefinitions(registry);
}
Also used : SimpleBeanDefinitionRegistry(cn.taketoday.beans.factory.support.SimpleBeanDefinitionRegistry) Resource(cn.taketoday.core.io.Resource) ClassPathResource(cn.taketoday.core.io.ClassPathResource) InputStreamResource(cn.taketoday.core.io.InputStreamResource) ClassPathResource(cn.taketoday.core.io.ClassPathResource) Test(org.junit.jupiter.api.Test)

Aggregations

SimpleBeanDefinitionRegistry (cn.taketoday.beans.factory.support.SimpleBeanDefinitionRegistry)34 Test (org.junit.jupiter.api.Test)34 AnnotatedBeanDefinition (cn.taketoday.beans.factory.annotation.AnnotatedBeanDefinition)18 AnnotatedGenericBeanDefinition (cn.taketoday.beans.factory.annotation.AnnotatedGenericBeanDefinition)18 BeanDefinitionRegistry (cn.taketoday.beans.factory.support.BeanDefinitionRegistry)18 ClassPathResource (cn.taketoday.core.io.ClassPathResource)10 InputStreamResource (cn.taketoday.core.io.InputStreamResource)10 Resource (cn.taketoday.core.io.Resource)10 BeanDefinitionStoreException (cn.taketoday.beans.factory.BeanDefinitionStoreException)4 InputSource (org.xml.sax.InputSource)4