This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-collections.git


The following commit(s) were added to refs/heads/master by this push:
     new f4c041b  COLLECTIONS-777 JUnit v5 (#281)
f4c041b is described below

commit f4c041ba949403ad6855a3811ad00fbf240255ea
Author: John Patrick <142304+nhojpatr...@users.noreply.github.com>
AuthorDate: Fri Mar 4 13:36:21 2022 +0000

    COLLECTIONS-777 JUnit v5 (#281)
    
    JUnit v5 assertThrows for PatriciaTrieTest.java
    
    JUnit v5 assertThrows UnmodifiableBagTest
    
    JUnit v5 assertThrows UnmodifiableSortedBagTest
    
    JUnit v5 assertThrows UnmodifiableBidiMapTest
    
    JUnit v5 assertThrows UnmodifiableOrderedBidiMapTest
    
    JUnit v5 assertThrows UnmodifiableSortedBidiMapTest
    
    JUnit v5 assertThrows TrieUtilsTest
    
    JUnit v5 assertThrows AbstractArrayListTest
    
    JUnit v5 assertThrows UnmodifiableTrieTest
    
    JUnit v5 assertThrows UnmodifiableSetTest
    
    JUnit v5 assertThrows CompositeMapTest
    
    JUnit v5 assertThrows SetUniqueListTest
    
    JUnit v5 assertThrows UnmodifiableMapEntryTest
    
    JUnit v5 assertThrows DefaultMapEntryTest
    
    JUnit v5 assertThrows AbstractMapEntryTest
    
    JUnit v5 assertThrows UnmodifiableOrderedMapIteratorTest
    
    JUnit v5 assertThrows UnmodifiableMapIteratorTest
    
    JUnit v5 assertThrows UnmodifiableIteratorTest
    
    JUnit v5 assertThrows PermutationIteratorTest
    
    JUnit v5 assertThrows ObjectArrayIteratorTest
    
    JUnit v5 assertThrows NodeListIteratorTest
    
    JUnit v5 assertThrows IteratorEnumerationTest
    
    JUnit v5 assertThrows FilterIteratorTest
    
    JUnit v5 assertThrows ArrayIteratorTest
    
    JUnit v5 assertThrows AbstractOrderedMapIteratorTest
    
    JUnit v5 assertThrows UnmodifiableCollectionTest
    
    JUnit v5 assertThrows UnmodifiableBoundedCollectionTest
    
    JUnit v5 assertThrows IndexedCollectionTest
---
 .../collections4/AbstractArrayListTest.java        | 10 +---
 .../apache/commons/collections4/TrieUtilsTest.java | 11 +---
 .../collections4/bag/UnmodifiableBagTest.java      |  9 +--
 .../bag/UnmodifiableSortedBagTest.java             |  9 +--
 .../bidimap/UnmodifiableBidiMapTest.java           |  9 +--
 .../bidimap/UnmodifiableOrderedBidiMapTest.java    | 10 ++--
 .../bidimap/UnmodifiableSortedBidiMapTest.java     |  9 +--
 .../collection/IndexedCollectionTest.java          | 10 ++--
 .../UnmodifiableBoundedCollectionTest.java         |  8 +--
 .../collection/UnmodifiableCollectionTest.java     |  8 +--
 .../iterators/AbstractOrderedMapIteratorTest.java  |  8 +--
 .../collections4/iterators/ArrayIteratorTest.java  |  8 +--
 .../collections4/iterators/FilterIteratorTest.java | 11 +---
 .../iterators/IteratorEnumerationTest.java         | 11 +---
 .../iterators/NodeListIteratorTest.java            | 11 ++--
 .../iterators/ObjectArrayIteratorTest.java         | 11 +---
 .../iterators/PermutationIteratorTest.java         | 10 ++--
 .../iterators/UnmodifiableIteratorTest.java        |  8 +--
 .../iterators/UnmodifiableMapIteratorTest.java     |  8 +--
 .../UnmodifiableOrderedMapIteratorTest.java        |  8 +--
 .../keyvalue/AbstractMapEntryTest.java             | 13 ++---
 .../collections4/keyvalue/DefaultMapEntryTest.java | 11 +---
 .../keyvalue/UnmodifiableMapEntryTest.java         |  8 +--
 .../collections4/list/SetUniqueListTest.java       |  8 +--
 .../commons/collections4/map/CompositeMapTest.java | 11 ++--
 .../collections4/set/UnmodifiableSetTest.java      |  9 +--
 .../collections4/trie/PatriciaTrieTest.java        | 66 +++++++++++-----------
 .../collections4/trie/UnmodifiableTrieTest.java    |  9 +--
 28 files changed, 120 insertions(+), 202 deletions(-)

diff --git 
a/src/test/java/org/apache/commons/collections4/AbstractArrayListTest.java 
b/src/test/java/org/apache/commons/collections4/AbstractArrayListTest.java
index 8e054ba..01d5978 100644
--- a/src/test/java/org/apache/commons/collections4/AbstractArrayListTest.java
+++ b/src/test/java/org/apache/commons/collections4/AbstractArrayListTest.java
@@ -16,13 +16,14 @@
  */
 package org.apache.commons.collections4;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.util.ArrayList;
 
 import org.apache.commons.collections4.list.AbstractListTest;
 
 /**
  * Abstract test class for ArrayList.
- *
  */
 public abstract class AbstractArrayListTest<E> extends AbstractListTest<E> {
 
@@ -41,12 +42,7 @@ public abstract class AbstractArrayListTest<E> extends 
AbstractListTest<E> {
         assertTrue("New list is empty", list.isEmpty());
         assertEquals("New list has size zero", 0, list.size());
 
-        try {
-            list.get(1);
-            fail("get(int i) should have thrown IndexOutOfBoundsException");
-        } catch (final IndexOutOfBoundsException e) {
-            // Expected result
-        }
+        assertThrows(IndexOutOfBoundsException.class, () -> list.get(1));
     }
 
     @SuppressWarnings("unchecked")
diff --git a/src/test/java/org/apache/commons/collections4/TrieUtilsTest.java 
b/src/test/java/org/apache/commons/collections4/TrieUtilsTest.java
index 5c8ab37..45fb669 100644
--- a/src/test/java/org/apache/commons/collections4/TrieUtilsTest.java
+++ b/src/test/java/org/apache/commons/collections4/TrieUtilsTest.java
@@ -17,8 +17,8 @@
 package org.apache.commons.collections4;
 
 import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
 
 import org.apache.commons.collections4.trie.PatriciaTrie;
 import org.apache.commons.collections4.trie.UnmodifiableTrie;
@@ -26,7 +26,6 @@ import org.junit.jupiter.api.Test;
 
 /**
  * Tests for TrieUtils factory methods.
- *
  */
 public class TrieUtilsTest {
 
@@ -36,12 +35,8 @@ public class TrieUtilsTest {
     public void testUnmodifiableTrie() {
         final Trie<String, Object> trie = TrieUtils.unmodifiableTrie(new 
PatriciaTrie<>());
         assertTrue(trie instanceof UnmodifiableTrie, "Returned object should 
be an UnmodifiableTrie.");
-        try {
-            TrieUtils.unmodifiableTrie(null);
-            fail("Expecting NullPointerException for null trie.");
-        } catch (final NullPointerException ex) {
-            // expected
-        }
+
+        assertThrows(NullPointerException.class, () -> 
TrieUtils.unmodifiableTrie(null));
 
         assertSame(trie, TrieUtils.unmodifiableTrie(trie), "UnmodifiableTrie 
shall not be decorated");
     }
diff --git 
a/src/test/java/org/apache/commons/collections4/bag/UnmodifiableBagTest.java 
b/src/test/java/org/apache/commons/collections4/bag/UnmodifiableBagTest.java
index 31a2c8d..d86f22a 100644
--- a/src/test/java/org/apache/commons/collections4/bag/UnmodifiableBagTest.java
+++ b/src/test/java/org/apache/commons/collections4/bag/UnmodifiableBagTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.collections4.bag;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.util.Arrays;
 
 import junit.framework.Test;
@@ -73,7 +75,6 @@ public class UnmodifiableBagTest<E> extends 
AbstractBagTest<E> {
         return false;
     }
 
-
     public void testUnmodifiable() {
         assertTrue(makeObject() instanceof Unmodifiable);
         assertTrue(makeFullCollection() instanceof Unmodifiable);
@@ -83,13 +84,9 @@ public class UnmodifiableBagTest<E> extends 
AbstractBagTest<E> {
         final Bag<E> queue = makeFullCollection();
         assertSame(queue, UnmodifiableBag.unmodifiableBag(queue));
 
-        try {
-            UnmodifiableBag.unmodifiableBag(null);
-            fail();
-        } catch (final NullPointerException ex) {}
+        assertThrows(NullPointerException.class, () -> 
UnmodifiableBag.unmodifiableBag(null));
     }
 
-
     @Override
     public String getCompatibilityVersion() {
         return "4";
diff --git 
a/src/test/java/org/apache/commons/collections4/bag/UnmodifiableSortedBagTest.java
 
b/src/test/java/org/apache/commons/collections4/bag/UnmodifiableSortedBagTest.java
index d2d599a..ae509f1 100644
--- 
a/src/test/java/org/apache/commons/collections4/bag/UnmodifiableSortedBagTest.java
+++ 
b/src/test/java/org/apache/commons/collections4/bag/UnmodifiableSortedBagTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.collections4.bag;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.util.Arrays;
 
 import junit.framework.Test;
@@ -73,7 +75,6 @@ public class UnmodifiableSortedBagTest<E> extends 
AbstractSortedBagTest<E> {
         return false;
     }
 
-
     public void testUnmodifiable() {
         assertTrue(makeObject() instanceof Unmodifiable);
         assertTrue(makeFullCollection() instanceof Unmodifiable);
@@ -83,13 +84,9 @@ public class UnmodifiableSortedBagTest<E> extends 
AbstractSortedBagTest<E> {
         final SortedBag<E> queue = makeFullCollection();
         assertSame(queue, UnmodifiableSortedBag.unmodifiableSortedBag(queue));
 
-        try {
-            UnmodifiableSortedBag.unmodifiableSortedBag(null);
-            fail();
-        } catch (final NullPointerException ex) {}
+        assertThrows(NullPointerException.class, () -> 
UnmodifiableSortedBag.unmodifiableSortedBag(null));
     }
 
-
     @Override
     public String getCompatibilityVersion() {
         return "4";
diff --git 
a/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableBidiMapTest.java
 
b/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableBidiMapTest.java
index ee99791..8ecd7e9 100644
--- 
a/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableBidiMapTest.java
+++ 
b/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableBidiMapTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.collections4.bidimap;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.util.HashMap;
 import java.util.Map;
 
@@ -27,7 +29,6 @@ import org.apache.commons.collections4.Unmodifiable;
 
 /**
  * JUnit tests.
- *
  */
 public class UnmodifiableBidiMapTest<K, V> extends AbstractBidiMapTest<K, V> {
 
@@ -79,7 +80,6 @@ public class UnmodifiableBidiMapTest<K, V> extends 
AbstractBidiMapTest<K, V> {
         return false;
     }
 
-
     public void testUnmodifiable() {
         assertTrue(makeObject() instanceof Unmodifiable);
         assertTrue(makeFullMap() instanceof Unmodifiable);
@@ -89,10 +89,7 @@ public class UnmodifiableBidiMapTest<K, V> extends 
AbstractBidiMapTest<K, V> {
         final BidiMap<K, V> map = makeFullMap();
         assertSame(map, UnmodifiableBidiMap.unmodifiableBidiMap(map));
 
-        try {
-            UnmodifiableBidiMap.unmodifiableBidiMap(null);
-            fail();
-        } catch (final NullPointerException ex) {}
+        assertThrows(NullPointerException.class, () -> 
UnmodifiableBidiMap.unmodifiableBidiMap(null));
     }
 
 }
diff --git 
a/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableOrderedBidiMapTest.java
 
b/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableOrderedBidiMapTest.java
index 8b0f48e..1401469 100644
--- 
a/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableOrderedBidiMapTest.java
+++ 
b/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableOrderedBidiMapTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.collections4.bidimap;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.util.Map;
 import java.util.TreeMap;
 
@@ -27,7 +29,6 @@ import org.apache.commons.collections4.Unmodifiable;
 
 /**
  * JUnit tests.
- *
  */
 public class UnmodifiableOrderedBidiMapTest<K extends Comparable<K>, V extends 
Comparable<V>> extends AbstractOrderedBidiMapTest<K, V> {
 
@@ -89,7 +90,6 @@ public class UnmodifiableOrderedBidiMapTest<K extends 
Comparable<K>, V extends C
         return false;
     }
 
-
     public void testUnmodifiable() {
         assertTrue(makeObject() instanceof Unmodifiable);
         assertTrue(makeFullMap() instanceof Unmodifiable);
@@ -99,9 +99,7 @@ public class UnmodifiableOrderedBidiMapTest<K extends 
Comparable<K>, V extends C
         final OrderedBidiMap<K, V> map = makeFullMap();
         assertSame(map, 
UnmodifiableOrderedBidiMap.unmodifiableOrderedBidiMap(map));
 
-        try {
-            UnmodifiableOrderedBidiMap.unmodifiableOrderedBidiMap(null);
-            fail();
-        } catch (final NullPointerException ex) {}
+        assertThrows(NullPointerException.class, () -> 
UnmodifiableOrderedBidiMap.unmodifiableOrderedBidiMap(null));
     }
+
 }
diff --git 
a/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableSortedBidiMapTest.java
 
b/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableSortedBidiMapTest.java
index 4f0b198..1f411f4 100644
--- 
a/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableSortedBidiMapTest.java
+++ 
b/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableSortedBidiMapTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.collections4.bidimap;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.util.SortedMap;
 import java.util.TreeMap;
 
@@ -27,7 +29,6 @@ import org.apache.commons.collections4.Unmodifiable;
 
 /**
  * JUnit tests.
- *
  */
 public class UnmodifiableSortedBidiMapTest<K extends Comparable<K>, V extends 
Comparable<V>> extends AbstractSortedBidiMapTest<K, V> {
 
@@ -93,7 +94,6 @@ public class UnmodifiableSortedBidiMapTest<K extends 
Comparable<K>, V extends Co
         return false;
     }
 
-
     public void testUnmodifiable() {
         assertTrue(makeObject() instanceof Unmodifiable);
         assertTrue(makeFullMap() instanceof Unmodifiable);
@@ -103,10 +103,7 @@ public class UnmodifiableSortedBidiMapTest<K extends 
Comparable<K>, V extends Co
         final SortedBidiMap<K, V> map = makeFullMap();
         assertSame(map, 
UnmodifiableSortedBidiMap.unmodifiableSortedBidiMap(map));
 
-        try {
-            UnmodifiableSortedBidiMap.unmodifiableSortedBidiMap(null);
-            fail();
-        } catch (final NullPointerException ex) {}
+        assertThrows(NullPointerException.class, () -> 
UnmodifiableSortedBidiMap.unmodifiableSortedBidiMap(null));
     }
 
 }
diff --git 
a/src/test/java/org/apache/commons/collections4/collection/IndexedCollectionTest.java
 
b/src/test/java/org/apache/commons/collections4/collection/IndexedCollectionTest.java
index 8623663..50aa1c7 100644
--- 
a/src/test/java/org/apache/commons/collections4/collection/IndexedCollectionTest.java
+++ 
b/src/test/java/org/apache/commons/collections4/collection/IndexedCollectionTest.java
@@ -17,6 +17,7 @@
 package org.apache.commons.collections4.collection;
 
 import static java.util.Arrays.asList;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.io.Serializable;
 import java.util.ArrayList;
@@ -124,12 +125,8 @@ public class IndexedCollectionTest extends 
AbstractCollectionTest<String> {
         final Collection<String> coll = makeUniqueTestCollection();
 
         coll.add("1");
-        try {
-            coll.add("1");
-            fail();
-        } catch (final IllegalArgumentException e) {
-            // expected
-        }
+
+        assertThrows(IllegalArgumentException.class, () -> coll.add("1"));
     }
 
     public void testDecoratedCollectionIsIndexedOnCreation() throws Exception {
@@ -159,4 +156,5 @@ public class IndexedCollectionTest extends 
AbstractCollectionTest<String> {
         assertEquals("2", indexed.get(2));
         assertEquals("3", indexed.get(3));
     }
+
 }
diff --git 
a/src/test/java/org/apache/commons/collections4/collection/UnmodifiableBoundedCollectionTest.java
 
b/src/test/java/org/apache/commons/collections4/collection/UnmodifiableBoundedCollectionTest.java
index f65e321..868f30e 100644
--- 
a/src/test/java/org/apache/commons/collections4/collection/UnmodifiableBoundedCollectionTest.java
+++ 
b/src/test/java/org/apache/commons/collections4/collection/UnmodifiableBoundedCollectionTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.collections4.collection;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -27,7 +29,6 @@ import org.apache.commons.collections4.list.FixedSizeList;
 /**
  * Extension of {@link AbstractCollectionTest} for exercising the
  * {@link UnmodifiableBoundedCollection} implementation.
- *
  */
 public class UnmodifiableBoundedCollectionTest<E> extends 
AbstractCollectionTest<E> {
 
@@ -88,10 +89,7 @@ public class UnmodifiableBoundedCollectionTest<E> extends 
AbstractCollectionTest
         final BoundedCollection<E> coll = makeFullCollection();
         assertSame(coll, 
UnmodifiableBoundedCollection.unmodifiableBoundedCollection(coll));
 
-        try {
-            UnmodifiableBoundedCollection.unmodifiableBoundedCollection(null);
-            fail();
-        } catch (final NullPointerException ex) {}
+        assertThrows(NullPointerException.class, () -> 
UnmodifiableBoundedCollection.unmodifiableBoundedCollection(null));
     }
 
 }
diff --git 
a/src/test/java/org/apache/commons/collections4/collection/UnmodifiableCollectionTest.java
 
b/src/test/java/org/apache/commons/collections4/collection/UnmodifiableCollectionTest.java
index ee7be3b..8a7e879 100644
--- 
a/src/test/java/org/apache/commons/collections4/collection/UnmodifiableCollectionTest.java
+++ 
b/src/test/java/org/apache/commons/collections4/collection/UnmodifiableCollectionTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.collections4.collection;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -76,13 +78,9 @@ public class UnmodifiableCollectionTest<E> extends 
AbstractCollectionTest<E> {
         final Collection<E> coll = makeFullCollection();
         assertSame(coll, UnmodifiableCollection.unmodifiableCollection(coll));
 
-        try {
-            UnmodifiableCollection.unmodifiableCollection(null);
-            fail();
-        } catch (final NullPointerException ex) {}
+        assertThrows(NullPointerException.class, () -> 
UnmodifiableCollection.unmodifiableCollection(null));
     }
 
-
     @Override
     public String getCompatibilityVersion() {
         return "4";
diff --git 
a/src/test/java/org/apache/commons/collections4/iterators/AbstractOrderedMapIteratorTest.java
 
b/src/test/java/org/apache/commons/collections4/iterators/AbstractOrderedMapIteratorTest.java
index 80d6a57..c27001d 100644
--- 
a/src/test/java/org/apache/commons/collections4/iterators/AbstractOrderedMapIteratorTest.java
+++ 
b/src/test/java/org/apache/commons/collections4/iterators/AbstractOrderedMapIteratorTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.collections4.iterators;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -66,10 +68,8 @@ public abstract class AbstractOrderedMapIteratorTest<K, V> 
extends AbstractMapIt
 
         final OrderedMapIterator<K, V> it = makeEmptyIterator();
         assertFalse(it.hasPrevious());
-        try {
-            it.previous();
-            fail();
-        } catch (final NoSuchElementException ex) {}
+
+        assertThrows(NoSuchElementException.class, () -> it.previous());
     }
 
     /**
diff --git 
a/src/test/java/org/apache/commons/collections4/iterators/ArrayIteratorTest.java
 
b/src/test/java/org/apache/commons/collections4/iterators/ArrayIteratorTest.java
index 24b7a3d..3dda871 100644
--- 
a/src/test/java/org/apache/commons/collections4/iterators/ArrayIteratorTest.java
+++ 
b/src/test/java/org/apache/commons/collections4/iterators/ArrayIteratorTest.java
@@ -25,7 +25,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
  * Tests the ArrayIterator to ensure that the next() method will actually
  * perform the iteration rather than the hasNext() method.
  * The code of this test was supplied by Mauricio S. Moura.
- *
  */
 public class ArrayIteratorTest<E> extends AbstractIteratorTest<E> {
 
@@ -64,12 +63,7 @@ public class ArrayIteratorTest<E> extends 
AbstractIteratorTest<E> {
     }
 
     public void testNullArray() {
-        try {
-            new ArrayIterator<>(null);
-            fail("Constructor should throw a NullPointerException when 
constructed with a null array");
-        } catch (final NullPointerException e) {
-            // expected
-        }
+        assertThrows(NullPointerException.class, () -> new 
ArrayIterator<>(null));
     }
 
     public void testReset() {
diff --git 
a/src/test/java/org/apache/commons/collections4/iterators/FilterIteratorTest.java
 
b/src/test/java/org/apache/commons/collections4/iterators/FilterIteratorTest.java
index cae41e3..63bee72 100644
--- 
a/src/test/java/org/apache/commons/collections4/iterators/FilterIteratorTest.java
+++ 
b/src/test/java/org/apache/commons/collections4/iterators/FilterIteratorTest.java
@@ -17,6 +17,7 @@
 package org.apache.commons.collections4.iterators;
 
 import static 
org.apache.commons.collections4.functors.TruePredicate.truePredicate;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -30,7 +31,6 @@ import 
org.apache.commons.collections4.functors.NotNullPredicate;
 
 /**
  * Test the filter iterator.
- *
  */
 public class FilterIteratorTest<E> extends AbstractIteratorTest<E> {
 
@@ -147,12 +147,7 @@ public class FilterIteratorTest<E> extends 
AbstractIteratorTest<E> {
 
     private void verifyNoMoreElements() {
         assertFalse(iterator.hasNext());
-        try {
-            iterator.next();
-            fail("NoSuchElementException expected");
-        } catch (final NoSuchElementException e) {
-            // success
-        }
+        assertThrows(NoSuchElementException.class, () -> iterator.next());
     }
 
     private void verifyElementsInPredicate(final String[] elements) {
@@ -210,5 +205,5 @@ public class FilterIteratorTest<E> extends 
AbstractIteratorTest<E> {
         final Predicate<E> pred = x -> false;
         return new FilterIterator<>(i, pred);
     }
-}
 
+}
diff --git 
a/src/test/java/org/apache/commons/collections4/iterators/IteratorEnumerationTest.java
 
b/src/test/java/org/apache/commons/collections4/iterators/IteratorEnumerationTest.java
index 06a3142..1007d81 100644
--- 
a/src/test/java/org/apache/commons/collections4/iterators/IteratorEnumerationTest.java
+++ 
b/src/test/java/org/apache/commons/collections4/iterators/IteratorEnumerationTest.java
@@ -24,12 +24,11 @@ import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
 
 /**
  * Tests the IteratorEnumeration.
- *
  */
 public class IteratorEnumerationTest {
 
@@ -46,11 +45,7 @@ public class IteratorEnumerationTest {
         assertEquals("c", enumeration.nextElement());
         assertFalse(enumeration.hasMoreElements());
 
-        try {
-            enumeration.nextElement();
-            fail("NoSuchElementException expected");
-        } catch (final NoSuchElementException e) {
-            // expected
-        }
+        assertThrows(NoSuchElementException.class, () -> 
enumeration.nextElement());
     }
+
 }
diff --git 
a/src/test/java/org/apache/commons/collections4/iterators/NodeListIteratorTest.java
 
b/src/test/java/org/apache/commons/collections4/iterators/NodeListIteratorTest.java
index 9eee8a6..5c953fe 100644
--- 
a/src/test/java/org/apache/commons/collections4/iterators/NodeListIteratorTest.java
+++ 
b/src/test/java/org/apache/commons/collections4/iterators/NodeListIteratorTest.java
@@ -17,6 +17,7 @@
 package org.apache.commons.collections4.iterators;
 
 import static org.easymock.EasyMock.*;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.util.Iterator;
 
@@ -110,13 +111,8 @@ public class NodeListIteratorTest extends 
AbstractIteratorTest<Node> {
         return false;
     }
 
-    public void testNullConstructor(){
-        try{
-            new NodeListIterator((Node) null);
-            fail("NullPointerException expected!");
-        }catch(final NullPointerException e){
-            // expected.
-        }
+    public void testNullConstructor() {
+        assertThrows(NullPointerException.class, () -> new 
NodeListIterator((Node) null));
     }
 
     /**
@@ -134,4 +130,5 @@ public class NodeListIteratorTest extends 
AbstractIteratorTest<Node> {
         createIteratorWithStandardConstr = false;
         testFullIterator();
     }
+
 }
diff --git 
a/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayIteratorTest.java
 
b/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayIteratorTest.java
index cea9f27..f1095cf 100644
--- 
a/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayIteratorTest.java
+++ 
b/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayIteratorTest.java
@@ -16,12 +16,13 @@
  */
 package org.apache.commons.collections4.iterators;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 
 /**
  * Tests the ObjectArrayIterator.
- *
  */
 public class ObjectArrayIteratorTest<E> extends AbstractIteratorTest<E> {
 
@@ -83,13 +84,7 @@ public class ObjectArrayIteratorTest<E> extends 
AbstractIteratorTest<E> {
     }
 
     public void testNullArray() {
-        try {
-            makeArrayIterator(null);
-
-            fail("Constructor should throw a NullPointerException when 
constructed with a null array");
-        } catch (final NullPointerException e) {
-            // expected
-        }
+        assertThrows(NullPointerException.class, () -> 
makeArrayIterator(null));
     }
 
     @SuppressWarnings("unchecked")
diff --git 
a/src/test/java/org/apache/commons/collections4/iterators/PermutationIteratorTest.java
 
b/src/test/java/org/apache/commons/collections4/iterators/PermutationIteratorTest.java
index 6db437e..8af44ff 100644
--- 
a/src/test/java/org/apache/commons/collections4/iterators/PermutationIteratorTest.java
+++ 
b/src/test/java/org/apache/commons/collections4/iterators/PermutationIteratorTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.collections4.iterators;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
@@ -162,12 +164,7 @@ public class PermutationIteratorTest extends 
AbstractIteratorTest<List<Character
             resultsList.add(permutation);
         }
         //asking for another permutation should throw an exception
-        try {
-            it.next();
-            fail();
-        } catch (final NoSuchElementException e) {
-            // expected
-        }
+        assertThrows(NoSuchElementException.class, () -> it.next());
     }
 
     public void testPermutatorHasMore() {
@@ -189,4 +186,5 @@ public class PermutationIteratorTest extends 
AbstractIteratorTest<List<Character
 
         assertFalse(it.hasNext());
     }
+
 }
diff --git 
a/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableIteratorTest.java
 
b/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableIteratorTest.java
index 3605706..a1cabeb 100644
--- 
a/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableIteratorTest.java
+++ 
b/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableIteratorTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.collections4.iterators;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -26,7 +28,6 @@ import org.apache.commons.collections4.Unmodifiable;
 
 /**
  * Tests the UnmodifiableIterator.
- *
  */
 public class UnmodifiableIteratorTest<E> extends AbstractIteratorTest<E> {
 
@@ -73,10 +74,7 @@ public class UnmodifiableIteratorTest<E> extends 
AbstractIteratorTest<E> {
         it = testList.iterator();
         assertNotSame(it, UnmodifiableIterator.unmodifiableIterator(it));
 
-        try {
-            UnmodifiableIterator.unmodifiableIterator(null);
-            fail();
-        } catch (final NullPointerException ex) {}
+        assertThrows(NullPointerException.class, () -> 
UnmodifiableIterator.unmodifiableIterator(null));
     }
 
 }
diff --git 
a/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableMapIteratorTest.java
 
b/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableMapIteratorTest.java
index 2fa9f46..76b3c70 100644
--- 
a/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableMapIteratorTest.java
+++ 
b/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableMapIteratorTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.collections4.iterators;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.util.HashMap;
 import java.util.Map;
 
@@ -26,7 +28,6 @@ import 
org.apache.commons.collections4.bidimap.DualHashBidiMap;
 
 /**
  * Tests the UnmodifiableMapIterator.
- *
  */
 public class UnmodifiableMapIteratorTest<K, V> extends 
AbstractMapIteratorTest<K, V> {
 
@@ -85,10 +86,7 @@ public class UnmodifiableMapIteratorTest<K, V> extends 
AbstractMapIteratorTest<K
         it = getMap().mapIterator();
         assertNotSame(it, UnmodifiableMapIterator.unmodifiableMapIterator(it));
 
-        try {
-            UnmodifiableMapIterator.unmodifiableMapIterator(null);
-            fail();
-        } catch (final NullPointerException ex) {}
+        assertThrows(NullPointerException.class, () -> 
UnmodifiableMapIterator.unmodifiableMapIterator(null));
     }
 
 }
diff --git 
a/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableOrderedMapIteratorTest.java
 
b/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableOrderedMapIteratorTest.java
index b2db021..75555a0 100644
--- 
a/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableOrderedMapIteratorTest.java
+++ 
b/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableOrderedMapIteratorTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.collections4.iterators;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.util.HashMap;
 import java.util.Map;
 import java.util.TreeMap;
@@ -27,7 +29,6 @@ import org.apache.commons.collections4.map.ListOrderedMap;
 
 /**
  * Tests the UnmodifiableOrderedMapIterator.
- *
  */
 public class UnmodifiableOrderedMapIteratorTest<K, V> extends 
AbstractOrderedMapIteratorTest<K, V> {
 
@@ -87,10 +88,7 @@ public class UnmodifiableOrderedMapIteratorTest<K, V> 
extends AbstractOrderedMap
         it = getMap().mapIterator();
         assertNotSame(it, 
UnmodifiableOrderedMapIterator.unmodifiableOrderedMapIterator(it));
 
-        try {
-            
UnmodifiableOrderedMapIterator.unmodifiableOrderedMapIterator(null);
-            fail();
-        } catch (final NullPointerException ex) {}
+        assertThrows(NullPointerException.class, () -> 
UnmodifiableOrderedMapIterator.unmodifiableOrderedMapIterator(null));
     }
 
 }
diff --git 
a/src/test/java/org/apache/commons/collections4/keyvalue/AbstractMapEntryTest.java
 
b/src/test/java/org/apache/commons/collections4/keyvalue/AbstractMapEntryTest.java
index 41b9b20..82461d3 100644
--- 
a/src/test/java/org/apache/commons/collections4/keyvalue/AbstractMapEntryTest.java
+++ 
b/src/test/java/org/apache/commons/collections4/keyvalue/AbstractMapEntryTest.java
@@ -24,8 +24,8 @@ import org.junit.jupiter.api.Test;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
 
 /**
  * Abstract tests that can be extended to test any Map.Entry implementation.
@@ -108,15 +108,10 @@ public abstract class AbstractMapEntryTest<K, V> {
 
         final Map.Entry<K, V> entry = makeMapEntry();
 
-        try {
-            entry.setValue((V) entry);
-            fail("Should throw an IllegalArgumentException");
-        } catch (final IllegalArgumentException iae) {
-            // expected to happen...
+        assertThrows(IllegalArgumentException.class, () -> entry.setValue((V) 
entry));
 
-            // check that the KVP's state has not changed
-            assertTrue(entry.getKey() == null && entry.getValue() == null);
-        }
+        // check that the KVP's state has not changed
+        assertTrue(entry.getKey() == null && entry.getValue() == null);
     }
 
     /**
diff --git 
a/src/test/java/org/apache/commons/collections4/keyvalue/DefaultMapEntryTest.java
 
b/src/test/java/org/apache/commons/collections4/keyvalue/DefaultMapEntryTest.java
index 9a164a4..f1cbccd 100644
--- 
a/src/test/java/org/apache/commons/collections4/keyvalue/DefaultMapEntryTest.java
+++ 
b/src/test/java/org/apache/commons/collections4/keyvalue/DefaultMapEntryTest.java
@@ -22,7 +22,7 @@ import org.apache.commons.collections4.KeyValue;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertSame;
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 /**
  * Test the DefaultMapEntry class.
@@ -84,13 +84,8 @@ public class DefaultMapEntryTest<K, V> extends 
AbstractMapEntryTest<K, V> {
     public void testSelfReferenceHandling() {
         final Map.Entry<K, V> entry = makeMapEntry();
 
-        try {
-            entry.setValue((V) entry);
-            assertSame(entry, entry.getValue());
-
-        } catch (final Exception e) {
-            fail("This Map.Entry implementation supports value 
self-reference.");
-        }
+        assertThrows(Exception.class, () -> entry.setValue((V) entry));
+        assertSame(entry, entry.getValue());
     }
 
 }
diff --git 
a/src/test/java/org/apache/commons/collections4/keyvalue/UnmodifiableMapEntryTest.java
 
b/src/test/java/org/apache/commons/collections4/keyvalue/UnmodifiableMapEntryTest.java
index c34dc08..65b46d6 100644
--- 
a/src/test/java/org/apache/commons/collections4/keyvalue/UnmodifiableMapEntryTest.java
+++ 
b/src/test/java/org/apache/commons/collections4/keyvalue/UnmodifiableMapEntryTest.java
@@ -23,8 +23,8 @@ import org.apache.commons.collections4.Unmodifiable;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
 
 /**
  * Test the UnmodifiableMapEntry class.
@@ -103,10 +103,8 @@ public class UnmodifiableMapEntryTest<K, V> extends 
AbstractMapEntryTest<K, V> {
     @Test
     public void testUnmodifiable() {
         final Map.Entry<K, V> entry = makeMapEntry();
-        try {
-            entry.setValue(null);
-            fail();
-        } catch (final UnsupportedOperationException ex) {}
+
+        assertThrows(UnsupportedOperationException.class, () -> 
entry.setValue(null));
     }
 
 }
diff --git 
a/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java 
b/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java
index 593060f..b9bd9c8 100644
--- a/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java
+++ b/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java
@@ -327,10 +327,8 @@ public class SetUniqueListTest<E> extends 
AbstractListTest<E> {
         resetFull();
         final ListIterator<E> it = getCollection().listIterator();
         it.next();
-        try {
-            it.set(null);
-            fail();
-        } catch (final UnsupportedOperationException ex) {}
+
+        assertThrows(UnsupportedOperationException.class, () -> it.set(null));
     }
 
     @Override
@@ -634,6 +632,6 @@ public class SetUniqueListTest<E> extends 
AbstractListTest<E> {
         // provide null values as Parameter
         assertThrows(NullPointerException.class, () -> 
setUniqueList.createSetBasedOnList(null, list));
         assertThrows(NullPointerException.class, () -> 
setUniqueList.createSetBasedOnList(new HashSet<>(), null));
-
     }
+
 }
diff --git 
a/src/test/java/org/apache/commons/collections4/map/CompositeMapTest.java 
b/src/test/java/org/apache/commons/collections4/map/CompositeMapTest.java
index 967dfd2..a93a2e7 100644
--- a/src/test/java/org/apache/commons/collections4/map/CompositeMapTest.java
+++ b/src/test/java/org/apache/commons/collections4/map/CompositeMapTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.collections4.map;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.util.Map;
 import java.util.HashMap;
 import java.util.Collection;
@@ -27,6 +29,7 @@ import java.util.Collection;
  * @since 3.0
  */
 public class CompositeMapTest<K, V> extends AbstractIterableMapTest<K, V> {
+
     /** used as a flag in MapMutator tests */
     private boolean pass = false;
 
@@ -78,12 +81,8 @@ public class CompositeMapTest<K, V> extends 
AbstractIterableMapTest<K, V> {
         map.addComposited(null);
         map.addComposited(three);
         assertTrue(map.containsKey("5"));
-        try {
-            map.addComposited(three);
-            fail("Expecting IllegalArgumentException.");
-        } catch (final IllegalArgumentException ex) {
-            // expected
-        }
+
+        assertThrows(IllegalArgumentException.class, () -> 
map.addComposited(three));
     }
 
     @SuppressWarnings("unchecked")
diff --git 
a/src/test/java/org/apache/commons/collections4/set/UnmodifiableSetTest.java 
b/src/test/java/org/apache/commons/collections4/set/UnmodifiableSetTest.java
index 50818f7..b6850dd 100644
--- a/src/test/java/org/apache/commons/collections4/set/UnmodifiableSetTest.java
+++ b/src/test/java/org/apache/commons/collections4/set/UnmodifiableSetTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.collections4.set;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
@@ -63,7 +65,6 @@ public class UnmodifiableSetTest<E> extends 
AbstractSetTest<E> {
         return false;
     }
 
-
     public void testUnmodifiable() {
         assertTrue(makeObject() instanceof Unmodifiable);
         assertTrue(makeFullCollection() instanceof Unmodifiable);
@@ -73,13 +74,9 @@ public class UnmodifiableSetTest<E> extends 
AbstractSetTest<E> {
         final Set<E> set = makeFullCollection();
         assertSame(set, UnmodifiableSet.unmodifiableSet(set));
 
-        try {
-            UnmodifiableSet.unmodifiableSet(null);
-            fail();
-        } catch (final NullPointerException ex) {}
+        assertThrows(NullPointerException.class, () -> 
UnmodifiableSet.unmodifiableSet(null));
     }
 
-
     @Override
     public String getCompatibilityVersion() {
         return "4";
diff --git 
a/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java 
b/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java
index f81bb08..7fb131d 100755
--- a/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java
+++ b/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java
@@ -58,7 +58,6 @@ public class PatriciaTrieTest<V> extends 
AbstractSortedMapTest<String, V> {
         return false;
     }
 
-
     public void testPrefixMap() {
         final PatriciaTrie<String> trie = new PatriciaTrie<>();
 
@@ -202,10 +201,10 @@ public class PatriciaTrieTest<V> extends 
AbstractSortedMapTest<String, V> {
         iterator = map.keySet().iterator();
         map.put("Amber", "Amber");
         Assertions.assertEquals(3, map.size());
-        try {
-            iterator.next();
-            Assertions.fail("CME expected");
-        } catch(final ConcurrentModificationException expected) {}
+
+        final Iterator<String> iterator1 = iterator;
+        Assertions.assertThrows(ConcurrentModificationException.class, () -> 
iterator1.next());
+
         Assertions.assertEquals("Amber", map.firstKey());
         Assertions.assertEquals("Ammun", map.lastKey());
 
@@ -243,28 +242,28 @@ public class PatriciaTrieTest<V> extends 
AbstractSortedMapTest<String, V> {
         map = trie.prefixMap("Ab");
         Assertions.assertTrue(map.isEmpty());
         Assertions.assertEquals(0, map.size());
-        try {
-            final Object o = map.firstKey();
-            Assertions.fail("got a first key: " + o);
-        } catch(final NoSuchElementException nsee) {}
-        try {
-            final Object o = map.lastKey();
-            Assertions.fail("got a last key: " + o);
-        } catch(final NoSuchElementException nsee) {}
+
+        final SortedMap<String, String> map1 = map;
+        Assertions.assertThrows(NoSuchElementException.class, () -> 
map1.firstKey());
+
+        final SortedMap<String, String> map2 = map;
+        Assertions.assertThrows(NoSuchElementException.class, () -> 
map2.lastKey());
+
         iterator = map.values().iterator();
         Assertions.assertFalse(iterator.hasNext());
 
         map = trie.prefixMap("Albertooo");
         Assertions.assertTrue(map.isEmpty());
         Assertions.assertEquals(0, map.size());
-        try {
-            final Object o = map.firstKey();
-            Assertions.fail("got a first key: " + o);
-        } catch(final NoSuchElementException nsee) {}
-        try {
-            final Object o = map.lastKey();
-            Assertions.fail("got a last key: " + o);
-        } catch(final NoSuchElementException nsee) {}
+
+        final SortedMap<String, String> map3 = map;
+        Assertions.assertThrows(NoSuchElementException.class, () -> 
map3.firstKey(),
+                () -> "got a first key: " + map3.firstKey());
+
+        final SortedMap<String, String> map4 = map;
+        Assertions.assertThrows(NoSuchElementException.class, () -> 
map4.lastKey(),
+                () -> "got a last key: " + map4.lastKey());
+
         iterator = map.values().iterator();
         Assertions.assertFalse(iterator.hasNext());
 
@@ -274,14 +273,15 @@ public class PatriciaTrieTest<V> extends 
AbstractSortedMapTest<String, V> {
         map = trie.prefixMap("\0");
         Assertions.assertTrue(map.isEmpty());
         Assertions.assertEquals(0, map.size());
-        try {
-            final Object o = map.firstKey();
-            Assertions.fail("got a first key: " + o);
-        } catch(final NoSuchElementException nsee) {}
-        try {
-            final Object o = map.lastKey();
-            Assertions.fail("got a last key: " + o);
-        } catch(final NoSuchElementException nsee) {}
+
+        final SortedMap<String, String> map5 = map;
+        Assertions.assertThrows(NoSuchElementException.class, () -> 
map5.firstKey(),
+                () -> "got a first key: " + map5.firstKey());
+
+        final SortedMap<String, String> map6 = map;
+        Assertions.assertThrows(NoSuchElementException.class, () -> 
map6.lastKey(),
+                () -> "got a last key: " + map6.lastKey());
+
         iterator = map.values().iterator();
         Assertions.assertFalse(iterator.hasNext());
     }
@@ -322,9 +322,10 @@ public class PatriciaTrieTest<V> extends 
AbstractSortedMapTest<String, V> {
         iter.remove();
         Assertions.assertEquals(1, map.size());
         Assertions.assertEquals("Akko", iter.next());
-        if (iter.hasNext()) {
-            Assertions.fail("shouldn't have next (but was: " + iter.next() + 
")");
-        }
+
+        final Iterator<String> iter1 = iter;
+        Assertions.assertFalse(iter.hasNext(), () -> "shouldn't have next (but 
was: " + iter1.next() + ")");
+
         Assertions.assertFalse(iter.hasNext());
     }
 
@@ -426,7 +427,6 @@ public class PatriciaTrieTest<V> extends 
AbstractSortedMapTest<String, V> {
         assertEquals(Arrays.asList(2, 3, 7, 1), new 
ArrayList<>(trie.values()));
     }
 
-
     @Override
     public String getCompatibilityVersion() {
         return "4";
diff --git 
a/src/test/java/org/apache/commons/collections4/trie/UnmodifiableTrieTest.java 
b/src/test/java/org/apache/commons/collections4/trie/UnmodifiableTrieTest.java
index 8376606..1d16384 100644
--- 
a/src/test/java/org/apache/commons/collections4/trie/UnmodifiableTrieTest.java
+++ 
b/src/test/java/org/apache/commons/collections4/trie/UnmodifiableTrieTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.collections4.trie;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import junit.framework.Test;
 
 import org.apache.commons.collections4.BulkTest;
@@ -68,7 +70,6 @@ public class UnmodifiableTrieTest<V> extends 
AbstractSortedMapTest<String, V> {
         return UnmodifiableTrie.unmodifiableTrie(m);
     }
 
-
     public void testUnmodifiable() {
         assertTrue(makeObject() instanceof Unmodifiable);
         assertTrue(makeFullMap() instanceof Unmodifiable);
@@ -78,13 +79,9 @@ public class UnmodifiableTrieTest<V> extends 
AbstractSortedMapTest<String, V> {
         final Trie<String, V> trie = makeFullMap();
         assertSame(trie, UnmodifiableTrie.unmodifiableTrie(trie));
 
-        try {
-            UnmodifiableTrie.unmodifiableTrie(null);
-            fail();
-        } catch (final NullPointerException ex) {}
+        assertThrows(NullPointerException.class, () -> 
UnmodifiableTrie.unmodifiableTrie(null));
     }
 
-
     /**
      * Override to prevent infinite recursion of tests.
      */

Reply via email to