use of cn.taketoday.context.ApplicationContext in project today-infrastructure by TAKETODAY.
the class Spr7816Tests method spr7816.
@Test
public void spr7816() {
ApplicationContext ctx = new ClassPathXmlApplicationContext("spr7816.xml", getClass());
FilterAdapter adapter = ctx.getBean(FilterAdapter.class);
assertThat(adapter.getSupportedTypes().get("Building")).isEqualTo(Building.class);
assertThat(adapter.getSupportedTypes().get("Entrance")).isEqualTo(Entrance.class);
assertThat(adapter.getSupportedTypes().get("Dwelling")).isEqualTo(Dwelling.class);
}
use of cn.taketoday.context.ApplicationContext in project today-infrastructure by TAKETODAY.
the class GenericXmlApplicationContextTests method classRelativeResourceLoading_ctor.
@Test
public void classRelativeResourceLoading_ctor() {
ApplicationContext ctx = new GenericXmlApplicationContext(RELATIVE_CLASS, RESOURCE_NAME);
assertThat(ctx.containsBean(TEST_BEAN_NAME)).isTrue();
}
use of cn.taketoday.context.ApplicationContext in project today-infrastructure by TAKETODAY.
the class PayloadApplicationEventTests method testEventClassWithInterface.
@Test
@SuppressWarnings("resource")
void testEventClassWithInterface() {
ApplicationContext ac = new AnnotationConfigApplicationContext(AuditableListener.class);
AuditablePayloadEvent<String> event = new AuditablePayloadEvent<>(this, "xyz");
ac.publishEvent(event);
assertThat(ac.getBean(AuditableListener.class).events.contains(event)).isTrue();
}
use of cn.taketoday.context.ApplicationContext in project today-infrastructure by TAKETODAY.
the class ApplicationContextEventTests method testEventPublicationInterceptor.
@Test
public void testEventPublicationInterceptor() throws Throwable {
MethodInvocation invocation = mock(MethodInvocation.class);
ApplicationContext ctx = mock(ApplicationContext.class);
EventPublicationInterceptor interceptor = new EventPublicationInterceptor();
interceptor.setApplicationEventClass(MyEvent.class);
interceptor.setApplicationEventPublisher(ctx);
interceptor.afterPropertiesSet();
given(invocation.proceed()).willReturn(new Object());
given(invocation.getThis()).willReturn(new Object());
interceptor.invoke(invocation);
verify(ctx).publishEvent(isA(MyEvent.class));
}
use of cn.taketoday.context.ApplicationContext in project today-infrastructure by TAKETODAY.
the class ConfigurationClassAspectIntegrationTests method withInnerClassAndLambdaExpression.
// @Test
// public void aspectAnnotatedConfiguration() {
// assertAdviceWasApplied(AspectConfig.class);
// }
//
// @Test
// public void configurationIncludesAspect() {
// assertAdviceWasApplied(ConfigurationWithAspect.class);
// }
//
// private void assertAdviceWasApplied(Class<?> configClass) {
// StandardBeanFactory factory = new StandardBeanFactory();
// new XmlBeanDefinitionReader(factory).loadBeanDefinitions(
// new ClassPathResource("aspectj-autoproxy-config.xml", ConfigurationClassAspectIntegrationTests.class));
// DefaultApplicationContext ctx = new DefaultApplicationContext(factory);
// ctx.addBeanFactoryPostProcessor(new ConfigurationClassPostProcessor(loadingContext));
// ctx.registerBeanDefinition("config", new BeanDefinition(configClass));
// ctx.refresh();
//
// TestBean testBean = ctx.getBean("testBean", TestBean.class);
// assertThat(testBean.getName()).isEqualTo("name");
// testBean.absquatulate();
// assertThat(testBean.getName()).isEqualTo("advisedName");
// }
@Test
public void withInnerClassAndLambdaExpression() {
ApplicationContext ctx = new StandardApplicationContext(Application.class, CountingAspect.class);
ctx.getBeansOfType(Runnable.class).forEach((k, v) -> v.run());
// TODO: returns just 1 as of AspectJ 1.9 beta 3, not detecting the applicable lambda expression anymore
// assertEquals(2, ctx.getBean(CountingAspect.class).count);
}
Aggregations