Search in sources :

Example 86 with GenericApplicationContext

use of org.springframework.context.support.GenericApplicationContext in project spring-framework by spring-projects.

the class AbstractMBeanServerTests method loadContext.

protected ConfigurableApplicationContext loadContext(String configLocation) {
    GenericApplicationContext ctx = new GenericApplicationContext();
    new XmlBeanDefinitionReader(ctx).loadBeanDefinitions(configLocation);
    ctx.getDefaultListableBeanFactory().registerSingleton("server", this.server);
    ctx.refresh();
    return ctx;
}
Also used : GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) XmlBeanDefinitionReader(org.springframework.beans.factory.xml.XmlBeanDefinitionReader)

Example 87 with GenericApplicationContext

use of org.springframework.context.support.GenericApplicationContext in project spring-framework by spring-projects.

the class FormattingConversionServiceTests method formatFieldForAnnotationWithPlaceholders.

@Test
@SuppressWarnings("resource")
public void formatFieldForAnnotationWithPlaceholders() throws Exception {
    GenericApplicationContext context = new GenericApplicationContext();
    PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
    Properties props = new Properties();
    props.setProperty("dateStyle", "S-");
    props.setProperty("datePattern", "M-d-yy");
    ppc.setProperties(props);
    context.getBeanFactory().registerSingleton("ppc", ppc);
    context.refresh();
    context.getBeanFactory().initializeBean(formattingService, "formattingService");
    formattingService.addFormatterForFieldAnnotation(new JodaDateTimeFormatAnnotationFormatterFactory());
    doTestFormatFieldForAnnotation(ModelWithPlaceholders.class, false);
}
Also used : PropertyPlaceholderConfigurer(org.springframework.beans.factory.config.PropertyPlaceholderConfigurer) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) JodaDateTimeFormatAnnotationFormatterFactory(org.springframework.format.datetime.joda.JodaDateTimeFormatAnnotationFormatterFactory) Properties(java.util.Properties) Test(org.junit.Test)

Example 88 with GenericApplicationContext

use of org.springframework.context.support.GenericApplicationContext in project spring-framework by spring-projects.

the class JeeNamespaceHandlerTests method setUp.

@Before
public void setUp() throws Exception {
    GenericApplicationContext ctx = new GenericApplicationContext();
    new XmlBeanDefinitionReader(ctx).loadBeanDefinitions(new ClassPathResource("jeeNamespaceHandlerTests.xml", getClass()));
    ctx.refresh();
    this.beanFactory = ctx.getBeanFactory();
    this.beanFactory.getBeanNamesForType(ITestBean.class);
}
Also used : GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) XmlBeanDefinitionReader(org.springframework.beans.factory.xml.XmlBeanDefinitionReader) ClassPathResource(org.springframework.core.io.ClassPathResource) Before(org.junit.Before)

Example 89 with GenericApplicationContext

use of org.springframework.context.support.GenericApplicationContext in project spring-framework by spring-projects.

the class AsyncExecutionTests method dynamicAsyncInterfaceWithPostProcessor.

@Test
public void dynamicAsyncInterfaceWithPostProcessor() throws Exception {
    originalThreadName = Thread.currentThread().getName();
    GenericApplicationContext context = new GenericApplicationContext();
    context.registerBeanDefinition("asyncTest", new RootBeanDefinition(DynamicAsyncInterfaceBean.class));
    context.registerBeanDefinition("asyncProcessor", new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class));
    context.refresh();
    AsyncInterface asyncTest = context.getBean("asyncTest", AsyncInterface.class);
    asyncTest.doSomething(10);
    Future<String> future = asyncTest.returnSomething(20);
    assertEquals("20", future.get());
}
Also used : GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) Test(org.junit.Test)

Example 90 with GenericApplicationContext

use of org.springframework.context.support.GenericApplicationContext in project spring-framework by spring-projects.

the class AsyncExecutionTests method asyncClassWithPostProcessor.

@Test
public void asyncClassWithPostProcessor() throws Exception {
    originalThreadName = Thread.currentThread().getName();
    GenericApplicationContext context = new GenericApplicationContext();
    context.registerBeanDefinition("asyncTest", new RootBeanDefinition(AsyncClassBean.class));
    context.registerBeanDefinition("asyncProcessor", new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class));
    context.refresh();
    AsyncClassBean asyncTest = context.getBean("asyncTest", AsyncClassBean.class);
    asyncTest.doSomething(10);
    Future<String> future = asyncTest.returnSomething(20);
    assertEquals("20", future.get());
}
Also used : GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) Test(org.junit.Test)

Aggregations

GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)245 Test (org.junit.Test)190 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)80 ConstructorArgumentValues (org.springframework.beans.factory.config.ConstructorArgumentValues)50 XmlBeanDefinitionReader (org.springframework.beans.factory.xml.XmlBeanDefinitionReader)38 BeanCreationException (org.springframework.beans.factory.BeanCreationException)26 ClassPathResource (org.springframework.core.io.ClassPathResource)19 TestBean (org.springframework.tests.sample.beans.TestBean)17 NoSuchBeanDefinitionException (org.springframework.beans.factory.NoSuchBeanDefinitionException)15 DefaultAdvisorAutoProxyCreator (org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator)12 MBeanExporter (org.springframework.jmx.export.MBeanExporter)11 BeansException (org.springframework.beans.BeansException)8 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)8 HashMap (java.util.HashMap)7 UnsatisfiedDependencyException (org.springframework.beans.factory.UnsatisfiedDependencyException)7 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6 Before (org.junit.Before)6 Properties (java.util.Properties)5 EntityManager (javax.persistence.EntityManager)5 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)5