Skip to content

Commit 0c570c0

Browse files
authored
Merge pull request #2823 from hazendaz/copyright
[tests] More test modernization cleanups
2 parents 8529238 + 09137f4 commit 0c570c0

File tree

10 files changed

+22
-17
lines changed

10 files changed

+22
-17
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ void shouldIterateOverIterable() {
9292
final Iterable<?> iterable = evaluator.evaluateIterable("array", parameterObject);
9393
int i = 0;
9494
for (Object o : iterable) {
95-
assertEquals(String.valueOf(++i), o);
95+
i++;
96+
assertEquals(String.valueOf(i), o);
9697
}
9798
}
9899

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,11 @@ void shouldSelectAuthorViaOutParams() throws Exception {
326326
assertEquals("[email protected]", author.getEmail());
327327
assertNull(author.getBio());
328328
} catch (ExecutorException e) {
329-
if (executor instanceof CachingExecutor) {
330-
// TODO see issue #464. Fail is OK.
331-
assertTrue(e.getMessage().contains("OUT params is not supported"));
332-
} else {
329+
if (!(executor instanceof CachingExecutor)) {
333330
throw e;
334331
}
332+
// TODO see issue #464. Fail is OK.
333+
assertTrue(e.getMessage().contains("OUT params is not supported"));
335334
} finally {
336335
executor.rollback(true);
337336
executor.close(false);

src/test/java/org/apache/ibatis/io/VFSTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void invoke() throws IOException, NoSuchMethodException {
9797

9898
}
9999

100-
private class InstanceGetterProcedure implements Runnable {
100+
private static class InstanceGetterProcedure implements Runnable {
101101

102102
volatile VFS instanceGot;
103103

src/test/java/org/apache/ibatis/scripting/xmltags/OgnlCacheTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ class DataClass {
4242
context.put("data", new DataClass());
4343
ExecutorService executor = Executors.newCachedThreadPool();
4444
IntStream.range(0, run).forEach(i -> {
45-
futures.add(executor.submit(() -> {
46-
return OgnlCache.getValue("data.id", context);
47-
}));
45+
futures.add(executor.submit(() -> OgnlCache.getValue("data.id", context)));
4846
});
4947
for (int i = 0; i < run; i++) {
5048
assertNotNull(futures.get(i).get());

src/test/java/org/apache/ibatis/submitted/default_method/Mapper.java

Lines changed: 2 additions & 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-2023 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.
@@ -31,6 +31,7 @@ default User defaultGetUser(Object... args) {
3131
}
3232

3333
interface SubMapper extends Mapper {
34+
@Override
3435
default User defaultGetUser(Object... args) {
3536
return getUserByIdAndName((String) args[0], (Integer) args[1]);
3637
}

src/test/java/org/apache/ibatis/submitted/enum_interface_type_handler/Color.java

Lines changed: 4 additions & 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-2023 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.
@@ -17,16 +17,19 @@
1717

1818
public enum Color implements HasValue {
1919
WHITE {
20+
@Override
2021
public int getValue() {
2122
return 1;
2223
}
2324
},
2425
RED {
26+
@Override
2527
public int getValue() {
2628
return 2;
2729
}
2830
},
2931
BLUE {
32+
@Override
3033
public int getValue() {
3134
return 3;
3235
}

src/test/java/org/apache/ibatis/submitted/nestedresulthandler/Item.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class Item {
1919
private Integer id;
2020
private String name;
2121

22+
@Override
2223
public String toString() {
2324
return new StringBuilder().append("Item(").append(id).append(", ").append(name).append(" )").toString();
2425
}

src/test/java/org/apache/ibatis/submitted/nestedresulthandler/Person.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class Person {
2424
private String name;
2525
private final List<Item> items = new ArrayList<>();
2626

27+
@Override
2728
public String toString() {
2829
return new StringBuilder().append("Person(").append(id).append(", ").append(name).append(", ").append(items)
2930
.append(" )").toString();

src/test/java/org/apache/ibatis/submitted/nestedresulthandler/PersonItemPair.java

Lines changed: 2 additions & 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-2023 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,6 +22,7 @@ public class PersonItemPair {
2222
private Person person;
2323
private Item item;
2424

25+
@Override
2526
public String toString() {
2627
return new StringBuilder().append("PersonItemPair(").append(person).append(", ").append(item).append(" )")
2728
.toString();

src/test/java/org/apache/ibatis/type/TypeHandlerRegistryTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,11 @@ void shouldAutoRegisterEnumTypeInMultiThreadEnvironment() throws Exception {
238238
try {
239239
for (int iteration = 0; iteration < 2000; iteration++) {
240240
TypeHandlerRegistry typeHandlerRegistry = new TypeHandlerRegistry();
241-
List<Future<Boolean>> taskResults = IntStream.range(0, 2).mapToObj(taskIndex -> executorService.submit(() -> {
242-
return typeHandlerRegistry.hasTypeHandler(TestEnum.class, JdbcType.VARCHAR);
243-
})).collect(Collectors.toList());
244-
for (int i = 0; i < taskResults.size(); i++) {
245-
Future<Boolean> future = taskResults.get(i);
241+
List<Future<Boolean>> taskResults = IntStream.range(0, 2)
242+
.mapToObj(taskIndex -> executorService
243+
.submit(() -> typeHandlerRegistry.hasTypeHandler(TestEnum.class, JdbcType.VARCHAR)))
244+
.collect(Collectors.toList());
245+
for (Future<Boolean> future : taskResults) {
246246
assertTrue(future.get(), "false is returned at round " + iteration);
247247
}
248248
}

0 commit comments

Comments
 (0)