1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.ibatis.submitted.duplicate_resource_loaded;
17
18 import java.io.Reader;
19 import java.util.List;
20 import java.util.Map;
21
22 import org.apache.ibatis.BaseDataTest;
23 import org.apache.ibatis.io.Resources;
24 import org.apache.ibatis.session.SqlSession;
25 import org.apache.ibatis.session.SqlSessionFactory;
26 import org.apache.ibatis.session.SqlSessionFactoryBuilder;
27 import org.junit.jupiter.api.Assertions;
28 import org.junit.jupiter.api.BeforeEach;
29 import org.junit.jupiter.api.Test;
30
31 class DuplicateResourceTest extends BaseDataTest {
32
33 @BeforeEach
34 void setup() throws Exception {
35 BaseDataTest.createBlogDataSource();
36 }
37
38 @Test
39 void shouldDemonstrateDuplicateResourceIssue() throws Exception {
40 final String resource = "org/apache/ibatis/submitted/duplicate_resource_loaded/Config.xml";
41 final Reader reader = Resources.getResourceAsReader(resource);
42 final SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
43 final SqlSessionFactory factory = builder.build(reader);
44 try (SqlSession sqlSession = factory.openSession()) {
45 final Mapper mapper = sqlSession.getMapper(Mapper.class);
46 final List<Map<String, Object>> list = mapper.selectAllBlogs();
47 Assertions.assertEquals(2, list.size());
48 }
49 }
50 }