Search in sources :

Example 11 with SimpleBeanDefinitionRegistry

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

the class XmlBeanDefinitionReaderTests method withInputSourceAndExplicitValidationMode.

@Test
public void withInputSourceAndExplicitValidationMode() {
    SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    InputSource resource = new InputSource(getClass().getResourceAsStream("test.xml"));
    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(registry);
    reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_DTD);
    reader.loadBeanDefinitions(resource);
    testBeanDefinitions(registry);
}
Also used : SimpleBeanDefinitionRegistry(org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry) InputSource(org.xml.sax.InputSource) Test(org.junit.Test)

Example 12 with SimpleBeanDefinitionRegistry

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

the class XmlBeanDefinitionReaderTests method setParserClassToUnsupportedParserType.

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

Example 13 with SimpleBeanDefinitionRegistry

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

the class XmlBeanDefinitionReaderTests method setParserClassSunnyDay.

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

Example 14 with SimpleBeanDefinitionRegistry

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

the class AnnotationBeanNameGeneratorTests method generateBeanNameWithAnonymousComponentYieldsGeneratedBeanName.

@Test
public void generateBeanNameWithAnonymousComponentYieldsGeneratedBeanName() {
    BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnonymousComponent.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 15 with SimpleBeanDefinitionRegistry

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

the class AnnotationBeanNameGeneratorTests method generateBeanNameFromComposedControllerAnnotationWithBlankName.

/**
	 * @since 4.0.1
	 * @see https://jira.spring.io/browse/SPR-11360
	 */
@Test
public void generateBeanNameFromComposedControllerAnnotationWithBlankName() {
    BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComposedControllerAnnotationWithBlankName.class);
    String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
    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)

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