1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.ibatis.submitted.autodiscover;
17
18 import static org.junit.jupiter.api.Assertions.assertNotNull;
19 import static org.junit.jupiter.api.Assertions.assertTrue;
20
21 import java.io.Reader;
22 import java.math.BigInteger;
23
24 import org.apache.ibatis.io.Resources;
25 import org.apache.ibatis.session.SqlSessionFactory;
26 import org.apache.ibatis.session.SqlSessionFactoryBuilder;
27 import org.apache.ibatis.submitted.autodiscover.mappers.DummyMapper;
28 import org.apache.ibatis.type.TypeAliasRegistry;
29 import org.apache.ibatis.type.TypeHandlerRegistry;
30 import org.junit.jupiter.api.BeforeAll;
31 import org.junit.jupiter.api.Test;
32
33 class AutodiscoverTest {
34
35 protected static SqlSessionFactory sqlSessionFactory;
36
37 @BeforeAll
38 static void setup() throws Exception {
39 try (Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/autodiscover/MapperConfig.xml")) {
40 sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
41 }
42 }
43
44 @Test
45 void testTypeAlias() {
46 TypeAliasRegistry typeAliasRegistry = sqlSessionFactory.getConfiguration().getTypeAliasRegistry();
47 assertNotNull(typeAliasRegistry.resolveAlias("testAlias"));
48 }
49
50 @Test
51 void testTypeHandler() {
52 TypeHandlerRegistry typeHandlerRegistry = sqlSessionFactory.getConfiguration().getTypeHandlerRegistry();
53 assertTrue(typeHandlerRegistry.hasTypeHandler(BigInteger.class));
54 }
55
56 @Test
57 void testMapper() {
58 assertTrue(sqlSessionFactory.getConfiguration().hasMapper(DummyMapper.class));
59 }
60 }