Package org.springframework.context.support

Examples of org.springframework.context.support.StaticApplicationContext.registerSingleton()


    assertEquals("test", tb2.getName());
  }

  public void testPropertyOverrideConfigurerWithNestedProperty() {
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.registerSingleton("tb", IndexedTestBean.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "tb.array[0].age=99\ntb.list[1].name=test");
    ac.registerSingleton("configurer", PropertyOverrideConfigurer.class, pvs);
    ac.refresh();
    IndexedTestBean tb = (IndexedTestBean) ac.getBean("tb");
View Full Code Here


  public void testPropertyOverrideConfigurerWithNestedProperty() {
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.registerSingleton("tb", IndexedTestBean.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "tb.array[0].age=99\ntb.list[1].name=test");
    ac.registerSingleton("configurer", PropertyOverrideConfigurer.class, pvs);
    ac.refresh();
    IndexedTestBean tb = (IndexedTestBean) ac.getBean("tb");
    assertEquals(99, tb.getArray()[0].getAge());
    assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
  }
View Full Code Here

    assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
  }

  public void testPropertyOverrideConfigurerWithNestedPropertyAndDotInBeanName() {
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.registerSingleton("my.tb", IndexedTestBean.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "my.tb_array[0].age=99\nmy.tb_list[1].name=test");
    pvs.addPropertyValue("beanNameSeparator", "_");
    ac.registerSingleton("configurer", PropertyOverrideConfigurer.class, pvs);
    ac.refresh();
View Full Code Here

    StaticApplicationContext ac = new StaticApplicationContext();
    ac.registerSingleton("my.tb", IndexedTestBean.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "my.tb_array[0].age=99\nmy.tb_list[1].name=test");
    pvs.addPropertyValue("beanNameSeparator", "_");
    ac.registerSingleton("configurer", PropertyOverrideConfigurer.class, pvs);
    ac.refresh();
    IndexedTestBean tb = (IndexedTestBean) ac.getBean("my.tb");
    assertEquals(99, tb.getArray()[0].getAge());
    assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
  }
View Full Code Here

    assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
  }

  public void testPropertyOverrideConfigurerWithNestedMapPropertyAndDotInMapKey() {
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.registerSingleton("tb", IndexedTestBean.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "tb.map[key1]=99\ntb.map[key2.ext]=test");
    ac.registerSingleton("configurer", PropertyOverrideConfigurer.class, pvs);
    ac.refresh();
    IndexedTestBean tb = (IndexedTestBean) ac.getBean("tb");
View Full Code Here

  public void testPropertyOverrideConfigurerWithNestedMapPropertyAndDotInMapKey() {
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.registerSingleton("tb", IndexedTestBean.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "tb.map[key1]=99\ntb.map[key2.ext]=test");
    ac.registerSingleton("configurer", PropertyOverrideConfigurer.class, pvs);
    ac.refresh();
    IndexedTestBean tb = (IndexedTestBean) ac.getBean("tb");
    assertEquals("99", tb.getMap().get("key1"));
    assertEquals("test", tb.getMap().get("key2.ext"));
  }
View Full Code Here

    assertEquals("test", tb.getMap().get("key2.ext"));
  }

  public void testPropertyOverrideConfigurerWithJavaMailProperties() {
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.registerSingleton("tb", JavaMailSenderImpl.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "tb.javaMailProperties[mail.smtp.auth]=true");
    ac.registerSingleton("configurer", PropertyOverrideConfigurer.class, pvs);
    ac.refresh();
    JavaMailSenderImpl tb = (JavaMailSenderImpl) ac.getBean("tb");
View Full Code Here

  public void testPropertyOverrideConfigurerWithJavaMailProperties() {
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.registerSingleton("tb", JavaMailSenderImpl.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "tb.javaMailProperties[mail.smtp.auth]=true");
    ac.registerSingleton("configurer", PropertyOverrideConfigurer.class, pvs);
    ac.refresh();
    JavaMailSenderImpl tb = (JavaMailSenderImpl) ac.getBean("tb");
    assertEquals("true", tb.getJavaMailProperties().getProperty("mail.smtp.auth"));
  }
View Full Code Here

    assertEquals("true", tb.getJavaMailProperties().getProperty("mail.smtp.auth"));
  }

  public void testPropertyOverrideConfigurerWithPropertiesFile() {
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.registerSingleton("tb", IndexedTestBean.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("location", "classpath:org/springframework/beans/factory/config/test.properties");
    ac.registerSingleton("configurer", PropertyOverrideConfigurer.class, pvs);
    ac.refresh();
    IndexedTestBean tb = (IndexedTestBean) ac.getBean("tb");
View Full Code Here

  public void testPropertyOverrideConfigurerWithPropertiesFile() {
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.registerSingleton("tb", IndexedTestBean.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("location", "classpath:org/springframework/beans/factory/config/test.properties");
    ac.registerSingleton("configurer", PropertyOverrideConfigurer.class, pvs);
    ac.refresh();
    IndexedTestBean tb = (IndexedTestBean) ac.getBean("tb");
    assertEquals(99, tb.getArray()[0].getAge());
    assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.