Skip to content

Commit 42cb7e7

Browse files
committed
Cleanup tests and note on why junit4 exits
with exclusion to turn it off to verify only the one class is using it.
1 parent 5d7e1eb commit 42cb7e7

File tree

212 files changed

+647
-665
lines changed

Some content is hidden

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

212 files changed

+647
-665
lines changed

pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,14 @@
232232
<artifactId>junit-jupiter</artifactId>
233233
<version>${testcontainers.version}</version>
234234
<scope>test</scope>
235+
<!--Only Mysqlcontainer is allowed to use junit 4: Uncomment to test
236+
<exclusions>
237+
<exclusion>
238+
<groupId>junit</groupId>
239+
<artifactId>junit</artifactId>
240+
</exclusion>
241+
</exclusions>
242+
-->
235243
</dependency>
236244
<dependency>
237245
<groupId>org.testcontainers</groupId>

src/test/java/org/apache/ibatis/binding/BindingTest.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/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/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/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

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

Lines changed: 3 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.
@@ -16,6 +16,7 @@
1616
package org.apache.ibatis.cache;
1717

1818
import static org.junit.jupiter.api.Assertions.assertEquals;
19+
import static org.junit.jupiter.api.Assertions.assertNull;
1920
import static org.junit.jupiter.api.Assertions.assertThrows;
2021

2122
import java.io.Serializable;
@@ -45,7 +46,7 @@ void shouldDemonstrateNullsAreSerializable() {
4546
cache.putObject(i, null);
4647
}
4748
for (int i = 0; i < 5; i++) {
48-
assertEquals(null, cache.getObject(i));
49+
assertNull(cache.getObject(i));
4950
}
5051
}
5152

src/test/java/org/apache/ibatis/datasource/pooled/MysqlTimeoutTest.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.
@@ -29,7 +29,7 @@
2929
import org.junit.jupiter.api.Test;
3030

3131
@Tag("TestcontainersTests")
32-
public class MysqlTimeoutTest {
32+
class MysqlTimeoutTest {
3333

3434
@Test
3535
void shouldReconnectWhenServerKilledLeakedConnection() throws Exception {

src/test/java/org/apache/ibatis/datasource/unpooled/NetworkTimeoutTest.java

Lines changed: 3 additions & 3 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.
@@ -28,7 +28,7 @@
2828
class NetworkTimeoutTest {
2929

3030
@Test
31-
void testNetworkTimeout_UnpooledDataSource() throws Exception {
31+
void networkTimeoutUnpooledDataSource() throws Exception {
3232
UnpooledDataSource dataSource = (UnpooledDataSource) PgContainer.getUnpooledDataSource();
3333
dataSource.setDefaultNetworkTimeout(5000);
3434
try (Connection connection = dataSource.getConnection()) {
@@ -37,7 +37,7 @@ void testNetworkTimeout_UnpooledDataSource() throws Exception {
3737
}
3838

3939
@Test
40-
void testNetworkTimeout_PooledDataSource() throws Exception {
40+
void networkTimeoutPooledDataSource() throws Exception {
4141
UnpooledDataSource unpooledDataSource = (UnpooledDataSource) PgContainer.getUnpooledDataSource();
4242
PooledDataSource dataSource = new PooledDataSource(unpooledDataSource);
4343
dataSource.setDefaultNetworkTimeout(5000);

src/test/java/org/apache/ibatis/executor/BaseExecutorTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ void shouldClearDeferredLoads() throws Exception {
478478
}
479479

480480
@Test
481-
void testCreateCacheKeyWithAdditionalParameter() {
481+
void createCacheKeyWithAdditionalParameter() {
482482
TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
483483

484484
MappedStatement mappedStatement = new MappedStatement.Builder(config, "testSelect",
@@ -510,7 +510,7 @@ void testCreateCacheKeyWithAdditionalParameter() {
510510
}
511511

512512
@Test
513-
void testCreateCacheKeyWithNull() {
513+
void createCacheKeyWithNull() {
514514
TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
515515

516516
MappedStatement mappedStatement = new MappedStatement.Builder(config, "testSelect",
@@ -538,7 +538,7 @@ void testCreateCacheKeyWithNull() {
538538
}
539539

540540
@Test
541-
void testCreateCacheKeyWithTypeHandler() {
541+
void createCacheKeyWithTypeHandler() {
542542
TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
543543

544544
MappedStatement mappedStatement = new MappedStatement.Builder(config, "testSelect",
@@ -566,7 +566,7 @@ void testCreateCacheKeyWithTypeHandler() {
566566
}
567567

568568
@Test
569-
void testCreateCacheKeyWithMetaObject() {
569+
void createCacheKeyWithMetaObject() {
570570
TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
571571

572572
MappedStatement mappedStatement = new MappedStatement.Builder(config, "testSelect",

src/test/java/org/apache/ibatis/executor/ResultExtractorTest.java

Lines changed: 2 additions & 3 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.
@@ -21,7 +21,6 @@
2121
import static org.mockito.Mockito.when;
2222

2323
import java.util.Arrays;
24-
import java.util.Collections;
2524
import java.util.HashSet;
2625
import java.util.List;
2726
import java.util.Set;
@@ -93,7 +92,7 @@ void shouldExtractSet() {
9392

9493
@Test
9594
void shouldExtractSingleObject() {
96-
final List<Object> list = Collections.singletonList("single object");
95+
final List<Object> list = List.of("single object");
9796
assertThat((String) resultExtractor.extractObjectFromList(list, String.class)).isEqualTo("single object");
9897
assertThat((String) resultExtractor.extractObjectFromList(list, null)).isEqualTo("single object");
9998
assertThat((String) resultExtractor.extractObjectFromList(list, Integer.class)).isEqualTo("single object");

src/test/java/org/apache/ibatis/executor/ReuseExecutorTest.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/executor/loader/CglibProxyTest.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/executor/loader/JavassistProxyTest.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/executor/loader/SerializableProxyTest.java

Lines changed: 4 additions & 5 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.
@@ -15,6 +15,7 @@
1515
*/
1616
package org.apache.ibatis.executor.loader;
1717

18+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
1819
import static org.junit.jupiter.api.Assertions.assertEquals;
1920
import static org.junit.jupiter.api.Assertions.assertFalse;
2021
import static org.junit.jupiter.api.Assertions.fail;
@@ -134,11 +135,9 @@ void shouldGenerateWriteReplace() throws Exception {
134135
void shouldNotGenerateWriteReplaceItThereIsAlreadyOne() {
135136
AuthorWithWriteReplaceMethod beanWithWriteReplace = new AuthorWithWriteReplaceMethod(999, "someone", "!@#@!#!@#",
136137
"[email protected]", "blah", Section.NEWS);
137-
try {
138+
Assertions.assertDoesNotThrow(() -> {
138139
beanWithWriteReplace.getClass().getDeclaredMethod("writeReplace");
139-
} catch (NoSuchMethodException e) {
140-
fail("Bean should declare a writeReplace method");
141-
}
140+
}, "Bean should declare a writeReplace method");
142141
Object proxy = proxyFactory.createProxy(beanWithWriteReplace, new ResultLoaderMap(), new Configuration(),
143142
new DefaultObjectFactory(), new ArrayList<>(), new ArrayList<>());
144143
Class<?>[] interfaces = proxy.getClass().getInterfaces();

src/test/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandlerTest.java

Lines changed: 2 additions & 3 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.
@@ -28,7 +28,6 @@
2828
import java.sql.Statement;
2929
import java.sql.Types;
3030
import java.util.ArrayList;
31-
import java.util.Collections;
3231
import java.util.HashMap;
3332
import java.util.List;
3433

@@ -118,7 +117,7 @@ void shouldThrowExceptionWithColumnName() throws Exception {
118117
when(resultMapping.getColumn()).thenReturn("column");
119118
when(resultMapping.getTypeHandler()).thenReturn(typeHandler);
120119
when(typeHandler.getResult(any(ResultSet.class), any(String.class))).thenThrow(new SQLException("exception"));
121-
List<ResultMapping> constructorMappings = Collections.singletonList(resultMapping);
120+
List<ResultMapping> constructorMappings = List.of(resultMapping);
122121

123122
try {
124123
defaultResultSetHandler.createParameterizedResultObject(rsw, null/* resultType */, constructorMappings,

src/test/java/org/apache/ibatis/io/ClassLoaderWrapperTest.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/io/ExternalResourcesTest.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.
@@ -82,7 +82,7 @@ void testcopyExternalResource_emptyStringAsFile() {
8282
}
8383

8484
@Test
85-
void testGetConfiguredTemplate() {
85+
void getConfiguredTemplate() {
8686
String templateName = "";
8787

8888
try (FileWriter fileWriter = new FileWriter(tempFile, StandardCharsets.UTF_8)) {

0 commit comments

Comments
 (0)