use of org.springframework.context.support.GenericXmlApplicationContext in project spring-framework by spring-projects.
the class GroovyAspectIntegrationTests method testGroovyBeanProxyTargetClass.
@Test
public void testGroovyBeanProxyTargetClass() {
context = new GenericXmlApplicationContext(getClass(), getClass().getSimpleName() + "-groovy-proxy-target-class-context.xml");
TestService bean = context.getBean("groovyBean", TestService.class);
LogUserAdvice logAdvice = context.getBean(LogUserAdvice.class);
assertThat(logAdvice.getCountThrows()).isEqualTo(0);
assertThatExceptionOfType(RuntimeException.class).isThrownBy(bean::sayHello).withMessage("GroovyServiceImpl");
assertThat(logAdvice.getCountBefore()).isEqualTo(1);
assertThat(logAdvice.getCountThrows()).isEqualTo(1);
}
use of org.springframework.context.support.GenericXmlApplicationContext in project spring-framework by spring-projects.
the class GroovyAspectIntegrationTests method testGroovyBeanInterface.
@Test
public void testGroovyBeanInterface() {
context = new GenericXmlApplicationContext(getClass(), getClass().getSimpleName() + "-groovy-interface-context.xml");
TestService bean = context.getBean("groovyBean", TestService.class);
LogUserAdvice logAdvice = context.getBean(LogUserAdvice.class);
assertThat(logAdvice.getCountThrows()).isEqualTo(0);
assertThatExceptionOfType(RuntimeException.class).isThrownBy(bean::sayHello).withMessage("GroovyServiceImpl");
assertThat(logAdvice.getCountThrows()).isEqualTo(1);
}
use of org.springframework.context.support.GenericXmlApplicationContext in project spring-framework by spring-projects.
the class DestroyMethodInferenceTests method xml.
@Test
public void xml() {
ConfigurableApplicationContext ctx = new GenericXmlApplicationContext(getClass(), "DestroyMethodInferenceTests-context.xml");
WithLocalCloseMethod x1 = ctx.getBean("x1", WithLocalCloseMethod.class);
WithLocalCloseMethod x2 = ctx.getBean("x2", WithLocalCloseMethod.class);
WithLocalCloseMethod x3 = ctx.getBean("x3", WithLocalCloseMethod.class);
WithNoCloseMethod x4 = ctx.getBean("x4", WithNoCloseMethod.class);
WithInheritedCloseMethod x8 = ctx.getBean("x8", WithInheritedCloseMethod.class);
WithDisposableBean x9 = ctx.getBean("x9", WithDisposableBean.class);
WithAutoCloseable x10 = ctx.getBean("x10", WithAutoCloseable.class);
assertThat(x1.closed).isFalse();
assertThat(x2.closed).isFalse();
assertThat(x3.closed).isFalse();
assertThat(x4.closed).isFalse();
assertThat(x8.closed).isFalse();
assertThat(x9.closed).isFalse();
assertThat(x10.closed).isFalse();
ctx.close();
assertThat(x1.closed).isFalse();
assertThat(x2.closed).isTrue();
assertThat(x3.closed).isTrue();
assertThat(x4.closed).isFalse();
assertThat(x8.closed).isFalse();
assertThat(x9.closed).isTrue();
assertThat(x10.closed).isTrue();
}
use of org.springframework.context.support.GenericXmlApplicationContext in project spring-framework by spring-projects.
the class EnableLoadTimeWeavingTests method control.
@Test
public void control() {
GenericXmlApplicationContext ctx = new GenericXmlApplicationContext(getClass(), "EnableLoadTimeWeavingTests-context.xml");
ctx.getBean("loadTimeWeaver", LoadTimeWeaver.class);
}
use of org.springframework.context.support.GenericXmlApplicationContext in project spring-framework by spring-projects.
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