|
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.
|
|
15 | 15 | */
|
16 | 16 | package org.apache.ibatis.submitted.global_variables_defaults;
|
17 | 17 |
|
18 |
| -import java.io.IOException; |
19 |
| -import java.io.Reader; |
20 |
| -import java.util.ArrayList; |
21 |
| -import java.util.Properties; |
22 |
| - |
23 | 18 | import org.apache.ibatis.builder.StaticSqlSource;
|
24 | 19 | import org.apache.ibatis.datasource.unpooled.UnpooledDataSource;
|
25 | 20 | import org.apache.ibatis.io.Resources;
|
26 | 21 | import org.apache.ibatis.mapping.MappedStatement;
|
27 |
| -import org.apache.ibatis.mapping.ResultMap; |
28 | 22 | import org.apache.ibatis.mapping.SqlCommandType;
|
29 | 23 | import org.apache.ibatis.parsing.PropertyParser;
|
30 | 24 | import org.apache.ibatis.session.Configuration;
|
|
34 | 28 | import org.assertj.core.api.Assertions;
|
35 | 29 | import org.junit.jupiter.api.Test;
|
36 | 30 |
|
| 31 | +import java.io.IOException; |
| 32 | +import java.io.Reader; |
| 33 | +import java.util.Properties; |
| 34 | + |
37 | 35 | class ConfigurationTest {
|
38 | 36 |
|
39 | 37 | @Test
|
@@ -87,24 +85,24 @@ 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 | 107 |
|
110 | 108 | }
|
0 commit comments