Package org.springframework.beans.factory.support

Examples of org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry


* @author Juergen Hoeller
*/
public class XmlBeanDefinitionReaderTests extends TestCase {

  public void testSetParserClassSunnyDay() {
    SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();;
    new XmlBeanDefinitionReader(registry).setDocumentReaderClass(DefaultBeanDefinitionDocumentReader.class);
  }
View Full Code Here


    new XmlBeanDefinitionReader(registry).setDocumentReaderClass(DefaultBeanDefinitionDocumentReader.class);
  }

  public void testSetParserClassToNull() {
    try {
      SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();;
      new XmlBeanDefinitionReader(registry).setDocumentReaderClass(null);
      fail("Should have thrown IllegalArgumentException (null parserClass)");
    }
    catch (IllegalArgumentException expected) {
    }
View Full Code Here

    }
  }

  public void testSetParserClassToUnsupportedParserType() throws Exception {
    try {
      SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();;
      new XmlBeanDefinitionReader(registry).setDocumentReaderClass(String.class);
      fail("Should have thrown IllegalArgumentException (unsupported parserClass)");
    }
    catch (IllegalArgumentException expected) {
    }
View Full Code Here

    }
  }

  public void testWithOpenInputStream() {
    try {
      SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();;
      Resource resource = new InputStreamResource(getClass().getResourceAsStream("test.xml"));
      new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
      fail("Should have thrown BeanDefinitionStoreException (can't determine validation mode)");
    }
    catch (BeanDefinitionStoreException expected) {
View Full Code Here

    catch (BeanDefinitionStoreException expected) {
    }
  }

  public void testWithOpenInputStreamAndExplicitValidationMode() {
    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);
View Full Code Here

    testBeanDefinitions(registry);
  }

  public void testWithInputSource() {
    try {
      SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();;
      InputSource resource = new InputSource(getClass().getResourceAsStream("test.xml"));
      new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
      fail("Should have thrown BeanDefinitionStoreException (can't determine validation mode)");
    }
    catch (BeanDefinitionStoreException expected) {
View Full Code Here

    catch (BeanDefinitionStoreException expected) {
    }
  }
                                                                            
  public void testWithInputSourceAndExplicitValidationMode() {
    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);
View Full Code Here

    reader.loadBeanDefinitions(resource);
    testBeanDefinitions(registry);
  }

  public void testWithFreshInputStream() {
    SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();;
    Resource resource = new ClassPathResource("test.xml", getClass());
    new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
    testBeanDefinitions(registry);
  }
View Full Code Here

            for (Resource resource : resources) {
                if (resource.getFilename().endsWith(".groovy")) {
                    loadBeans(resource);
                }
                else if (resource.getFilename().endsWith(".xml")) {
                    SimpleBeanDefinitionRegistry beanRegistry = new SimpleBeanDefinitionRegistry();
                    XmlBeanDefinitionReader beanReader = new XmlBeanDefinitionReader(beanRegistry);
                    beanReader.loadBeanDefinitions(resource);
                    String[] beanNames = beanRegistry.getBeanDefinitionNames();
                    for (String beanName : beanNames) {
                        springConfig.addBeanDefinition(beanName, beanRegistry.getBeanDefinition(beanName));
                    }
                }
            }
        } catch (IOException e) {
            LOG.error("Error loading beans for resource pattern: " + resourcePattern, e);
View Full Code Here

* @author Juergen Hoeller
*/
public class XmlBeanDefinitionReaderTests extends TestCase {

  public void testSetParserClassSunnyDay() {
    SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    new XmlBeanDefinitionReader(registry).setDocumentReaderClass(DefaultBeanDefinitionDocumentReader.class);
  }
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.