use of cn.taketoday.context.support.GenericXmlApplicationContext in project today-infrastructure by TAKETODAY.
the class AsyncAnnotationBeanPostProcessorTests method configuredThroughNamespace.
@Test
public void configuredThroughNamespace() {
GenericXmlApplicationContext context = new GenericXmlApplicationContext();
context.load(new ClassPathResource("taskNamespaceTests.xml", getClass()));
context.refresh();
ITestBean testBean = context.getBean("target", ITestBean.class);
testBean.test();
testBean.await(3000);
Thread asyncThread = testBean.getThread();
assertThat(asyncThread.getName().startsWith("testExecutor")).isTrue();
TestableAsyncUncaughtExceptionHandler exceptionHandler = context.getBean("exceptionHandler", TestableAsyncUncaughtExceptionHandler.class);
assertThat(exceptionHandler.isCalled()).as("handler should not have been called yet").isFalse();
testBean.failWithVoid();
exceptionHandler.await(3000);
Method m = ReflectionUtils.findMethod(TestBean.class, "failWithVoid");
exceptionHandler.assertCalledWith(m, UnsupportedOperationException.class);
context.close();
}
use of cn.taketoday.context.support.GenericXmlApplicationContext in project today-infrastructure by TAKETODAY.
the class JCacheAspectJNamespaceConfigTests method getApplicationContext.
@Override
protected ApplicationContext getApplicationContext() {
GenericXmlApplicationContext context = new GenericXmlApplicationContext();
// Disallow bean definition overriding to test https://github.com/spring-projects/spring-framework/pull/27499
context.setAllowBeanDefinitionOverriding(false);
context.load("/cn/taketoday/cache/config/annotation-jcache-aspectj.xml");
context.refresh();
return context;
}
use of cn.taketoday.context.support.GenericXmlApplicationContext in project today-infrastructure by TAKETODAY.
the class EnvironmentSystemIntegrationTests method genericXmlApplicationContext.
@Test
void genericXmlApplicationContext() {
GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
assertHasStandardEnvironment(ctx);
ctx.setEnvironment(prodEnv);
ctx.load(Constants.XML_PATH);
ctx.refresh();
assertHasEnvironment(ctx, prodEnv);
assertEnvironmentBeanRegistered(ctx);
assertEnvironmentAwareInvoked(ctx, prodEnv);
assertThat(ctx.containsBean(Constants.DEV_BEAN_NAME)).isFalse();
assertThat(ctx.containsBean(Constants.PROD_BEAN_NAME)).isTrue();
}
use of cn.taketoday.context.support.GenericXmlApplicationContext in project today-infrastructure by TAKETODAY.
the class AnnotationNamespaceDrivenTests method cacheResolver.
@Test
public void cacheResolver() {
try {
ConfigurableApplicationContext context = new GenericXmlApplicationContext("cn/taketoday/cache/config/annotationDrivenCacheNamespace-resolver.xml");
CacheInterceptor ci = context.getBean(CacheInterceptor.class);
assertThat(ci.getCacheResolver()).isSameAs(context.getBean("cacheResolver"));
context.close();
} catch (Throwable e) {
e.printStackTrace();
}
}
use of cn.taketoday.context.support.GenericXmlApplicationContext in project today-framework by TAKETODAY.
the class AsyncAnnotationBeanPostProcessorTests method configuredThroughNamespace.
@Test
public void configuredThroughNamespace() {
GenericXmlApplicationContext context = new GenericXmlApplicationContext();
context.load(new ClassPathResource("taskNamespaceTests.xml", getClass()));
context.refresh();
ITestBean testBean = context.getBean("target", ITestBean.class);
testBean.test();
testBean.await(3000);
Thread asyncThread = testBean.getThread();
assertThat(asyncThread.getName().startsWith("testExecutor")).isTrue();
TestableAsyncUncaughtExceptionHandler exceptionHandler = context.getBean("exceptionHandler", TestableAsyncUncaughtExceptionHandler.class);
assertThat(exceptionHandler.isCalled()).as("handler should not have been called yet").isFalse();
testBean.failWithVoid();
exceptionHandler.await(3000);
Method m = ReflectionUtils.findMethod(TestBean.class, "failWithVoid");
exceptionHandler.assertCalledWith(m, UnsupportedOperationException.class);
context.close();
}
Aggregations