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