Package org.springframework.context.support

Examples of org.springframework.context.support.StaticApplicationContext


      assertTrue(ex.getMessage().indexOf("ref") != -1);
    }
  }

  public void testPropertyPlaceholderConfigurerWithIgnoreUnresolvablePlaceholder() {
    StaticApplicationContext ac = new StaticApplicationContext();
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("name", "${ref}");
    ac.registerSingleton("tb", TestBean.class, pvs);
    pvs = new MutablePropertyValues();
    pvs.addPropertyValue("ignoreUnresolvablePlaceholders", Boolean.TRUE);
    ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
    ac.refresh();
    TestBean tb = (TestBean) ac.getBean("tb");
    assertEquals("${ref}", tb.getName());
  }
View Full Code Here


    TestBean tb = (TestBean) ac.getBean("tb");
    assertEquals("${ref}", tb.getName());
  }

  public void testPropertyPlaceholderConfigurerWithEmptyStringAsNull() {
    StaticApplicationContext ac = new StaticApplicationContext();
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("name", "");
    ac.registerSingleton("tb", TestBean.class, pvs);
    pvs = new MutablePropertyValues();
    pvs.addPropertyValue("nullValue", "");
    ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
    ac.refresh();
    TestBean tb = (TestBean) ac.getBean("tb");
    assertNull(tb.getName());
  }
View Full Code Here

    TestBean tb = (TestBean) ac.getBean("tb");
    assertNull(tb.getName());
  }

  public void testPropertyPlaceholderConfigurerWithEmptyStringInPlaceholderAsNull() {
    StaticApplicationContext ac = new StaticApplicationContext();
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("name", "${ref}");
    ac.registerSingleton("tb", TestBean.class, pvs);
    pvs = new MutablePropertyValues();
    pvs.addPropertyValue("nullValue", "");
    Properties props = new Properties();
    props.put("ref", "");
    pvs.addPropertyValue("properties", props);
    ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
    ac.refresh();
    TestBean tb = (TestBean) ac.getBean("tb");
    assertNull(tb.getName());
  }
View Full Code Here

    TestBean tb = (TestBean) ac.getBean("tb");
    assertNull(tb.getName());
  }

  public void testPropertyPlaceholderConfigurerWithNestedPlaceholderInKey() {
    StaticApplicationContext ac = new StaticApplicationContext();
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("name", "${my${key}key}");
    ac.registerSingleton("tb", TestBean.class, pvs);
    pvs = new MutablePropertyValues();
    Properties props = new Properties();
    props.put("key", "new");
    props.put("mynewkey", "myname");
    pvs.addPropertyValue("properties", props);
    ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
    ac.refresh();
    TestBean tb = (TestBean) ac.getBean("tb");
    assertEquals("myname", tb.getName());
  }
View Full Code Here

    TestBean tb = (TestBean) ac.getBean("tb");
    assertEquals("myname", tb.getName());
  }

  public void testPropertyPlaceholderConfigurerWithSystemPropertyInLocation() {
    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", "${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

      assertTrue(ex.getMessage().indexOf(userDir) != -1);
    }
  }

  public void testPropertyPlaceholderConfigurerWithSystemPropertiesInLocation() {
    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", "${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

          ex.getMessage().indexOf(userDir + "/test//" + userDir) != -1);
    }
  }

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

      assertTrue(ex.getMessage().indexOf("myprop") != -1);
    }
  }

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

      // expected
    }
  }

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

      // expected
    }
  }

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

TOP

Related Classes of org.springframework.context.support.StaticApplicationContext

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.