Package org.springframework.context.support

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


    ac.registerSingleton("tb", TestBean.class, pvs);
    pvs = new MutablePropertyValues();
    pvs.addPropertyValue("location", "${user.dir}/test");
    ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
    try {
      ac.refresh();
      fail("Should have thrown BeanInitializationException");
    }
    catch (BeanInitializationException ex) {
      // expected
      assertTrue(ex.getCause() instanceof FileNotFoundException);
View Full Code Here


    ac.registerSingleton("tb", TestBean.class, pvs);
    pvs = new MutablePropertyValues();
    pvs.addPropertyValue("location", "${user.dir}/test/${user.dir}");
    ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
    try {
      ac.refresh();
      fail("Should have thrown BeanInitializationException");
    }
    catch (BeanInitializationException ex) {
      // expected
      assertTrue(ex.getCause() instanceof FileNotFoundException);
View Full Code Here

    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");
    }
    catch (BeanInitializationException ex) {
      // expected
      assertTrue(ex.getCause() instanceof FileNotFoundException);
View Full Code Here

    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");
    }
    catch (BeanDefinitionStoreException ex) {
      // expected
    }
View Full Code Here

    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");
    }
    catch (BeanDefinitionStoreException ex) {
      // expected
    }
View Full Code Here

    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");
    }
    catch (BeanDefinitionStoreException ex) {
      // expected
    }
View Full Code Here

    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());
  }

  public void testPropertyPlaceholderConfigurerWithAutowireByType() {
View Full Code Here

    props.put("test", "mytest");
    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());
  }

  public void testPropertyPlaceholderConfigurerWithAliases() {
View Full Code Here

    props.put("test", "mytest");
    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");
View Full Code Here

    pvs.addPropertyValue("properties", props);
    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");
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.