use of org.springframework.beans.factory.xml.XmlBeanDefinitionReader in project grails-core by grails.
the class BeanBuilder method initializeSpringConfig.
protected void initializeSpringConfig() {
xmlBeanDefinitionReader = new XmlBeanDefinitionReader((GenericApplicationContext) springConfig.getUnrefreshedApplicationContext());
initializeBeanBuilderForClassLoader(classLoader);
}
use of org.springframework.beans.factory.xml.XmlBeanDefinitionReader in project spring-framework by spring-projects.
the class ProxyFactoryBeanTests method testTargetAsInnerBean.
/**
* Test that inner bean for target means that we can use
* autowire without ambiguity from target and proxy
*/
@Test
public void testTargetAsInnerBean() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(INNER_BEAN_TARGET_CONTEXT, CLASS));
ITestBean itb = (ITestBean) bf.getBean("testBean");
assertEquals("innerBeanTarget", itb.getName());
assertEquals("Only have proxy and interceptor: no target", 3, bf.getBeanDefinitionCount());
DependsOnITestBean doit = (DependsOnITestBean) bf.getBean("autowireCheck");
assertSame(itb, doit.tb);
}
use of org.springframework.beans.factory.xml.XmlBeanDefinitionReader in project spring-framework by spring-projects.
the class ProxyFactoryBeanTests method testEmptyInterceptorNames.
// These two fail the whole bean factory
// TODO put in sep file to check quality of error message
/*
@Test
public void testNoInterceptorNamesWithoutTarget() {
try {
ITestBean tb = (ITestBean) factory.getBean("noInterceptorNamesWithoutTarget");
fail("Should require interceptor names");
}
catch (AopConfigException ex) {
// Ok
}
}
@Test
public void testNoInterceptorNamesWithTarget() {
ITestBean tb = (ITestBean) factory.getBean("noInterceptorNamesWithoutTarget");
}
*/
@Test
public void testEmptyInterceptorNames() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(INVALID_CONTEXT, CLASS));
try {
bf.getBean("emptyInterceptorNames");
fail("Interceptor names cannot be empty");
} catch (BeanCreationException ex) {
// Ok
}
}
use of org.springframework.beans.factory.xml.XmlBeanDefinitionReader in project spring-framework by spring-projects.
the class ProxyFactoryBeanTests method testSerializableSingletonProxy.
@Test
public void testSerializableSingletonProxy() throws Exception {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
Person p = (Person) bf.getBean("serializableSingleton");
assertSame("Should be a Singleton", p, bf.getBean("serializableSingleton"));
Person p2 = (Person) SerializationTestUtils.serializeAndDeserialize(p);
assertEquals(p, p2);
assertNotSame(p, p2);
assertEquals("serializableSingleton", p2.getName());
// Add unserializable advice
Advice nop = new NopInterceptor();
((Advised) p).addAdvice(nop);
// Check it still works
assertEquals(p2.getName(), p2.getName());
assertFalse("Not serializable because an interceptor isn't serializable", SerializationTestUtils.isSerializable(p));
// Remove offending interceptor...
assertTrue(((Advised) p).removeAdvice(nop));
assertTrue("Serializable again because offending interceptor was removed", SerializationTestUtils.isSerializable(p));
}
use of org.springframework.beans.factory.xml.XmlBeanDefinitionReader in project spring-framework by spring-projects.
the class ScopedProxyTests method testProxyAssignable.
/* SPR-2108 */
@Test
public void testProxyAssignable() throws Exception {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(MAP_CONTEXT);
Object baseMap = bf.getBean("singletonMap");
assertTrue(baseMap instanceof Map);
}
Aggregations