1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.ibatis.submitted.multidb;
17
18 import static org.junit.jupiter.api.Assertions.assertEquals;
19
20 import java.io.Reader;
21
22 import org.apache.ibatis.io.Resources;
23 import org.apache.ibatis.session.Configuration;
24 import org.apache.ibatis.session.SqlSessionFactoryBuilder;
25 import org.apache.ibatis.session.defaults.DefaultSqlSessionFactory;
26 import org.junit.jupiter.api.Test;
27
28 class ProviderTest {
29
30 @Test
31 void shouldUseDefaultId() throws Exception {
32 Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/multidb/MultiDbConfig.xml");
33 DefaultSqlSessionFactory sqlSessionFactory = (DefaultSqlSessionFactory) new SqlSessionFactoryBuilder()
34 .build(reader);
35 Configuration c = sqlSessionFactory.getConfiguration();
36 assertEquals("hsql", c.getDatabaseId());
37 }
38
39 @Test
40 void shouldUseProvider() throws Exception {
41 Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/multidb/ProviderConfig.xml");
42 DefaultSqlSessionFactory sqlSessionFactory = (DefaultSqlSessionFactory) new SqlSessionFactoryBuilder()
43 .build(reader);
44 Configuration c = sqlSessionFactory.getConfiguration();
45 assertEquals("translated", c.getDatabaseId());
46 }
47 }