use of cn.taketoday.beans.factory.support.GenericBeanDefinition in project today-infrastructure by TAKETODAY.
the class StandardDependenciesBeanPostProcessorTests method testIncompleteBeanDefinition.
@Test
public void testIncompleteBeanDefinition() {
bf.registerBeanDefinition("testBean", new GenericBeanDefinition());
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> bf.getBean("testBean")).withRootCauseInstanceOf(IllegalStateException.class);
}
use of cn.taketoday.beans.factory.support.GenericBeanDefinition in project today-infrastructure by TAKETODAY.
the class AutowiredAnnotationBeanPostProcessorTests method testIncompleteBeanDefinition.
@Test
public void testIncompleteBeanDefinition() {
bf.registerBeanDefinition("testBean", new GenericBeanDefinition());
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> bf.getBean("testBean")).withRootCauseInstanceOf(IllegalStateException.class);
}
use of cn.taketoday.beans.factory.support.GenericBeanDefinition in project today-infrastructure by TAKETODAY.
the class BeanDefinitionTests method genericBeanDefinitionEquality.
@Test
public void genericBeanDefinitionEquality() {
GenericBeanDefinition bd = new GenericBeanDefinition();
bd.setParentName("parent");
bd.setScope("request");
bd.setAbstract(true);
bd.setLazyInit(true);
GenericBeanDefinition otherBd = new GenericBeanDefinition();
otherBd.setScope("request");
otherBd.setAbstract(true);
otherBd.setLazyInit(true);
boolean condition1 = !bd.equals(otherBd);
assertThat(condition1).isTrue();
boolean condition = !otherBd.equals(bd);
assertThat(condition).isTrue();
otherBd.setParentName("parent");
assertThat(bd.equals(otherBd)).isTrue();
assertThat(otherBd.equals(bd)).isTrue();
assertThat(bd.hashCode() == otherBd.hashCode()).isTrue();
bd.getPropertyValues();
assertThat(bd.equals(otherBd)).isTrue();
assertThat(otherBd.equals(bd)).isTrue();
assertThat(bd.hashCode() == otherBd.hashCode()).isTrue();
bd.getConstructorArgumentValues();
assertThat(bd.equals(otherBd)).isTrue();
assertThat(otherBd.equals(bd)).isTrue();
assertThat(bd.hashCode() == otherBd.hashCode()).isTrue();
}
use of cn.taketoday.beans.factory.support.GenericBeanDefinition in project today-infrastructure by TAKETODAY.
the class MapperScanTest method testScanWithNameConflict.
@Test
void testScanWithNameConflict() {
GenericBeanDefinition definition = new GenericBeanDefinition();
definition.setBeanClass(Object.class);
applicationContext.registerBeanDefinition("mapperInterface", definition);
applicationContext.register(AppConfigWithPackageScan.class);
startContext();
assertThat(applicationContext.getBean("mapperInterface").getClass()).as("scanner should not overwrite existing bean definition").isSameAs(Object.class);
}
use of cn.taketoday.beans.factory.support.GenericBeanDefinition in project today-infrastructure by TAKETODAY.
the class MapperScanTest method testScanWithExplicitSqlSessionTemplate.
@Test
void testScanWithExplicitSqlSessionTemplate() {
GenericBeanDefinition definition = new GenericBeanDefinition();
definition.setBeanClass(SqlSessionTemplate.class);
ConstructorArgumentValues constructorArgs = new ConstructorArgumentValues();
constructorArgs.addGenericArgumentValue(new RuntimeBeanReference("sqlSessionFactory"));
definition.setConstructorArgumentValues(constructorArgs);
applicationContext.registerBeanDefinition("sqlSessionTemplate", definition);
applicationContext.register(AppConfigWithSqlSessionTemplate.class);
startContext();
// all interfaces with methods should be loaded
applicationContext.getBean("mapperInterface");
applicationContext.getBean("mapperSubinterface");
applicationContext.getBean("mapperChildInterface");
applicationContext.getBean("annotatedMapper");
}
Aggregations