Search in sources :

Example 1 with DefaultBeanNameGenerator

use of org.springframework.beans.factory.support.DefaultBeanNameGenerator in project spring-boot by spring-projects.

the class SpringApplicationTests method customBeanNameGenerator.

@Test
void customBeanNameGenerator() {
    TestSpringApplication application = new TestSpringApplication(ExampleWebConfig.class);
    BeanNameGenerator beanNameGenerator = new DefaultBeanNameGenerator();
    application.setBeanNameGenerator(beanNameGenerator);
    this.context = application.run();
    then(application.getLoader()).should().setBeanNameGenerator(beanNameGenerator);
    Object actualGenerator = this.context.getBean(AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR);
    assertThat(actualGenerator).isSameAs(beanNameGenerator);
}
Also used : BeanNameGenerator(org.springframework.beans.factory.support.BeanNameGenerator) DefaultBeanNameGenerator(org.springframework.beans.factory.support.DefaultBeanNameGenerator) DefaultBeanNameGenerator(org.springframework.beans.factory.support.DefaultBeanNameGenerator) Test(org.junit.jupiter.api.Test)

Example 2 with DefaultBeanNameGenerator

use of org.springframework.beans.factory.support.DefaultBeanNameGenerator in project spring-boot by spring-projects.

the class SpringApplicationTests method customBeanNameGeneratorWithNonWebApplication.

@Test
void customBeanNameGeneratorWithNonWebApplication() {
    TestSpringApplication application = new TestSpringApplication(ExampleWebConfig.class);
    application.setWebApplicationType(WebApplicationType.NONE);
    BeanNameGenerator beanNameGenerator = new DefaultBeanNameGenerator();
    application.setBeanNameGenerator(beanNameGenerator);
    this.context = application.run();
    then(application.getLoader()).should().setBeanNameGenerator(beanNameGenerator);
    Object actualGenerator = this.context.getBean(AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR);
    assertThat(actualGenerator).isSameAs(beanNameGenerator);
}
Also used : BeanNameGenerator(org.springframework.beans.factory.support.BeanNameGenerator) DefaultBeanNameGenerator(org.springframework.beans.factory.support.DefaultBeanNameGenerator) DefaultBeanNameGenerator(org.springframework.beans.factory.support.DefaultBeanNameGenerator) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 BeanNameGenerator (org.springframework.beans.factory.support.BeanNameGenerator)2 DefaultBeanNameGenerator (org.springframework.beans.factory.support.DefaultBeanNameGenerator)2