use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project spring-framework by spring-projects.
the class ConfigurationClassWithPlaceholderConfigurerBeanTests method valueFieldsResolveToPlaceholderSpecifiedDefaultValue.
@Test
public void valueFieldsResolveToPlaceholderSpecifiedDefaultValue() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(ConfigWithValueField.class);
ctx.register(ConfigWithPlaceholderConfigurer.class);
ctx.refresh();
TestBean testBean = ctx.getBean(TestBean.class);
assertThat(testBean.getName(), equalTo("bar"));
}
use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project spring-framework by spring-projects.
the class ConfigurationMetaAnnotationTests method customConfigurationStereotype.
@Test
public void customConfigurationStereotype() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(Config.class);
ctx.refresh();
assertThat(ctx.containsBean("customName"), is(true));
TestBean a = ctx.getBean("a", TestBean.class);
TestBean b = ctx.getBean("b", TestBean.class);
assertThat(b, sameInstance(a.getSpouse()));
}
use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project spring-framework by spring-projects.
the class ImportAnnotationDetectionTests method localAndMetaImportsAreProcessed.
@Test
public void localAndMetaImportsAreProcessed() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(MultiMetaImportConfigWithLocalImport.class);
ctx.refresh();
assertThat(ctx.containsBean("testBean1"), is(true));
assertThat(ctx.containsBean("testBean2"), is(true));
assertThat(ctx.containsBean("testBean3"), is(true));
}
use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project spring-framework by spring-projects.
the class BeanMethodQualificationTests method testCustomWithAttributeOverride.
@Test
public void testCustomWithAttributeOverride() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(CustomConfigWithAttributeOverride.class, CustomPojo.class);
assertFalse(ctx.getBeanFactory().containsSingleton("testBeanX"));
CustomPojo pojo = ctx.getBean(CustomPojo.class);
assertThat(pojo.testBean.getName(), equalTo("interesting"));
}
use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project spring-framework by spring-projects.
the class BeanMethodQualificationTests method testCustomWithAsm.
@Test
public void testCustomWithAsm() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.registerBeanDefinition("customConfig", new RootBeanDefinition(CustomConfig.class.getName()));
RootBeanDefinition customPojo = new RootBeanDefinition(CustomPojo.class.getName());
customPojo.setLazyInit(true);
ctx.registerBeanDefinition("customPojo", customPojo);
ctx.refresh();
assertFalse(ctx.getBeanFactory().containsSingleton("testBean1"));
CustomPojo pojo = ctx.getBean(CustomPojo.class);
assertThat(pojo.testBean.getName(), equalTo("interesting"));
}
Aggregations