Package org.springframework.context.support

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


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

  public void testPropertyOverrideConfigurerWithInvalidPropertiesFile() {
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.registerSingleton("tb", IndexedTestBean.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("locations",
        new String[] {"classpath:org/springframework/beans/factory/config/test.properties",
                      "classpath:org/springframework/beans/factory/config/xtest.properties"});
    pvs.addPropertyValue("ignoreResourceNotFound", Boolean.TRUE);
View Full Code Here


    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("locations",
        new String[] {"classpath:org/springframework/beans/factory/config/test.properties",
                      "classpath:org/springframework/beans/factory/config/xtest.properties"});
    pvs.addPropertyValue("ignoreResourceNotFound", Boolean.TRUE);
    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

    if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_15) {
      return;
    }

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

    StaticApplicationContext ac = new StaticApplicationContext();
    ac.registerSingleton("tb", IndexedTestBean.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("location", "classpath:org/springframework/beans/factory/config/test-properties.xml");
    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 testPropertyOverrideConfigurerWithConvertProperties() {
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.registerSingleton("tb", IndexedTestBean.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "tb.array[0].name=99\ntb.list[1].name=test");
    ac.registerSingleton("configurer", ConvertingOverrideConfigurer.class, pvs);
    ac.refresh();
    IndexedTestBean tb = (IndexedTestBean) ac.getBean("tb");
View Full Code Here

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

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

  public void testPropertyOverrideConfigurerWithInvalidKey() {
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.registerSingleton("tb1", TestBean.class);
    ac.registerSingleton("tb2", TestBean.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "argh=hgra\ntb1.age=99\ntb2.name=test");
    pvs.addPropertyValue("ignoreInvalidKeys", "true");
    ac.registerSingleton("configurer1", PropertyOverrideConfigurer.class, pvs);
View Full Code Here

  }

  public void testPropertyOverrideConfigurerWithInvalidKey() {
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.registerSingleton("tb1", TestBean.class);
    ac.registerSingleton("tb2", TestBean.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "argh=hgra\ntb1.age=99\ntb2.name=test");
    pvs.addPropertyValue("ignoreInvalidKeys", "true");
    ac.registerSingleton("configurer1", PropertyOverrideConfigurer.class, pvs);
    pvs = new MutablePropertyValues();
View Full Code Here

    ac.registerSingleton("tb1", TestBean.class);
    ac.registerSingleton("tb2", TestBean.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "argh=hgra\ntb1.age=99\ntb2.name=test");
    pvs.addPropertyValue("ignoreInvalidKeys", "true");
    ac.registerSingleton("configurer1", PropertyOverrideConfigurer.class, pvs);
    pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "tb2.age=99\ntb2.name=test2");
    pvs.addPropertyValue("order", "0");
    ac.registerSingleton("configurer2", PropertyOverrideConfigurer.class, pvs);
    try {
View Full Code Here

    pvs.addPropertyValue("ignoreInvalidKeys", "true");
    ac.registerSingleton("configurer1", PropertyOverrideConfigurer.class, pvs);
    pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "tb2.age=99\ntb2.name=test2");
    pvs.addPropertyValue("order", "0");
    ac.registerSingleton("configurer2", PropertyOverrideConfigurer.class, pvs);
    try {
      ac.refresh();
    }
    catch (BeanInitializationException ex) {
      assertTrue(ex.getMessage().toLowerCase().indexOf("argh") != -1);
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.