Search in sources :

Example 1 with XmlBeanDefinitionReader

use of org.springframework.beans.factory.xml.XmlBeanDefinitionReader in project spring-framework by spring-projects.

the class AopNamespaceHandlerEventTests method setUp.

@Before
public void setUp() throws Exception {
    this.reader = new XmlBeanDefinitionReader(this.beanFactory);
    this.reader.setEventListener(this.eventListener);
}
Also used : XmlBeanDefinitionReader(org.springframework.beans.factory.xml.XmlBeanDefinitionReader) Before(org.junit.Before)

Example 2 with XmlBeanDefinitionReader

use of org.springframework.beans.factory.xml.XmlBeanDefinitionReader in project spring-framework by spring-projects.

the class TopLevelAopTagTests method testParse.

@Test
public void testParse() throws Exception {
    DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
    reader.loadBeanDefinitions(CONTEXT);
    assertTrue(beanFactory.containsBeanDefinition("testPointcut"));
}
Also used : XmlBeanDefinitionReader(org.springframework.beans.factory.xml.XmlBeanDefinitionReader) DefaultListableBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory) Test(org.junit.Test)

Example 3 with XmlBeanDefinitionReader

use of org.springframework.beans.factory.xml.XmlBeanDefinitionReader in project spring-framework by spring-projects.

the class PrototypeTargetTests method testPrototypeProxyWithPrototypeTarget.

@Test
public void testPrototypeProxyWithPrototypeTarget() {
    TestBeanImpl.constructionCount = 0;
    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
    for (int i = 0; i < 10; i++) {
        TestBean tb = (TestBean) bf.getBean("testBeanPrototype");
        tb.doSomething();
    }
    TestInterceptor interceptor = (TestInterceptor) bf.getBean("testInterceptor");
    assertEquals(10, TestBeanImpl.constructionCount);
    assertEquals(10, interceptor.invocationCount);
}
Also used : XmlBeanDefinitionReader(org.springframework.beans.factory.xml.XmlBeanDefinitionReader) DefaultListableBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory) Test(org.junit.Test)

Example 4 with XmlBeanDefinitionReader

use of org.springframework.beans.factory.xml.XmlBeanDefinitionReader in project spring-framework by spring-projects.

the class Foo method setUp.

@Before
public void setUp() {
    beanFactory = new DefaultListableBeanFactory();
    new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory).loadBeanDefinitions(new ClassPathResource("FactoryBeanLookupTests-context.xml", this.getClass()));
}
Also used : XmlBeanDefinitionReader(org.springframework.beans.factory.xml.XmlBeanDefinitionReader) DefaultListableBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory) BeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry) ClassPathResource(org.springframework.core.io.ClassPathResource) Before(org.junit.Before)

Example 5 with XmlBeanDefinitionReader

use of org.springframework.beans.factory.xml.XmlBeanDefinitionReader in project spring-framework by spring-projects.

the class FactoryBeanTests method testFactoryBeansWithAutowiring.

@Test
public void testFactoryBeansWithAutowiring() throws Exception {
    DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
    new XmlBeanDefinitionReader(factory).loadBeanDefinitions(WITH_AUTOWIRING_CONTEXT);
    BeanFactoryPostProcessor ppc = (BeanFactoryPostProcessor) factory.getBean("propertyPlaceholderConfigurer");
    ppc.postProcessBeanFactory(factory);
    assertNull(factory.getType("betaFactory"));
    Alpha alpha = (Alpha) factory.getBean("alpha");
    Beta beta = (Beta) factory.getBean("beta");
    Gamma gamma = (Gamma) factory.getBean("gamma");
    Gamma gamma2 = (Gamma) factory.getBean("gammaFactory");
    assertSame(beta, alpha.getBeta());
    assertSame(gamma, beta.getGamma());
    assertSame(gamma2, beta.getGamma());
    assertEquals("yourName", beta.getName());
}
Also used : XmlBeanDefinitionReader(org.springframework.beans.factory.xml.XmlBeanDefinitionReader) DefaultListableBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory) BeanFactoryPostProcessor(org.springframework.beans.factory.config.BeanFactoryPostProcessor) Test(org.junit.Test)

Aggregations

XmlBeanDefinitionReader (org.springframework.beans.factory.xml.XmlBeanDefinitionReader)138 Test (org.junit.Test)79 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)74 ClassPathResource (org.springframework.core.io.ClassPathResource)59 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)36 Before (org.junit.Before)24 ITestBean (org.springframework.tests.sample.beans.ITestBean)18 TestBean (org.springframework.tests.sample.beans.TestBean)11 BeansException (org.springframework.beans.BeansException)9 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)7 Resource (org.springframework.core.io.Resource)7 UrlResource (org.springframework.core.io.UrlResource)7 URL (java.net.URL)6 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)6 HashMap (java.util.HashMap)5 Person (org.springframework.tests.sample.beans.Person)5 ArrayList (java.util.ArrayList)4 BeanCreationException (org.springframework.beans.factory.BeanCreationException)4 NopInterceptor (org.springframework.tests.aop.interceptor.NopInterceptor)4 Map (java.util.Map)3