Package org.springframework.beans

Examples of org.springframework.beans.TestBean


  private void testSingleTestBean(ListableBeanFactory lbf) {
    assertTrue("1 beans defined", lbf.getBeanDefinitionCount() == 1);
    String[] names = lbf.getBeanDefinitionNames();
    assertTrue("Array length == 1", names.length == 1);
    assertTrue("0th element == test", names[0].equals("test"));
    TestBean tb = (TestBean) lbf.getBean("test");
    assertTrue("Test is non null", tb != null);
    assertTrue("Test bean name is Tony", "Tony".equals(tb.getName()));
    assertTrue("Test bean age is 48", tb.getAge() == 48);
  }
View Full Code Here


    pvs.addPropertyValue("properties", new Properties(props));
    RootBeanDefinition ppcDef = new RootBeanDefinition(PropertyPlaceholderConfigurer.class, pvs);
    ppcDef.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE);
    ac.registerBeanDefinition("configurer", ppcDef);
    ac.refresh();
    TestBean tb = (TestBean) ac.getBean("tb");
    assertEquals("mytest", tb.getTouchy());
  }
View Full Code Here

    props.put("myAlias", "alias");
    props.put("myTarget", "tb");
    pvs.addPropertyValue("properties", new Properties(props));
    ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
    ac.refresh();
    TestBean tb = (TestBean) ac.getBean("tb");
    assertEquals("mytest", tb.getTouchy());
    tb = (TestBean) ac.getBean("alias");
    assertEquals("mytest", tb.getTouchy());
    tb = (TestBean) ac.getBean("alias2");
    assertEquals("mytest", tb.getTouchy());
  }
View Full Code Here

    p.setProperty("r.name", "rod");
    p.setProperty("k.(class)", TestBean.class.getName());
    p.setProperty("k.name", "kerry");
    p.setProperty("k.spouse", "*r");
    (new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
    TestBean k = (TestBean) lbf.getBean("k");
    TestBean r = (TestBean) lbf.getBean("r");
    assertTrue(k.getSpouse() == r);
  }
View Full Code Here

    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    Properties p = new Properties();
    p.setProperty("r.(class)", TestBean.class.getName());
    p.setProperty("r.name", "*" + name);
    (new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
    TestBean r = (TestBean) lbf.getBean("r");
    assertTrue(r.getName().equals(name));
  }
View Full Code Here

    ac.registerSingleton("configurer", PreferencesPlaceholderConfigurer.class, pvs);
    Preferences.systemRoot().put("myName", "myNameValue");
    Preferences.systemRoot().put("myTouchy", "myTouchyValue");
    Preferences.userRoot().put("myTouchy", "myOtherTouchyValue");
    ac.refresh();
    TestBean tb = (TestBean) ac.getBean("tb");
    assertEquals("myNameValue", tb.getName());
    assertEquals(99, tb.getAge());
    assertEquals("myOtherTouchyValue", tb.getTouchy());
    Preferences.userRoot().remove("myTouchy");
    Preferences.systemRoot().remove("myTouchy");
    Preferences.systemRoot().remove("myName");
  }
View Full Code Here

    NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
    lbf.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, nf, true));
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("myFloat", "1,1");
    lbf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class, pvs));
    TestBean testBean = (TestBean) lbf.getBean("testBean");
    assertTrue(testBean.getMyFloat().floatValue() == 1.1f);
  }
View Full Code Here

    ac.registerSingleton("configurer", PreferencesPlaceholderConfigurer.class, pvs);
    Preferences.systemRoot().node("mySystemPath").put("myName", "myNameValue");
    Preferences.systemRoot().node("mySystemPath").put("myTouchy", "myTouchyValue");
    Preferences.userRoot().node("myUserPath").put("myTouchy", "myOtherTouchyValue");
    ac.refresh();
    TestBean tb = (TestBean) ac.getBean("tb");
    assertEquals("myNameValue", tb.getName());
    assertEquals(99, tb.getAge());
    assertEquals("myOtherTouchyValue", tb.getTouchy());
    Preferences.userRoot().node("myUserPath").remove("myTouchy");
    Preferences.systemRoot().node("mySystemPath").remove("myTouchy");
    Preferences.systemRoot().node("mySystemPath").remove("myName");
  }
View Full Code Here

    reader.loadBeanDefinitions(getResource());
  }


  public void testSimpleParser() throws Exception {
    TestBean bean = (TestBean) this.beanFactory.getBean("testBean");
    assetTestBean(bean);
  }
View Full Code Here

    TestBean bean = (TestBean) this.beanFactory.getBean("testBean");
    assetTestBean(bean);
  }

  public void testSimpleDecorator() throws Exception {
    TestBean bean = (TestBean) this.beanFactory.getBean("customisedTestBean");
    assetTestBean(bean);
  }
View Full Code Here

TOP

Related Classes of org.springframework.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.