Package org.springframework.tests.sample.beans

Examples of org.springframework.tests.sample.beans.TestBean


    DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
    RootBeanDefinition robDef = new RootBeanDefinition(TestBean.class);
    robDef.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE);
    robDef.getPropertyValues().add("spouse", new RuntimeBeanReference("sally"));
    child.registerBeanDefinition("rob2", robDef);
    TestBean rob = (TestBean) child.getBean("rob2");
    assertEquals("props1", rob.getSomeProperties().getProperty("name"));
    assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
  }
View Full Code Here


    robDef.getPropertyValues().add("spouse", new RuntimeBeanReference("sally"));
    child.registerBeanDefinition("rob2", robDef);
    RootBeanDefinition propsDef = new RootBeanDefinition(PropertiesFactoryBean.class);
    propsDef.getPropertyValues().add("properties", "name=props3");
    child.registerBeanDefinition("props3", propsDef);
    TestBean rob = (TestBean) child.getBean("rob2");
    assertEquals("props1", rob.getSomeProperties().getProperty("name"));
    assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
  }
View Full Code Here

    child.registerBeanDefinition("rob2", robDef);
    RootBeanDefinition propsDef = new RootBeanDefinition(PropertiesFactoryBean.class);
    propsDef.getPropertyValues().add("properties", "name=props3");
    propsDef.setPrimary(true);
    child.registerBeanDefinition("props3", propsDef);
    TestBean rob = (TestBean) child.getBean("rob2");
    assertEquals("props3", rob.getSomeProperties().getProperty("name"));
    assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
  }
View Full Code Here

    child.registerBeanDefinition("rob2", robDef);
    RootBeanDefinition propsDef = new RootBeanDefinition(PropertiesFactoryBean.class);
    propsDef.getPropertyValues().add("properties", "name=props3");
    propsDef.setPrimary(true);
    child.registerBeanDefinition("props3", propsDef);
    TestBean rob = (TestBean) child.getBean("rob2");
    assertEquals("props3", rob.getSomeProperties().getProperty("name"));
    assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
  }
View Full Code Here

  public void testByTypeAutowireWithInclusion() throws Exception {
    CountingFactory.reset();
    DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-with-inclusion.xml");
    beanFactory.preInstantiateSingletons();
    TestBean rob = (TestBean) beanFactory.getBean("rob");
    assertEquals("props1", rob.getSomeProperties().getProperty("name"));
    assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
  }
View Full Code Here

  public void testByTypeAutowireWithSelectiveInclusion() throws Exception {
    CountingFactory.reset();
    DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-with-selective-inclusion.xml");
    beanFactory.preInstantiateSingletons();
    TestBean rob = (TestBean) beanFactory.getBean("rob");
    assertEquals("props1", rob.getSomeProperties().getProperty("name"));
    assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
  }
View Full Code Here

    assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
  }

  public void testConstructorAutowireWithAutoSelfExclusion() throws Exception {
    DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-constructor-with-exclusion.xml");
    TestBean rob = (TestBean) beanFactory.getBean("rob");
    TestBean sally = (TestBean) beanFactory.getBean("sally");
    assertEquals(sally, rob.getSpouse());
    TestBean rob2 = (TestBean) beanFactory.getBean("rob");
    assertEquals(rob, rob2);
    assertNotSame(rob, rob2);
    assertEquals(rob.getSpouse(), rob2.getSpouse());
    assertNotSame(rob.getSpouse(), rob2.getSpouse());
  }
View Full Code Here

    assertNotSame(rob.getSpouse(), rob2.getSpouse());
  }

  public void testConstructorAutowireWithExclusion() throws Exception {
    DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-constructor-with-exclusion.xml");
    TestBean rob = (TestBean) beanFactory.getBean("rob");
    assertEquals("props1", rob.getSomeProperties().getProperty("name"));
  }
View Full Code Here

    singletonToBeProxied.getName();
    assertEquals(initialNr + 1, ti.nrOfInvocations);

    FactoryBean<?> factory = (FactoryBean<?>) sac.getBean("&singletonFactoryToBeProxied");
    assertTrue(Proxy.isProxyClass(factory.getClass()));
    TestBean tb = (TestBean) sac.getBean("singletonFactoryToBeProxied");
    assertFalse(AopUtils.isAopProxy(tb));
    assertEquals(initialNr + 3, ti.nrOfInvocations);
    tb.getAge();
    assertEquals(initialNr + 3, ti.nrOfInvocations);
  }
View Full Code Here

    tapc.testInterceptor.nrOfInvocations = 0;

    FactoryBean<?> factory = (FactoryBean<?>) sac.getBean("&singletonFactoryToBeProxied");
    assertTrue(AopUtils.isCglibProxy(factory));

    TestBean tb = (TestBean) sac.getBean("singletonFactoryToBeProxied");
    assertTrue(AopUtils.isCglibProxy(tb));
    assertEquals(2, tapc.testInterceptor.nrOfInvocations);
    tb.getAge();
    assertEquals(3, tapc.testInterceptor.nrOfInvocations);
  }
View Full Code Here

TOP

Related Classes of org.springframework.tests.sample.beans.TestBean

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.