Package org.springframework.context.support

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


    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("touchy", "${os.name}");
    ac.registerSingleton("tb", TestBean.class, pvs);
    pvs = new MutablePropertyValues();
    ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
    ac.refresh();
    TestBean tb = (TestBean) ac.getBean("tb");
    assertEquals(System.getProperty("os.name"), tb.getTouchy());
  }

  public void testPropertyPlaceholderConfigurerWithSystemPropertyNotUsed() {
View Full Code Here


    pvs = new MutablePropertyValues();
    Properties props = new Properties();
    props.put("os.name", "myos");
    pvs.addPropertyValue("properties", props);
    ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
    ac.refresh();
    TestBean tb = (TestBean) ac.getBean("tb");
    assertEquals("myos", tb.getTouchy());
  }

  public void testPropertyPlaceholderConfigurerWithOverridingSystemProperty() {
View Full Code Here

    Properties props = new Properties();
    props.put("os.name", "myos");
    pvs.addPropertyValue("properties", props);
    pvs.addPropertyValue("systemPropertiesModeName", "SYSTEM_PROPERTIES_MODE_OVERRIDE");
    ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
    ac.refresh();
    TestBean tb = (TestBean) ac.getBean("tb");
    assertEquals(System.getProperty("os.name"), tb.getTouchy());
  }

  public void testPropertyPlaceholderConfigurerWithUnresolvableSystemProperty() {
View Full Code Here

    ac.registerSingleton("tb", TestBean.class, pvs);
    pvs = new MutablePropertyValues();
    pvs.addPropertyValue("systemPropertiesModeName", "SYSTEM_PROPERTIES_MODE_NEVER");
    ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
    try {
      ac.refresh();
      fail("Should have thrown BeanDefinitionStoreException");
    }
    catch (BeanDefinitionStoreException ex) {
      // expected
      assertTrue(ex.getMessage().indexOf("user.dir") != -1);
View Full Code Here

  public void testResolveMessage() {
    MockRequestContext context = new MockRequestContext();
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.getStaticMessageSource().addMessage("foo", Locale.FRANCE, "bar");
    ac.refresh();
    context.getRootFlow().setApplicationContext(ac);
    context.getMockExternalContext().setLocale(Locale.FRANCE);
    Expression exp = parser.parseExpression("resourceBundle.foo", new FluentParserContext()
        .evaluate(RequestContext.class));
    assertEquals("bar", exp.getValue(context));
View Full Code Here

    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("name", "${ref}");
    ac.registerSingleton("tb", TestBean.class, pvs);
    ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, null);
    try {
      ac.refresh();
      fail("Should have thrown BeanDefinitionStoreException");
    }
    catch (BeanDefinitionStoreException ex) {
      // expected
      assertTrue(ex.getMessage().indexOf("ref") != -1);
View Full Code Here

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

  public void testPropertyPlaceholderConfigurerWithEmptyStringAsNull() {
View Full Code Here

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

  public void testPropertyPlaceholderConfigurerWithEmptyStringInPlaceholderAsNull() {
View Full Code Here

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

  public void testPropertyPlaceholderConfigurerWithNestedPlaceholderInKey() {
View Full Code Here

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

  public void testPropertyPlaceholderConfigurerWithSystemPropertyInLocation() {
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.