Package org.springframework.tests.sample.beans.factory

Examples of org.springframework.tests.sample.beans.factory.DummyFactory


    rod = (TestBean) parent.getBean("rod");
    assertTrue("Bean from root context", "Roderick".equals(rod.getName()));
  }

  public void testFactoryReferences() {
    DummyFactory factory = (DummyFactory) getBeanFactory().getBean("&singletonFactory");

    DummyReferencer ref = (DummyReferencer) getBeanFactory().getBean("factoryReferencer");
    assertTrue(ref.getTestBean1() == ref.getTestBean2());
    assertTrue(ref.getDummyFactory() == factory);
View Full Code Here


  }

  public void testBeanPostProcessor() throws Exception {
    TestBean kerry = (TestBean) getBeanFactory().getBean("kerry");
    TestBean kathy = (TestBean) getBeanFactory().getBean("kathy");
    DummyFactory factory = (DummyFactory) getBeanFactory().getBean("&singletonFactory");
    TestBean factoryCreated = (TestBean) getBeanFactory().getBean("singletonFactory");
    assertTrue(kerry.isPostProcessed());
    assertTrue(kathy.isPostProcessed());
    assertTrue(factory.isPostProcessed());
    assertTrue(factoryCreated.isPostProcessed());
  }
View Full Code Here

  public void testFactorySingleton() throws Exception {
    assertTrue(getBeanFactory().isSingleton("&singletonFactory"));
    assertTrue(getBeanFactory().isSingleton("singletonFactory"));
    TestBean tb = (TestBean) getBeanFactory().getBean("singletonFactory");
    assertTrue("Singleton from factory has correct name, not " + tb.getName(), tb.getName().equals(DummyFactory.SINGLETON_NAME));
    DummyFactory factory = (DummyFactory) getBeanFactory().getBean("&singletonFactory");
    TestBean tb2 = (TestBean) getBeanFactory().getBean("singletonFactory");
    assertTrue("Singleton references ==", tb == tb2);
    assertTrue("FactoryBean is BeanFactoryAware", factory.getBeanFactory() != null);
  }
View Full Code Here

   * Check that we can get the factory bean itself.
   * This is only possible if we're dealing with a factory
   * @throws Exception
   */
  public void testGetFactoryItself() throws Exception {
    DummyFactory factory = (DummyFactory) getBeanFactory().getBean("&singletonFactory");
    assertTrue(factory != null);
  }
View Full Code Here

   * @throws Exception
   */
  public void testFactoryIsInitialized() throws Exception {
    TestBean tb = (TestBean) getBeanFactory().getBean("singletonFactory");
    assertNotNull(tb);
    DummyFactory factory = (DummyFactory) getBeanFactory().getBean("&singletonFactory");
    assertTrue("Factory was initialized because it implemented InitializingBean", factory.wasInitialized());
  }
View Full Code Here

    Object test3 = this.listableBeanFactory.getBean("test3");
    Object test = this.listableBeanFactory.getBean("test");

    TestBean t1 = new TestBean();
    TestBean t2 = new TestBean();
    DummyFactory t3 = new DummyFactory();
    DummyFactory t4 = new DummyFactory();
    t4.setSingleton(false);
    this.listableBeanFactory.registerSingleton("t1", t1);
    this.listableBeanFactory.registerSingleton("t2", t2);
    this.listableBeanFactory.registerSingleton("t3", t3);
    this.listableBeanFactory.registerSingleton("t4", t4);
View Full Code Here

  @Test
  public void testFindsBeansOfTypeWithStaticFactory() {
    StaticListableBeanFactory lbf = new StaticListableBeanFactory();
    TestBean t1 = new TestBean();
    TestBean t2 = new TestBean();
    DummyFactory t3 = new DummyFactory();
    DummyFactory t4 = new DummyFactory();
    t4.setSingleton(false);
    lbf.addBean("t1", t1);
    lbf.addBean("t2", t2);
    lbf.addBean("t3", t3);
    lbf.addBean("t4", t4);
View Full Code Here

  @Test
  public void testFactoryReferenceCircle() {
    DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
    new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(FACTORY_CIRCLE_CONTEXT);
    TestBean tb = (TestBean) xbf.getBean("singletonFactory");
    DummyFactory db = (DummyFactory) xbf.getBean("&singletonFactory");
    assertTrue(tb == db.getOtherTestBean());
  }
View Full Code Here

TOP

Related Classes of org.springframework.tests.sample.beans.factory.DummyFactory

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.