@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)); } }
@Test public void viaComponentScanning() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.scan("org.springframework.context.annotation.role"); ctx.refresh(); assertThat("Expected bean to have ROLE_APPLICATION", ctx.getBeanDefinition("componentWithoutRole").getRole(), is(BeanDefinition.ROLE_APPLICATION)); assertThat(ctx.getBeanDefinition("componentWithoutRole").getDescription(), is((Object) null)); assertThat("Expected bean to have ROLE_INFRASTRUCTURE", ctx.getBeanDefinition("componentWithRole").getRole(), is(BeanDefinition.ROLE_INFRASTRUCTURE)); assertThat(ctx.getBeanDefinition("componentWithRole").getDescription(), is("A Component with a role")); }
@Test public void onBeanMethod() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(Config.class); ctx.refresh(); assertThat("Expected bean to have ROLE_APPLICATION", ctx.getBeanDefinition("foo").getRole(), is(BeanDefinition.ROLE_APPLICATION)); assertThat(ctx.getBeanDefinition("foo").getDescription(), is((Object) null)); assertThat("Expected bean to have ROLE_INFRASTRUCTURE", ctx.getBeanDefinition("bar").getRole(), is(BeanDefinition.ROLE_INFRASTRUCTURE)); assertThat(ctx.getBeanDefinition("bar").getDescription(), is("A Bean method with a role")); }
@Test public void onComponentClass() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(ComponentWithoutRole.class, ComponentWithRole.class); ctx.refresh(); assertThat("Expected bean to have ROLE_APPLICATION", ctx.getBeanDefinition("componentWithoutRole").getRole(), is(BeanDefinition.ROLE_APPLICATION)); assertThat(ctx.getBeanDefinition("componentWithoutRole").getDescription(), is((Object) null)); assertThat("Expected bean to have ROLE_INFRASTRUCTURE", ctx.getBeanDefinition("componentWithRole").getRole(), is(BeanDefinition.ROLE_INFRASTRUCTURE)); assertThat(ctx.getBeanDefinition("componentWithRole").getDescription(), is("A Component with a role")); }
throw new CannotLoadBeanClassException(beanDefinition.getDescription(), beanName, beanMethod.getReturnTypeName(), e);
beanDefinitionRegistry.getBeanDefinition(name).getDescription(), getProperties(o))); } else { result.add(new BeanDefinitionImpl(classification, id, beanDefinitionRegistry.getBeanDefinition(name).getDescription(), getProperties(o))); beanDefinitionRegistry.getBeanDefinition(name).getDescription(), getProperties(o)));
throw new CannotLoadBeanClassException(beanDefinition.getDescription(), beanName, beanMethod.getReturnTypeName(), e);
beanDefinitionRegistry.getBeanDefinition(name).getDescription(), getProperties(o))); } else { result.add(new BeanDefinitionImpl(classification, id, beanDefinitionRegistry.getBeanDefinition(name).getDescription(), getProperties(o))); beanDefinitionRegistry.getBeanDefinition(name).getDescription(), getProperties(o)));
setOriginatingBeanDefinition( original ); setPrimary( original.isPrimary() ); setDescription( original.getDescription() ); setRole( original.getRole() ); setScope( original.getScope() );