|
1 | 1 | /*
|
2 |
| - * Copyright 2009-2023 the original author or authors. |
| 2 | + * Copyright 2009-2025 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
17 | 17 |
|
18 | 18 | import java.io.IOException;
|
19 | 19 | import java.io.Reader;
|
20 |
| -import java.util.ArrayList; |
21 | 20 | import java.util.Properties;
|
22 | 21 |
|
23 | 22 | import org.apache.ibatis.builder.StaticSqlSource;
|
24 | 23 | import org.apache.ibatis.datasource.unpooled.UnpooledDataSource;
|
25 | 24 | import org.apache.ibatis.io.Resources;
|
26 | 25 | import org.apache.ibatis.mapping.MappedStatement;
|
27 |
| -import org.apache.ibatis.mapping.ResultMap; |
28 | 26 | import org.apache.ibatis.mapping.SqlCommandType;
|
29 | 27 | import org.apache.ibatis.parsing.PropertyParser;
|
30 | 28 | import org.apache.ibatis.session.Configuration;
|
@@ -87,24 +85,23 @@ void applyPropertyValueOnXmlConfiguration() throws IOException {
|
87 | 85 | @Test
|
88 | 86 | void testAmbiguityCache() {
|
89 | 87 | Configuration configuration = new Configuration();
|
| 88 | + |
90 | 89 | configuration.addMappedStatement(
|
91 |
| - new MappedStatement.Builder(configuration, |
92 |
| - "org.apache.ibatis.submitted.DemoMapper1.selectById", |
93 |
| - new StaticSqlSource(configuration, "select * from test where id = 1"), SqlCommandType.SELECT).build() |
94 |
| - ); |
95 |
| - configuration.addMappedStatement( |
96 |
| - new MappedStatement.Builder(configuration, |
97 |
| - "org.apache.ibatis.submitted.DemoMapper1.test", |
98 |
| - new StaticSqlSource(configuration, "select * from test"), SqlCommandType.SELECT).build() |
99 |
| - ); |
100 |
| - configuration.addMappedStatement( |
101 |
| - new MappedStatement.Builder(configuration, |
102 |
| - "org.apache.ibatis.submitted.DemoMapper2.test", |
103 |
| - new StaticSqlSource(configuration, "select * from test"), SqlCommandType.SELECT).build() |
104 |
| - ); |
| 90 | + new MappedStatement.Builder(configuration, "org.apache.ibatis.submitted.DemoMapper1.selectById", |
| 91 | + new StaticSqlSource(configuration, "select * from test where id = 1"), SqlCommandType.SELECT).build()); |
| 92 | + configuration |
| 93 | + .addMappedStatement(new MappedStatement.Builder(configuration, "org.apache.ibatis.submitted.DemoMapper1.test", |
| 94 | + new StaticSqlSource(configuration, "select * from test"), SqlCommandType.SELECT).build()); |
| 95 | + configuration |
| 96 | + .addMappedStatement(new MappedStatement.Builder(configuration, "org.apache.ibatis.submitted.DemoMapper2.test", |
| 97 | + new StaticSqlSource(configuration, "select * from test"), SqlCommandType.SELECT).build()); |
| 98 | + |
105 | 99 | Assertions.assertThat(configuration.getMappedStatement("selectById")).isNotNull();
|
| 100 | + Assertions.assertThat(configuration.getMappedStatement("org.apache.ibatis.submitted.DemoMapper1.test")).isNotNull(); |
| 101 | + Assertions.assertThat(configuration.getMappedStatement("org.apache.ibatis.submitted.DemoMapper2.test")).isNotNull(); |
| 102 | + |
106 | 103 | Assertions.assertThatThrownBy(() -> configuration.getMappedStatement("test"))
|
107 |
| - .isInstanceOf(IllegalArgumentException.class).hasMessage("test is ambiguous in Mapped Statements collection (try using the full name including the namespace, or rename one of the entries)"); |
| 104 | + .isInstanceOf(IllegalArgumentException.class).hasMessage( |
| 105 | + "test is ambiguous in Mapped Statements collection (try using the full name including the namespace, or rename one of the entries)"); |
108 | 106 | }
|
109 |
| - |
110 | 107 | }
|
0 commit comments