Search in sources :

Example 1 with SimpleBeanDefinitionRegistry

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

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(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)

Example 2 with SimpleBeanDefinitionRegistry

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

the class XmlBeanDefinitionReaderTests method withInputSource.

@Test(expected = BeanDefinitionStoreException.class)
public void withInputSource() {
    SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    InputSource resource = new InputSource(getClass().getResourceAsStream("test.xml"));
    new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
}
Also used : SimpleBeanDefinitionRegistry(org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry) InputSource(org.xml.sax.InputSource) Test(org.junit.Test)

Example 3 with SimpleBeanDefinitionRegistry

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

the class XmlBeanDefinitionReaderTests method withFreshInputStream.

@Test
public void withFreshInputStream() {
    SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    Resource resource = new ClassPathResource("test.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)

Example 4 with SimpleBeanDefinitionRegistry

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

the class XmlBeanDefinitionReaderTests method withOpenInputStreamAndExplicitValidationMode.

@Test
public void withOpenInputStreamAndExplicitValidationMode() {
    SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    Resource resource = new InputStreamResource(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) ClassPathResource(org.springframework.core.io.ClassPathResource) InputStreamResource(org.springframework.core.io.InputStreamResource) Resource(org.springframework.core.io.Resource) InputStreamResource(org.springframework.core.io.InputStreamResource) Test(org.junit.Test)

Example 5 with SimpleBeanDefinitionRegistry

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

the class XmlBeanDefinitionReaderTests method withOpenInputStream.

@Test(expected = BeanDefinitionStoreException.class)
public void withOpenInputStream() {
    SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    Resource resource = new InputStreamResource(getClass().getResourceAsStream("test.xml"));
    new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
}
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) InputStreamResource(org.springframework.core.io.InputStreamResource) 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