Package org.springframework.context.support

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


    pvs = new MutablePropertyValues();
    pvs.addPropertyValue("singleton", "false");
    sac.registerSingleton("prototypeFactoryToBeProxied", DummyFactory.class, pvs);

    sac.refresh();

    TestAutoProxyCreator tapc = (TestAutoProxyCreator) sac.getBean("testAutoProxyCreator");
    tapc.testInterceptor.nrOfInvocations = 0;

    FactoryBean prototypeFactory = (FactoryBean) sac.getBean("&prototypeFactoryToBeProxied");
View Full Code Here


    return services;
  }

  private static StaticApplicationContext createTestApplicationContext() {
    StaticApplicationContext context = new StaticApplicationContext();
    context.refresh();
    return context;
  }
}
View Full Code Here

    StaticApplicationContext context = new StaticApplicationContext();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
    reader.loadBeanDefinitions(CONFIG_LOCATION);
    context.registerSingleton("testBean", NonQualifiedTestBean.class);
    try {
      context.refresh();
      fail("Should have thrown a BeanCreationException");
    }
    catch (BeanCreationException e) {
      assertTrue(e.getMessage().contains("found 6"));
    }
View Full Code Here

  public void testQualifiedByValue() {
    StaticApplicationContext context = new StaticApplicationContext();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
    reader.loadBeanDefinitions(CONFIG_LOCATION);
    context.registerSingleton("testBean", QualifiedByValueTestBean.class);
    context.refresh();
    QualifiedByValueTestBean testBean = (QualifiedByValueTestBean) context.getBean("testBean");
    Person person = testBean.getLarry();
    assertEquals("Larry", person.getName());
  }
View Full Code Here

  public void testQualifiedByBeanName() {
    StaticApplicationContext context = new StaticApplicationContext();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
    reader.loadBeanDefinitions(CONFIG_LOCATION);
    context.registerSingleton("testBean", QualifiedByBeanNameTestBean.class);
    context.refresh();
    QualifiedByBeanNameTestBean testBean = (QualifiedByBeanNameTestBean) context.getBean("testBean");
    Person person = testBean.getLarry();
    assertEquals("LarryBean", person.getName());
  }
View Full Code Here

  public void testQualifiedByAlias() {
    StaticApplicationContext context = new StaticApplicationContext();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
    reader.loadBeanDefinitions(CONFIG_LOCATION);
    context.registerSingleton("testBean", QualifiedByAliasTestBean.class);
    context.refresh();
    QualifiedByAliasTestBean testBean = (QualifiedByAliasTestBean) context.getBean("testBean");
    Person person = testBean.getStooge();
    assertEquals("LarryBean", person.getName());   
  }
View Full Code Here

  public void testQualifiedByAnnotation() {
    StaticApplicationContext context = new StaticApplicationContext();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
    reader.loadBeanDefinitions(CONFIG_LOCATION);
    context.registerSingleton("testBean", QualifiedByAnnotationTestBean.class);
    context.refresh();
    QualifiedByAnnotationTestBean testBean = (QualifiedByAnnotationTestBean) context.getBean("testBean");
    Person person = testBean.getLarry();
    assertEquals("LarrySpecial", person.getName());
  }
View Full Code Here

  public void testQualifiedByCustomValue() {
    StaticApplicationContext context = new StaticApplicationContext();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
    reader.loadBeanDefinitions(CONFIG_LOCATION);
    context.registerSingleton("testBean", QualifiedByCustomValueTestBean.class);
    context.refresh();
    QualifiedByCustomValueTestBean testBean = (QualifiedByCustomValueTestBean) context.getBean("testBean");
    Person person = testBean.getCurly();
    assertEquals("Curly", person.getName());
  }
View Full Code Here

  public void testQualifiedByAnnotationValue() {
    StaticApplicationContext context = new StaticApplicationContext();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
    reader.loadBeanDefinitions(CONFIG_LOCATION);
    context.registerSingleton("testBean", QualifiedByAnnotationValueTestBean.class);
    context.refresh();
    QualifiedByAnnotationValueTestBean testBean = (QualifiedByAnnotationValueTestBean) context.getBean("testBean");
    Person person = testBean.getLarry();
    assertEquals("LarrySpecial", person.getName());
  }
View Full Code Here

    StaticApplicationContext context = new StaticApplicationContext();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
    reader.loadBeanDefinitions(CONFIG_LOCATION);
    context.registerSingleton("testBean", QualifiedByAttributesTestBean.class);
    try {
      context.refresh();
      fail("should have thrown a BeanCreationException");
    }
    catch (BeanCreationException e) {
      assertTrue(e.getMessage().contains("found 6"));
    }
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.