diff --git a/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java b/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java index 9f5e2010b..4ce267cd7 100644 --- a/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java @@ -1229,7 +1229,7 @@ public class CollectionUtilsTest extends MockTestCase { final List combinedList = new ArrayList<>(collectionD); combinedList.addAll(collectionE); - Collections.sort(combinedList); + combinedList.sort(null); assertEquals(combinedList, result2, "Merge two lists 2"); @@ -1258,7 +1258,7 @@ public class CollectionUtilsTest extends MockTestCase { final Set combinedSet = new HashSet<>(collectionD); combinedSet.addAll(collectionE); final List combinedList = new ArrayList<>(combinedSet); - Collections.sort(combinedList); + combinedList.sort(null); assertEquals(combinedList, result2, "Merge two lists 2 - ignore duplicates"); } diff --git a/src/test/java/org/apache/commons/collections4/FluentIterableTest.java b/src/test/java/org/apache/commons/collections4/FluentIterableTest.java index 9e9b2f7dc..492044a0c 100644 --- a/src/test/java/org/apache/commons/collections4/FluentIterableTest.java +++ b/src/test/java/org/apache/commons/collections4/FluentIterableTest.java @@ -161,7 +161,7 @@ public class FluentIterableTest { final List combinedList = new ArrayList<>(); CollectionUtils.addAll(combinedList, iterableOdd); CollectionUtils.addAll(combinedList, iterableEven); - Collections.sort(combinedList); + combinedList.sort(null); assertEquals(combinedList, result); try { @@ -183,7 +183,7 @@ public class FluentIterableTest { final List combinedList = new ArrayList<>(); CollectionUtils.addAll(combinedList, iterableOdd); CollectionUtils.addAll(combinedList, iterableEven); - Collections.sort(combinedList); + combinedList.sort(null); assertEquals(combinedList, result); // null comparator is equivalent to natural ordering @@ -352,7 +352,7 @@ public class FluentIterableTest { List combinedList = new ArrayList<>(); CollectionUtils.addAll(combinedList, iterableOdd); CollectionUtils.addAll(combinedList, iterableEven); - Collections.sort(combinedList); + combinedList.sort(null); assertEquals(combinedList, result); try { diff --git a/src/test/java/org/apache/commons/collections4/IteratorUtilsTest.java b/src/test/java/org/apache/commons/collections4/IteratorUtilsTest.java index 71294e58b..f2c88f7a8 100644 --- a/src/test/java/org/apache/commons/collections4/IteratorUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/IteratorUtilsTest.java @@ -579,7 +579,7 @@ public class IteratorUtilsTest { final List combinedList = new ArrayList<>(collectionOdd); combinedList.addAll(collectionEven); - Collections.sort(combinedList); + combinedList.sort(null); assertEquals(combinedList, result); diff --git a/src/test/java/org/apache/commons/collections4/bidimap/AbstractSortedBidiMapTest.java b/src/test/java/org/apache/commons/collections4/bidimap/AbstractSortedBidiMapTest.java index 87d7663c9..6532cde75 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/AbstractSortedBidiMapTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/AbstractSortedBidiMapTest.java @@ -44,7 +44,7 @@ public abstract class AbstractSortedBidiMapTest, V exten public AbstractSortedBidiMapTest(final String testName) { super(testName); sortedKeys = getAsList(getSampleKeys()); - Collections.sort(sortedKeys); + sortedKeys.sort(null); sortedKeys = Collections.unmodifiableList(sortedKeys); final Map map = new TreeMap<>(); diff --git a/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap2Test.java b/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap2Test.java index b52cf2dbb..8134d7d9a 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap2Test.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap2Test.java @@ -129,7 +129,7 @@ public class DualTreeBidiMap2Test, V extends Comparable< // Sort by the comparator used in the makeEmptyBidiMap() method List newSortedKeys = getAsList(getSampleKeys()); - Collections.sort(newSortedKeys, new ReverseComparator<>(ComparableComparator.comparableComparator())); + newSortedKeys.sort(new ReverseComparator<>(ComparableComparator.comparableComparator())); newSortedKeys = Collections.unmodifiableList(newSortedKeys); final Iterator mapIter = sm.keySet().iterator(); diff --git a/src/test/java/org/apache/commons/collections4/junit/AbstractAvailableLocalesTest.java b/src/test/java/org/apache/commons/collections4/junit/AbstractAvailableLocalesTest.java index 4254bcc21..32a73efc1 100644 --- a/src/test/java/org/apache/commons/collections4/junit/AbstractAvailableLocalesTest.java +++ b/src/test/java/org/apache/commons/collections4/junit/AbstractAvailableLocalesTest.java @@ -74,7 +74,7 @@ public abstract class AbstractAvailableLocalesTest { } } } - Collections.sort(availableLocales, new ObjectToStringComparator()); + availableLocales.sort(ObjectToStringComparator.INSTANCE); return availableLocales; } diff --git a/src/test/java/org/apache/commons/collections4/junit/ObjectToStringComparator.java b/src/test/java/org/apache/commons/collections4/junit/ObjectToStringComparator.java index eee8ed801..e36736704 100644 --- a/src/test/java/org/apache/commons/collections4/junit/ObjectToStringComparator.java +++ b/src/test/java/org/apache/commons/collections4/junit/ObjectToStringComparator.java @@ -27,7 +27,7 @@ public final class ObjectToStringComparator implements Comparator, Seria * * @since 4.5 */ - public final ObjectToStringComparator INSTANCE = new ObjectToStringComparator(); + public static final ObjectToStringComparator INSTANCE = new ObjectToStringComparator(); private static final long serialVersionUID = 1L; diff --git a/src/test/java/org/apache/commons/collections4/map/AbstractOrderedMapTest.java b/src/test/java/org/apache/commons/collections4/map/AbstractOrderedMapTest.java index 17ff23683..aa7eee1f9 100644 --- a/src/test/java/org/apache/commons/collections4/map/AbstractOrderedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/AbstractOrderedMapTest.java @@ -78,7 +78,7 @@ public abstract class AbstractOrderedMapTest extends AbstractIterableMapTe @SuppressWarnings("unchecked") public K[] getSampleKeys() { final List list = new ArrayList<>(Arrays.asList(super.getSampleKeys())); - Collections.sort(list, new NullComparator()); + list.sort(new NullComparator()); return (K[]) list.toArray(); }