Skip to content

Commit d1dca2a

Browse files
committed
Merge branch 'master' into feature/101-support-constructor-collection-injection
2 parents be53709 + c6da404 commit d1dca2a

File tree

261 files changed

+2166
-1180
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

261 files changed

+2166
-1180
lines changed

.github/workflows/ci.yaml

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,11 @@ jobs:
2020
- name: Set up JDK ${{ matrix.java }} ${{ matrix.distribution }}
2121
uses: actions/setup-java@v4
2222
with:
23-
java-version: ${{ matrix.java }}
23+
cache: ${{ matrix.cache }}
2424
distribution: ${{ matrix.distribution }}
25-
- name: Print JDK Version
26-
run: java -version
27-
- name: Cache local Maven m2
28-
uses: actions/cache@v4
29-
with:
30-
path: ~/.m2
31-
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
32-
restore-keys: |
33-
${{ runner.os }}-m2
34-
- name: Skip tests that require illegal reflective access
25+
java-version: ${{ matrix.java }}
26+
- name: Setup testContainers profile for ubuntu
3527
if: ${{ matrix.os == 'ubuntu-latest' }}
36-
run: echo 'ARG_LINE=-D"excludedGroups=RequireIllegalAccess"' >> $GITHUB_ENV
37-
- name: Skip tests that require illegal reflective access
38-
if: ${{ matrix.os != 'ubuntu-latest' }}
39-
run: echo 'ARG_LINE=-D"excludedGroups=TestcontainersTests,RequireIllegalAccess"' >> $GITHUB_ENV
40-
- name: Active Profiles
41-
run: ./mvnw help:active-profiles
42-
- name: Test with Maven
43-
if: ${{ matrix.os != 'windows-latest' }}
44-
run: ./mvnw test -B -V --no-transfer-progress -D"license.skip=true" -D"jacoco.skip=true" $ARG_LINE
28+
run: echo 'TEST_CONTAINERS_PROFILE=-PtestContainers' >> $GITHUB_ENV
4529
- name: Test with Maven
46-
if: ${{ matrix.os == 'windows-latest' }}
47-
run: ./mvnw test -B -V --no-transfer-progress -D"license.skip=true" -D"jacoco.skip=true" -D"excludedGroups=TestcontainersTests,RequireIllegalAccess"
30+
run: ./mvnw test -B -V --no-transfer-progress -D"license.skip=true" $TEST_CONTAINERS_PROFILE

ICLA

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MyBatis
22
Individual Contributor License Agreement ("Agreement") V2.0
3-
https://mybatis.googlecode.com/svn/trunk/ICLA
3+
https://github.com/mybatis/mybatis-3/edit/master/ICLA
44

55
Thank you for your interest in MyBatis (the
66
"Project"). In order to clarify the intellectual property license

README.md

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -37,38 +37,36 @@ Tests
3737

3838
Mybatis-3 code runs more expressive testing depending on jdk usage and platform.
3939

40-
By default, we set ```<excludedGroups>TestcontainersTests</excludedGroups>``` which will exclude a subset of tests with @Tag('TestcontainersTests'). Further, if pre jdk 16, we will further exclude record classes from executions further reducing tests.
41-
42-
When using jdk 16+, we adjust the rule to ```<excludedGroups>TestcontainersTests,RequireIllegalAccess</excludedGroups>```.
40+
By default, we set ```<excludedGroups>TestcontainersTests,RequireIllegalAccess</excludedGroups>``` which will exclude a subset of tests with @Tag('TestcontainersTests') and @Tag('RequireIllegalAccess').
4341

4442
When we run on ci platform, we further make adjustments as needed. See [here](.github/workflows/ci.yaml) for details.
4543

46-
As of 2/20/2023, using combined system + jdk will result in given number of tests ran. This will change as tests are added or removed over time.
44+
As of 12/28/2024, using combined system + jdk will result in given number of tests ran. This will change as tests are added or removed over time.
4745

4846
without adjusting settings (ie use as is, platform does not matter)
4947

50-
- any OS + jdk 11 = 1730 tests
51-
- any OS + jdk 17 = 1710 tests
52-
- any OS + jdk 19 = 1710 tests
53-
- any OS + jdk 20 = 1710 tests
54-
- any OS + jdk 21 = 1710 tests
48+
- any OS + jdk 17 = 1899 tests
49+
- any OS + jdk 21 = 1899 tests
50+
- any OS + jdk 23 = 1899 tests
51+
- any OS + jdk 24 = 1899 tests
52+
- any OS + jdk 25 = 1899 tests
5553

5654
our adjustments for GH actions where platform does matter
5755

58-
- windows + jdk 11 = 1730 tests
59-
- windows + jdk 17 = 1710 tests
60-
- windows + jdk 19 = 1710 tests
61-
- windows + jdk 20 = 1710 tests
62-
- windows + jdk 21 = 1710 tests
63-
64-
- linux + jdk 11 = 1765 tests
65-
- linux + jdk 17 = 1745 tests
66-
- linux + jdk 19 = 1745 tests
67-
- linux + jdk 20 = 1745 tests
68-
- linux + jdk 21 = 1745 tests
69-
70-
- mac + jdk 11 = 1730 tests
71-
- mac + jdk 17 = 1710 tests
72-
- mac + jdk 19 = 1710 tests
73-
- mac + jdk 20 = 1710 tests
74-
- mac + jdk 21 = 1710 tests
56+
- windows + jdk 17 = 1899 tests
57+
- windows + jdk 21 = 1899 tests
58+
- windows + jdk 23 = 1899 tests
59+
- windows + jdk 24 = 1899 tests
60+
- windows + jdk 25 = 1899 tests
61+
62+
- linux + jdk 17 = 1934 tests
63+
- linux + jdk 21 = 1934 tests
64+
- linux + jdk 23 = 1934 tests
65+
- linux + jdk 24 = 1934 tests
66+
- linux + jdk 25 = 1934 tests
67+
68+
- mac + jdk 17 = 1899 tests
69+
- mac + jdk 21 = 1899 tests
70+
- mac + jdk 23 = 1899 tests
71+
- mac + jdk 24 = 1899 tests
72+
- mac + jdk 25 = 1899 tests

pom.xml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@
8181

8282
<!-- Add slow test groups here and annotate classes similar to @Tag('groupName'). -->
8383
<!-- Excluded groups are ran on github ci, to force here, pass -d"excludedGroups=" -->
84-
<excludedGroups>TestcontainersTests</excludedGroups>
84+
<!-- Note: RequireIllegalAccess tests are now no longer valid as they only worked prior to java 16 -->
85+
<excludedGroups>TestcontainersTests,RequireIllegalAccess</excludedGroups>
8586

8687
<!-- Automatic Module Name -->
8788
<module.name>org.mybatis</module.name>
@@ -232,6 +233,14 @@
232233
<artifactId>junit-jupiter</artifactId>
233234
<version>${testcontainers.version}</version>
234235
<scope>test</scope>
236+
<!--Only Mysqlcontainer is allowed to use junit 4 due to testContainers coupling: Uncomment to test no other leakage
237+
<exclusions>
238+
<exclusion>
239+
<groupId>junit</groupId>
240+
<artifactId>junit</artifactId>
241+
</exclusion>
242+
</exclusions>
243+
-->
235244
</dependency>
236245
<dependency>
237246
<groupId>org.testcontainers</groupId>
@@ -415,12 +424,9 @@
415424

416425
<profiles>
417426
<profile>
418-
<id>16</id>
419-
<activation>
420-
<jdk>[16,)</jdk>
421-
</activation>
427+
<id>testContainers</id>
422428
<properties>
423-
<excludedGroups>TestcontainersTests,RequireIllegalAccess</excludedGroups>
429+
<excludedGroups>RequireIllegalAccess</excludedGroups>
424430
</properties>
425431
</profile>
426432
<profile>

src/main/java/org/apache/ibatis/builder/xml/XMLMapperBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ private ResultMap resultMapElement(XNode resultMapNode, List<ResultMapping> addi
239239
resultMappings.add(buildResultMappingFromContext(resultChild, typeClass, flags));
240240
}
241241
}
242-
String id = resultMapNode.getStringAttribute("id", resultMapNode.getValueBasedIdentifier());
242+
String id = resultMapNode.getStringAttribute("id", resultMapNode::getValueBasedIdentifier);
243243
String extend = resultMapNode.getStringAttribute("extends");
244244
Boolean autoMapping = resultMapNode.getBooleanAttribute("autoMapping");
245245
ResultMapResolver resultMapResolver = new ResultMapResolver(builderAssistant, id, typeClass, extend, discriminator,
@@ -290,7 +290,7 @@ private Discriminator processDiscriminatorElement(XNode context, Class<?> result
290290
for (XNode caseChild : context.getChildren()) {
291291
String value = caseChild.getStringAttribute("value");
292292
String resultMap = caseChild.getStringAttribute("resultMap",
293-
processNestedResultMappings(caseChild, resultMappings, resultType));
293+
() -> processNestedResultMappings(caseChild, resultMappings, resultType));
294294
discriminatorMap.put(value, resultMap);
295295
}
296296
return builderAssistant.buildDiscriminator(resultType, column, javaTypeClass, jdbcTypeEnum, typeHandlerClass,

src/test/java/org/apache/ibatis/autoconstructor/BadSubject.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2022 the original author or authors.
2+
* Copyright 2009-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ public BadSubject(final int id, final String name, final int age, final Height h
3030
this.weight = weight == null ? 0 : weight;
3131
}
3232

33-
private class Height {
33+
private static class Height {
3434

3535
}
3636
}

src/test/java/org/apache/ibatis/binding/WrongMapperTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2023 the original author or authors.
2+
* Copyright 2009-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,9 +24,7 @@ class WrongMapperTest {
2424
@Test
2525
void shouldFailForBothOneAndMany() {
2626
Configuration configuration = new Configuration();
27-
Assertions.assertThrows(RuntimeException.class, () -> {
28-
configuration.addMapper(MapperWithOneAndMany.class);
29-
});
27+
Assertions.assertThrows(RuntimeException.class, () -> configuration.addMapper(MapperWithOneAndMany.class));
3028
}
3129

3230
}

src/test/java/org/apache/ibatis/binding/WrongNamespacesTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2022 the original author or authors.
2+
* Copyright 2009-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/test/java/org/apache/ibatis/builder/ParameterExpressionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2022 the original author or authors.
2+
* Copyright 2009-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/test/java/org/apache/ibatis/builder/SqlSourceBuilderTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2022 the original author or authors.
2+
* Copyright 2009-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@
2222
import org.junit.jupiter.api.BeforeEach;
2323
import org.junit.jupiter.api.Test;
2424

25-
public class SqlSourceBuilderTest {
25+
class SqlSourceBuilderTest {
2626

2727
private static Configuration configuration;
2828
private static SqlSourceBuilder sqlSourceBuilder;
@@ -36,15 +36,15 @@ void setUp() {
3636
}
3737

3838
@Test
39-
void testShrinkWhitespacesInSqlIsFalse() {
39+
void shrinkWhitespacesInSqlIsFalse() {
4040
SqlSource sqlSource = sqlSourceBuilder.parse(sqlFromXml, null, null);
4141
BoundSql boundSql = sqlSource.getBoundSql(null);
4242
String actual = boundSql.getSql();
4343
Assertions.assertEquals(sqlFromXml, actual);
4444
}
4545

4646
@Test
47-
void testShrinkWhitespacesInSqlIsTrue() {
47+
void shrinkWhitespacesInSqlIsTrue() {
4848
configuration.setShrinkWhitespacesInSql(true);
4949
SqlSource sqlSource = sqlSourceBuilder.parse(sqlFromXml, null, null);
5050
BoundSql boundSql = sqlSource.getBoundSql(null);

src/test/java/org/apache/ibatis/builder/XmlConfigBuilderTest.java

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,16 @@ public E getNullableResult(CallableStatement cs, int columnIndex) throws SQLExce
155155

156156
@Test
157157
void registerJavaTypeInitializingTypeHandler() {
158-
// @formatter:off
159-
final String MAPPER_CONFIG = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
160-
+ "<!DOCTYPE configuration PUBLIC \"-//mybatis.org//DTD Config 3.0//EN\" \"https://mybatis.org/dtd/mybatis-3-config.dtd\">\n"
161-
+ "<configuration>\n"
162-
+ " <typeHandlers>\n"
163-
+ " <typeHandler javaType=\"org.apache.ibatis.builder.XmlConfigBuilderTest$MyEnum\"\n"
164-
+ " handler=\"org.apache.ibatis.builder.XmlConfigBuilderTest$EnumOrderTypeHandler\"/>\n"
165-
+ " </typeHandlers>\n"
166-
+ "</configuration>\n";
167-
// @formatter:on
158+
final String MAPPER_CONFIG = """
159+
<?xml version="1.0" encoding="UTF-8" ?>
160+
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "https://mybatis.org/dtd/mybatis-3-config.dtd">
161+
<configuration>
162+
<typeHandlers>
163+
<typeHandler javaType="org.apache.ibatis.builder.XmlConfigBuilderTest$MyEnum"
164+
handler="org.apache.ibatis.builder.XmlConfigBuilderTest$EnumOrderTypeHandler"/>
165+
</typeHandlers>
166+
</configuration>
167+
""";
168168

169169
XMLConfigBuilder builder = new XMLConfigBuilder(new StringReader(MAPPER_CONFIG));
170170
builder.parse();
@@ -283,15 +283,15 @@ void parseIsTwice() throws Exception {
283283

284284
@Test
285285
void unknownSettings() {
286-
// @formatter:off
287-
final String MAPPER_CONFIG = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
288-
+ "<!DOCTYPE configuration PUBLIC \"-//mybatis.org//DTD Config 3.0//EN\" \"https://mybatis.org/dtd/mybatis-3-config.dtd\">\n"
289-
+ "<configuration>\n"
290-
+ " <settings>\n"
291-
+ " <setting name=\"foo\" value=\"bar\"/>\n"
292-
+ " </settings>\n"
293-
+ "</configuration>\n";
294-
// @formatter:on
286+
final String MAPPER_CONFIG = """
287+
<?xml version="1.0" encoding="UTF-8" ?>
288+
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "https://mybatis.org/dtd/mybatis-3-config.dtd">
289+
<configuration>
290+
<settings>
291+
<setting name="foo" value="bar"/>
292+
</settings>
293+
</configuration>
294+
""";
295295

296296
XMLConfigBuilder builder = new XMLConfigBuilder(new StringReader(MAPPER_CONFIG));
297297
when(builder::parse);
@@ -301,15 +301,15 @@ void unknownSettings() {
301301

302302
@Test
303303
void unknownJavaTypeOnTypeHandler() {
304-
// @formatter:off
305-
final String MAPPER_CONFIG = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
306-
+ "<!DOCTYPE configuration PUBLIC \"-//mybatis.org//DTD Config 3.0//EN\" \"https://mybatis.org/dtd/mybatis-3-config.dtd\">\n"
307-
+ "<configuration>\n"
308-
+ " <typeAliases>\n"
309-
+ " <typeAlias type=\"a.b.c.Foo\"/>\n"
310-
+ " </typeAliases>\n"
311-
+ "</configuration>\n";
312-
// @formatter:on
304+
final String MAPPER_CONFIG = """
305+
<?xml version="1.0" encoding="UTF-8" ?>
306+
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "https://mybatis.org/dtd/mybatis-3-config.dtd">
307+
<configuration>
308+
<typeAliases>
309+
<typeAlias type="a.b.c.Foo"/>
310+
</typeAliases>
311+
</configuration>
312+
""";
313313

314314
XMLConfigBuilder builder = new XMLConfigBuilder(new StringReader(MAPPER_CONFIG));
315315
when(builder::parse);
@@ -319,13 +319,13 @@ void unknownJavaTypeOnTypeHandler() {
319319

320320
@Test
321321
void propertiesSpecifyResourceAndUrlAtSameTime() {
322-
// @formatter:off
323-
final String MAPPER_CONFIG = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
324-
+ "<!DOCTYPE configuration PUBLIC \"-//mybatis.org//DTD Config 3.0//EN\" \"https://mybatis.org/dtd/mybatis-3-config.dtd\">\n"
325-
+ "<configuration>\n"
326-
+ " <properties resource=\"a/b/c/foo.properties\" url=\"file:./a/b/c/jdbc.properties\"/>\n"
327-
+ "</configuration>\n";
328-
// @formatter:on
322+
final String MAPPER_CONFIG = """
323+
<?xml version="1.0" encoding="UTF-8" ?>
324+
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "https://mybatis.org/dtd/mybatis-3-config.dtd">
325+
<configuration>
326+
<properties resource="a/b/c/foo.properties" url="file:./a/b/c/jdbc.properties"/>
327+
</configuration>
328+
""";
329329

330330
XMLConfigBuilder builder = new XMLConfigBuilder(new StringReader(MAPPER_CONFIG));
331331
when(builder::parse);

src/test/java/org/apache/ibatis/builder/XmlMapperBuilderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2023 the original author or authors.
2+
* Copyright 2009-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -221,7 +221,7 @@ void errorResultMapLocation() throws Exception {
221221
builder.parse();
222222
String resultMapName = "java.lang.String";
223223
// namespace + "." + id
224-
String statementId = "org.mybatis.spring.ErrorProblemMapper" + "." + "findProblemResultMapTest";
224+
String statementId = "org.mybatis.spring.ErrorProblemMapper.findProblemResultMapTest";
225225
// same as MapperBuilderAssistant.getStatementResultMaps Exception message
226226
String message = "Could not find result map '" + resultMapName + "' referenced from '" + statementId + "'";
227227
IncompleteElementException exception = Assertions.assertThrows(IncompleteElementException.class,

src/test/java/org/apache/ibatis/builder/xml/dynamic/DynamicSqlSourceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2023 the original author or authors.
2+
* Copyright 2009-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/test/java/org/apache/ibatis/builder/xsd/XmlMapperBuilderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2023 the original author or authors.
2+
* Copyright 2009-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/test/java/org/apache/ibatis/cache/CacheKeyTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2023 the original author or authors.
2+
* Copyright 2009-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -112,9 +112,7 @@ void shouldDemonstrateClonedNullCacheKeysAreEqual() throws Exception {
112112
void serializationExceptionTest() {
113113
CacheKey cacheKey = new CacheKey();
114114
cacheKey.update(new Object());
115-
assertThrows(NotSerializableException.class, () -> {
116-
serialize(cacheKey);
117-
});
115+
assertThrows(NotSerializableException.class, () -> serialize(cacheKey));
118116
}
119117

120118
@Test

0 commit comments

Comments
 (0)