Search in sources :

Example 6 with SimpleBeanDefinitionRegistry

use of org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry in project spring-framework by spring-projects.

the class AnnotationBeanNameGeneratorTests method generateBeanNameWithNamedComponentWhereTheNameIsBlank.

@Test
public void generateBeanNameWithNamedComponentWhereTheNameIsBlank() {
    BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComponentWithBlankName.class);
    String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
    assertNotNull("The generated beanName must *never* be null.", beanName);
    assertTrue("The generated beanName must *never* be blank.", StringUtils.hasText(beanName));
    String expectedGeneratedBeanName = this.beanNameGenerator.buildDefaultBeanName(bd);
    assertEquals(expectedGeneratedBeanName, beanName);
}
Also used : SimpleBeanDefinitionRegistry(org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry) AnnotatedBeanDefinition(org.springframework.beans.factory.annotation.AnnotatedBeanDefinition) SimpleBeanDefinitionRegistry(org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry) BeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry) AnnotatedGenericBeanDefinition(org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition) Test(org.junit.Test)

Example 7 with SimpleBeanDefinitionRegistry

use of org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry in project spring-framework by spring-projects.

the class AnnotationBeanNameGeneratorTests method generateBeanNameFromComposedControllerAnnotationWithStringValue.

/**
	 * @since 4.0.1
	 * @see https://jira.spring.io/browse/SPR-11360
	 */
@Test
public void generateBeanNameFromComposedControllerAnnotationWithStringValue() {
    BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComposedControllerAnnotationWithStringValue.class);
    String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
    assertEquals("restController", beanName);
}
Also used : SimpleBeanDefinitionRegistry(org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry) AnnotatedBeanDefinition(org.springframework.beans.factory.annotation.AnnotatedBeanDefinition) SimpleBeanDefinitionRegistry(org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry) BeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry) AnnotatedGenericBeanDefinition(org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition) Test(org.junit.Test)

Example 8 with SimpleBeanDefinitionRegistry

use of org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry in project spring-security by spring-projects.

the class MessageSecurityPostProcessorTest method handlesBeansWithoutClass.

@Test
public void handlesBeansWithoutClass() {
    BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    registry.registerBeanDefinition("beanWithoutClass", new GenericBeanDefinition());
    postProcessor.postProcessBeanDefinitionRegistry(registry);
}
Also used : SimpleBeanDefinitionRegistry(org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry) GenericBeanDefinition(org.springframework.beans.factory.support.GenericBeanDefinition) SimpleBeanDefinitionRegistry(org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry) BeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry) Test(org.junit.Test)

Example 9 with SimpleBeanDefinitionRegistry

use of org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry in project spring-framework by spring-projects.

the class XmlBeanDefinitionReaderTests method setParserClassToNull.

@Test(expected = IllegalArgumentException.class)
public void setParserClassToNull() {
    SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    new XmlBeanDefinitionReader(registry).setDocumentReaderClass(null);
}
Also used : SimpleBeanDefinitionRegistry(org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry) Test(org.junit.Test)

Example 10 with SimpleBeanDefinitionRegistry

use of org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry in project spring-framework by spring-projects.

the class XmlBeanDefinitionReaderTests method withWildcardImport.

@Test
public void withWildcardImport() {
    SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    Resource resource = new ClassPathResource("importPattern.xml", getClass());
    new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
    testBeanDefinitions(registry);
}
Also used : SimpleBeanDefinitionRegistry(org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry) ClassPathResource(org.springframework.core.io.ClassPathResource) InputStreamResource(org.springframework.core.io.InputStreamResource) Resource(org.springframework.core.io.Resource) ClassPathResource(org.springframework.core.io.ClassPathResource) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)20 SimpleBeanDefinitionRegistry (org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry)20 BeanDefinitionRegistry (org.springframework.beans.factory.support.BeanDefinitionRegistry)10 AnnotatedBeanDefinition (org.springframework.beans.factory.annotation.AnnotatedBeanDefinition)9 AnnotatedGenericBeanDefinition (org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition)9 ClassPathResource (org.springframework.core.io.ClassPathResource)5 InputStreamResource (org.springframework.core.io.InputStreamResource)5 Resource (org.springframework.core.io.Resource)5 InputSource (org.xml.sax.InputSource)2 GenericBeanDefinition (org.springframework.beans.factory.support.GenericBeanDefinition)1