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 161e1f11f [COLLECTIONS-777] Migrate to JUnit 5 161e1f11f is described below commit 161e1f11fbecf2df7ac082f73c5ba568ac2dc795 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sun Oct 20 10:07:45 2024 -0400 [COLLECTIONS-777] Migrate to JUnit 5 [COLLECTIONS-809] Update try/catch/fail logic to assertThrows --- .../collections4/bidimap/AbstractBidiMapTest.java | 5 +---- .../bidimap/AbstractOrderedBidiMapDecoratorTest.java | 2 +- .../collections4/list/AbstractLinkedListTest.java | 16 +++------------- .../commons/collections4/list/AbstractListTest.java | 10 ++-------- .../apache/commons/collections4/map/AbstractMapTest.java | 5 +---- 5 files changed, 8 insertions(+), 30 deletions(-) diff --git a/src/test/java/org/apache/commons/collections4/bidimap/AbstractBidiMapTest.java b/src/test/java/org/apache/commons/collections4/bidimap/AbstractBidiMapTest.java index 8f44575bd..74cbd0727 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/AbstractBidiMapTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/AbstractBidiMapTest.java @@ -72,10 +72,7 @@ public abstract class AbstractBidiMapTest<K, V> extends AbstractIterableMapTest< TestBidiMapEntrySet.this.verify(); if (!isSetValueSupported()) { - try { - entry1.setValue(newValue1); - } catch (final UnsupportedOperationException ex) { - } + assertThrows(UnsupportedOperationException.class, () -> entry1.setValue(newValue1)); return; } diff --git a/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapDecoratorTest.java b/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapDecoratorTest.java index 4f10c4324..2d6483d6b 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapDecoratorTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapDecoratorTest.java @@ -27,7 +27,7 @@ import org.apache.commons.collections4.OrderedBidiMap; * @param <K> the type of the keys in this map * @param <V> the type of the values in this map */ -public class AbstractOrderedBidiMapDecoratorTest<K, V> +public abstract class AbstractOrderedBidiMapDecoratorTest<K, V> extends AbstractOrderedBidiMapTest<K, V> { /** diff --git a/src/test/java/org/apache/commons/collections4/list/AbstractLinkedListTest.java b/src/test/java/org/apache/commons/collections4/list/AbstractLinkedListTest.java index 397cb03d0..db67c94ec 100644 --- a/src/test/java/org/apache/commons/collections4/list/AbstractLinkedListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/AbstractLinkedListTest.java @@ -56,12 +56,8 @@ public abstract class AbstractLinkedListTest<E> extends AbstractListTest<E> { resetEmpty(); final AbstractLinkedList<E> list = getCollection(); if (!isAddSupported()) { - try { - list.addFirst(null); - } catch (final UnsupportedOperationException ex) { - } + assertThrows(UnsupportedOperationException.class, () -> list.addFirst(null)); } - list.addFirst((E) "value1"); list.addNodeAfter(list.getNode(0, false), (E) "value2"); assertEquals("value1", list.getFirst()); @@ -110,10 +106,7 @@ public abstract class AbstractLinkedListTest<E> extends AbstractListTest<E> { resetEmpty(); final AbstractLinkedList<E> list = getCollection(); if (!isRemoveSupported()) { - try { - list.removeFirst(); - } catch (final UnsupportedOperationException ex) { - } + assertThrows(UnsupportedOperationException.class, list::removeFirst); } list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" })); @@ -136,10 +129,7 @@ public abstract class AbstractLinkedListTest<E> extends AbstractListTest<E> { resetEmpty(); final AbstractLinkedList<E> list = getCollection(); if (!isRemoveSupported()) { - try { - list.removeLast(); - } catch (final UnsupportedOperationException ex) { - } + assertThrows(UnsupportedOperationException.class, list::removeLast); } list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" })); diff --git a/src/test/java/org/apache/commons/collections4/list/AbstractListTest.java b/src/test/java/org/apache/commons/collections4/list/AbstractListTest.java index 6bd558923..a5be4c23f 100644 --- a/src/test/java/org/apache/commons/collections4/list/AbstractListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/AbstractListTest.java @@ -819,15 +819,9 @@ public abstract class AbstractListTest<E> extends AbstractCollectionTest<E> { @Test public void testListListIteratorByIndex() { resetFull(); - try { - getCollection().listIterator(-1); - } catch (final IndexOutOfBoundsException ex) { - } + assertThrows(IndexOutOfBoundsException.class, () -> getCollection().listIterator(-1)); resetFull(); - try { - getCollection().listIterator(getCollection().size() + 1); - } catch (final IndexOutOfBoundsException ex) { - } + assertThrows(IndexOutOfBoundsException.class, () -> getCollection().listIterator(getCollection().size() + 1)); resetFull(); for (int i = 0; i <= getConfirmed().size(); i++) { forwardTest(getCollection().listIterator(i), i); diff --git a/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java b/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java index b3faa0133..91a6737ef 100644 --- a/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java @@ -280,10 +280,7 @@ public abstract class AbstractMapTest<M extends Map<K, V>, K, V> extends Abstrac verify(); if (!isSetValueSupported()) { - try { - entry1.setValue(newValue1); - } catch (final UnsupportedOperationException ex) { - } + assertThrows(UnsupportedOperationException.class, () -> entry1.setValue(newValue1)); return; }