Package org.springframework.beans

Examples of org.springframework.beans.MutablePropertyValues


  }

  public void testPossibleMatches() {
    try {
      DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
      MutablePropertyValues pvs = new MutablePropertyValues();
      pvs.addPropertyValue("ag", "foobar");
      lbf.registerBeanDefinition("tb", new RootBeanDefinition(TestBean.class, pvs));
      lbf.getBean("tb");
      fail("Should throw exception on invalid property");
    }
    catch (BeanCreationException ex) {
View Full Code Here


    }
  }

  public void testPropertyPlaceholderConfigurerWithUnresolvableSystemPropertiesInLocation() {
    StaticApplicationContext ac = new StaticApplicationContext();
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("spouse", new RuntimeBeanReference("${ref}"));
    ac.registerSingleton("tb", TestBean.class, pvs);
    pvs = new MutablePropertyValues();
    pvs.addPropertyValue("location", "${myprop}/test/${myprop}");
    ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
    try {
      ac.refresh();
      fail("Should have thrown BeanDefinitionStoreException");
    }
View Full Code Here

  public void testCustomEditor() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    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

    }
  }

  public void testPropertyPlaceholderConfigurerWithCircularReference() {
    StaticApplicationContext ac = new StaticApplicationContext();
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("age", "${age}");
    pvs.addPropertyValue("name", "name${var}");
    ac.registerSingleton("tb", TestBean.class, pvs);
    pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "age=99\nvar=${m}var\nm=${var}");
    ac.registerSingleton("configurer1", PropertyPlaceholderConfigurer.class, pvs);
    try {
      ac.refresh();
      fail("Should have thrown BeanDefinitionStoreException");
    }
View Full Code Here

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

    }
  }

  public void testPropertyPlaceholderConfigurerWithMultiLevelCircularReference() {
    StaticApplicationContext ac = new StaticApplicationContext();
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("name", "name${var}");
    ac.registerSingleton("tb1", TestBean.class, pvs);
    pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "var=${m}var\nm=${var2}\nvar2=${var}");
    ac.registerSingleton("configurer1", PropertyPlaceholderConfigurer.class, pvs);
    try {
      ac.refresh();
      fail("Should have thrown BeanDefinitionStoreException");
    }
View Full Code Here

  public void testCustomTypeConverter() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
    lbf.setTypeConverter(new CustomTypeConverter(nf));
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("myFloat", "1,1");
    ConstructorArgumentValues cav = new ConstructorArgumentValues();
    cav.addIndexedArgumentValue(0, "myName");
    cav.addIndexedArgumentValue(1, "myAge");
    lbf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class, cav, pvs));
    TestBean testBean = (TestBean) lbf.getBean("testBean");
View Full Code Here

    }
  }

  public void testPropertyPlaceholderConfigurerWithNestedCircularReference() {
    StaticApplicationContext ac = new StaticApplicationContext();
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("name", "name${var}");
    ac.registerSingleton("tb1", TestBean.class, pvs);
    pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "var=${m}var\nm=${var2}\nvar2=${m}");
    ac.registerSingleton("configurer1", PropertyPlaceholderConfigurer.class, pvs);
    try {
      ac.refresh();
      fail("Should have thrown BeanDefinitionStoreException");
    }
View Full Code Here

  public void testCustomTypeConverterWithBeanReference() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
    lbf.setTypeConverter(new CustomTypeConverter(nf));
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("myFloat", new RuntimeBeanReference("myFloat"));
    ConstructorArgumentValues cav = new ConstructorArgumentValues();
    cav.addIndexedArgumentValue(0, "myName");
    cav.addIndexedArgumentValue(1, "myAge");
    lbf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class, cav, pvs));
    lbf.registerSingleton("myFloat", "1,1");
View Full Code Here

    }
  }

  public void testPropertyPlaceholderConfigurerWithDefaultProperties() {
    StaticApplicationContext ac = new StaticApplicationContext();
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("touchy", "${test}");
    ac.registerSingleton("tb", TestBean.class, pvs);
    pvs = new MutablePropertyValues();
    Properties props = new Properties();
    props.put("test", "mytest");
    pvs.addPropertyValue("properties", new Properties(props));
    ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
    ac.refresh();
    TestBean tb = (TestBean) ac.getBean("tb");
    assertEquals("mytest", tb.getTouchy());
  }
View Full Code Here

TOP

Related Classes of org.springframework.beans.MutablePropertyValues

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.