1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.ibatis.submitted.xml_references;
17
18 import java.io.Reader;
19 import java.util.Properties;
20
21 import org.apache.ibatis.datasource.unpooled.UnpooledDataSourceFactory;
22 import org.apache.ibatis.io.Resources;
23 import org.apache.ibatis.mapping.Environment;
24 import org.apache.ibatis.session.Configuration;
25 import org.apache.ibatis.session.SqlSessionFactory;
26 import org.apache.ibatis.session.SqlSessionFactoryBuilder;
27 import org.apache.ibatis.session.defaults.DefaultSqlSessionFactory;
28 import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
29 import org.junit.jupiter.api.Test;
30
31 class EnumWithOgnlTest {
32
33 @Test
34 void testConfiguration() {
35 UnpooledDataSourceFactory dataSourceFactory = new UnpooledDataSourceFactory();
36 Properties dataSourceProperties = new Properties();
37 dataSourceProperties.put("driver", "org.hsqldb.jdbcDriver");
38 dataSourceProperties.put("url", "jdbc:hsqldb:mem:xml_references");
39 dataSourceProperties.put("username", "sa");
40 dataSourceFactory.setProperties(dataSourceProperties);
41 Environment environment = new Environment("test", new JdbcTransactionFactory(), dataSourceFactory.getDataSource());
42 Configuration configuration = new Configuration();
43 configuration.setEnvironment(environment);
44 configuration.getTypeAliasRegistry().registerAlias(Person.class);
45 configuration.addMapper(PersonMapper.class);
46 configuration.addMapper(PersonMapper2.class);
47 new DefaultSqlSessionFactory(configuration);
48 }
49
50 @Test
51 void testMixedConfiguration() throws Exception {
52 try (Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/xml_references/ibatisConfig.xml")) {
53 SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
54 sqlSessionFactory.getConfiguration().addMapper(PersonMapper2.class);
55 }
56 }
57 }