use of cn.taketoday.context.ApplicationContext in project today-infrastructure by TAKETODAY.
the class JoinPointMonitorAtAspectJAspect method checkAtAspectJAspect.
private void checkAtAspectJAspect(String appContextFile) {
ApplicationContext context = new ClassPathXmlApplicationContext(appContextFile, getClass());
ICounter counter = (ICounter) context.getBean("counter");
boolean condition = counter instanceof Advised;
assertThat(condition).as("Proxy didn't get created").isTrue();
counter.increment();
JoinPointMonitorAtAspectJAspect callCountingAspect = (JoinPointMonitorAtAspectJAspect) context.getBean("monitoringAspect");
assertThat(callCountingAspect.beforeExecutions).as("Advise didn't get executed").isEqualTo(1);
assertThat(callCountingAspect.aroundExecutions).as("Advise didn't get executed").isEqualTo(1);
}
use of cn.taketoday.context.ApplicationContext in project today-infrastructure by TAKETODAY.
the class JoinPointMonitorAtAspectJAspect method checkXmlAspect.
private void checkXmlAspect(String appContextFile) {
ApplicationContext context = new ClassPathXmlApplicationContext(appContextFile, getClass());
ICounter counter = (ICounter) context.getBean("counter");
boolean condition = counter instanceof Advised;
assertThat(condition).as("Proxy didn't get created").isTrue();
counter.increment();
JoinPointMonitorAspect callCountingAspect = (JoinPointMonitorAspect) context.getBean("monitoringAspect");
assertThat(callCountingAspect.beforeExecutions).as("Advise didn't get executed").isEqualTo(1);
assertThat(callCountingAspect.aroundExecutions).as("Advise didn't get executed").isEqualTo(1);
}
use of cn.taketoday.context.ApplicationContext in project today-infrastructure by TAKETODAY.
the class CacheResolverCustomizationTests method setup.
@BeforeEach
public void setup() {
ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
this.cacheManager = context.getBean("cacheManager", CacheManager.class);
this.anotherCacheManager = context.getBean("anotherCacheManager", CacheManager.class);
this.simpleService = context.getBean(SimpleService.class);
}
use of cn.taketoday.context.ApplicationContext in project today-infrastructure by TAKETODAY.
the class AnnoTestBean method getBeanByTypeAmbiguityRaisesException.
@Test
void getBeanByTypeAmbiguityRaisesException() {
ApplicationContext context = new AnnotationConfigApplicationContext(TwoTestBeanConfig.class);
assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() -> context.getBean(AnnoTestBean.class)).withMessageContaining("No qualifying bean of type '" + AnnoTestBean.class.getName() + "'").withMessageContaining("tb1").withMessageContaining("tb2");
}
use of cn.taketoday.context.ApplicationContext in project today-infrastructure by TAKETODAY.
the class AnnoTestBean method explicitConfigClassBeanNameIsRespected.
/**
* Tests that specifying @Configuration(value="foo") results in registering
* the configuration class with bean name 'foo'.
*/
@Test
void explicitConfigClassBeanNameIsRespected() {
ApplicationContext context = new AnnotationConfigApplicationContext(ConfigWithCustomName.class);
// attempt to retrieve the instance by its specified name
ConfigWithCustomName configObject = (ConfigWithCustomName) context.getBean("customConfigBeanName");
assertThat(configObject).isNotNull();
}
Aggregations