Package org.springframework.context.support

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


    pvs = new MutablePropertyValues();
    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());
  }
View Full Code Here


  public void testPropertyPlaceholderConfigurerWithUnresolvableSystemProperty() {
    StaticApplicationContext ac = new StaticApplicationContext();
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("touchy", "${user.dir}");
    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();
View Full Code Here

    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("touchy", "${user.dir}");
    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) {
View Full Code Here

    assertEquals(1, messages.getMessagesBySource("validationcontext").length);
  }

  public void testValidateWithMessageContextForBeanValidator() {
    StaticApplicationContext applicationContext = new StaticApplicationContext();
    applicationContext.registerSingleton("modelValidator", StubModelMessageContext.class);
    ((Flow) requestContext.getActiveFlow()).setApplicationContext(applicationContext);
    ValidationHelper helper = new ValidationHelper(new Object(), requestContext, eventId, modelName, null, null);
    helper.validate();
    MessageContext messages = requestContext.getMessageContext();
    assertEquals(1, messages.getAllMessages().length);
View Full Code Here

    assertEquals(1, messages.getMessagesBySource("messagecontext-external").length);
  }

  public void testValidateWithValidationContextForBeanValidator() {
    StaticApplicationContext applicationContext = new StaticApplicationContext();
    applicationContext.registerSingleton("modelValidator", StubModelValidationContext.class);
    ((Flow) requestContext.getActiveFlow()).setApplicationContext(applicationContext);
    ValidationHelper helper = new ValidationHelper(new Object(), requestContext, eventId, modelName, null, null);
    helper.validate();
    MessageContext messages = requestContext.getMessageContext();
    assertEquals(1, messages.getAllMessages().length);
View Full Code Here

    assertEquals(1, messages.getMessagesBySource("validationcontext-external").length);
  }

  public void testValidateWithErrorsForBeanValidator() {
    StaticApplicationContext applicationContext = new StaticApplicationContext();
    applicationContext.registerSingleton("modelValidator", StubModelErrors.class);
    ((Flow) requestContext.getActiveFlow()).setApplicationContext(applicationContext);
    ValidationHelper helper = new ValidationHelper(new Object(), requestContext, eventId, modelName, null, null);
    helper.validate();
    MessageContext messages = requestContext.getMessageContext();
    assertEquals(1, messages.getAllMessages().length);
View Full Code Here

    assertEquals(1, messages.getMessagesBySource("errors-external").length);
  }

  public void testValidateWithErrorsForBeanValidatorOverridden() {
    StaticApplicationContext applicationContext = new StaticApplicationContext();
    applicationContext.registerSingleton("modelValidator", StubModelErrorsOverridden.class);
    ((Flow) requestContext.getActiveFlow()).setApplicationContext(applicationContext);
    ValidationHelper helper = new ValidationHelper(new Object(), requestContext, eventId, modelName, null, null);
    helper.validate();
    MessageContext messages = requestContext.getMessageContext();
    assertEquals(1, messages.getAllMessages().length);
View Full Code Here

  public void testPropertyPlaceholderConfigurerWithUnresolvablePlaceholder() {
    StaticApplicationContext ac = new StaticApplicationContext();
    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");
    }
View Full Code Here

  public void testPropertyPlaceholderConfigurerWithUnresolvablePlaceholder() {
    StaticApplicationContext ac = new StaticApplicationContext();
    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) {
View Full Code Here

  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");
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.