use of org.apache.ibatis.annotations.Mapper in project today-framework by TAKETODAY.
the class MapperScannerConfigurerTest method testScopedProxyMapperScanByDefault.
@Test
@Disabled
void testScopedProxyMapperScanByDefault() {
applicationContext.getBeanDefinition("mapperScanner").propertyValues().add("defaultScope", "thread");
startContext();
List<String> scopedProxyTargetBeans = Stream.of(applicationContext.getBeanDefinitionNames()).filter(x -> x.startsWith("scopedTarget")).collect(Collectors.toList());
assertThat(scopedProxyTargetBeans).hasSize(6).contains("scopedTarget.scopedProxyMapper", "scopedTarget.annotatedMapper", "scopedTarget.annotatedMapperZeroMethods", "scopedTarget.mapperInterface", "scopedTarget.mapperSubinterface", "scopedTarget.mapperChildInterface");
for (String scopedProxyTargetBean : scopedProxyTargetBeans) {
{
BeanDefinition definition = applicationContext.getBeanDefinition(scopedProxyTargetBean);
assertThat(definition.getBeanClassName()).isEqualTo("cn.taketoday.orm.mybatis.mapper.MapperFactoryBean");
assertThat(definition.getScope()).isEqualTo("thread");
}
{
BeanDefinition definition = applicationContext.getBeanDefinition(scopedProxyTargetBean.substring(13));
assertThat(definition.getBeanClassName()).isEqualTo("cn.taketoday.aop.scope.ScopedProxyFactoryBean");
assertThat(definition.getScope()).isEqualTo("");
}
}
{
ScopedProxyMapper mapper = applicationContext.getBean(ScopedProxyMapper.class);
assertThat(mapper.test()).isEqualTo("test");
}
{
AnnotatedMapper mapper = applicationContext.getBean(AnnotatedMapper.class);
assertThat(mapper.test()).isEqualTo("main");
}
SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class);
assertEquals(2, sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers().size());
}
Aggregations