use of org.springframework.context.ConfigurableApplicationContext in project spring-framework by spring-projects.
the class EnableAspectJAutoProxyTests method withAnnotationOnArgumentAndCglibProxy.
@Test
public void withAnnotationOnArgumentAndCglibProxy() {
ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(ConfigWithCglibProxy.class, SampleService.class, LoggingAspect.class);
SampleService sampleService = ctx.getBean(SampleService.class);
sampleService.execute(new SampleDto());
sampleService.execute(new SampleInputBean());
sampleService.execute((SampleDto) null);
sampleService.execute((SampleInputBean) null);
}
use of org.springframework.context.ConfigurableApplicationContext in project spring-framework by spring-projects.
the class EnableAspectJAutoProxyTests method withAnnotationOnArgumentAndJdkProxy.
@Test
public void withAnnotationOnArgumentAndJdkProxy() {
ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(ConfigWithJdkProxy.class, SampleService.class, LoggingAspect.class);
SampleService sampleService = ctx.getBean(SampleService.class);
sampleService.execute(new SampleDto());
sampleService.execute(new SampleInputBean());
sampleService.execute((SampleDto) null);
sampleService.execute((SampleInputBean) null);
}
use of org.springframework.context.ConfigurableApplicationContext in project spring-framework by spring-projects.
the class MyPostProcessor method test.
@Test
public void test() {
ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(MyConfig.class);
assertThat("someDependency was not post processed", ctx.getBeanFactory().getBeanDefinition("someDependency").getDescription(), equalTo("post processed by MyPostProcessor"));
MyConfig config = ctx.getBean(MyConfig.class);
assertTrue("Config class was not enhanced", ClassUtils.isCglibProxy(config));
}
use of org.springframework.context.ConfigurableApplicationContext in project spring-framework by spring-projects.
the class LiveBeansViewTests method registerUnregisterServeralContextsDifferentOrder.
@Test
public void registerUnregisterServeralContextsDifferentOrder() throws MalformedObjectNameException {
this.environment.setProperty(LiveBeansView.MBEAN_DOMAIN_PROPERTY_NAME, this.name.getMethodName());
ConfigurableApplicationContext context = createApplicationContext("app");
ConfigurableApplicationContext childContext = createApplicationContext("child");
assertEquals(0, searchLiveBeansViewMeans().size());
LiveBeansView.registerApplicationContext(context);
assertSingleLiveBeansViewMbean("app");
LiveBeansView.registerApplicationContext(childContext);
// Only one MBean
assertSingleLiveBeansViewMbean("app");
LiveBeansView.unregisterApplicationContext(context);
LiveBeansView.unregisterApplicationContext(childContext);
assertEquals(0, searchLiveBeansViewMeans().size());
}
use of org.springframework.context.ConfigurableApplicationContext in project spring-framework by spring-projects.
the class LiveBeansViewTests method registerUnregisterServeralContexts.
@Test
public void registerUnregisterServeralContexts() throws MalformedObjectNameException {
this.environment.setProperty(LiveBeansView.MBEAN_DOMAIN_PROPERTY_NAME, this.name.getMethodName());
ConfigurableApplicationContext context = createApplicationContext("app");
ConfigurableApplicationContext childContext = createApplicationContext("child");
assertEquals(0, searchLiveBeansViewMeans().size());
LiveBeansView.registerApplicationContext(context);
assertSingleLiveBeansViewMbean("app");
LiveBeansView.registerApplicationContext(childContext);
// Only one MBean
assertEquals(1, searchLiveBeansViewMeans().size());
LiveBeansView.unregisterApplicationContext(childContext);
// Root context removes it
assertSingleLiveBeansViewMbean("app");
LiveBeansView.unregisterApplicationContext(context);
assertEquals(0, searchLiveBeansViewMeans().size());
}
Aggregations