use of org.springframework.core.io.ClassPathResource in project spring-framework by spring-projects.
the class SimplePropertyNamespaceHandlerTests method innerBeanConfigured.
@Test
public void innerBeanConfigured() throws Exception {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(new ClassPathResource("simplePropertyNamespaceHandlerTests.xml", getClass()));
TestBean sally = (TestBean) beanFactory.getBean("sally2");
ITestBean rob = sally.getSpouse();
assertEquals("Rob Harrop", rob.getName());
assertEquals(24, rob.getAge());
assertEquals(rob.getSpouse(), sally);
}
use of org.springframework.core.io.ClassPathResource in project spring-framework by spring-projects.
the class SchemaValidationTests method withAutodetection.
@Test
public void withAutodetection() throws Exception {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(bf);
try {
reader.loadBeanDefinitions(new ClassPathResource("invalidPerSchema.xml", getClass()));
fail("Should not be able to parse a file with errors");
} catch (BeansException ex) {
assertTrue(ex.getCause() instanceof SAXParseException);
}
}
use of org.springframework.core.io.ClassPathResource in project spring-framework by spring-projects.
the class SchemaValidationTests method withExplicitValidationMode.
@Test
public void withExplicitValidationMode() throws Exception {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(bf);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
try {
reader.loadBeanDefinitions(new ClassPathResource("invalidPerSchema.xml", getClass()));
fail("Should not be able to parse a file with errors");
} catch (BeansException ex) {
assertTrue(ex.getCause() instanceof SAXParseException);
}
}
use of org.springframework.core.io.ClassPathResource in project spring-framework by spring-projects.
the class SimplePropertyNamespaceHandlerTests method simpleBeanConfigured.
@Test
public void simpleBeanConfigured() throws Exception {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(new ClassPathResource("simplePropertyNamespaceHandlerTests.xml", getClass()));
ITestBean rob = (TestBean) beanFactory.getBean("rob");
ITestBean sally = (TestBean) beanFactory.getBean("sally");
assertEquals("Rob Harrop", rob.getName());
assertEquals(24, rob.getAge());
assertEquals(rob.getSpouse(), sally);
}
use of org.springframework.core.io.ClassPathResource 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);
}
Aggregations