Package org.springframework.context.support

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


    pvs.addPropertyValue("userTreePath", "myUserPath");
    ac.registerSingleton("configurer", PreferencesPlaceholderConfigurer.class, pvs);
    Preferences.systemRoot().node("mySystemPath").put("myName", "myNameValue");
    Preferences.systemRoot().node("mySystemPath").put("myTouchy", "myTouchyValue");
    Preferences.userRoot().node("myUserPath").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().node("myUserPath").remove("myTouchy");
View Full Code Here


    pvs.addPropertyValue("userTreePath", "myUserPath");
    ac.registerSingleton("configurer", PreferencesPlaceholderConfigurer.class, pvs);
    Preferences.systemRoot().node("mySystemPath").node("mypath").put("myName", "myNameValue");
    Preferences.systemRoot().node("mySystemPath/myotherpath").put("myTouchy", "myTouchyValue");
    Preferences.userRoot().node("myUserPath/myotherpath").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().node("myUserPath/myotherpath").remove("myTouchy");
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

    ac.registerSingleton("tb1", TestBean.class);
    ac.registerSingleton("tb2", TestBean.class);
    TestBeanFactoryPostProcessor bfpp = new TestBeanFactoryPostProcessor();
    ac.addBeanFactoryPostProcessor(bfpp);
    assertFalse(bfpp.wasCalled);
    ac.refresh();
    assertTrue(bfpp.wasCalled);
  }
 
  public void testDefinedBeanFactoryPostProcessor() {
    StaticApplicationContext ac = new StaticApplicationContext();
View Full Code Here

  public void testDefinedBeanFactoryPostProcessor() {
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.registerSingleton("tb1", TestBean.class);
    ac.registerSingleton("tb2", TestBean.class);
    ac.registerSingleton("bfpp", TestBeanFactoryPostProcessor.class);
    ac.refresh();
    TestBeanFactoryPostProcessor bfpp = (TestBeanFactoryPostProcessor) ac.getBean("bfpp");
    assertTrue(bfpp.wasCalled);
  }

  public void testMultipleDefinedBeanFactoryPostProcessors() {
View Full Code Here

    pvs1.addPropertyValue("initValue", "${key}");
    ac.registerSingleton("bfpp1", TestBeanFactoryPostProcessor.class, pvs1);
    MutablePropertyValues pvs2 = new MutablePropertyValues();
    pvs2.addPropertyValue("properties", "key=value");
    ac.registerSingleton("bfpp2", PropertyPlaceholderConfigurer.class, pvs2);
    ac.refresh();
    TestBeanFactoryPostProcessor bfpp = (TestBeanFactoryPostProcessor) ac.getBean("bfpp1");
    assertEquals("value", bfpp.initValue);
    assertTrue(bfpp.wasCalled);
  }
View Full Code Here

    StaticApplicationContext ctx = new StaticApplicationContext();
    ctx.registerSingleton("testService", TestService.class, new MutablePropertyValues());
    MutablePropertyValues mpv = new MutablePropertyValues();
    mpv.addPropertyValue(new PropertyValue("serviceLocatorInterface", TestServiceLocator.class));
    ctx.registerSingleton("factory", ServiceLocatorFactoryBean.class, mpv);
    ctx.refresh();

    TestServiceLocator factory = (TestServiceLocator) ctx.getBean("factory");
    TestService testService = factory.getTestService();
    assertNotNull(testService);
  }
View Full Code Here

    mpv.addPropertyValue(new PropertyValue("serviceLocatorInterface", TestServiceLocator2.class));
    ctx.registerSingleton("factory2", ServiceLocatorFactoryBean.class, mpv);
    mpv = new MutablePropertyValues();
    mpv.addPropertyValue(new PropertyValue("serviceLocatorInterface", TestService2Locator.class));
    ctx.registerSingleton("factory3", ServiceLocatorFactoryBean.class, mpv);
    ctx.refresh();

    final TestServiceLocator factory = (TestServiceLocator) ctx.getBean("factory");
    new AssertThrows(NoSuchBeanDefinitionException.class, "Must fail on more than one matching type") {
      public void test() throws Exception {
        factory.getTestService();
View Full Code Here

    ctx.registerSingleton("factory2", ServiceLocatorFactoryBean.class, mpv);
    mpv = new MutablePropertyValues();
    mpv.addPropertyValue(new PropertyValue("serviceLocatorInterface", TestService2Locator.class));
    mpv.addPropertyValue(new PropertyValue("serviceLocatorExceptionClass", CustomServiceLocatorException3.class));
    ctx.registerSingleton("factory3", ServiceLocatorFactoryBean.class, mpv);
    ctx.refresh();

    TestServiceLocator factory = (TestServiceLocator) ctx.getBean("factory");
    try {
      factory.getTestService();
      fail("Must fail on more than one matching type");
View Full Code Here

    StaticApplicationContext ctx = new StaticApplicationContext();
    ctx.registerSingleton("testService", TestService.class, new MutablePropertyValues());
    MutablePropertyValues mpv = new MutablePropertyValues();
    mpv.addPropertyValue(new PropertyValue("serviceLocatorInterface", TestServiceLocator2.class));
    ctx.registerSingleton("factory", ServiceLocatorFactoryBean.class, mpv);
    ctx.refresh();

    // test string-arg getter with null id
    final TestServiceLocator2 factory = (TestServiceLocator2) ctx.getBean("factory");
    TestService testBean = factory.getTestService(null);
    // now test with explicit id
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.