diff --git a/src/test/java/org/apache/commons/collections4/AbstractArrayListTest.java b/src/test/java/org/apache/commons/collections4/AbstractArrayListTest.java index 01d5978eed..f8164c441a 100644 --- a/src/test/java/org/apache/commons/collections4/AbstractArrayListTest.java +++ b/src/test/java/org/apache/commons/collections4/AbstractArrayListTest.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import org.apache.commons.collections4.list.AbstractListTest; +import org.junit.Test; /** * Abstract test class for ArrayList. @@ -37,6 +38,7 @@ public AbstractArrayListTest(final String testName) { @Override public abstract ArrayList makeObject(); + @Test public void testNewArrayList() { final ArrayList list = makeObject(); assertTrue("New list is empty", list.isEmpty()); @@ -45,6 +47,7 @@ public void testNewArrayList() { assertThrows(IndexOutOfBoundsException.class, () -> list.get(1)); } + @Test @SuppressWarnings("unchecked") public void testSearch() { final ArrayList list = makeObject(); diff --git a/src/test/java/org/apache/commons/collections4/AbstractLinkedListTest.java b/src/test/java/org/apache/commons/collections4/AbstractLinkedListTest.java index 888fd70351..025f534c22 100644 --- a/src/test/java/org/apache/commons/collections4/AbstractLinkedListTest.java +++ b/src/test/java/org/apache/commons/collections4/AbstractLinkedListTest.java @@ -25,6 +25,7 @@ import java.util.NoSuchElementException; import org.apache.commons.collections4.list.AbstractListTest; +import org.junit.Test; /** * Tests base {@link java.util.LinkedList} methods and contracts. @@ -67,6 +68,7 @@ protected LinkedList getConfirmedLinkedList() { /** * Tests {@link LinkedList#addFirst(Object)}. */ + @Test @SuppressWarnings("unchecked") public void testLinkedListAddFirst() { if (!isAddSupported()) { @@ -88,6 +90,7 @@ public void testLinkedListAddFirst() { /** * Tests {@link LinkedList#addLast(Object)}. */ + @Test @SuppressWarnings("unchecked") public void testLinkedListAddLast() { if (!isAddSupported()) { @@ -109,6 +112,7 @@ public void testLinkedListAddLast() { /** * Tests {@link LinkedList#getFirst()}. */ + @Test public void testLinkedListGetFirst() { resetEmpty(); assertThrows(NoSuchElementException.class, () -> getCollection().getFirst(), @@ -126,6 +130,7 @@ public void testLinkedListGetFirst() { /** * Tests {@link LinkedList#getLast()}. */ + @Test public void testLinkedListGetLast() { resetEmpty(); assertThrows(NoSuchElementException.class, () -> getCollection().getLast(), @@ -143,6 +148,7 @@ public void testLinkedListGetLast() { /** * Tests {@link LinkedList#removeFirst()}. */ + @Test public void testLinkedListRemoveFirst() { if (!isRemoveSupported()) { return; @@ -164,6 +170,7 @@ public void testLinkedListRemoveFirst() { /** * Tests {@link LinkedList#removeLast()}. */ + @Test public void testLinkedListRemoveLast() { if (!isRemoveSupported()) { return; diff --git a/src/test/java/org/apache/commons/collections4/AbstractObjectTest.java b/src/test/java/org/apache/commons/collections4/AbstractObjectTest.java index ba7f02d471..f8a67d630a 100644 --- a/src/test/java/org/apache/commons/collections4/AbstractObjectTest.java +++ b/src/test/java/org/apache/commons/collections4/AbstractObjectTest.java @@ -16,6 +16,8 @@ */ package org.apache.commons.collections4; +import org.junit.Test; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -97,21 +99,25 @@ public boolean isEqualsCheckable() { return true; } + @Test public void testObjectEqualsSelf() { final Object obj = makeObject(); assertEquals("A Object should equal itself", obj, obj); } + @Test public void testEqualsNull() { final Object obj = makeObject(); assertFalse(obj.equals(null)); // make sure this doesn't throw NPE either } + @Test public void testObjectHashCodeEqualsSelfHashCode() { final Object obj = makeObject(); assertEquals("hashCode should be repeatable", obj.hashCode(), obj.hashCode()); } + @Test public void testObjectHashCodeEqualsContract() { final Object obj1 = makeObject(); if (obj1.equals(obj1)) { @@ -141,6 +147,7 @@ protected Object serializeDeserialize(final Object obj) throws Exception { return dest; } + @Test public void testSerializeDeserializeThenCompare() throws Exception { final Object obj = makeObject(); if (obj instanceof Serializable && isTestSerialization()) { @@ -159,6 +166,7 @@ public void testSerializeDeserializeThenCompare() throws Exception { * @throws IOException * @throws ClassNotFoundException */ + @Test public void testSimpleSerialization() throws Exception { final Object o = makeObject(); if (o instanceof Serializable && isTestSerialization()) { @@ -171,6 +179,7 @@ public void testSimpleSerialization() throws Exception { * Tests serialization by comparing against a previously stored version in SCM. * If the test object is serializable, confirm that a canonical form exists. */ + @Test public void testCanonicalEmptyCollectionExists() { if (supportsEmptyCollections() && isTestSerialization() && !skipSerializedCanonicalTests()) { final Object object = makeObject(); @@ -187,6 +196,7 @@ public void testCanonicalEmptyCollectionExists() { * Tests serialization by comparing against a previously stored version in SCM. * If the test object is serializable, confirm that a canonical form exists. */ + @Test public void testCanonicalFullCollectionExists() { if (supportsFullCollections() && isTestSerialization() && !skipSerializedCanonicalTests()) { final Object object = makeObject(); diff --git a/src/test/java/org/apache/commons/collections4/AbstractTreeMapTest.java b/src/test/java/org/apache/commons/collections4/AbstractTreeMapTest.java index b8f0a9699d..88a037ab5d 100644 --- a/src/test/java/org/apache/commons/collections4/AbstractTreeMapTest.java +++ b/src/test/java/org/apache/commons/collections4/AbstractTreeMapTest.java @@ -19,6 +19,7 @@ import java.util.TreeMap; import org.apache.commons.collections4.map.AbstractMapTest; +import org.junit.Test; /** * Tests TreeMap. @@ -41,12 +42,14 @@ public boolean isAllowNullKey() { @Override public abstract TreeMap makeObject(); + @Test public void testNewMap() { final TreeMap map = makeObject(); assertTrue("New map is empty", map.isEmpty()); assertEquals("New map has size zero", 0, map.size()); } + @Test @SuppressWarnings("unchecked") public void testSearch() { final TreeMap map = makeObject(); diff --git a/src/test/java/org/apache/commons/collections4/ArrayStackTest.java b/src/test/java/org/apache/commons/collections4/ArrayStackTest.java index 8f1ce5d81d..c8f4db4ec9 100644 --- a/src/test/java/org/apache/commons/collections4/ArrayStackTest.java +++ b/src/test/java/org/apache/commons/collections4/ArrayStackTest.java @@ -20,7 +20,7 @@ import java.util.EmptyStackException; -import junit.framework.Test; +import org.junit.Test; /** * Tests ArrayStack. @@ -32,7 +32,7 @@ public ArrayStackTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(ArrayStackTest.class); } @@ -41,6 +41,7 @@ public ArrayStack makeObject() { return new ArrayStack<>(); } + @Test public void testNewStack() { final ArrayStack stack = makeObject(); assertTrue("New stack is empty", stack.empty()); @@ -51,6 +52,7 @@ public void testNewStack() { assertThrows(EmptyStackException.class, () -> stack.pop()); } + @Test @SuppressWarnings("unchecked") public void testPushPeekPop() { final ArrayStack stack = makeObject(); @@ -79,6 +81,7 @@ public void testPushPeekPop() { assertEquals("Stack size is zero", 0, stack.size()); } + @Test @Override @SuppressWarnings("unchecked") public void testSearch() { diff --git a/src/test/java/org/apache/commons/collections4/BulkTest.java b/src/test/java/org/apache/commons/collections4/BulkTest.java index 00cc73497c..58ff23389f 100644 --- a/src/test/java/org/apache/commons/collections4/BulkTest.java +++ b/src/test/java/org/apache/commons/collections4/BulkTest.java @@ -52,11 +52,13 @@ * this.set = set; * } * + * @Test * public void testContains() { * boolean r = set.contains(set.iterator().next())); * assertTrue("Set should contain first element, r); * } * + * @Test * public void testClear() { * set.clear(); * assertTrue("Set should be empty after clear", set.isEmpty()); @@ -73,6 +75,7 @@ * return result; * } * + * @Test * public void testClear() { * Map map = makeFullMap(); * map.clear(); diff --git a/src/test/java/org/apache/commons/collections4/PredicateUtilsTest.java b/src/test/java/org/apache/commons/collections4/PredicateUtilsTest.java index 3d7387f890..e13cc0a886 100644 --- a/src/test/java/org/apache/commons/collections4/PredicateUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/PredicateUtilsTest.java @@ -152,8 +152,8 @@ public void testAndPredicateEx() { // allPredicate //------------------------------------------------------------------ - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("unchecked") public void testAllPredicate() { assertPredicateTrue(AllPredicate.allPredicate(), null); assertTrue(AllPredicate.allPredicate(truePredicate(), truePredicate(), truePredicate()).evaluate(null)); @@ -195,8 +195,8 @@ public void testAllPredicateEx1() { assertThrows(NullPointerException.class, () -> AllPredicate.allPredicate((Predicate[]) null)); } - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("unchecked") public void testAllPredicateEx2() { assertThrows(NullPointerException.class, () -> AllPredicate.allPredicate(new Predicate[] { null })); } @@ -243,8 +243,8 @@ public void testOrPredicateEx() { // anyPredicate //------------------------------------------------------------------ - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("unchecked") public void testAnyPredicate() { assertPredicateFalse(PredicateUtils.anyPredicate(), null); @@ -287,8 +287,8 @@ public void testAnyPredicateEx1() { assertThrows(NullPointerException.class, () -> PredicateUtils.anyPredicate((Predicate[]) null)); } - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("unchecked") public void testAnyPredicateEx2() { assertThrows(NullPointerException.class, () -> PredicateUtils.anyPredicate(new Predicate[] {null})); } @@ -335,8 +335,8 @@ public void testEitherPredicateEx() { // onePredicate //------------------------------------------------------------------ - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("unchecked") public void testOnePredicate() { assertPredicateFalse(PredicateUtils.onePredicate((Predicate[]) new Predicate[] {}), null); assertFalse(PredicateUtils.onePredicate(truePredicate(), truePredicate(), truePredicate()).evaluate(null)); @@ -380,8 +380,8 @@ public void testOnePredicateEx1() { assertThrows(NullPointerException.class, () -> PredicateUtils.onePredicate((Predicate[]) null)); } - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("unchecked") public void testOnePredicateEx2() { assertThrows(NullPointerException.class, () -> PredicateUtils.onePredicate(new Predicate[] {null})); } @@ -396,8 +396,8 @@ public void testOnePredicateEx4() { assertThrows(NullPointerException.class, () -> PredicateUtils.onePredicate((Collection>) null)); } - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("unchecked") public void testOnePredicateEx5() { PredicateUtils.onePredicate(Collections.EMPTY_LIST); } @@ -426,8 +426,8 @@ public void testNeitherPredicateEx() { // nonePredicate //------------------------------------------------------------------ - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("unchecked") public void testNonePredicate() { assertPredicateTrue(PredicateUtils.nonePredicate(), null); assertFalse(PredicateUtils.nonePredicate(truePredicate(), truePredicate(), truePredicate()).evaluate(null)); @@ -469,14 +469,14 @@ public void testNonePredicateEx1() { assertThrows(NullPointerException.class, () -> PredicateUtils.nonePredicate((Predicate[]) null)); } - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("unchecked") public void testNonePredicateEx2() { assertThrows(NullPointerException.class, () -> PredicateUtils.nonePredicate(new Predicate[] {null})); } - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("unchecked") public void testNonePredicateEx3() { assertThrows(NullPointerException.class, () -> PredicateUtils.nonePredicate(null, null)); } diff --git a/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java b/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java index b6cd0adaa5..cc49c98f06 100644 --- a/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java @@ -32,6 +32,7 @@ import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.collection.AbstractCollectionTest; import org.apache.commons.collections4.set.AbstractSetTest; +import org.junit.Test; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -130,6 +131,7 @@ public Bag getCollection() { return (Bag) super.getCollection(); } + @Test @SuppressWarnings("unchecked") public void testBagAdd() { if (!isAddSupported()) { @@ -148,6 +150,7 @@ public void testBagAdd() { assertTrue(bag.contains("B")); } + @Test @SuppressWarnings("unchecked") public void testBagEqualsSelf() { final Bag bag = makeObject(); @@ -165,6 +168,7 @@ public void testBagEqualsSelf() { assertEquals(bag, bag); } + @Test @SuppressWarnings("unchecked") public void testBagRemove() { if (!isRemoveSupported()) { @@ -189,6 +193,7 @@ public void testBagRemove() { assertEquals("Should have count of 0", 0, bag.getCount("A")); } + @Test @SuppressWarnings("unchecked") public void testBagRemoveAll() { if (!isRemoveSupported()) { @@ -211,6 +216,7 @@ public void testBagRemoveAll() { assertEquals("Should have count of 2", 2, bag.size()); } + @Test @SuppressWarnings("unchecked") public void testBagContains() { if (!isAddSupported()) { @@ -235,6 +241,7 @@ public void testBagContains() { assertTrue("Bag has at least 1 'B'", bag.contains("B")); } + @Test @SuppressWarnings("unchecked") public void testBagContainsAll() { if (!isAddSupported()) { @@ -289,6 +296,7 @@ public void testBagContainsAll() { assertTrue("Bag containsAll of 1 'A' 1 'B'", bag.containsAll(known1A1B)); } + @Test @SuppressWarnings("unchecked") public void testBagSize() { if (!isAddSupported()) { @@ -314,6 +322,7 @@ public void testBagSize() { assertEquals("Should have 1 total item", 1, bag.size()); } + @Test @SuppressWarnings("unchecked") public void testBagRetainAll() { if (!isAddSupported()) { @@ -334,6 +343,7 @@ public void testBagRetainAll() { assertEquals("Should have 2 total items", 2, bag.size()); } + @Test @SuppressWarnings("unchecked") public void testBagIterator() { if (!isAddSupported()) { @@ -365,6 +375,7 @@ public void testBagIterator() { assertEquals("Bag should have 1 'A'", 1, bag.getCount("A")); } + @Test @SuppressWarnings("unchecked") public void testBagIteratorFail() { if (!isAddSupported()) { @@ -382,6 +393,7 @@ public void testBagIteratorFail() { assertThrows(ConcurrentModificationException.class, () -> it.next()); } + @Test @SuppressWarnings("unchecked") public void testBagIteratorFailNoMore() { if (!isAddSupported()) { @@ -400,6 +412,7 @@ public void testBagIteratorFailNoMore() { assertThrows(NoSuchElementException.class, () -> it.next()); } + @Test @SuppressWarnings("unchecked") public void testBagIteratorFailDoubleRemove() { if (!isAddSupported()) { @@ -425,6 +438,7 @@ public void testBagIteratorFailDoubleRemove() { assertEquals(1, bag.size()); } + @Test @SuppressWarnings("unchecked") public void testBagIteratorRemoveProtectsInvariants() { if (!isAddSupported()) { @@ -451,6 +465,7 @@ public void testBagIteratorRemoveProtectsInvariants() { assertFalse(it2.hasNext()); } + @Test @SuppressWarnings("unchecked") public void testBagToArray() { if (!isAddSupported()) { @@ -475,6 +490,7 @@ public void testBagToArray() { assertEquals(1, c); } + @Test @SuppressWarnings("unchecked") public void testBagToArrayPopulate() { if (!isAddSupported()) { @@ -499,6 +515,7 @@ public void testBagToArrayPopulate() { assertEquals(1, c); } + @Test @SuppressWarnings("unchecked") public void testBagEquals() { if (!isAddSupported()) { @@ -523,6 +540,7 @@ public void testBagEquals() { assertEquals(bag, bag2); } + @Test @SuppressWarnings("unchecked") public void testBagEqualsHashBag() { if (!isAddSupported()) { @@ -547,6 +565,7 @@ public void testBagEqualsHashBag() { assertEquals(bag, bag2); } + @Test @SuppressWarnings("unchecked") public void testBagHashCode() { if (!isAddSupported()) { @@ -661,6 +680,7 @@ public void verify() { * Compare the current serialized form of the Bag * against the canonical version in SCM. */ + @Test public void testEmptyBagCompatibility() throws IOException, ClassNotFoundException { // test to make sure the canonical form has been preserved final Bag bag = makeObject(); @@ -675,6 +695,7 @@ public void testEmptyBagCompatibility() throws IOException, ClassNotFoundExcepti * Compare the current serialized form of the Bag * against the canonical version in SCM. */ + @Test public void testFullBagCompatibility() throws IOException, ClassNotFoundException { // test to make sure the canonical form has been preserved final Bag bag = makeFullCollection(); diff --git a/src/test/java/org/apache/commons/collections4/bag/CollectionBagTest.java b/src/test/java/org/apache/commons/collections4/bag/CollectionBagTest.java index da3c7d7339..24015a9b1f 100644 --- a/src/test/java/org/apache/commons/collections4/bag/CollectionBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/CollectionBagTest.java @@ -24,6 +24,7 @@ import org.apache.commons.collections4.Bag; import org.apache.commons.collections4.collection.AbstractCollectionTest; +import org.junit.Test; /** * Test class for {@link CollectionBag}. @@ -89,6 +90,7 @@ public String getCompatibilityVersion() { * Compares the current serialized form of the Bag * against the canonical version in SCM. */ + @Test public void testEmptyBagCompatibility() throws IOException, ClassNotFoundException { // test to make sure the canonical form has been preserved final Bag bag = makeObject(); @@ -103,6 +105,7 @@ public void testEmptyBagCompatibility() throws IOException, ClassNotFoundExcepti * Compares the current serialized form of the Bag * against the canonical version in SCM. */ + @Test public void testFullBagCompatibility() throws IOException, ClassNotFoundException { // test to make sure the canonical form has been preserved final Bag bag = (Bag) makeFullCollection(); diff --git a/src/test/java/org/apache/commons/collections4/bag/CollectionSortedBagTest.java b/src/test/java/org/apache/commons/collections4/bag/CollectionSortedBagTest.java index 9c093108d3..eda4d1fc27 100644 --- a/src/test/java/org/apache/commons/collections4/bag/CollectionSortedBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/CollectionSortedBagTest.java @@ -25,6 +25,7 @@ import org.apache.commons.collections4.Bag; import org.apache.commons.collections4.SortedBag; import org.apache.commons.collections4.collection.AbstractCollectionTest; +import org.junit.Test; /** * Test class for {@link CollectionSortedBag}. @@ -127,6 +128,7 @@ public String getCompatibilityVersion() { * Compare the current serialized form of the Bag * against the canonical version in SCM. */ + @Test public void testEmptyBagCompatibility() throws IOException, ClassNotFoundException { // test to make sure the canonical form has been preserved final Bag bag = makeObject(); @@ -141,6 +143,7 @@ public void testEmptyBagCompatibility() throws IOException, ClassNotFoundExcepti * Compare the current serialized form of the Bag * against the canonical version in SCM. */ + @Test public void testFullBagCompatibility() throws IOException, ClassNotFoundException { // test to make sure the canonical form has been preserved final SortedBag bag = (SortedBag) makeFullCollection(); diff --git a/src/test/java/org/apache/commons/collections4/bag/HashBagTest.java b/src/test/java/org/apache/commons/collections4/bag/HashBagTest.java index 654195e4b6..9a19b482fb 100644 --- a/src/test/java/org/apache/commons/collections4/bag/HashBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/HashBagTest.java @@ -16,8 +16,6 @@ */ package org.apache.commons.collections4.bag; -import junit.framework.Test; - import org.apache.commons.collections4.Bag; import org.apache.commons.collections4.BulkTest; @@ -32,7 +30,7 @@ public HashBagTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(HashBagTest.class); } diff --git a/src/test/java/org/apache/commons/collections4/bag/PredicatedBagTest.java b/src/test/java/org/apache/commons/collections4/bag/PredicatedBagTest.java index 9f97050e0c..e185b1305f 100644 --- a/src/test/java/org/apache/commons/collections4/bag/PredicatedBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/PredicatedBagTest.java @@ -20,12 +20,11 @@ import java.util.Set; -import junit.framework.Test; - import org.apache.commons.collections4.Bag; import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.Predicate; import org.apache.commons.collections4.functors.TruePredicate; +import org.junit.Test; /** * Extension of {@link AbstractBagTest} for exercising the {@link PredicatedBag} @@ -39,7 +38,7 @@ public PredicatedBagTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(PredicatedBagTest.class); } @@ -66,6 +65,7 @@ protected Bag makeTestBag() { //-------------------------------------------------------------------------- + @Test @SuppressWarnings("unchecked") public void testlegalAddRemove() { final Bag bag = makeTestBag(); @@ -83,6 +83,7 @@ public void testlegalAddRemove() { assertFalse("Unique set now does not contain the first element", set.contains(els[0])); } + @Test @SuppressWarnings("unchecked") public void testIllegalAdd() { final Bag bag = makeTestBag(); @@ -93,6 +94,7 @@ public void testIllegalAdd() { assertFalse("Collection shouldn't contain illegal element", bag.contains(i)); } + @Test @SuppressWarnings("unchecked") public void testIllegalDecorate() { final HashBag elements = new HashBag<>(); diff --git a/src/test/java/org/apache/commons/collections4/bag/PredicatedSortedBagTest.java b/src/test/java/org/apache/commons/collections4/bag/PredicatedSortedBagTest.java index 1e409743a1..5850592ca4 100644 --- a/src/test/java/org/apache/commons/collections4/bag/PredicatedSortedBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/PredicatedSortedBagTest.java @@ -20,12 +20,11 @@ import java.util.Comparator; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.Predicate; import org.apache.commons.collections4.SortedBag; import org.apache.commons.collections4.functors.TruePredicate; +import org.junit.Test; /** * Extension of {@link AbstractSortedBagTest} for exercising the {@link PredicatedSortedBag} @@ -41,7 +40,7 @@ public PredicatedSortedBagTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(PredicatedSortedBagTest.class); } @@ -68,6 +67,7 @@ protected SortedBag makeTestBag() { //-------------------------------------------------------------------------- + @Test public void testDecorate() { final SortedBag bag = decorateBag(new TreeBag(), stringPredicate()); ((PredicatedSortedBag) bag).decorated(); @@ -77,6 +77,7 @@ public void testDecorate() { assertThrows(NullPointerException.class, () -> decorateBag(nullBag, stringPredicate())); } + @Test @SuppressWarnings("unchecked") public void testSortOrder() { final SortedBag bag = decorateBag(new TreeBag(), stringPredicate()); diff --git a/src/test/java/org/apache/commons/collections4/bag/SynchronizedBagTest.java b/src/test/java/org/apache/commons/collections4/bag/SynchronizedBagTest.java index 2edd08c851..d45cef5f8b 100644 --- a/src/test/java/org/apache/commons/collections4/bag/SynchronizedBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/SynchronizedBagTest.java @@ -16,8 +16,6 @@ */ package org.apache.commons.collections4.bag; -import junit.framework.Test; - import org.apache.commons.collections4.Bag; import org.apache.commons.collections4.BulkTest; @@ -33,7 +31,7 @@ public SynchronizedBagTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(SynchronizedBagTest.class); } diff --git a/src/test/java/org/apache/commons/collections4/bag/TransformedBagTest.java b/src/test/java/org/apache/commons/collections4/bag/TransformedBagTest.java index d5faf86907..f21c600007 100644 --- a/src/test/java/org/apache/commons/collections4/bag/TransformedBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/TransformedBagTest.java @@ -16,12 +16,11 @@ */ package org.apache.commons.collections4.bag; -import junit.framework.Test; - import org.apache.commons.collections4.Bag; import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.Transformer; import org.apache.commons.collections4.collection.TransformedCollectionTest; +import org.junit.Test; /** * Extension of {@link AbstractBagTest} for exercising the {@link TransformedBag} @@ -35,7 +34,7 @@ public TransformedBagTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(TransformedBagTest.class); } @@ -47,6 +46,7 @@ public Bag makeObject() { (Transformer) TransformedCollectionTest.NOOP_TRANSFORMER); } + @Test @SuppressWarnings("unchecked") public void testTransformedBag() { //T had better be Object! @@ -65,6 +65,7 @@ public void testTransformedBag() { assertTrue(bag.remove(Integer.valueOf((String) els[0]))); } + @Test @SuppressWarnings("unchecked") public void testTransformedBag_decorateTransform() { final Bag originalBag = new HashBag<>(); diff --git a/src/test/java/org/apache/commons/collections4/bag/TransformedSortedBagTest.java b/src/test/java/org/apache/commons/collections4/bag/TransformedSortedBagTest.java index e1f076965a..736938019a 100644 --- a/src/test/java/org/apache/commons/collections4/bag/TransformedSortedBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/TransformedSortedBagTest.java @@ -16,12 +16,11 @@ */ package org.apache.commons.collections4.bag; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.SortedBag; import org.apache.commons.collections4.Transformer; import org.apache.commons.collections4.collection.TransformedCollectionTest; +import org.junit.Test; /** * Extension of {@link AbstractSortedBagTest} for exercising the {@link TransformedSortedBag} @@ -35,7 +34,7 @@ public TransformedSortedBagTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(TransformedSortedBagTest.class); } @@ -46,6 +45,7 @@ public SortedBag makeObject() { return TransformedSortedBag.transformingSortedBag(new TreeBag(), (Transformer) TransformedCollectionTest.NOOP_TRANSFORMER); } + @Test @SuppressWarnings("unchecked") public void testTransformedBag() { final SortedBag bag = TransformedSortedBag.transformingSortedBag(new TreeBag(), (Transformer) TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER); @@ -61,6 +61,7 @@ public void testTransformedBag() { } + @Test public void testTransformedBag_decorateTransform() { final TreeBag originalBag = new TreeBag<>(); final Object[] els = {"1", "3", "5", "7", "2", "4", "6"}; diff --git a/src/test/java/org/apache/commons/collections4/bag/TreeBagTest.java b/src/test/java/org/apache/commons/collections4/bag/TreeBagTest.java index 297444f3d8..643aafcc6a 100644 --- a/src/test/java/org/apache/commons/collections4/bag/TreeBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/TreeBagTest.java @@ -18,11 +18,10 @@ import static org.junit.jupiter.api.Assertions.assertThrows; -import junit.framework.Test; - import org.apache.commons.collections4.Bag; import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.SortedBag; +import org.junit.Test; /** * Extension of {@link AbstractBagTest} for exercising the {@link TreeBag} @@ -34,7 +33,7 @@ public TreeBagTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(TreeBagTest.class); } @@ -53,12 +52,14 @@ public SortedBag setupBag() { return bag; } + @Test public void testCollections265() { final Bag bag = new TreeBag<>(); assertThrows(IllegalArgumentException.class, () -> bag.add(new Object())); } + @Test public void testCollections555() { final Bag bag = new TreeBag<>(); @@ -72,6 +73,7 @@ public void testCollections555() { assertThrows(NullPointerException.class, () -> bag2.add(null)); } + @Test public void testOrdering() { final Bag bag = setupBag(); assertEquals("Should get elements in correct order", "A", bag.toArray()[0]); 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 d86f22abb1..fb30567bb3 100644 --- a/src/test/java/org/apache/commons/collections4/bag/UnmodifiableBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/UnmodifiableBagTest.java @@ -20,12 +20,11 @@ import java.util.Arrays; -import junit.framework.Test; - import org.apache.commons.collections4.Bag; import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.Unmodifiable; import org.apache.commons.collections4.collection.AbstractCollectionTest; +import org.junit.Test; /** * Extension of {@link AbstractCollectionTest} for exercising the @@ -39,7 +38,7 @@ public UnmodifiableBagTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(UnmodifiableBagTest.class); } @@ -75,11 +74,13 @@ public boolean isNullSupported() { return false; } + @Test public void testUnmodifiable() { assertTrue(makeObject() instanceof Unmodifiable); assertTrue(makeFullCollection() instanceof Unmodifiable); } + @Test public void testDecorateFactory() { final Bag queue = makeFullCollection(); assertSame(queue, UnmodifiableBag.unmodifiableBag(queue)); 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 ae509f1c15..aa2006f97e 100644 --- a/src/test/java/org/apache/commons/collections4/bag/UnmodifiableSortedBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/UnmodifiableSortedBagTest.java @@ -20,12 +20,11 @@ import java.util.Arrays; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.SortedBag; import org.apache.commons.collections4.Unmodifiable; import org.apache.commons.collections4.collection.AbstractCollectionTest; +import org.junit.Test; /** * Extension of {@link AbstractCollectionTest} for exercising the @@ -39,7 +38,7 @@ public UnmodifiableSortedBagTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(UnmodifiableSortedBagTest.class); } @@ -75,11 +74,13 @@ public boolean isNullSupported() { return false; } + @Test public void testUnmodifiable() { assertTrue(makeObject() instanceof Unmodifiable); assertTrue(makeFullCollection() instanceof Unmodifiable); } + @Test public void testDecorateFactory() { final SortedBag queue = makeFullCollection(); assertSame(queue, UnmodifiableSortedBag.unmodifiableSortedBag(queue)); 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 ce803b070b..81dc707a96 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/AbstractBidiMapTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/AbstractBidiMapTest.java @@ -29,6 +29,7 @@ import org.apache.commons.collections4.MapIterator; import org.apache.commons.collections4.iterators.AbstractMapIteratorTest; import org.apache.commons.collections4.map.AbstractIterableMapTest; +import org.junit.Test; /** * Abstract test class for {@link BidiMap} methods and contracts. @@ -76,6 +77,7 @@ public String getCompatibilityVersion() { } // BidiPut + @Test @SuppressWarnings("unchecked") public void testBidiPut() { if (!isPutAddSupported() || !isPutChangeSupported()) { @@ -138,10 +140,12 @@ public void verifyInverse() { } // testGetKey + @Test public void testBidiGetKey() { doTestGetKey(makeFullMap(), getSampleKeys()[0], getSampleValues()[0]); } + @Test public void testBidiGetKeyInverse() { doTestGetKey( makeFullMap().inverseBidiMap(), @@ -155,6 +159,7 @@ private void doTestGetKey(final BidiMap map, final Object key, final Objec } // testInverse + @Test public void testBidiInverse() { final BidiMap map = makeFullMap(); final BidiMap inverseMap = map.inverseBidiMap(); @@ -175,6 +180,7 @@ public void testBidiInverse() { inverseMap.getKey(getSampleKeys()[0])); } + @Test public void testBidiModifyEntrySet() { if (!isSetValueSupported()) { return; @@ -207,6 +213,7 @@ private void modifyEntrySet(final BidiMap map) { map.getKey(oldValue)); } + @Test public void testBidiClear() { if (!isRemoveSupported()) { assertThrows(UnsupportedOperationException.class, () -> makeFullMap().clear()); @@ -225,6 +232,7 @@ public void testBidiClear() { assertTrue("Inverse map was not cleared.", map.inverseBidiMap().isEmpty()); } + @Test public void testBidiRemove() { if (!isRemoveSupported()) { assertThrows(UnsupportedOperationException.class, () -> makeFullMap().remove(getSampleKeys()[0])); @@ -255,6 +263,7 @@ private void removeValue(final BidiMap map, final Object value) { assertNull("Value was not removed.", map.getKey(value)); } + @Test public void testBidiKeySetValuesOrder() { resetFull(); final Iterator keys = map.keySet().iterator(); @@ -268,6 +277,7 @@ public void testBidiKeySetValuesOrder() { assertFalse(values.hasNext()); } + @Test public void testBidiRemoveByKeySet() { if (!isRemoveSupported()) { return; @@ -287,6 +297,7 @@ private void removeByKeySet(final BidiMap map, final Object key, final Obj assertFalse("Value was not removed from inverse map.", map.inverseBidiMap().containsKey(value)); } + @Test public void testBidiRemoveByEntrySet() { if (!isRemoveSupported()) { return; @@ -326,6 +337,7 @@ public class TestBidiMapEntrySet extends TestMapEntrySet { public TestBidiMapEntrySet() { } + @Test public void testMapEntrySetIteratorEntrySetValueCrossCheck() { final K key1 = getSampleKeys()[0]; final K key2 = getSampleKeys()[1]; @@ -511,6 +523,7 @@ public void verify() { } + @Test public void testBidiMapIteratorSet() { final V newValue1 = getOtherValues()[0]; final V newValue2 = getOtherValues()[1]; diff --git a/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapTest.java b/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapTest.java index 69dfce43ca..e5add82dfa 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapTest.java @@ -29,6 +29,7 @@ import org.apache.commons.collections4.MapIterator; import org.apache.commons.collections4.OrderedBidiMap; import org.apache.commons.collections4.iterators.AbstractMapIteratorTest; +import org.junit.Test; /** * Abstract test class for {@link OrderedBidiMap} methods and contracts. @@ -42,6 +43,7 @@ public AbstractOrderedBidiMapTest(final String testName) { public AbstractOrderedBidiMapTest() { } + @Test public void testFirstKey() { resetEmpty(); OrderedBidiMap bidi = getMap(); @@ -55,6 +57,7 @@ public void testFirstKey() { assertEquals(confirmedFirst, bidi.firstKey()); } + @Test public void testLastKey() { resetEmpty(); OrderedBidiMap bidi = getMap(); @@ -71,6 +74,7 @@ public void testLastKey() { assertEquals(confirmedLast, bidi.lastKey()); } + @Test public void testNextKey() { resetEmpty(); OrderedBidiMap bidi = (OrderedBidiMap) map; @@ -103,6 +107,7 @@ public void testNextKey() { } } + @Test public void testPreviousKey() { resetEmpty(); OrderedBidiMap bidi = getMap(); 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 6532cde757..659381a6a5 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/AbstractSortedBidiMapTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/AbstractSortedBidiMapTest.java @@ -30,6 +30,7 @@ import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.SortedBidiMap; import org.apache.commons.collections4.map.AbstractSortedMapTest; +import org.junit.Test; /** * Abstract test class for {@link SortedBidiMap} methods and contracts. @@ -101,6 +102,7 @@ public SortedMap makeConfirmedMap() { return new TreeMap<>(); } + @Test public void testBidiHeadMapContains() { // extra test as other tests get complex final SortedBidiMap sm = makeFullMap(); @@ -123,6 +125,7 @@ public void testBidiHeadMapContains() { assertFalse(head.containsValue(secondValue)); } + @Test public void testBidiClearByHeadMap() { if (!isRemoveSupported()) { return; @@ -169,6 +172,7 @@ public void testBidiClearByHeadMap() { assertFalse(sub.containsValue(toKeyValue)); } + @Test public void testBidiRemoveByHeadMap() { if (!isRemoveSupported()) { return; @@ -212,6 +216,7 @@ public void testBidiRemoveByHeadMap() { assertFalse(sub.containsValue(secondValue)); } + @Test public void testBidiRemoveByHeadMapEntrySet() { if (!isRemoveSupported()) { return; @@ -265,6 +270,7 @@ public void testBidiRemoveByHeadMapEntrySet() { assertFalse(set.contains(secondEntry)); } + @Test public void testBidiTailMapContains() { // extra test as other tests get complex final SortedBidiMap sm = makeFullMap(); @@ -292,6 +298,7 @@ public void testBidiTailMapContains() { assertTrue(sub.containsValue(secondValue)); } + @Test public void testBidiClearByTailMap() { if (!isRemoveSupported()) { return; @@ -340,6 +347,7 @@ public void testBidiClearByTailMap() { assertFalse(sub.containsValue(secondValue)); } + @Test public void testBidiRemoveByTailMap() { if (!isRemoveSupported()) { return; @@ -384,6 +392,7 @@ public void testBidiRemoveByTailMap() { assertFalse(sub.containsValue(secondValue)); } + @Test public void testBidiRemoveByTailMapEntrySet() { if (!isRemoveSupported()) { return; @@ -437,6 +446,7 @@ public void testBidiRemoveByTailMapEntrySet() { assertFalse(set.contains(secondEntry)); } + @Test public void testBidiSubMapContains() { // extra test as other tests get complex final SortedBidiMap sm = makeFullMap(); @@ -471,6 +481,7 @@ public void testBidiSubMapContains() { assertFalse(sub.containsValue(thirdValue)); } + @Test public void testBidiClearBySubMap() { if (!isRemoveSupported()) { return; @@ -527,6 +538,7 @@ public void testBidiClearBySubMap() { assertFalse(sub.containsValue(toKeyValue)); } + @Test public void testBidiRemoveBySubMap() { if (!isRemoveSupported()) { return; @@ -572,6 +584,7 @@ public void testBidiRemoveBySubMap() { assertFalse(sub.containsValue(secondValue)); } + @Test public void testBidiRemoveBySubMapEntrySet() { if (!isRemoveSupported()) { return; diff --git a/src/test/java/org/apache/commons/collections4/bidimap/DualHashBidiMapTest.java b/src/test/java/org/apache/commons/collections4/bidimap/DualHashBidiMapTest.java index 3a5c16d496..6ba2f2c024 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/DualHashBidiMapTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/DualHashBidiMapTest.java @@ -16,8 +16,6 @@ */ package org.apache.commons.collections4.bidimap; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; /** @@ -25,7 +23,7 @@ */ public class DualHashBidiMapTest extends AbstractBidiMapTest { - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(DualHashBidiMapTest.class); } diff --git a/src/test/java/org/apache/commons/collections4/bidimap/DualLinkedHashBidiMapTest.java b/src/test/java/org/apache/commons/collections4/bidimap/DualLinkedHashBidiMapTest.java index 728eff80d0..454c51e8b2 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/DualLinkedHashBidiMapTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/DualLinkedHashBidiMapTest.java @@ -16,8 +16,6 @@ */ package org.apache.commons.collections4.bidimap; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; /** @@ -26,7 +24,7 @@ */ public class DualLinkedHashBidiMapTest extends AbstractBidiMapTest { - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(DualLinkedHashBidiMapTest.class); } 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 8134d7d9ab..eb45fcb8a5 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap2Test.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap2Test.java @@ -27,12 +27,11 @@ import java.util.List; import java.util.TreeMap; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.SortedBidiMap; import org.apache.commons.collections4.comparators.ComparableComparator; import org.apache.commons.collections4.comparators.ReverseComparator; +import org.junit.Test; /** * JUnit tests. @@ -41,7 +40,7 @@ @SuppressWarnings("boxing") public class DualTreeBidiMap2Test, V extends Comparable> extends AbstractSortedBidiMapTest { - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(DualTreeBidiMap2Test.class); } @@ -61,6 +60,7 @@ public TreeMap makeConfirmedMap() { return new TreeMap<>(new ReverseComparator<>(ComparableComparator.comparableComparator())); } + @Test public void testComparator() { resetEmpty(); final SortedBidiMap bidi = (SortedBidiMap) map; @@ -68,6 +68,7 @@ public void testComparator() { assertTrue(bidi.comparator() instanceof ReverseComparator); } + @Test public void testComparator2() { final DualTreeBidiMap dtbm = new DualTreeBidiMap<>( String.CASE_INSENSITIVE_ORDER, null); @@ -78,6 +79,7 @@ public void testComparator2() { } + @Test public void testSerializeDeserializeCheckComparator() throws Exception { final SortedBidiMap obj = makeObject(); if (obj instanceof Serializable && isTestSerialization()) { @@ -105,6 +107,7 @@ public int compare(final Integer o1, final Integer o2) { } } + @Test public void testCollections364() throws Exception { final DualTreeBidiMap original = new DualTreeBidiMap<>( String.CASE_INSENSITIVE_ORDER, new IntegerComparator()); @@ -124,6 +127,7 @@ public void testCollections364() throws Exception { assertEquals(original.valueComparator().getClass(), deserialized.valueComparator().getClass()); } + @Test public void testSortOrder() throws Exception { final SortedBidiMap sm = makeFullMap(); diff --git a/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMapTest.java b/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMapTest.java index 0f25f86223..9ddbdd4d24 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMapTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMapTest.java @@ -16,8 +16,6 @@ */ package org.apache.commons.collections4.bidimap; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; /** @@ -26,7 +24,7 @@ */ public class DualTreeBidiMapTest, V extends Comparable> extends AbstractSortedBidiMapTest { - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(DualTreeBidiMapTest.class); } diff --git a/src/test/java/org/apache/commons/collections4/bidimap/TreeBidiMapTest.java b/src/test/java/org/apache/commons/collections4/bidimap/TreeBidiMapTest.java index a0bf32c0c5..b5387a3b60 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/TreeBidiMapTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/TreeBidiMapTest.java @@ -18,7 +18,6 @@ import java.util.TreeMap; -import junit.framework.Test; import org.apache.commons.collections4.BidiMap; import org.apache.commons.collections4.BulkTest; @@ -28,7 +27,7 @@ */ public class TreeBidiMapTest, V extends Comparable> extends AbstractOrderedBidiMapTest { - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(TreeBidiMapTest.class); } 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 8ecd7e9031..3cec392580 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableBidiMapTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableBidiMapTest.java @@ -21,18 +21,17 @@ import java.util.HashMap; import java.util.Map; -import junit.framework.Test; - import org.apache.commons.collections4.BidiMap; import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.Unmodifiable; +import org.junit.Test; /** * JUnit tests. */ public class UnmodifiableBidiMapTest extends AbstractBidiMapTest { - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(UnmodifiableBidiMapTest.class); } @@ -80,11 +79,13 @@ public boolean isRemoveSupported() { return false; } + @Test public void testUnmodifiable() { assertTrue(makeObject() instanceof Unmodifiable); assertTrue(makeFullMap() instanceof Unmodifiable); } + @Test public void testDecorateFactory() { final BidiMap map = makeFullMap(); assertSame(map, UnmodifiableBidiMap.unmodifiableBidiMap(map)); 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 1401469150..79f7ec92a8 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableOrderedBidiMapTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableOrderedBidiMapTest.java @@ -21,18 +21,17 @@ import java.util.Map; import java.util.TreeMap; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.OrderedBidiMap; import org.apache.commons.collections4.Unmodifiable; +import org.junit.Test; /** * JUnit tests. */ public class UnmodifiableOrderedBidiMapTest, V extends Comparable> extends AbstractOrderedBidiMapTest { - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(UnmodifiableOrderedBidiMapTest.class); } @@ -90,11 +89,13 @@ public boolean isRemoveSupported() { return false; } + @Test public void testUnmodifiable() { assertTrue(makeObject() instanceof Unmodifiable); assertTrue(makeFullMap() instanceof Unmodifiable); } + @Test public void testDecorateFactory() { final OrderedBidiMap map = makeFullMap(); assertSame(map, UnmodifiableOrderedBidiMap.unmodifiableOrderedBidiMap(map)); 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 1f411f420b..ba529141d9 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableSortedBidiMapTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableSortedBidiMapTest.java @@ -21,18 +21,17 @@ import java.util.SortedMap; import java.util.TreeMap; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.SortedBidiMap; import org.apache.commons.collections4.Unmodifiable; +import org.junit.Test; /** * JUnit tests. */ public class UnmodifiableSortedBidiMapTest, V extends Comparable> extends AbstractSortedBidiMapTest { - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(UnmodifiableSortedBidiMapTest.class); } @@ -94,11 +93,13 @@ public boolean isRemoveSupported() { return false; } + @Test public void testUnmodifiable() { assertTrue(makeObject() instanceof Unmodifiable); assertTrue(makeFullMap() instanceof Unmodifiable); } + @Test public void testDecorateFactory() { final SortedBidiMap map = makeFullMap(); assertSame(map, UnmodifiableSortedBidiMap.unmodifiableSortedBidiMap(map)); diff --git a/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java b/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java index fa969bb992..e742302cdc 100644 --- a/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java +++ b/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java @@ -39,6 +39,7 @@ import java.util.function.Predicate; import org.apache.commons.collections4.AbstractObjectTest; +import org.junit.Test; /** * Abstract test class for {@link java.util.Collection} methods and contracts. @@ -490,6 +491,7 @@ public Object[] getOtherNonNullStringElements() { /** * Tests {@link Collection#add(Object)}. */ + @Test public void testCollectionAdd() { if (!isAddSupported()) { return; @@ -522,6 +524,7 @@ public void testCollectionAdd() { /** * Tests {@link Collection#addAll(Collection)}. */ + @Test public void testCollectionAddAll() { if (!isAddSupported()) { return; @@ -566,6 +569,7 @@ public void testCollectionAddAll() { * If {@link #isAddSupported()} returns false, tests that add operations * raise UnsupportedOperationException. */ + @Test public void testUnsupportedAdd() { if (isAddSupported()) { return; @@ -601,6 +605,7 @@ public void testUnsupportedAdd() { /** * Test {@link Collection#clear()}. */ + @Test public void testCollectionClear() { if (!isRemoveSupported()) { return; @@ -619,6 +624,7 @@ public void testCollectionClear() { /** * Tests {@link Collection#contains(Object)}. */ + @Test public void testCollectionContains() { Object[] elements; @@ -656,6 +662,7 @@ public void testCollectionContains() { /** * Tests {@link Collection#containsAll(Collection)}. */ + @Test public void testCollectionContainsAll() { resetEmpty(); Collection col = new HashSet<>(); @@ -699,6 +706,7 @@ public void testCollectionContainsAll() { /** * Tests {@link Collection#isEmpty()}. */ + @Test public void testCollectionIsEmpty() { resetEmpty(); assertTrue("New Collection should be empty.", getCollection().isEmpty()); @@ -714,6 +722,7 @@ public void testCollectionIsEmpty() { /** * Tests the read-only functionality of {@link Collection#iterator()}. */ + @Test public void testCollectionIterator() { resetEmpty(); Iterator it1 = getCollection().iterator(); @@ -750,6 +759,7 @@ public void testCollectionIterator() { /** * Tests removals from {@link Collection#iterator()}. */ + @Test @SuppressWarnings("unchecked") public void testCollectionIteratorRemove() { if (!isRemoveSupported()) { @@ -810,6 +820,7 @@ public void testCollectionIteratorRemove() { /** * Tests {@link Collection#remove(Object)}. */ + @Test public void testCollectionRemove() { if (!isRemoveSupported()) { return; @@ -856,6 +867,7 @@ public void testCollectionRemove() { /** * Tests {@link Collection#removeAll(Collection)}. */ + @Test public void testCollectionRemoveAll() { if (!isRemoveSupported()) { return; @@ -900,6 +912,7 @@ public void testCollectionRemoveAll() { * Tests {@link Collection#removeIf(Predicate)}. * @since 4.4 */ + @Test public void testCollectionRemoveIf() { if (!isRemoveSupported()) { return; @@ -943,6 +956,7 @@ public void testCollectionRemoveIf() { /** * Tests {@link Collection#retainAll(Collection)}. */ + @Test public void testCollectionRetainAll() { if (!isRemoveSupported()) { return; @@ -1003,6 +1017,7 @@ public void testCollectionRetainAll() { /** * Tests {@link Collection#size()}. */ + @Test public void testCollectionSize() { resetEmpty(); assertEquals("Size of new Collection is 0.", 0, getCollection().size()); @@ -1014,6 +1029,7 @@ public void testCollectionSize() { /** * Tests {@link Collection#toArray()}. */ + @Test public void testCollectionToArray() { resetEmpty(); assertEquals("Empty Collection should return empty array for toArray", @@ -1058,6 +1074,7 @@ public void testCollectionToArray() { /** * Tests {@link Collection#toArray(Object[])}. */ + @Test public void testCollectionToArray2() { resetEmpty(); Object[] a = { new Object(), null, null }; @@ -1108,6 +1125,7 @@ public void testCollectionToArray2() { /** * Tests {@code toString} on a collection. */ + @Test public void testCollectionToString() { resetEmpty(); assertNotNull("toString shouldn't return null", getCollection().toString()); @@ -1120,6 +1138,7 @@ public void testCollectionToString() { * If isRemoveSupported() returns false, tests to see that remove * operations raise an UnsupportedOperationException. */ + @Test public void testUnsupportedRemove() { if (isRemoveSupported()) { return; @@ -1158,6 +1177,7 @@ public void testUnsupportedRemove() { /** * Tests that the collection's iterator is fail-fast. */ + @Test public void testCollectionIteratorFailFast() { if (!isFailFastSupported()) { return; @@ -1224,6 +1244,7 @@ public void testCollectionIteratorFailFast() { "next after retainAll should raise ConcurrentModification"); } + @Test @Override public void testSerializeDeserializeThenCompare() throws Exception { Object obj = makeObject(); diff --git a/src/test/java/org/apache/commons/collections4/collection/CompositeCollectionTest.java b/src/test/java/org/apache/commons/collections4/collection/CompositeCollectionTest.java index 91f9ad6bec..e469b8d78c 100644 --- a/src/test/java/org/apache/commons/collections4/collection/CompositeCollectionTest.java +++ b/src/test/java/org/apache/commons/collections4/collection/CompositeCollectionTest.java @@ -27,6 +27,7 @@ import java.util.function.Predicate; import org.junit.jupiter.api.Assertions; +import org.junit.Test; /** * Extension of {@link AbstractCollectionTest} for exercising the @@ -146,6 +147,7 @@ protected void setUpTest() { two = new HashSet<>(); } + @Test @SuppressWarnings({ "unchecked", "serial" }) public void testAddAllMutator() { setUpTest(); @@ -182,6 +184,7 @@ public boolean remove(final CompositeCollection composite, assertTrue(one.contains("foo")); } + @Test @SuppressWarnings("unchecked") public void testAddAllToCollection() { setUpTest(); @@ -193,6 +196,7 @@ public void testAddAllToCollection() { assertEquals(c.size(), toCollection.size()); } + @Test @SuppressWarnings({ "unchecked", "serial" }) public void testAddMutator() { setUpTest(); @@ -228,7 +232,7 @@ public boolean remove(final CompositeCollection composite, assertTrue(one.contains("foo")); } - + @Test @SuppressWarnings("unchecked") public void testClear() { setUpTest(); @@ -241,6 +245,7 @@ public void testClear() { assertTrue(c.isEmpty()); } + @Test @SuppressWarnings("unchecked") public void testContainsAll() { setUpTest(); @@ -251,6 +256,7 @@ public void testContainsAll() { assertFalse(c.containsAll(null)); } + @Test public void testAddNullList() { final ArrayList nullList = null; final CompositeCollection cc = new CompositeCollection<>(); @@ -258,6 +264,7 @@ public void testAddNullList() { Assertions.assertEquals(0, cc.size()); } + @Test public void testAddNullLists2Args() { final ArrayList nullList = null; final CompositeCollection cc = new CompositeCollection<>(); @@ -265,6 +272,7 @@ public void testAddNullLists2Args() { Assertions.assertEquals(0, cc.size()); } + @Test public void testAddNullListsVarArgs() { final ArrayList nullList = null; final CompositeCollection cc = new CompositeCollection<>(); @@ -272,6 +280,7 @@ public void testAddNullListsVarArgs() { Assertions.assertEquals(0, cc.size()); } + @Test @SuppressWarnings("unchecked") public void testIsEmpty() { setUpTest(); @@ -283,6 +292,7 @@ public void testIsEmpty() { assertFalse(c.isEmpty()); } + @Test @SuppressWarnings("unchecked") public void testIterator() { setUpTest(); @@ -300,6 +310,7 @@ public void testIterator() { assertFalse(two.contains(next)); } + @Test @SuppressWarnings("unchecked") public void testMultipleCollectionsSize() { setUpTest(); @@ -313,6 +324,7 @@ public void testMultipleCollectionsSize() { assertEquals(set.size() + other.size(), c.size()); } + @Test @SuppressWarnings("unchecked") public void testRemove() { setUpMutatorTest(); @@ -326,6 +338,7 @@ public void testRemove() { assertFalse(two.contains("1")); } + @Test @SuppressWarnings("unchecked") public void testRemoveAll() { setUpMutatorTest(); @@ -348,6 +361,7 @@ public void testRemoveAll() { /** * @since 4.4 */ + @Test @SuppressWarnings("unchecked") public void testRemoveIf() { setUpMutatorTest(); @@ -367,6 +381,7 @@ public void testRemoveIf() { assertFalse(two.contains("1")); } + @Test @SuppressWarnings("unchecked") public void testRemoveComposited() { setUpMutatorTest(); @@ -379,6 +394,7 @@ public void testRemoveComposited() { assertEquals(2, c.size()); } + @Test @SuppressWarnings("unchecked") public void testRetainAll() { setUpTest(); @@ -398,6 +414,7 @@ public void testRetainAll() { assertTrue(one.contains("1")); } + @Test @SuppressWarnings("unchecked") public void testSize() { setUpTest(); @@ -408,6 +425,7 @@ public void testSize() { assertEquals(set.size(), c.size()); } + @Test @SuppressWarnings("unchecked") public void testToCollection() { setUpTest(); @@ -425,6 +443,7 @@ public void testToCollection() { * Override testUnsupportedRemove, since the default impl expects removeAll, * retainAll and iterator().remove to throw */ + @Test @Override public void testUnsupportedRemove() { resetFull(); 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 50aa1c7a9a..1e5985edcc 100644 --- a/src/test/java/org/apache/commons/collections4/collection/IndexedCollectionTest.java +++ b/src/test/java/org/apache/commons/collections4/collection/IndexedCollectionTest.java @@ -25,6 +25,7 @@ import java.util.Collection; import org.apache.commons.collections4.Transformer; +import org.junit.Test; /** * Extension of {@link AbstractCollectionTest} for exercising the @@ -104,6 +105,7 @@ protected boolean skipSerializedCanonicalTests() { //------------------------------------------------------------------------ + @Test public void testAddedObjectsCanBeRetrievedByKey() throws Exception { final Collection coll = makeTestCollection(); coll.add("12"); @@ -121,6 +123,7 @@ public void testAddedObjectsCanBeRetrievedByKey() throws Exception { assertEquals("4", indexed.get(4)); } + @Test public void testEnsureDuplicateObjectsCauseException() throws Exception { final Collection coll = makeUniqueTestCollection(); @@ -129,6 +132,7 @@ public void testEnsureDuplicateObjectsCauseException() throws Exception { assertThrows(IllegalArgumentException.class, () -> coll.add("1")); } + @Test public void testDecoratedCollectionIsIndexedOnCreation() throws Exception { final Collection original = makeFullCollection(); final IndexedCollection indexed = decorateUniqueCollection(original); @@ -138,6 +142,7 @@ public void testDecoratedCollectionIsIndexedOnCreation() throws Exception { assertEquals("3", indexed.get(3)); } + @Test public void testReindexUpdatesIndexWhenDecoratedCollectionIsModifiedSeparately() throws Exception { final Collection original = new ArrayList<>(); final IndexedCollection indexed = decorateUniqueCollection(original); diff --git a/src/test/java/org/apache/commons/collections4/collection/PredicatedCollectionTest.java b/src/test/java/org/apache/commons/collections4/collection/PredicatedCollectionTest.java index c344bcb4b2..ba9bbee429 100644 --- a/src/test/java/org/apache/commons/collections4/collection/PredicatedCollectionTest.java +++ b/src/test/java/org/apache/commons/collections4/collection/PredicatedCollectionTest.java @@ -25,6 +25,7 @@ import org.apache.commons.collections4.Predicate; import org.apache.commons.collections4.functors.TruePredicate; +import org.junit.Test; /** * Extension of {@link AbstractCollectionTest} for exercising the @@ -80,6 +81,7 @@ public Collection makeTestCollection() { return decorateCollection(new ArrayList(), testPredicate); } + @Test @SuppressWarnings("unchecked") public void testIllegalAdd() { final Collection c = makeTestCollection(); @@ -90,6 +92,7 @@ public void testIllegalAdd() { assertFalse("Collection shouldn't contain illegal element", c.contains(i)); } + @Test @SuppressWarnings("unchecked") public void testIllegalAddAll() { final Collection c = makeTestCollection(); diff --git a/src/test/java/org/apache/commons/collections4/collection/TransformedCollectionTest.java b/src/test/java/org/apache/commons/collections4/collection/TransformedCollectionTest.java index 757af8ccb1..e623830e4f 100644 --- a/src/test/java/org/apache/commons/collections4/collection/TransformedCollectionTest.java +++ b/src/test/java/org/apache/commons/collections4/collection/TransformedCollectionTest.java @@ -24,6 +24,7 @@ import org.apache.commons.collections4.Transformer; import org.apache.commons.collections4.TransformerUtils; +import org.junit.Test; /** * Extension of {@link AbstractCollectionTest} for exercising the {@link TransformedCollection} @@ -86,6 +87,7 @@ public Object[] getOtherElements() { return new Object[] {"9", "88", "678", "87", "98", "78", "99"}; } + @Test public void testTransformedCollection() { final Collection coll = TransformedCollection.transformingCollection(new ArrayList<>(), STRING_TO_INTEGER_TRANSFORMER); assertEquals(0, coll.size()); @@ -100,6 +102,7 @@ public void testTransformedCollection() { assertTrue(coll.remove(Integer.valueOf((String) elements[0]))); } + @Test public void testTransformedCollection_decorateTransform() { final Collection originalCollection = new ArrayList<>(); final Object[] elements = getFullElements(); 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 868f30e1c2..a4f4974ea7 100644 --- a/src/test/java/org/apache/commons/collections4/collection/UnmodifiableBoundedCollectionTest.java +++ b/src/test/java/org/apache/commons/collections4/collection/UnmodifiableBoundedCollectionTest.java @@ -25,6 +25,7 @@ import org.apache.commons.collections4.BoundedCollection; import org.apache.commons.collections4.Unmodifiable; import org.apache.commons.collections4.list.FixedSizeList; +import org.junit.Test; /** * Extension of {@link AbstractCollectionTest} for exercising the @@ -79,12 +80,13 @@ public String getCompatibilityVersion() { return "4"; } - + @Test public void testUnmodifiable() { assertTrue(makeObject() instanceof Unmodifiable); assertTrue(makeFullCollection() instanceof Unmodifiable); } + @Test public void testDecorateFactory() { final BoundedCollection coll = makeFullCollection(); assertSame(coll, UnmodifiableBoundedCollection.unmodifiableBoundedCollection(coll)); 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 8a7e879031..f9b0dd04ad 100644 --- a/src/test/java/org/apache/commons/collections4/collection/UnmodifiableCollectionTest.java +++ b/src/test/java/org/apache/commons/collections4/collection/UnmodifiableCollectionTest.java @@ -24,6 +24,7 @@ import java.util.List; import org.apache.commons.collections4.Unmodifiable; +import org.junit.Test; /** * Extension of {@link AbstractCollectionTest} for exercising the @@ -68,12 +69,13 @@ public boolean isRemoveSupported() { return false; } - + @Test public void testUnmodifiable() { assertTrue(makeObject() instanceof Unmodifiable); assertTrue(makeFullCollection() instanceof Unmodifiable); } + @Test public void testDecorateFactory() { final Collection coll = makeFullCollection(); assertSame(coll, UnmodifiableCollection.unmodifiableCollection(coll)); diff --git a/src/test/java/org/apache/commons/collections4/comparators/AbstractComparatorTest.java b/src/test/java/org/apache/commons/collections4/comparators/AbstractComparatorTest.java index 3ddc0e7e7c..5017e060f3 100644 --- a/src/test/java/org/apache/commons/collections4/comparators/AbstractComparatorTest.java +++ b/src/test/java/org/apache/commons/collections4/comparators/AbstractComparatorTest.java @@ -175,8 +175,8 @@ public String getCanonicalComparatorName(final Object object) { * Compare the current serialized form of the Comparator * against the canonical version in SCM. */ - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("unchecked") public void testComparatorCompatibility() throws IOException, ClassNotFoundException { if (!skipSerializedCanonicalTests()) { Comparator comparator = null; diff --git a/src/test/java/org/apache/commons/collections4/comparators/AbstractNullComparatorTest.java b/src/test/java/org/apache/commons/collections4/comparators/AbstractNullComparatorTest.java index 1b1478d713..07014a7e7d 100644 --- a/src/test/java/org/apache/commons/collections4/comparators/AbstractNullComparatorTest.java +++ b/src/test/java/org/apache/commons/collections4/comparators/AbstractNullComparatorTest.java @@ -20,7 +20,6 @@ import java.util.LinkedList; import java.util.List; -import junit.framework.Test; import junit.framework.TestSuite; /** @@ -33,7 +32,7 @@ public AbstractNullComparatorTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { final TestSuite suite = new TestSuite(AbstractNullComparatorTest.class.getName()); suite.addTest(new TestSuite(TestNullComparator1.class)); suite.addTest(new TestSuite(TestNullComparator2.class)); diff --git a/src/test/java/org/apache/commons/collections4/comparators/BooleanComparatorTest.java b/src/test/java/org/apache/commons/collections4/comparators/BooleanComparatorTest.java index 9b4f807d8e..3a637ba27b 100644 --- a/src/test/java/org/apache/commons/collections4/comparators/BooleanComparatorTest.java +++ b/src/test/java/org/apache/commons/collections4/comparators/BooleanComparatorTest.java @@ -74,7 +74,6 @@ public void testConstructors() { } @Test - public void testStaticFactoryMethods() { allTests(false, BooleanComparator.getFalseFirstComparator()); allTests(false, BooleanComparator.booleanComparator(false)); diff --git a/src/test/java/org/apache/commons/collections4/comparators/ReverseComparatorTest.java b/src/test/java/org/apache/commons/collections4/comparators/ReverseComparatorTest.java index f8b2e4f471..c6474a4771 100644 --- a/src/test/java/org/apache/commons/collections4/comparators/ReverseComparatorTest.java +++ b/src/test/java/org/apache/commons/collections4/comparators/ReverseComparatorTest.java @@ -77,8 +77,8 @@ public List getComparableObjectsOrdered() { * doesn't adhere to the "soft" Comparator contract, and we've * already "canonized" the comparator returned by makeComparator. */ - @Override @Test + @Override public void testSerializeDeserializeThenCompare() throws Exception { final Comparator comp = new ReverseComparator<>(new ComparableComparator()); diff --git a/src/test/java/org/apache/commons/collections4/comparators/TransformingComparatorTest.java b/src/test/java/org/apache/commons/collections4/comparators/TransformingComparatorTest.java index e9df2887cc..832a8c586b 100644 --- a/src/test/java/org/apache/commons/collections4/comparators/TransformingComparatorTest.java +++ b/src/test/java/org/apache/commons/collections4/comparators/TransformingComparatorTest.java @@ -23,6 +23,7 @@ import org.apache.commons.collections4.ComparatorUtils; import org.apache.commons.collections4.Transformer; import org.apache.commons.collections4.TransformerUtils; +import org.junit.Test; /** * Test class for TransformingComparator. @@ -60,6 +61,7 @@ public List getComparableObjectsOrdered() { return list; } + @Test public void testEquals() { final Transformer t1 = TransformerUtils.nopTransformer(); final TransformingComparator comp1 = new TransformingComparator<>(t1); diff --git a/src/test/java/org/apache/commons/collections4/iterators/AbstractIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/AbstractIteratorTest.java index 247ac6bf82..1bcf717343 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/AbstractIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/AbstractIteratorTest.java @@ -22,6 +22,7 @@ import java.util.NoSuchElementException; import org.apache.commons.collections4.AbstractObjectTest; +import org.junit.Test; /** * Abstract class for testing the Iterator interface. @@ -99,6 +100,7 @@ public void verify() { /** * Test the empty iterator. */ + @Test public void testEmptyIterator() { if (!supportsEmptyIterator()) { return; @@ -120,6 +122,7 @@ public void testEmptyIterator() { /** * Test normal iteration behavior. */ + @Test public void testFullIterator() { if (!supportsFullIterator()) { return; @@ -153,6 +156,7 @@ public void testFullIterator() { /** * Test remove behavior. */ + @Test public void testRemove() { final Iterator it = makeObject(); diff --git a/src/test/java/org/apache/commons/collections4/iterators/AbstractListIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/AbstractListIteratorTest.java index 2a1a53b565..93ab4a0139 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/AbstractListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/AbstractListIteratorTest.java @@ -22,6 +22,8 @@ import java.util.ListIterator; import java.util.NoSuchElementException; +import org.junit.Test; + /** * Abstract class for testing the ListIterator interface. *

@@ -90,6 +92,7 @@ public E addSetValue() { /** * Test that the empty list iterator contract is correct. */ + @Test public void testEmptyListIteratorIsIndeedEmpty() { if (!supportsEmptyIterator()) { return; @@ -114,6 +117,7 @@ public void testEmptyListIteratorIsIndeedEmpty() { /** * Test navigation through the iterator. */ + @Test public void testWalkForwardAndBack() { final ArrayList list = new ArrayList<>(); final ListIterator it = makeObject(); @@ -146,6 +150,7 @@ public void testWalkForwardAndBack() { /** * Test add behavior. */ + @Test public void testAdd() { ListIterator it = makeObject(); @@ -182,6 +187,7 @@ public void testAdd() { /** * Test set behavior. */ + @Test public void testSet() { final ListIterator it = makeObject(); @@ -204,6 +210,7 @@ public void testSet() { } + @Test public void testRemoveThenSet() { final ListIterator it = makeObject(); if (supportsRemove() && supportsSet()) { @@ -214,6 +221,7 @@ public void testRemoveThenSet() { } } + @Test public void testAddThenSet() { final ListIterator it = makeObject(); // add then set @@ -228,6 +236,7 @@ public void testAddThenSet() { /** * Test remove after add behavior. */ + @Test public void testAddThenRemove() { final ListIterator it = makeObject(); diff --git a/src/test/java/org/apache/commons/collections4/iterators/AbstractMapIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/AbstractMapIteratorTest.java index 320c704a8e..7a9093bd54 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/AbstractMapIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/AbstractMapIteratorTest.java @@ -24,6 +24,7 @@ import java.util.Set; import org.apache.commons.collections4.MapIterator; +import org.junit.Test; /** * Abstract class for testing the MapIterator interface. @@ -110,6 +111,7 @@ public V[] addSetValues() { /** * Test that the empty list iterator contract is correct. */ + @Test public void testEmptyMapIterator() { if (!supportsEmptyIterator()) { return; @@ -144,6 +146,7 @@ public void testEmptyMapIterator() { /** * Test that the full list iterator contract is correct. */ + @Test public void testFullMapIterator() { if (!supportsFullIterator()) { return; @@ -173,6 +176,7 @@ public void testFullMapIterator() { } } + @Test public void testMapIteratorSet() { if (!supportsFullIterator()) { return; @@ -216,6 +220,7 @@ public void testMapIteratorSet() { verify(); } + @Test @Override public void testRemove() { // override final MapIterator it = makeObject(); @@ -241,6 +246,7 @@ public void testRemove() { // override verify(); } + @Test public void testMapIteratorSetRemoveSet() { if (!supportsSetValue() || !supportsRemove()) { return; @@ -261,6 +267,7 @@ public void testMapIteratorSetRemoveSet() { verify(); } + @Test public void testMapIteratorRemoveGetKey() { if (!supportsRemove()) { return; @@ -279,6 +286,7 @@ public void testMapIteratorRemoveGetKey() { verify(); } + @Test public void testMapIteratorRemoveGetValue() { if (!supportsRemove()) { return; 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 c27001df1a..adea036ee4 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/AbstractOrderedMapIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/AbstractOrderedMapIteratorTest.java @@ -27,6 +27,7 @@ import java.util.Set; import org.apache.commons.collections4.OrderedMapIterator; +import org.junit.Test; /** * Abstract class for testing the OrderedMapIterator interface. @@ -58,6 +59,7 @@ public AbstractOrderedMapIteratorTest(final String testName) { /** * Test that the empty list iterator contract is correct. */ + @Test @Override public void testEmptyMapIterator() { if (!supportsEmptyIterator()) { @@ -75,6 +77,7 @@ public void testEmptyMapIterator() { /** * Test that the full list iterator contract is correct. */ + @Test @Override public void testFullMapIterator() { if (!supportsFullIterator()) { @@ -130,6 +133,7 @@ public void testFullMapIterator() { /** * Test that the iterator order matches the keySet order. */ + @Test public void testMapIteratorOrder() { if (!supportsFullIterator()) { return; diff --git a/src/test/java/org/apache/commons/collections4/iterators/ArrayIterator2Test.java b/src/test/java/org/apache/commons/collections4/iterators/ArrayIterator2Test.java index 5764a71d8c..0c952ea21d 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ArrayIterator2Test.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ArrayIterator2Test.java @@ -22,6 +22,8 @@ import java.util.Iterator; import java.util.NoSuchElementException; +import org.junit.Test; + /** * Tests the ArrayIterator with primitive type arrays. */ @@ -60,6 +62,7 @@ public boolean supportsRemove() { return false; } + @Test public void testIterator() { final Iterator iter = makeObject(); for (final int element : testArray) { @@ -78,6 +81,7 @@ public void testIterator() { } } + @Test public void testIndexedArray() { Iterator iter = makeArrayIterator(testArray, 2); int count = 0; 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 3dda8717ce..528247cbe5 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ArrayIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ArrayIteratorTest.java @@ -19,6 +19,8 @@ import java.util.Iterator; import java.util.NoSuchElementException; +import org.junit.Test; + import static org.junit.jupiter.api.Assertions.assertThrows; /** @@ -49,6 +51,7 @@ public boolean supportsRemove() { return false; } + @Test public void testIterator() { final Iterator iter = makeObject(); for (final String testValue : testArray) { @@ -62,10 +65,12 @@ public void testIterator() { assertThrows(NoSuchElementException.class, iter::next, "NoSuchElementException must be thrown"); } + @Test public void testNullArray() { assertThrows(NullPointerException.class, () -> new ArrayIterator<>(null)); } + @Test public void testReset() { final ArrayIterator it = makeObject(); it.next(); diff --git a/src/test/java/org/apache/commons/collections4/iterators/ArrayListIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/ArrayListIteratorTest.java index f045fb50f4..3d9e796c0d 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ArrayListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ArrayListIteratorTest.java @@ -19,6 +19,8 @@ import java.util.ListIterator; import java.util.NoSuchElementException; +import org.junit.Test; + import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -54,6 +56,7 @@ public boolean supportsRemove() { * Test the basic ListIterator functionality - going backwards using * {@code previous()}. */ + @Test public void testListIterator() { final ListIterator iter = makeObject(); @@ -85,6 +88,7 @@ public void testListIterator() { /** * Tests the {@link java.util.ListIterator#set} operation. */ + @Test @SuppressWarnings("unchecked") public void testListIteratorSet() { final String[] testData = { "a", "b", "c" }; diff --git a/src/test/java/org/apache/commons/collections4/iterators/CollatingIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/CollatingIteratorTest.java index 00c14df8d7..80e588f56f 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/CollatingIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/CollatingIteratorTest.java @@ -22,6 +22,7 @@ import java.util.List; import org.apache.commons.collections4.comparators.ComparableComparator; +import org.junit.Test; /** * Unit test suite for {@link CollatingIterator}. @@ -85,6 +86,7 @@ public CollatingIterator makeObject() { //------------------------------------------------------------------- Tests + @Test public void testGetSetComparator() { final CollatingIterator iter = new CollatingIterator<>(); assertNull(iter.getComparator()); @@ -94,6 +96,7 @@ public void testGetSetComparator() { assertNull(iter.getComparator()); } + @Test public void testIterateEven() { final CollatingIterator iter = new CollatingIterator<>(comparator); iter.addIterator(evens.iterator()); @@ -105,6 +108,7 @@ public void testIterateEven() { assertFalse(iter.hasNext()); } + @Test public void testIterateEvenOdd() { final CollatingIterator iter = new CollatingIterator<>(comparator, evens.iterator(), odds.iterator()); for (int i = 0; i < 20; i++) { @@ -115,6 +119,7 @@ public void testIterateEvenOdd() { assertFalse(iter.hasNext()); } + @Test public void testIterateOddEven() { final CollatingIterator iter = new CollatingIterator<>(comparator, odds.iterator(), evens.iterator()); for (int i = 0; i < 20; i++) { @@ -125,6 +130,7 @@ public void testIterateOddEven() { assertFalse(iter.hasNext()); } + @Test public void testIterateEvenEven() { final CollatingIterator iter = new CollatingIterator<>(comparator); iter.addIterator(evens.iterator()); @@ -140,6 +146,7 @@ public void testIterateEvenEven() { assertFalse(iter.hasNext()); } + @Test public void testIterateFibEvenOdd() { final CollatingIterator iter = new CollatingIterator<>(comparator); iter.addIterator(fib.iterator()); @@ -206,6 +213,7 @@ public void testIterateFibEvenOdd() { assertFalse(iter.hasNext()); } + @Test public void testRemoveFromSingle() { final CollatingIterator iter = new CollatingIterator<>(comparator); iter.addIterator(evens.iterator()); @@ -221,6 +229,7 @@ public void testRemoveFromSingle() { assertEquals(expectedSize, evens.size()); } + @Test public void testRemoveFromDouble() { final CollatingIterator iter = new CollatingIterator<>(comparator); iter.addIterator(evens.iterator()); @@ -237,6 +246,7 @@ public void testRemoveFromDouble() { assertEquals(expectedSize, evens.size() + odds.size()); } + @Test public void testNullComparator() { final List l1 = Arrays.asList(1, 3, 5); final List l2 = Arrays.asList(2, 4, 6); 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 63bee72769..e6c312e029 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/FilterIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/FilterIteratorTest.java @@ -28,6 +28,7 @@ import org.apache.commons.collections4.Predicate; import org.apache.commons.collections4.functors.NotNullPredicate; +import org.junit.Test; /** * Test the filter iterator. @@ -84,12 +85,14 @@ public FilterIterator makeObject() { return makePassThroughFilter(list.iterator()); } + @Test public void testRepeatedHasNext() { for (int i = 0; i <= array.length; i++) { assertTrue(iterator.hasNext()); } } + @Test @SuppressWarnings("unused") public void testRepeatedNext() { for (final String element : array) { @@ -98,6 +101,7 @@ public void testRepeatedNext() { verifyNoMoreElements(); } + @Test public void testReturnValues() { verifyElementsInPredicate(new String[0]); verifyElementsInPredicate(new String[] { "a" }); @@ -113,6 +117,7 @@ public void testReturnValues() { * Test that when the iterator is changed, the hasNext method returns the * correct response for the new iterator. */ + @Test @SuppressWarnings("unchecked") public void testSetIterator() { final Iterator iter1 = Collections.singleton((E) new Object()).iterator(); @@ -132,6 +137,7 @@ public void testSetIterator() { * Test that when the predicate is changed, the hasNext method returns the * correct response for the new predicate. */ + @Test public void testSetPredicate() { final Iterator iter = Collections.singleton((E) null).iterator(); diff --git a/src/test/java/org/apache/commons/collections4/iterators/IteratorChainTest.java b/src/test/java/org/apache/commons/collections4/iterators/IteratorChainTest.java index 1c32ee4c81..256281b041 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/IteratorChainTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/IteratorChainTest.java @@ -26,6 +26,7 @@ import org.apache.commons.collections4.IteratorUtils; import org.apache.commons.collections4.Predicate; +import org.junit.Test; /** * Tests the IteratorChain class. @@ -73,6 +74,7 @@ public IteratorChain makeObject() { return chain; } + @Test public void testIterator() { final Iterator iter = makeObject(); for (final String testValue : testArray) { @@ -90,6 +92,7 @@ public void testIterator() { } } + @Test public void testRemoveFromFilteredIterator() { final Predicate myPredicate = i -> i.compareTo(Integer.valueOf(4)) < 0; @@ -114,6 +117,7 @@ public void testRemoveFromFilteredIterator() { assertEquals(1, list2.size()); } + @Test @Override public void testRemove() { final Iterator iter = makeObject(); @@ -136,6 +140,7 @@ public void testRemove() { assertTrue("List is empty", list3.isEmpty()); } + @Test public void testFirstIteratorIsEmptyBug() { final List empty = new ArrayList<>(); final List notEmpty = new ArrayList<>(); @@ -154,6 +159,7 @@ public void testFirstIteratorIsEmptyBug() { assertFalse("should not have next", chain.hasNext()); } + @Test public void testEmptyChain() { final IteratorChain chain = new IteratorChain<>(); assertFalse(chain.hasNext()); diff --git a/src/test/java/org/apache/commons/collections4/iterators/IteratorIterableTest.java b/src/test/java/org/apache/commons/collections4/iterators/IteratorIterableTest.java index c66e42a64d..3de5ad9891 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/IteratorIterableTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/IteratorIterableTest.java @@ -20,9 +20,8 @@ import java.util.Iterator; import java.util.List; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; +import org.junit.Test; /** * Tests for IteratorIterable. @@ -30,7 +29,7 @@ */ public class IteratorIterableTest extends BulkTest { - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(IteratorIterableTest.class); } @@ -47,6 +46,7 @@ private Iterator createIterator() { return iter; } + @Test @SuppressWarnings("unused") public void testIterator() { final Iterator iter = createIterator(); @@ -61,6 +61,7 @@ public void testIterator() { } } + @Test public void testMultipleUserIterator() { final Iterator iter = createIterator(); diff --git a/src/test/java/org/apache/commons/collections4/iterators/LazyIteratorChainTest.java b/src/test/java/org/apache/commons/collections4/iterators/LazyIteratorChainTest.java index b62ec95ace..a150cdfc83 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/LazyIteratorChainTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/LazyIteratorChainTest.java @@ -26,6 +26,7 @@ import org.apache.commons.collections4.IteratorUtils; import org.apache.commons.collections4.Predicate; +import org.junit.Test; /** * Tests the LazyIteratorChain class. @@ -87,6 +88,7 @@ protected Iterator nextIterator(final int count) { return chain; } + @Test public void testIterator() { final Iterator iter = makeObject(); for (final String testValue : testArray) { @@ -104,6 +106,7 @@ public void testIterator() { } } + @Test public void testRemoveFromFilteredIterator() { final Predicate myPredicate = i -> i.compareTo(Integer.valueOf(4)) < 0; @@ -128,6 +131,7 @@ public void testRemoveFromFilteredIterator() { assertEquals(1, list2.size()); } + @Test @Override public void testRemove() { final Iterator iter = makeObject(); @@ -150,6 +154,7 @@ public void testRemove() { assertTrue("List is empty", list3.isEmpty()); } + @Test public void testFirstIteratorIsEmptyBug() { final List empty = new ArrayList<>(); final List notEmpty = new ArrayList<>(); @@ -177,6 +182,7 @@ protected Iterator nextIterator(final int count) { assertFalse("should not have next", chain.hasNext()); } + @Test public void testEmptyChain() { final LazyIteratorChain chain = makeEmptyIterator(); assertFalse(chain.hasNext()); diff --git a/src/test/java/org/apache/commons/collections4/iterators/ListIteratorWrapper2Test.java b/src/test/java/org/apache/commons/collections4/iterators/ListIteratorWrapper2Test.java index dc1fe478f8..d43659eec2 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ListIteratorWrapper2Test.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ListIteratorWrapper2Test.java @@ -22,6 +22,7 @@ import java.util.NoSuchElementException; import org.apache.commons.collections4.ResettableListIterator; +import org.junit.Test; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -63,6 +64,7 @@ public ResettableListIterator makeObject() { return new ListIteratorWrapper<>(list1.listIterator()); } + @Test public void testIterator() { final ListIterator iter = makeObject(); for (final String testValue : testArray) { @@ -102,6 +104,7 @@ public void testIterator() { } + @Test @Override public void testRemove() { final ListIterator iter = makeObject(); @@ -171,6 +174,7 @@ public void testRemove() { //further testing would be fairly meaningless: } + @Test public void testReset() { final ResettableListIterator iter = makeObject(); final E first = iter.next(); diff --git a/src/test/java/org/apache/commons/collections4/iterators/ListIteratorWrapperTest.java b/src/test/java/org/apache/commons/collections4/iterators/ListIteratorWrapperTest.java index a86cd97ba2..35c8b2afba 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ListIteratorWrapperTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ListIteratorWrapperTest.java @@ -24,6 +24,7 @@ import java.util.NoSuchElementException; import org.apache.commons.collections4.ResettableListIterator; +import org.junit.Test; /** * Tests the ListIteratorWrapper to insure that it simulates @@ -64,6 +65,7 @@ public ResettableListIterator makeObject() { return new ListIteratorWrapper<>(list1.iterator()); } + @Test public void testIterator() { final ListIterator iter = makeObject(); for (final String testValue : testArray) { @@ -103,6 +105,7 @@ public void testIterator() { } + @Test @Override public void testRemove() { final ListIterator iter = makeObject(); @@ -193,6 +196,7 @@ public void testRemove() { } + @Test public void testReset() { final ResettableListIterator iter = makeObject(); final E first = iter.next(); 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 5c953fee6a..38975ad00c 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/NodeListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/NodeListIteratorTest.java @@ -21,6 +21,7 @@ import java.util.Iterator; +import org.junit.Test; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -111,6 +112,7 @@ public boolean supportsRemove() { return false; } + @Test public void testNullConstructor() { assertThrows(NullPointerException.class, () -> new NodeListIterator((Node) null)); } @@ -118,6 +120,7 @@ public void testNullConstructor() { /** * tests the convenience Constructor with parameter type org.w3c.Node */ + @Test public void testEmptyIteratorWithNodeConstructor(){ createIteratorWithStandardConstr = false; testEmptyIterator(); @@ -126,6 +129,7 @@ public void testEmptyIteratorWithNodeConstructor(){ /** * tests the convenience Constructor with parameter type org.w3c.Node */ + @Test public void testFullIteratorWithNodeConstructor(){ 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 f1095cf259..604839f046 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayIteratorTest.java @@ -21,6 +21,8 @@ import java.util.Iterator; import java.util.NoSuchElementException; +import org.junit.Test; + /** * Tests the ObjectArrayIterator. */ @@ -66,6 +68,7 @@ public boolean supportsRemove() { return false; } + @Test public void testIterator() { final Iterator iter = makeObject(); for (final String testValue : testArray) { @@ -83,10 +86,12 @@ public void testIterator() { } } + @Test public void testNullArray() { assertThrows(NullPointerException.class, () -> makeArrayIterator(null)); } + @Test @SuppressWarnings("unchecked") public void testReset() { final ObjectArrayIterator it = makeArrayIterator((E[]) testArray); diff --git a/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayListIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayListIteratorTest.java index 1d6ed7e146..5a621ff5d2 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayListIteratorTest.java @@ -19,6 +19,8 @@ import java.util.ListIterator; import java.util.NoSuchElementException; +import org.junit.Test; + import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -51,6 +53,7 @@ public ObjectArrayListIterator makeArrayListIterator(final E[] array) { * Test the basic ListIterator functionality - going backwards using * {@code previous()}. */ + @Test public void testListIterator() { final ListIterator iter = makeObject(); @@ -82,6 +85,7 @@ public void testListIterator() { /** * Tests the {@link java.util.ListIterator#set} operation. */ + @Test @SuppressWarnings("unchecked") public void testListIteratorSet() { final String[] testData = { "a", "b", "c" }; diff --git a/src/test/java/org/apache/commons/collections4/iterators/ObjectGraphIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/ObjectGraphIteratorTest.java index 1123ef0002..c38f519adf 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ObjectGraphIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ObjectGraphIteratorTest.java @@ -25,6 +25,7 @@ import org.apache.commons.collections4.IteratorUtils; import org.apache.commons.collections4.Transformer; +import org.junit.Test; /** * Testcase. @@ -70,6 +71,7 @@ public ObjectGraphIterator makeObject() { return new ObjectGraphIterator<>(iteratorList.iterator()); } + @Test public void testIteratorConstructor_null1() { final Iterator it = new ObjectGraphIterator<>(null); @@ -80,16 +82,19 @@ public void testIteratorConstructor_null1() { assertThrows(IllegalStateException.class, () -> it.remove()); } + @Test public void testIteratorConstructor_null_next() { final Iterator it = new ObjectGraphIterator<>(null); assertThrows(NoSuchElementException.class, () -> it.next()); } + @Test public void testIteratorConstructor_null_remove() { final Iterator it = new ObjectGraphIterator<>(null); assertThrows(IllegalStateException.class, () -> it.remove()); } + @Test public void testIteratorConstructorIteration_Empty() { final List> iteratorList = new ArrayList<>(); final Iterator it = new ObjectGraphIterator<>(iteratorList.iterator()); @@ -101,6 +106,7 @@ public void testIteratorConstructorIteration_Empty() { assertThrows(IllegalStateException.class, () -> it.remove()); } + @Test public void testIteratorConstructorIteration_Simple() { final List> iteratorList = new ArrayList<>(); iteratorList.add(list1.iterator()); @@ -117,6 +123,7 @@ public void testIteratorConstructorIteration_Simple() { assertThrows(NoSuchElementException.class, () -> it.next()); } + @Test public void testIteratorConstructorIteration_SimpleNoHasNext() { final List> iteratorList = new ArrayList<>(); iteratorList.add(list1.iterator()); @@ -131,6 +138,7 @@ public void testIteratorConstructorIteration_SimpleNoHasNext() { assertThrows(NoSuchElementException.class, () -> it.next()); } + @Test public void testIteratorConstructorIteration_WithEmptyIterators() { final List> iteratorList = new ArrayList<>(); iteratorList.add(IteratorUtils.emptyIterator()); @@ -151,6 +159,7 @@ public void testIteratorConstructorIteration_WithEmptyIterators() { assertThrows(NoSuchElementException.class, () -> it.next()); } + @Test public void testIteratorConstructorRemove() { final List> iteratorList = new ArrayList<>(); iteratorList.add(list1.iterator()); @@ -168,6 +177,7 @@ public void testIteratorConstructorRemove() { assertEquals(0, list3.size()); } + @Test public void testIteration_IteratorOfIterators() { final List> iteratorList = new ArrayList<>(); iteratorList.add(list1.iterator()); @@ -182,6 +192,7 @@ public void testIteration_IteratorOfIterators() { assertFalse(it.hasNext()); } + @Test public void testIteration_IteratorOfIteratorsWithEmptyIterators() { final List> iteratorList = new ArrayList<>(); iteratorList.add(IteratorUtils.emptyIterator()); @@ -200,6 +211,7 @@ public void testIteration_IteratorOfIteratorsWithEmptyIterators() { assertFalse(it.hasNext()); } + @Test public void testIteration_RootNull() { final Iterator it = new ObjectGraphIterator<>(null, null); @@ -210,6 +222,7 @@ public void testIteration_RootNull() { assertThrows(IllegalStateException.class, () -> it.remove()); } + @Test public void testIteration_RootNoTransformer() { final Forest forest = new Forest(); final Iterator it = new ObjectGraphIterator<>(forest, null); @@ -221,6 +234,7 @@ public void testIteration_RootNoTransformer() { assertThrows(NoSuchElementException.class, () -> it.next()); } + @Test public void testIteration_Transformed1() { final Forest forest = new Forest(); final Leaf l1 = forest.addTree().addBranch().addLeaf(); @@ -233,6 +247,7 @@ public void testIteration_Transformed1() { assertThrows(NoSuchElementException.class, () -> it.next()); } + @Test public void testIteration_Transformed2() { final Forest forest = new Forest(); forest.addTree(); @@ -266,6 +281,7 @@ public void testIteration_Transformed2() { assertThrows(NoSuchElementException.class, () -> it.next()); } + @Test public void testIteration_Transformed3() { final Forest forest = new Forest(); forest.addTree(); diff --git a/src/test/java/org/apache/commons/collections4/iterators/PeekingIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/PeekingIteratorTest.java index 4ce8cd85d8..6d63b54f13 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/PeekingIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/PeekingIteratorTest.java @@ -65,7 +65,6 @@ public boolean supportsRemove() { return true; } - @Test public void testEmpty() { final Iterator it = makeEmptyIterator(); 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 8af44ff460..baf32174d9 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/PermutationIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/PermutationIteratorTest.java @@ -26,6 +26,8 @@ import java.util.NoSuchElementException; import java.util.Set; +import org.junit.Test; + /** * Test class for PermutationIterator. * @@ -68,7 +70,7 @@ public PermutationIterator makeObject() { return new PermutationIterator<>(testList); } - + @Test @SuppressWarnings("boxing") // OK in test code public void testPermutationResultSize() { int factorial = 1; @@ -90,6 +92,7 @@ public void testPermutationResultSize() { /** * test checking that all the permutations are returned */ + @Test @SuppressWarnings("boxing") // OK in test code public void testPermutationExhaustivity() { final List perm1 = new ArrayList<>(); @@ -140,6 +143,7 @@ public void testPermutationExhaustivity() { /** * test checking that all the permutations are returned only once. */ + @Test public void testPermutationUnicity() { final List> resultsList = new ArrayList<>(); final Set> resultsSet = new HashSet<>(); @@ -155,6 +159,7 @@ public void testPermutationUnicity() { assertEquals(6, resultsSet.size()); } + @Test public void testPermutationException() { final List> resultsList = new ArrayList<>(); @@ -167,6 +172,7 @@ public void testPermutationException() { assertThrows(NoSuchElementException.class, () -> it.next()); } + @Test public void testPermutatorHasMore() { final PermutationIterator it = makeObject(); for (int i = 0; i < 6; i++) { @@ -176,6 +182,7 @@ public void testPermutatorHasMore() { assertFalse(it.hasNext()); } + @Test public void testEmptyCollection() { final PermutationIterator it = makeEmptyIterator(); // there is one permutation for an empty set: 0! = 1 diff --git a/src/test/java/org/apache/commons/collections4/iterators/ReverseListIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/ReverseListIteratorTest.java index 7890e6ca05..f4da00ef8f 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ReverseListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ReverseListIteratorTest.java @@ -26,6 +26,7 @@ import java.util.NoSuchElementException; import org.apache.commons.collections4.ResettableListIterator; +import org.junit.Test; /** * Tests the ReverseListIterator. @@ -51,6 +52,7 @@ public ReverseListIterator makeObject() { } // overrides + @Test @Override public void testEmptyListIteratorIsIndeedEmpty() { final ListIterator it = makeEmptyIterator(); @@ -70,6 +72,7 @@ public void testEmptyListIteratorIsIndeedEmpty() { ); } + @Test @Override public void testWalkForwardAndBack() { final ArrayList list = new ArrayList<>(); @@ -108,6 +111,7 @@ public void testWalkForwardAndBack() { "NoSuchElementException must be thrown from previous at start of ListIterator"); } + @Test public void testReverse() { final ListIterator it = makeObject(); assertTrue(it.hasNext()); @@ -140,6 +144,7 @@ public void testReverse() { assertEquals("Four", it.previous()); } + @Test public void testReset() { final ResettableListIterator it = makeObject(); assertEquals("Four", it.next()); diff --git a/src/test/java/org/apache/commons/collections4/iterators/SingletonIterator2Test.java b/src/test/java/org/apache/commons/collections4/iterators/SingletonIterator2Test.java index 9e4c20e653..fbbb3d30cb 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/SingletonIterator2Test.java +++ b/src/test/java/org/apache/commons/collections4/iterators/SingletonIterator2Test.java @@ -20,6 +20,7 @@ import java.util.NoSuchElementException; import org.apache.commons.collections4.ResettableIterator; +import org.junit.Test; /** * Tests the SingletonIterator to ensure that the next() method will actually @@ -60,6 +61,7 @@ public boolean supportsEmptyIterator() { return false; } + @Test public void testIterator() { final Iterator iter = makeObject(); assertTrue("Iterator has a first item", iter.hasNext()); @@ -76,6 +78,7 @@ public void testIterator() { } } + @Test public void testReset() { final ResettableIterator it = makeObject(); diff --git a/src/test/java/org/apache/commons/collections4/iterators/SingletonIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/SingletonIteratorTest.java index 0b57386e71..9c8a7489cd 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/SingletonIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/SingletonIteratorTest.java @@ -20,6 +20,7 @@ import java.util.NoSuchElementException; import org.apache.commons.collections4.ResettableIterator; +import org.junit.Test; /** * Tests the SingletonIterator to ensure that the next() method will actually @@ -63,6 +64,7 @@ public boolean supportsEmptyIterator() { return true; } + @Test public void testIterator() { final Iterator iter = makeObject(); assertTrue("Iterator has a first item", iter.hasNext()); @@ -79,6 +81,7 @@ public void testIterator() { } } + @Test @SuppressWarnings("unchecked") public void testSingletonIteratorRemove() { final ResettableIterator iter = new SingletonIterator<>((E) "xyzzy"); @@ -89,6 +92,7 @@ public void testSingletonIteratorRemove() { assertFalse(iter.hasNext()); } + @Test public void testReset() { final ResettableIterator it = makeObject(); diff --git a/src/test/java/org/apache/commons/collections4/iterators/SingletonListIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/SingletonListIteratorTest.java index 45af94f8ce..0d89f157b7 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/SingletonListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/SingletonListIteratorTest.java @@ -20,6 +20,7 @@ import java.util.NoSuchElementException; import org.apache.commons.collections4.ResettableListIterator; +import org.junit.Test; /** * Tests the SingletonListIterator. @@ -67,6 +68,7 @@ public boolean supportsEmptyIterator() { return true; } + @Test public void testIterator() { final ListIterator iter = makeObject(); assertTrue( "Iterator should have next item", iter.hasNext() ); @@ -111,6 +113,7 @@ public void testIterator() { } } + @Test public void testReset() { final ResettableListIterator it = makeObject(); diff --git a/src/test/java/org/apache/commons/collections4/iterators/UniqueFilterIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/UniqueFilterIteratorTest.java index 6044c9c0e5..19ee7fd60b 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/UniqueFilterIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/UniqueFilterIteratorTest.java @@ -21,6 +21,8 @@ import java.util.List; import java.util.NoSuchElementException; +import org.junit.Test; + /** * Tests the UniqueFilterIterator class. * @@ -65,6 +67,7 @@ public UniqueFilterIterator makeObject() { return new UniqueFilterIterator<>(i); } + @Test public void testIterator() { final Iterator iter = makeObject(); for (final String testValue : testArray) { 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 a1cabeb2ae..9dd369af49 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableIteratorTest.java @@ -25,6 +25,7 @@ import java.util.List; import org.apache.commons.collections4.Unmodifiable; +import org.junit.Test; /** * Tests the UnmodifiableIterator. @@ -63,10 +64,12 @@ public boolean supportsRemove() { return false; } + @Test public void testIterator() { assertTrue(makeEmptyIterator() instanceof Unmodifiable); } + @Test public void testDecorateFactory() { Iterator it = makeObject(); assertSame(it, UnmodifiableIterator.unmodifiableIterator(it)); diff --git a/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableListIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableListIteratorTest.java index 41a5797382..e5b29e2d8d 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableListIteratorTest.java @@ -23,6 +23,7 @@ import java.util.ListIterator; import org.apache.commons.collections4.Unmodifiable; +import org.junit.Test; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -73,10 +74,12 @@ public boolean supportsSet() { return false; } + @Test public void testListIterator() { assertTrue(makeEmptyIterator() instanceof Unmodifiable); } + @Test public void testDecorateFactory() { ListIterator it = makeObject(); assertSame(it, UnmodifiableListIterator.unmodifiableListIterator(it)); 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 76b3c707d5..2bd299f1e1 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableMapIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableMapIteratorTest.java @@ -25,6 +25,7 @@ import org.apache.commons.collections4.MapIterator; import org.apache.commons.collections4.Unmodifiable; import org.apache.commons.collections4.bidimap.DualHashBidiMap; +import org.junit.Test; /** * Tests the UnmodifiableMapIterator. @@ -75,10 +76,12 @@ public boolean supportsSetValue() { return false; } + @Test public void testMapIterator() { assertTrue(makeEmptyIterator() instanceof Unmodifiable); } + @Test public void testDecorateFactory() { MapIterator it = makeObject(); assertSame(it, UnmodifiableMapIterator.unmodifiableMapIterator(it)); 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 75555a0808..5efd4639ae 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableOrderedMapIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableOrderedMapIteratorTest.java @@ -26,6 +26,7 @@ import org.apache.commons.collections4.OrderedMapIterator; import org.apache.commons.collections4.Unmodifiable; import org.apache.commons.collections4.map.ListOrderedMap; +import org.junit.Test; /** * Tests the UnmodifiableOrderedMapIterator. @@ -77,10 +78,12 @@ public boolean supportsSetValue() { return false; } + @Test public void testOrderedMapIterator() { assertTrue(makeEmptyIterator() instanceof Unmodifiable); } + @Test public void testDecorateFactory() { OrderedMapIterator it = makeObject(); assertSame(it, UnmodifiableOrderedMapIterator.unmodifiableOrderedMapIterator(it)); diff --git a/src/test/java/org/apache/commons/collections4/iterators/ZippingIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/ZippingIteratorTest.java index 2a26ee4209..a66ecda6be 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ZippingIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ZippingIteratorTest.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import org.apache.commons.collections4.IteratorUtils; +import org.junit.Test; /** * Unit test suite for {@link ZippingIterator}. @@ -77,6 +78,7 @@ public ZippingIterator makeObject() { //------------------------------------------------------------------- Tests + @Test public void testIterateEven() { @SuppressWarnings("unchecked") final ZippingIterator iter = new ZippingIterator<>(evens.iterator()); @@ -87,6 +89,7 @@ public void testIterateEven() { assertFalse(iter.hasNext()); } + @Test public void testIterateEvenOdd() { final ZippingIterator iter = new ZippingIterator<>(evens.iterator(), odds.iterator()); for (int i = 0; i < 20; i++) { @@ -96,6 +99,7 @@ public void testIterateEvenOdd() { assertFalse(iter.hasNext()); } + @Test public void testIterateOddEven() { final ZippingIterator iter = new ZippingIterator<>(odds.iterator(), evens.iterator()); for (int i = 0, j = 0; i < 20; i++) { @@ -111,6 +115,7 @@ public void testIterateOddEven() { assertFalse(iter.hasNext()); } + @Test public void testIterateEvenEven() { final ZippingIterator iter = new ZippingIterator<>(evens.iterator(), evens.iterator()); for (final Integer even : evens) { @@ -122,6 +127,7 @@ public void testIterateEvenEven() { assertFalse(iter.hasNext()); } + @Test public void testIterateFibEvenOdd() { final ZippingIterator iter = new ZippingIterator<>(fib.iterator(), evens.iterator(), odds.iterator()); @@ -157,6 +163,7 @@ public void testIterateFibEvenOdd() { assertFalse(iter.hasNext()); } + @Test public void testRemoveFromSingle() { @SuppressWarnings("unchecked") final ZippingIterator iter = new ZippingIterator<>(evens.iterator()); @@ -172,6 +179,7 @@ public void testRemoveFromSingle() { assertEquals(expectedSize, evens.size()); } + @Test public void testRemoveFromDouble() { final ZippingIterator iter = new ZippingIterator<>(evens.iterator(), odds.iterator()); int expectedSize = evens.size() + odds.size(); 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 82461d33ac..3dedf86253 100644 --- a/src/test/java/org/apache/commons/collections4/keyvalue/AbstractMapEntryTest.java +++ b/src/test/java/org/apache/commons/collections4/keyvalue/AbstractMapEntryTest.java @@ -74,8 +74,8 @@ public Map.Entry makeKnownMapEntry(final K key, final V value) { return entry; } - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("unchecked") public void testAccessorsAndMutators() { Map.Entry entry = makeMapEntry((K) key, (V) value); @@ -99,8 +99,8 @@ public void testAccessorsAndMutators() { * */ - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("unchecked") public void testSelfReferenceHandling() { // test that #setValue does not permit // the MapEntry to contain itself (and thus cause infinite recursion @@ -120,8 +120,8 @@ public void testSelfReferenceHandling() { */ public abstract void testConstructors(); - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("unchecked") public void testEqualsAndHashCode() { // 1. test with object data Map.Entry e1 = makeMapEntry((K) key, (V) value); @@ -142,8 +142,8 @@ public void testEqualsAndHashCode() { assertEquals(e1.hashCode(), e2.hashCode()); } - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("unchecked") public void testToString() { Map.Entry entry = makeMapEntry((K) key, (V) value); assertEquals(entry.toString(), entry.getKey() + "=" + entry.getValue()); diff --git a/src/test/java/org/apache/commons/collections4/keyvalue/DefaultKeyValueTest.java b/src/test/java/org/apache/commons/collections4/keyvalue/DefaultKeyValueTest.java index 5aac52d5c9..d9e4a8c694 100644 --- a/src/test/java/org/apache/commons/collections4/keyvalue/DefaultKeyValueTest.java +++ b/src/test/java/org/apache/commons/collections4/keyvalue/DefaultKeyValueTest.java @@ -56,8 +56,8 @@ protected DefaultKeyValue makeDefaultKeyValue(final K key, final V value) return new DefaultKeyValue<>(key, value); } - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("unchecked") public void testAccessorsAndMutators() { final DefaultKeyValue kv = makeDefaultKeyValue(); @@ -75,8 +75,8 @@ public void testAccessorsAndMutators() { assertNull(kv.getValue()); } - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("unchecked") public void testSelfReferenceHandling() { // test that #setKey and #setValue do not permit // the KVP to contain itself (and thus cause infinite recursion @@ -92,8 +92,8 @@ public void testSelfReferenceHandling() { /** * Subclasses should override this method to test their own constructors. */ - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("unchecked") public void testConstructors() { // 1. test default constructor DefaultKeyValue kv = new DefaultKeyValue<>(); @@ -126,8 +126,8 @@ public void testConstructors() { assertSame(value, kv.getValue()); } - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("unchecked") public void testEqualsAndHashCode() { // 1. test with object data DefaultKeyValue kv = makeDefaultKeyValue((K) key, (V) value); @@ -146,8 +146,8 @@ public void testEqualsAndHashCode() { assertEquals(kv.hashCode(), kv2.hashCode()); } - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("unchecked") public void testToString() { DefaultKeyValue kv = makeDefaultKeyValue((K) key, (V) value); assertEquals(kv.toString(), kv.getKey() + "=" + kv.getValue()); @@ -157,8 +157,8 @@ public void testToString() { assertEquals(kv.toString(), kv.getKey() + "=" + kv.getValue()); } - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("unchecked") public void testToMapEntry() { final DefaultKeyValue kv = makeDefaultKeyValue((K) key, (V) value); 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 f1cbccd8f0..b7365e8b0b 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,6 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertSame; -import static org.junit.jupiter.api.Assertions.assertThrows; /** * Test the DefaultMapEntry class. @@ -55,9 +54,9 @@ public Map.Entry makeMapEntry(final K key, final V value) { * Subclasses should override this method. * */ + @Test @Override @SuppressWarnings("unchecked") - @Test public void testConstructors() { // 1. test key-value constructor final Map.Entry entry = new DefaultMapEntry<>((K) key, (V) value); @@ -79,12 +78,13 @@ public void testConstructors() { assertSame(value, entry2.getValue()); } + @Test @Override @SuppressWarnings("unchecked") public void testSelfReferenceHandling() { final Map.Entry entry = makeMapEntry(); - assertThrows(Exception.class, () -> entry.setValue((V) entry)); + entry.setValue((V) entry); assertSame(entry, entry.getValue()); } diff --git a/src/test/java/org/apache/commons/collections4/keyvalue/TiedMapEntryTest.java b/src/test/java/org/apache/commons/collections4/keyvalue/TiedMapEntryTest.java index f231d24e7e..14e7a74dff 100644 --- a/src/test/java/org/apache/commons/collections4/keyvalue/TiedMapEntryTest.java +++ b/src/test/java/org/apache/commons/collections4/keyvalue/TiedMapEntryTest.java @@ -43,8 +43,8 @@ public Map.Entry makeMapEntry(final K key, final V value) { /** * Tests the constructors. */ - @Override @Test + @Override public void testConstructors() { // ignore } @@ -52,8 +52,8 @@ public void testConstructors() { /** * Tests the constructors. */ - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("unchecked") public void testSetValue() { final Map map = new HashMap<>(); map.put((K) "A", (V) "a"); 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 65b46d6b41..1f4627ca20 100644 --- a/src/test/java/org/apache/commons/collections4/keyvalue/UnmodifiableMapEntryTest.java +++ b/src/test/java/org/apache/commons/collections4/keyvalue/UnmodifiableMapEntryTest.java @@ -57,9 +57,9 @@ public Map.Entry makeMapEntry(final K key, final V value) { * Subclasses should override this method. * */ + @Test @Override @SuppressWarnings("unchecked") - @Test public void testConstructors() { // 1. test key-value constructor Map.Entry entry = new UnmodifiableMapEntry<>((K) key, (V) value); @@ -80,6 +80,7 @@ public void testConstructors() { assertTrue(entry instanceof Unmodifiable); } + @Test @Override @SuppressWarnings("unchecked") public void testAccessorsAndMutators() { @@ -94,8 +95,8 @@ public void testAccessorsAndMutators() { assertSame(null, entry.getValue()); } - @Override @Test + @Override public void testSelfReferenceHandling() { // block } 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 5853867156..fd769101d5 100644 --- a/src/test/java/org/apache/commons/collections4/list/AbstractLinkedListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/AbstractLinkedListTest.java @@ -20,6 +20,8 @@ import java.util.Arrays; +import org.junit.Test; + /** * Test case for {@link AbstractLinkedList}. */ @@ -29,6 +31,7 @@ public AbstractLinkedListTest(final String testName) { super(testName); } + @Test @SuppressWarnings("unchecked") public void testRemoveFirst() { resetEmpty(); @@ -53,6 +56,7 @@ public void testRemoveFirst() { checkNodes(); } + @Test @SuppressWarnings("unchecked") public void testRemoveLast() { resetEmpty(); @@ -74,6 +78,7 @@ public void testRemoveLast() { assertEquals("value4", list.removeFirst()); } + @Test @SuppressWarnings("unchecked") public void testAddNodeAfter() { resetEmpty(); @@ -107,6 +112,7 @@ public void testAddNodeAfter() { assertEquals("value5", list.getLast()); } + @Test @SuppressWarnings("unchecked") public void testRemoveNode() { resetEmpty(); @@ -133,6 +139,7 @@ public void testRemoveNode() { checkNodes(); } + @Test @SuppressWarnings("unchecked") public void testGetNode() { resetEmpty(); 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 ce464cdf03..664b4652d9 100644 --- a/src/test/java/org/apache/commons/collections4/list/AbstractListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/AbstractListTest.java @@ -37,6 +37,7 @@ import org.apache.commons.collections4.collection.AbstractCollectionTest; import org.apache.commons.collections4.iterators.AbstractListIteratorTest; import org.junit.jupiter.api.Assertions; +import org.junit.Test; /** * Abstract test class for {@link java.util.List} methods and contracts. @@ -173,6 +174,7 @@ public List getConfirmed() { * Tests bounds checking for {@link List#add(int, Object)} on an * empty list. */ + @Test public void testListAddByIndexBoundsChecking() { if (!isAddSupported()) { return; @@ -201,6 +203,7 @@ public void testListAddByIndexBoundsChecking() { * Tests bounds checking for {@link List#add(int, Object)} on a * full list. */ + @Test public void testListAddByIndexBoundsChecking2() { if (!isAddSupported()) { return; @@ -228,6 +231,7 @@ public void testListAddByIndexBoundsChecking2() { /** * Tests {@link List#add(int,Object)}. */ + @Test public void testListAddByIndex() { if (!isAddSupported()) { return; @@ -247,6 +251,7 @@ public void testListAddByIndex() { /** * Tests {@link List#equals(Object)}. */ + @Test public void testListEquals() { resetEmpty(); List list = getCollection(); @@ -317,6 +322,7 @@ public Iterator iterator() { /** * Tests {@link List#hashCode()}. */ + @Test public void testListHashCode() { resetEmpty(); int hash1 = getCollection().hashCode(); @@ -334,6 +340,7 @@ public void testListHashCode() { /** * Tests {@link List#get(int)}. */ + @Test public void testListGetByIndex() { resetFull(); final List list = getCollection(); @@ -348,6 +355,7 @@ public void testListGetByIndex() { * Tests bounds checking for {@link List#get(int)} on an * empty list. */ + @Test public void testListGetByIndexBoundsChecking() { final List list = makeObject(); @@ -371,6 +379,7 @@ public void testListGetByIndexBoundsChecking() { * Tests bounds checking for {@link List#get(int)} on a * full list. */ + @Test public void testListGetByIndexBoundsChecking2() { final List list = makeFullCollection(); @@ -390,6 +399,7 @@ public void testListGetByIndexBoundsChecking2() { /** * Tests {@link List#indexOf}. */ + @Test public void testListIndexOf() { resetFull(); final List list1 = getCollection(); @@ -412,6 +422,7 @@ public void testListIndexOf() { /** * Tests {@link List#lastIndexOf}. */ + @Test public void testListLastIndexOf() { resetFull(); final List list1 = getCollection(); @@ -437,6 +448,7 @@ public void testListLastIndexOf() { * Tests bounds checking for {@link List#set(int,Object)} on an * empty list. */ + @Test public void testListSetByIndexBoundsChecking() { if (!isSetSupported()) { return; @@ -465,6 +477,7 @@ public void testListSetByIndexBoundsChecking() { * Tests bounds checking for {@link List#set(int,Object)} on a * full list. */ + @Test public void testListSetByIndexBoundsChecking2() { if (!isSetSupported()) { return; @@ -489,6 +502,7 @@ public void testListSetByIndexBoundsChecking2() { /** * Test {@link List#set(int,Object)}. */ + @Test public void testListSetByIndex() { if (!isSetSupported()) { return; @@ -511,6 +525,7 @@ public void testListSetByIndex() { * If {@link #isSetSupported()} returns false, tests that set operation * raises UnsupportedOperationException. */ + @Test public void testUnsupportedSet() { if (isSetSupported()) { return; @@ -528,6 +543,7 @@ public void testUnsupportedSet() { * Tests bounds checking for {@link List#remove(int)} on an * empty list. */ + @Test public void testListRemoveByIndexBoundsChecking() { if (!isRemoveSupported()) { return; @@ -555,6 +571,7 @@ public void testListRemoveByIndexBoundsChecking() { * Tests bounds checking for {@link List#remove(int)} on a * full list. */ + @Test public void testListRemoveByIndexBoundsChecking2() { if (!isRemoveSupported()) { return; @@ -578,6 +595,7 @@ public void testListRemoveByIndexBoundsChecking2() { /** * Tests {@link List#remove(int)}. */ + @Test public void testListRemoveByIndex() { if (!isRemoveSupported()) { return; @@ -596,6 +614,7 @@ public void testListRemoveByIndex() { /** * Tests the read-only bits of {@link List#listIterator()}. */ + @Test public void testListListIterator() { resetFull(); forwardTest(getCollection().listIterator(), 0); @@ -605,6 +624,7 @@ public void testListListIterator() { /** * Tests the read-only bits of {@link List#listIterator(int)}. */ + @Test public void testListListIteratorByIndex() { resetFull(); try { @@ -628,6 +648,7 @@ public void testListListIteratorByIndex() { /** * Tests remove on list iterator is correct. */ + @Test public void testListListIteratorPreviousRemoveNext() { if (!isRemoveSupported()) { return; @@ -660,6 +681,7 @@ public void testListListIteratorPreviousRemoveNext() { /** * Tests remove on list iterator is correct. */ + @Test public void testListListIteratorPreviousRemovePrevious() { if (!isRemoveSupported()) { return; @@ -692,6 +714,7 @@ public void testListListIteratorPreviousRemovePrevious() { /** * Tests remove on list iterator is correct. */ + @Test public void testListListIteratorNextRemoveNext() { if (!isRemoveSupported()) { return; @@ -721,6 +744,7 @@ public void testListListIteratorNextRemoveNext() { /** * Tests remove on list iterator is correct. */ + @Test public void testListListIteratorNextRemovePrevious() { if (!isRemoveSupported()) { return; @@ -812,6 +836,7 @@ private void backwardTest(final ListIterator iter, int i) { * Tests the {@link ListIterator#add(Object)} method of the list * iterator. */ + @Test public void testListIteratorAdd() { if (!isAddSupported()) { return; @@ -847,6 +872,7 @@ public void testListIteratorAdd() { * Tests the {@link ListIterator#set(Object)} method of the list * iterator. */ + @Test public void testListIteratorSet() { if (!isSetSupported()) { return; @@ -866,6 +892,7 @@ public void testListIteratorSet() { } } + @Test @SuppressWarnings("unchecked") public void testEmptyListSerialization() throws IOException, ClassNotFoundException { final List list = makeObject(); @@ -880,6 +907,7 @@ public void testEmptyListSerialization() throws IOException, ClassNotFoundExcept assertEquals("Both lists are empty", 0, list2.size()); } + @Test @SuppressWarnings("unchecked") public void testFullListSerialization() throws IOException, ClassNotFoundException { final List list = makeFullCollection(); @@ -899,6 +927,7 @@ public void testFullListSerialization() throws IOException, ClassNotFoundExcepti * Compare the current serialized form of the List * against the canonical version in SCM. */ + @Test @SuppressWarnings("unchecked") public void testEmptyListCompatibility() throws IOException, ClassNotFoundException { /* @@ -923,6 +952,7 @@ && isTestSerialization()) { * Compare the current serialized form of the List * against the canonical version in SCM. */ + @Test @SuppressWarnings("unchecked") public void testFullListCompatibility() throws IOException, ClassNotFoundException { /* @@ -1041,6 +1071,7 @@ public boolean isTestSerialization() { * Tests that a sublist raises a {@link java.util.ConcurrentModificationException ConcurrentModificationException} * if elements are added to the original list. */ + @Test public void testListSubListFailFastOnAdd() { if (!isFailFastSupported()) { return; @@ -1075,6 +1106,7 @@ public void testListSubListFailFastOnAdd() { * Tests that a sublist raises a {@link java.util.ConcurrentModificationException ConcurrentModificationException} * if elements are removed from the original list. */ + @Test public void testListSubListFailFastOnRemove() { if (!isFailFastSupported()) { return; diff --git a/src/test/java/org/apache/commons/collections4/list/CursorableLinkedListTest.java b/src/test/java/org/apache/commons/collections4/list/CursorableLinkedListTest.java index 9bb54920ce..5030614ec4 100644 --- a/src/test/java/org/apache/commons/collections4/list/CursorableLinkedListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/CursorableLinkedListTest.java @@ -28,9 +28,8 @@ import java.util.ListIterator; import java.util.NoSuchElementException; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; +import org.junit.Test; /** * Test class. @@ -41,7 +40,7 @@ public CursorableLinkedListTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(CursorableLinkedListTest.class); } @@ -57,6 +56,7 @@ public CursorableLinkedList makeObject() { return new CursorableLinkedList<>(); } + @Test @SuppressWarnings("unchecked") public void testAdd() { assertEquals("[]", list.toString()); @@ -88,6 +88,7 @@ public void testAdd() { assertEquals("[-2, -1, 0, A, B, C, 1, 2, 3, 4, 5, A, B, C]", list.toString()); } + @Test @SuppressWarnings("unchecked") public void testClear() { assertEquals(0, list.size()); @@ -124,6 +125,7 @@ public void testClear() { assertTrue(list.isEmpty()); } + @Test @SuppressWarnings("unchecked") public void testContains() { assertFalse(list.contains("A")); @@ -139,6 +141,7 @@ public void testContains() { assertFalse(list.contains("A")); } + @Test @SuppressWarnings("unchecked") public void testContainsAll() { assertTrue(list.containsAll(list)); @@ -160,6 +163,7 @@ public void testContainsAll() { assertTrue(list.containsAll(list)); } + @Test @SuppressWarnings("unchecked") public void testCursorNavigation() { list.add((E) "1"); @@ -215,6 +219,7 @@ public void testCursorNavigation() { it.close(); } + @Test @SuppressWarnings("unchecked") public void testCursorSet() { list.add((E) "1"); @@ -240,6 +245,7 @@ public void testCursorSet() { it.close(); } + @Test @SuppressWarnings("unchecked") public void testCursorRemove() { list.add((E) "1"); @@ -281,6 +287,7 @@ public void testCursorRemove() { it.close(); } + @Test @SuppressWarnings("unchecked") public void testCursorAdd() { final CursorableLinkedList.Cursor it = list.cursor(); @@ -300,6 +307,7 @@ public void testCursorAdd() { it.close(); } + @Test @SuppressWarnings("unchecked") public void testCursorConcurrentModification() { // this test verifies that cursors remain valid when the list @@ -360,6 +368,7 @@ public void testCursorConcurrentModification() { c2.close(); // not necessary } + @Test @SuppressWarnings("unchecked") public void testCursorNextIndexMid() { list.add((E) "1"); @@ -381,6 +390,7 @@ public void testCursorNextIndexMid() { assertEquals("3", c1.next()); } + @Test @SuppressWarnings("unchecked") public void testCursorNextIndexFirst() { list.add((E) "1"); @@ -398,6 +408,7 @@ public void testCursorNextIndexFirst() { assertEquals("3", c1.next()); } + @Test @SuppressWarnings("unchecked") public void testCursorNextIndexAddBefore() { list.add((E) "1"); @@ -414,6 +425,7 @@ public void testCursorNextIndexAddBefore() { assertEquals("2", c1.next()); } + @Test @SuppressWarnings("unchecked") public void testCursorNextIndexAddNext() { list.add((E) "1"); @@ -431,6 +443,7 @@ public void testCursorNextIndexAddNext() { assertEquals("1", c1.next()); } + @Test @SuppressWarnings("unchecked") public void testCursorNextIndexAddAfter() { list.add((E) "1"); @@ -448,6 +461,7 @@ public void testCursorNextIndexAddAfter() { assertEquals("0", c1.next()); } + @Test @SuppressWarnings("unchecked") public void testInternalState_CursorNextNextPreviousRemoveIndex1ByList() { list.add((E) "A"); @@ -474,6 +488,7 @@ public void testInternalState_CursorNextNextPreviousRemoveIndex1ByList() { assertThrows(IllegalStateException.class, () -> c1.remove()); } + @Test @SuppressWarnings("unchecked") public void testInternalState_CursorNextRemoveIndex1ByList() { list.add((E) "A"); @@ -498,6 +513,7 @@ public void testInternalState_CursorNextRemoveIndex1ByList() { assertThrows(IllegalStateException.class, () -> c1.remove()); } + @Test @SuppressWarnings("unchecked") public void testInternalState_CursorNextNextRemoveIndex1ByList() { list.add((E) "A"); @@ -523,6 +539,7 @@ public void testInternalState_CursorNextNextRemoveIndex1ByList() { assertThrows(IllegalStateException.class, () -> c1.remove()); } + @Test @SuppressWarnings("unchecked") public void testInternalState_CursorNextNextNextRemoveIndex1ByList() { list.add((E) "A"); @@ -549,6 +566,7 @@ public void testInternalState_CursorNextNextNextRemoveIndex1ByList() { assertThrows(IllegalStateException.class, () -> c1.remove()); } + @Test @SuppressWarnings("unchecked") public void testInternalState_CursorNextNextPreviousRemoveByIterator() { list.add((E) "A"); @@ -573,6 +591,7 @@ public void testInternalState_CursorNextNextPreviousRemoveByIterator() { assertThrows(IllegalStateException.class, () -> c1.remove()); } + @Test @SuppressWarnings("unchecked") public void testInternalState_CursorNextNextRemoveByIterator() { list.add((E) "A"); @@ -596,6 +615,7 @@ public void testInternalState_CursorNextNextRemoveByIterator() { assertThrows(IllegalStateException.class, () -> c1.remove()); } + @Test @SuppressWarnings("unchecked") public void testInternalState_CursorNextNextPreviousAddIndex1ByList() { list.add((E) "A"); @@ -621,6 +641,7 @@ public void testInternalState_CursorNextNextPreviousAddIndex1ByList() { assertThrows(IllegalStateException.class, () -> c1.remove()); } + @Test @SuppressWarnings("unchecked") public void testInternalState_CursorNextAddIndex1ByList() { list.add((E) "A"); @@ -644,6 +665,7 @@ public void testInternalState_CursorNextAddIndex1ByList() { assertThrows(IllegalStateException.class, () -> c1.remove()); } + @Test @SuppressWarnings("unchecked") public void testInternalState_CursorNextNextAddIndex1ByList() { list.add((E) "A"); @@ -667,6 +689,7 @@ public void testInternalState_CursorNextNextAddIndex1ByList() { assertThrows(IllegalStateException.class, () -> c1.remove()); } + @Test @SuppressWarnings("unchecked") public void testInternalState_CursorNextNextPreviousAddByIterator() { list.add((E) "A"); @@ -690,6 +713,7 @@ public void testInternalState_CursorNextNextPreviousAddByIterator() { assertThrows(IllegalStateException.class, () -> c1.remove()); } + @Test @SuppressWarnings("unchecked") public void testInternalState_CursorNextNextAddByIterator() { list.add((E) "A"); @@ -713,6 +737,7 @@ public void testInternalState_CursorNextNextAddByIterator() { assertThrows(IllegalStateException.class, () -> c1.remove()); } + @Test @SuppressWarnings("unchecked") public void testInternalState_CursorNextNextRemoveByListSetByIterator() { list.add((E) "A"); @@ -734,6 +759,7 @@ public void testInternalState_CursorNextNextRemoveByListSetByIterator() { assertThrows(IllegalStateException.class, () -> c1.set((E) "Z")); } + @Test @SuppressWarnings("unchecked") public void testInternalState_CursorNextNextPreviousSetByIterator() { list.add((E) "A"); @@ -759,6 +785,7 @@ public void testInternalState_CursorNextNextPreviousSetByIterator() { assertThrows(IllegalStateException.class, () -> c1.remove()); } + @Test @SuppressWarnings("unchecked") public void testInternalState_CursorNextNextSetByIterator() { list.add((E) "A"); @@ -783,6 +810,7 @@ public void testInternalState_CursorNextNextSetByIterator() { assertThrows(IllegalStateException.class, () -> c1.remove()); } + @Test @SuppressWarnings("unchecked") public void testEqualsAndHashCode() { assertEquals(list, list); @@ -847,6 +875,7 @@ public void testEqualsAndHashCode() { assertFalse(list2.equals(list)); } + @Test @SuppressWarnings("unchecked") public void testGet() { assertThrows(IndexOutOfBoundsException.class, () -> list.get(0), @@ -865,6 +894,7 @@ public void testGet() { ); } + @Test @SuppressWarnings("unchecked") public void testIndexOf() { assertEquals(-1, list.indexOf("A")); @@ -886,6 +916,7 @@ public void testIndexOf() { assertEquals(2, list.lastIndexOf("B")); } + @Test @SuppressWarnings("unchecked") public void testIsEmpty() { assertTrue(list.isEmpty()); @@ -899,6 +930,7 @@ public void testIsEmpty() { assertTrue(list.isEmpty()); } + @Test @SuppressWarnings("unchecked") public void testIterator() { list.add((E) "1"); @@ -943,6 +975,7 @@ public void testIterator() { assertFalse(it.hasNext()); } + @Test @SuppressWarnings("unchecked") public void testListIteratorNavigation() { list.add((E) "1"); @@ -1027,6 +1060,7 @@ public void testListIteratorNavigation() { assertEquals(0, it.nextIndex()); } + @Test @Override @SuppressWarnings("unchecked") public void testListIteratorSet() { @@ -1052,6 +1086,7 @@ public void testListIteratorSet() { assertEquals("[A, B, 3, D, E]", list.toString()); } + @Test @SuppressWarnings("unchecked") public void testListIteratorRemove() { list.add((E) "1"); @@ -1094,6 +1129,7 @@ public void testListIteratorRemove() { assertEquals("[]", list.toString()); } + @Test @Override @SuppressWarnings("unchecked") public void testListIteratorAdd() { @@ -1113,6 +1149,7 @@ public void testListIteratorAdd() { assertEquals("[1, 2, 3, 4, 5]", list.toString()); } + @Test @SuppressWarnings("unchecked") public void testRemoveAll() { list.add((E) "1"); @@ -1133,6 +1170,7 @@ public void testRemoveAll() { assertFalse(list.removeAll(set)); } + @Test @SuppressWarnings("unchecked") public void testRemoveByIndex() { list.add((E) "1"); @@ -1153,6 +1191,7 @@ public void testRemoveByIndex() { assertEquals("[]", list.toString()); } + @Test @SuppressWarnings("unchecked") public void testRemove() { list.add((E) "1"); @@ -1190,6 +1229,7 @@ public void testRemove() { assertEquals("[]", list.toString()); } + @Test @SuppressWarnings("unchecked") public void testRetainAll() { list.add((E) "1"); @@ -1215,6 +1255,7 @@ public void testRetainAll() { assertFalse(list.retainAll(set)); } + @Test @SuppressWarnings("unchecked") public void testSet() { list.add((E) "1"); @@ -1235,6 +1276,7 @@ public void testSet() { assertEquals("[A, B, C, D, E]", list.toString()); } + @Test @SuppressWarnings("unchecked") public void testSubList() { list.add((E) "A"); @@ -1252,6 +1294,7 @@ public void testSubList() { assertEquals("[]", list.subList(5, 5).toString()); } + @Test @SuppressWarnings("unchecked") public void testSubListAddEnd() { list.add((E) "A"); @@ -1269,6 +1312,7 @@ public void testSubListAddEnd() { assertEquals("[F, G]", sublist.toString()); } + @Test @SuppressWarnings("unchecked") public void testSubListAddBegin() { list.add((E) "A"); @@ -1286,6 +1330,7 @@ public void testSubListAddBegin() { assertEquals("[a, b]", sublist.toString()); } + @Test @SuppressWarnings("unchecked") public void testSubListAddMiddle() { list.add((E) "A"); @@ -1303,6 +1348,7 @@ public void testSubListAddMiddle() { assertEquals("[B, C, a, b]", sublist.toString()); } + @Test @SuppressWarnings("unchecked") public void testSubListRemove() { list.add((E) "A"); @@ -1325,6 +1371,7 @@ public void testSubListRemove() { assertEquals("[A, E]", list.toString()); } + @Test @SuppressWarnings("unchecked") public void testToArray() { list.add((E) "1"); @@ -1369,6 +1416,7 @@ public void testToArray() { assertEquals(5, elts4b.length); } + @Test @SuppressWarnings("unchecked") public void testSerialization() throws Exception { list.add((E) "A"); @@ -1392,6 +1440,7 @@ public void testSerialization() throws Exception { assertEquals(list, list2); } + @Test @SuppressWarnings("unchecked") public void testSerializationWithOpenCursor() throws Exception { list.add((E) "A"); @@ -1414,6 +1463,7 @@ public void testSerializationWithOpenCursor() throws Exception { assertEquals(list, list2); } + @Test @SuppressWarnings("unchecked") public void testLongSerialization() throws Exception { // recursive serialization will cause a stack diff --git a/src/test/java/org/apache/commons/collections4/list/FixedSizeListTest.java b/src/test/java/org/apache/commons/collections4/list/FixedSizeListTest.java index 81e20b079e..3136603558 100644 --- a/src/test/java/org/apache/commons/collections4/list/FixedSizeListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/FixedSizeListTest.java @@ -23,6 +23,7 @@ import java.util.List; import org.junit.jupiter.api.Assertions; +import org.junit.Test; /** * Extension of {@link AbstractListTest} for exercising the {@link FixedSizeList} @@ -69,6 +70,7 @@ public String getCompatibilityVersion() { // writeExternalFormToDisk((java.io.Serializable) getCollection(), "src/test/resources/data/test/FixedSizeList.fullCollection.version4.obj"); // } + @Test public void testListAllowsMutationOfUnderlyingCollection() { final List decoratedList = new ArrayList<>(); @@ -93,13 +95,14 @@ private FixedSizeList initFixedSizeList() { return FixedSizeList.fixedSizeList(decoratedList); } + @Test public void testAdd() { final FixedSizeList fixedSizeList = initFixedSizeList(); assertThrows(UnsupportedOperationException.class, () -> fixedSizeList.add(2, "New Value")); } - + @Test public void testAddAll() { final FixedSizeList fixedSizeList = initFixedSizeList(); @@ -110,12 +113,14 @@ public void testAddAll() { assertThrows(UnsupportedOperationException.class, () -> fixedSizeList.addAll(2, addList)); } + @Test public void testRemove() { final FixedSizeList fixedSizeList = initFixedSizeList(); assertThrows(UnsupportedOperationException.class, () -> fixedSizeList.remove(1)); } + @Test public void testSubList() { final FixedSizeList fixedSizeList = initFixedSizeList(); @@ -124,12 +129,14 @@ public void testSubList() { Assertions.assertEquals(0, subFixedSizeList.size()); } + @Test public void testIsFull() { final FixedSizeList fixedSizeList = initFixedSizeList(); Assertions.assertTrue(fixedSizeList.isFull()); } + @Test public void testMaxSize() { final FixedSizeList fixedSizeList = initFixedSizeList(); diff --git a/src/test/java/org/apache/commons/collections4/list/GrowthListTest.java b/src/test/java/org/apache/commons/collections4/list/GrowthListTest.java index 3fc2f9572a..538a4c1bb8 100644 --- a/src/test/java/org/apache/commons/collections4/list/GrowthListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/GrowthListTest.java @@ -27,6 +27,7 @@ import java.util.List; import org.junit.jupiter.api.function.Executable; +import org.junit.Test; /** * Extension of {@link AbstractListTest} for exercising the {@link GrowthList}. @@ -50,6 +51,7 @@ public List makeFullCollection() { return GrowthList.growthList(list); } + @Test public void testGrowthList() { final Integer zero = Integer.valueOf(0); final Integer one = Integer.valueOf(1); @@ -64,6 +66,7 @@ public void testGrowthList() { assertEquals(3, grower.size()); } + @Test public void testGrowthAdd() { final Integer one = Integer.valueOf(1); final GrowthList grower = new GrowthList<>(); @@ -74,6 +77,7 @@ public void testGrowthAdd() { assertEquals(one, grower.get(1)); } + @Test public void testGrowthAddAll() { final Integer one = Integer.valueOf(1); final Integer two = Integer.valueOf(2); @@ -89,6 +93,7 @@ public void testGrowthAddAll() { assertEquals(two, grower.get(2)); } + @Test public void testGrowthSet1() { final Integer one = Integer.valueOf(1); final GrowthList grower = new GrowthList<>(); @@ -99,6 +104,7 @@ public void testGrowthSet1() { assertEquals(one, grower.get(1)); } + @Test public void testGrowthSet2() { final Integer one = Integer.valueOf(1); final GrowthList grower = new GrowthList<>(); @@ -111,6 +117,7 @@ public void testGrowthSet2() { /** * Override. */ + @Test @Override public void testListAddByIndexBoundsChecking() { final E element = getOtherElements()[0]; @@ -125,6 +132,7 @@ public void testListAddByIndexBoundsChecking() { /** * Override. */ + @Test @Override public void testListAddByIndexBoundsChecking2() { final E element = getOtherElements()[0]; @@ -136,6 +144,7 @@ public void testListAddByIndexBoundsChecking2() { /** * Override. */ + @Test @Override public void testListSetByIndexBoundsChecking() { final List list = makeObject(); @@ -147,6 +156,7 @@ public void testListSetByIndexBoundsChecking() { /** * Override. */ + @Test @Override public void testListSetByIndexBoundsChecking2() { final List list = makeFullCollection(); diff --git a/src/test/java/org/apache/commons/collections4/list/LazyListTest.java b/src/test/java/org/apache/commons/collections4/list/LazyListTest.java index e6c56c98da..aa7aabe7b2 100644 --- a/src/test/java/org/apache/commons/collections4/list/LazyListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/LazyListTest.java @@ -19,6 +19,7 @@ import org.apache.commons.collections4.AbstractObjectTest; import org.apache.commons.collections4.Factory; import org.apache.commons.collections4.Transformer; +import org.junit.Test; import java.time.LocalDateTime; import java.util.ArrayList; @@ -37,26 +38,31 @@ public Object makeObject() { return new LazyList<>(new ArrayList<>(), dateFactory); } + @Test @Override public void testSimpleSerialization() { // Factory and Transformer are not serializable } + @Test @Override public void testSerializeDeserializeThenCompare() { // Factory and Transformer are not serializable } + @Test @Override public void testCanonicalEmptyCollectionExists() { // Factory and Transformer are not serializable } + @Test @Override public void testCanonicalFullCollectionExists() { // Factory and Transformer are not serializable } + @Test public void testElementCreationWithFactory() { final Factory dateFactory = LocalDateTime::now; final List list = new LazyList<>(new ArrayList<>(), dateFactory); @@ -68,6 +74,7 @@ public void testElementCreationWithFactory() { assertFalse(list.isEmpty()); } + @Test public void testElementCreationWithTransformer() { final Factory dateFactory = LocalDateTime::now; final List list = new LazyList<>(new ArrayList<>(), dateFactory); @@ -79,6 +86,7 @@ public void testElementCreationWithTransformer() { assertFalse(list.isEmpty()); } + @Test public void testCreateNullGapsWithFactory() { final Factory dateFactory = LocalDateTime::now; final List list = new LazyList<>(new ArrayList<>(), dateFactory); @@ -88,6 +96,7 @@ public void testCreateNullGapsWithFactory() { assertNotNull(fourthElement); } + @Test public void testCreateNullGapsWithTransformer() { final List hours = Arrays.asList(7, 5, 8, 2); final Transformer dateFactory = input -> LocalDateTime.now().withHour(hours.get(input)); @@ -98,6 +107,7 @@ public void testCreateNullGapsWithTransformer() { assertNotNull(fourthElement); } + @Test public void testGetWithNull() { final List hours = Arrays.asList(7, 5, 8, 2); final Transformer transformer = input -> LocalDateTime.now().withHour(hours.get(input)); @@ -111,6 +121,7 @@ public void testGetWithNull() { assertNotNull(fourthElement); } + @Test public void testSubListWitheFactory() { final Factory dateFactory = LocalDateTime::now; final List list = new LazyList<>(new ArrayList<>(), dateFactory); @@ -120,6 +131,7 @@ public void testSubListWitheFactory() { testSubList(list); } + @Test public void testSubListWithTransformer() { final List hours = Arrays.asList(7, 5, 8, 2); final Transformer transformer = input -> LocalDateTime.now().withHour(hours.get(input)); diff --git a/src/test/java/org/apache/commons/collections4/list/NodeCachingLinkedListTest.java b/src/test/java/org/apache/commons/collections4/list/NodeCachingLinkedListTest.java index 13b22e58ea..131a3ecd32 100644 --- a/src/test/java/org/apache/commons/collections4/list/NodeCachingLinkedListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/NodeCachingLinkedListTest.java @@ -19,9 +19,8 @@ import java.util.Arrays; import java.util.LinkedList; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; +import org.junit.Test; /** * Test class for NodeCachingLinkedList, a performance optimised LinkedList. @@ -33,7 +32,7 @@ public NodeCachingLinkedListTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(NodeCachingLinkedListTest.class); } @@ -47,6 +46,7 @@ public String getCompatibilityVersion() { return "4"; } + @Test @SuppressWarnings("unchecked") public void testShrinkCache() { if (!isRemoveSupported() || !isAddSupported()) { diff --git a/src/test/java/org/apache/commons/collections4/list/PredicatedListTest.java b/src/test/java/org/apache/commons/collections4/list/PredicatedListTest.java index 673953793e..be93001374 100644 --- a/src/test/java/org/apache/commons/collections4/list/PredicatedListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/PredicatedListTest.java @@ -23,6 +23,7 @@ import org.apache.commons.collections4.Predicate; import org.apache.commons.collections4.functors.TruePredicate; +import org.junit.Test; /** * Extension of {@link AbstractListTest} for exercising the @@ -64,6 +65,7 @@ public List makeTestList() { return decorateList(new ArrayList(), testPredicate); } + @Test @SuppressWarnings("unchecked") public void testIllegalAdd() { final List list = makeTestList(); @@ -75,6 +77,7 @@ public void testIllegalAdd() { assertFalse("Collection shouldn't contain illegal element", list.contains(i)); } + @Test @SuppressWarnings("unchecked") public void testIllegalAddAll() { final List list = makeTestList(); @@ -93,6 +96,7 @@ public void testIllegalAddAll() { assertFalse("List shouldn't contain illegal element", list.contains("four")); } + @Test @SuppressWarnings("unchecked") public void testIllegalSet() { final List list = makeTestList(); @@ -100,6 +104,7 @@ public void testIllegalSet() { "Integer should fail string predicate."); } + @Test @SuppressWarnings("unchecked") public void testLegalAddAll() { final List list = makeTestList(); @@ -115,6 +120,7 @@ public void testLegalAddAll() { assertTrue("List should contain legal element", list.contains("three")); } + @Test public void testSubList() { final List list = makeTestList(); list.add((E) "zero"); 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 87de370804..75301176ee 100644 --- a/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java @@ -17,6 +17,7 @@ package org.apache.commons.collections4.list; import org.apache.commons.collections4.set.UnmodifiableSet; +import org.junit.Test; import java.util.*; @@ -81,6 +82,7 @@ public List makeObject() { return new SetUniqueList<>(new ArrayList(), new HashSet()); } + @Test @SuppressWarnings("unchecked") public void testAdd() { final SetUniqueList lset = new SetUniqueList<>(new ArrayList(), new HashSet()); @@ -96,6 +98,7 @@ public void testAdd() { assertEquals("Unique element was not added.", 2, lset.size()); } + @Test @SuppressWarnings("unchecked") public void testAddAll() { final SetUniqueList lset = new SetUniqueList<>(new ArrayList(), new HashSet()); @@ -106,6 +109,7 @@ public void testAddAll() { assertEquals("Duplicate element was added.", 1, lset.size()); } + @Test @Override public void testCollectionAddAll() { // override for set behavior @@ -135,6 +139,7 @@ public void testCollectionAddAll() { size + elements.length, getCollection().size()); } + @Test @Override public void testCollectionIteratorRemove() { try { @@ -144,6 +149,7 @@ public void testCollectionIteratorRemove() { extraVerify = true; } } + @Test public void testCollections304() { final List list = new LinkedList<>(); final SetUniqueList decoratedList = SetUniqueList.setUniqueList(list); @@ -167,6 +173,7 @@ public void testCollections304() { assertEquals(4, decoratedList.size()); } + @Test @SuppressWarnings("unchecked") public void testCollections307() { List list = new ArrayList<>(); @@ -208,6 +215,7 @@ public void testCollections307() { assertFalse(subUniqueList.contains("World")); // fails } + @Test public void testCollections701() { final SetUniqueList uniqueList = new SetUniqueList<>(new ArrayList<>(), new HashSet<>()); final Integer obj1 = Integer.valueOf(1); @@ -233,6 +241,7 @@ public void testCollections701() { assertEquals(4, decoratedList.size()); } + @Test public void testFactory() { final Integer[] array = { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(1) }; final ArrayList list = new ArrayList<>(Arrays.asList(array)); @@ -245,6 +254,7 @@ public void testFactory() { assertEquals(Integer.valueOf(2), list.get(1)); } + @Test public void testIntCollectionAddAll() { // make a SetUniqueList with one element final List list = new SetUniqueList<>(new ArrayList(), new HashSet()); @@ -270,6 +280,7 @@ public void testIntCollectionAddAll() { assertEquals("Third new element should be at index 0", thirdNewElement, list.get(0)); } + @Test @SuppressWarnings("unchecked") public void testListIterator() { final SetUniqueList lset = new SetUniqueList<>(new ArrayList(), new HashSet()); @@ -292,6 +303,7 @@ public void testListIterator() { assertEquals("Duplicate element was added", 2, lset.size()); } + @Test @Override public void testListIteratorAdd() { // override to cope with Set behavior @@ -321,6 +333,7 @@ public void testListIteratorAdd() { } } + @Test @Override public void testListIteratorSet() { // override to block @@ -331,6 +344,7 @@ public void testListIteratorSet() { assertThrows(UnsupportedOperationException.class, () -> it.set(null)); } + @Test @Override @SuppressWarnings("unchecked") public void testListSetByIndex() { @@ -345,6 +359,7 @@ public void testListSetByIndex() { assertEquals(Long.valueOf(1000), getCollection().get(1)); // set into 2, but shifted down to 1 } + @Test @SuppressWarnings("unchecked") public void testRetainAll() { final List list = new ArrayList<>(10); @@ -367,6 +382,7 @@ public void testRetainAll() { assertTrue(uniqueList.contains(Integer.valueOf(8))); } + @Test @SuppressWarnings("unchecked") public void testRetainAllWithInitialList() { // initialized with empty list @@ -393,6 +409,7 @@ public void testRetainAllWithInitialList() { assertTrue(uniqueList.contains(Integer.valueOf(8))); } + @Test @SuppressWarnings("unchecked") public void testSet() { final SetUniqueList lset = new SetUniqueList<>(new ArrayList(), new HashSet()); @@ -432,6 +449,7 @@ public void testSet() { assertSame(obj1, lset.get(0)); } + @Test public void testSetCollections444() { final SetUniqueList lset = new SetUniqueList<>(new ArrayList(), new HashSet()); @@ -450,6 +468,7 @@ public void testSetCollections444() { assertTrue(lset.contains(obj2)); } + @Test @SuppressWarnings("unchecked") public void testSetDownwardsInList() { /* @@ -478,6 +497,7 @@ public void testSetDownwardsInList() { assertTrue(s.contains(b)); assertFalse(s.contains(a)); } + @Test @SuppressWarnings("unchecked") public void testSetInBiggerList() { /* @@ -514,6 +534,7 @@ public void testSetInBiggerList() { assertTrue(s.contains(c)); } + @Test @SuppressWarnings("unchecked") public void testSetUpwardsInList() { /* @@ -550,6 +571,7 @@ public void testSetUpwardsInList() { assertTrue(s.contains(c)); } + @Test public void testSubListIsUnmodifiable() { resetFull(); final List subList = getCollection().subList(1, 3); @@ -557,6 +579,7 @@ public void testSubListIsUnmodifiable() { assertThrows(UnsupportedOperationException.class, () -> subList.remove(0)); } + @Test @SuppressWarnings("unchecked") public void testUniqueListDoubleInsert() { final List l = SetUniqueList.setUniqueList(new LinkedList()); @@ -572,6 +595,7 @@ public void testUniqueListDoubleInsert() { assertEquals(1, l.size()); } + @Test @SuppressWarnings("unchecked") public void testUniqueListReInsert() { final List l = SetUniqueList.setUniqueList(new LinkedList()); @@ -607,6 +631,7 @@ public void verify() { } } + @Test @SuppressWarnings("unchecked") public void testCreateSetBasedOnList() { final List list = new ArrayList<>(); diff --git a/src/test/java/org/apache/commons/collections4/list/TransformedListTest.java b/src/test/java/org/apache/commons/collections4/list/TransformedListTest.java index cef6b57516..cea63c1d39 100644 --- a/src/test/java/org/apache/commons/collections4/list/TransformedListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/TransformedListTest.java @@ -23,6 +23,7 @@ import org.apache.commons.collections4.Transformer; import org.apache.commons.collections4.collection.TransformedCollectionTest; +import org.junit.Test; /** * Extension of {@link AbstractListTest} for exercising the {@link TransformedList} @@ -59,6 +60,7 @@ public List makeFullCollection() { return TransformedList.transformingList(list, (Transformer) TransformedCollectionTest.NOOP_TRANSFORMER); } + @Test @SuppressWarnings("unchecked") public void testTransformedList() { final List list = TransformedList.transformingList(new ArrayList(), (Transformer) TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER); @@ -107,6 +109,7 @@ public void testTransformedList() { assertEquals(Integer.valueOf(2), list.get(2)); } + @Test public void testTransformedList_decorateTransform() { final List originalList = new ArrayList<>(); final Object[] els = {"1", "3", "5", "7", "2", "4", "6"}; @@ -124,6 +127,7 @@ public void testTransformedList_decorateTransform() { assertTrue(list.remove(Integer.valueOf((String) els[0]))); } + @Test public void testSubList() { final List list = makeObject(); List subList = list.subList(0, 0); diff --git a/src/test/java/org/apache/commons/collections4/list/TreeListTest.java b/src/test/java/org/apache/commons/collections4/list/TreeListTest.java index 078f37a3eb..db38ef2e9e 100644 --- a/src/test/java/org/apache/commons/collections4/list/TreeListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/TreeListTest.java @@ -20,9 +20,8 @@ import java.util.List; import java.util.ListIterator; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; +import org.junit.Test; /** * JUnit tests @@ -48,7 +47,7 @@ public TreeListTest(final String name) { // benchmark(new NodeCachingLinkedList()); // } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(TreeListTest.class); } @@ -108,6 +107,7 @@ public TreeList makeObject() { return new TreeList<>(); } + @Test @SuppressWarnings("unchecked") public void testAddMultiple() { final List l = makeObject(); @@ -125,6 +125,7 @@ public void testAddMultiple() { assertEquals("harald", l.get(5)); } + @Test @SuppressWarnings("unchecked") public void testRemove() { final List l = makeObject(); @@ -164,6 +165,7 @@ public void testRemove() { assertEquals("harald", l.get(i++)); } + @Test @SuppressWarnings("unchecked") public void testInsertBefore() { final List l = makeObject(); @@ -173,6 +175,7 @@ public void testInsertBefore() { assertEquals("erna", l.get(1)); } + @Test @SuppressWarnings("unchecked") public void testIndexOf() { final List l = makeObject(); @@ -214,6 +217,7 @@ public void testIndexOf() { // l.add("A6"); // } + @Test public void testBug35258() { final Object objectToRemove = Integer.valueOf(3); @@ -244,6 +248,7 @@ public void testBug35258() { assertFalse(li.hasNext()); } + @Test public void testBugCollections447() { final List treeList = new TreeList<>(); treeList.add("A"); @@ -264,6 +269,7 @@ public void testBugCollections447() { assertEquals("A", li.previous()); } + @Test @SuppressWarnings("boxing") // OK in test code public void testIterationOrder() { // COLLECTIONS-433: @@ -290,6 +296,7 @@ public void testIterationOrder() { } } + @Test @SuppressWarnings("boxing") // OK in test code public void testIterationOrderAfterAddAll() { // COLLECTIONS-433: diff --git a/src/test/java/org/apache/commons/collections4/list/UnmodifiableListTest.java b/src/test/java/org/apache/commons/collections4/list/UnmodifiableListTest.java index 5751ea5cf7..e90c75b53c 100644 --- a/src/test/java/org/apache/commons/collections4/list/UnmodifiableListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/UnmodifiableListTest.java @@ -24,6 +24,8 @@ import java.util.Iterator; import java.util.List; +import org.junit.Test; + /** * Extension of {@link AbstractListTest} for exercising the * {@link UnmodifiableList} implementation. @@ -75,12 +77,14 @@ protected void setupList() { /** * Verify that base list and sublists are not modifiable */ + @Test public void testUnmodifiable() { setupList(); verifyUnmodifiable(list); verifyUnmodifiable(list.subList(0, 2)); } + @Test public void testDecorateFactory() { final List list = makeObject(); assertSame(list, UnmodifiableList.unmodifiableList(list)); @@ -117,6 +121,7 @@ protected void verifyUnmodifiable(final List list) { /** * Verify that iterator is not modifiable */ + @Test public void testUnmodifiableIterator() { setupList(); final Iterator iterator = list.iterator(); diff --git a/src/test/java/org/apache/commons/collections4/map/AbstractIterableMapTest.java b/src/test/java/org/apache/commons/collections4/map/AbstractIterableMapTest.java index f11d681c8d..36b452daa8 100644 --- a/src/test/java/org/apache/commons/collections4/map/AbstractIterableMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/AbstractIterableMapTest.java @@ -26,6 +26,7 @@ import org.apache.commons.collections4.IterableMap; import org.apache.commons.collections4.MapIterator; import org.apache.commons.collections4.iterators.AbstractMapIteratorTest; +import org.junit.Test; /** * Abstract test class for {@link IterableMap} methods and contracts. @@ -55,6 +56,7 @@ public IterableMap makeFullMap() { return (IterableMap) super.makeFullMap(); } + @Test public void testFailFastEntrySet() { if (!isRemoveSupported()) { return; @@ -77,6 +79,7 @@ public void testFailFastEntrySet() { assertThrows(ConcurrentModificationException.class, () -> finalIt1.next()); } + @Test public void testFailFastKeySet() { if (!isRemoveSupported()) { return; @@ -99,6 +102,7 @@ public void testFailFastKeySet() { assertThrows(ConcurrentModificationException.class, () -> finalIt1.next()); } + @Test public void testFailFastValues() { if (!isRemoveSupported()) { return; 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 69be394f67..3099c28dd1 100644 --- a/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java @@ -37,6 +37,7 @@ import org.apache.commons.collections4.collection.AbstractCollectionTest; import org.apache.commons.collections4.keyvalue.DefaultMapEntry; import org.apache.commons.collections4.set.AbstractSetTest; +import org.junit.Test; /** * Abstract test class for {@link java.util.Map} methods and contracts. @@ -480,6 +481,7 @@ public String getCompatibilityVersion() { * value if useNullValue() is true and may only have duplicate values if * isAllowDuplicateValues() returns true. */ + @Test public void testSampleMappings() { final Object[] keys = getSampleKeys(); final Object[] values = getSampleValues(); @@ -531,6 +533,7 @@ public void testSampleMappings() { * Test to ensure that makeEmptyMap and makeFull returns a new non-null * map with each invocation. */ + @Test public void testMakeMap() { final Map em = makeObject(); assertNotNull("failure in test: makeEmptyMap must return a non-null map.", em); @@ -554,6 +557,7 @@ public void testMakeMap() { /** * Tests Map.isEmpty() */ + @Test public void testMapIsEmpty() { resetEmpty(); assertTrue("Map.isEmpty() should return true with an empty map", getMap().isEmpty()); @@ -567,6 +571,7 @@ public void testMapIsEmpty() { /** * Tests Map.size() */ + @Test public void testMapSize() { resetEmpty(); assertEquals("Map.size() should be 0 with an empty map", @@ -587,6 +592,7 @@ public void testMapSize() { * elements, this method checks to ensure clear throws an * UnsupportedOperationException. */ + @Test public void testMapClear() { if (!isRemoveSupported()) { resetFull(); @@ -611,6 +617,7 @@ public void testMapClear() { * sample keys on a map created using an empty map and returns true for * all sample keys returned on a full map. */ + @Test public void testMapContainsKey() { final Object[] keys = getSampleKeys(); @@ -633,6 +640,7 @@ public void testMapContainsKey() { * sample values on an empty map and returns true for all sample values on * a full map. */ + @Test public void testMapContainsValue() { final Object[] values = getSampleValues(); @@ -654,6 +662,7 @@ public void testMapContainsValue() { /** * Tests Map.equals(Object) */ + @Test public void testMapEquals() { resetEmpty(); assertEquals("Empty maps unequal.", getMap(), confirmed); @@ -680,6 +689,7 @@ public void testMapEquals() { /** * Tests Map.get(Object) */ + @Test public void testMapGet() { resetEmpty(); @@ -701,6 +711,7 @@ public void testMapGet() { /** * Tests Map.hashCode() */ + @Test public void testMapHashCode() { resetEmpty(); assertEquals("Empty maps have different hashCodes.", getMap().hashCode(), confirmed.hashCode()); @@ -718,6 +729,7 @@ public void testMapHashCode() { * default implementation just verifies that the toString() method does * not return null. */ + @Test public void testMapToString() { resetEmpty(); assertNotNull("Empty map toString() should not return null", getMap().toString()); @@ -732,6 +744,7 @@ public void testMapToString() { * Compare the current serialized form of the Map * against the canonical version in SCM. */ + @Test public void testEmptyMapCompatibility() throws Exception { /* * Create canonical objects with this code @@ -754,6 +767,7 @@ public void testEmptyMapCompatibility() throws Exception { * Compare the current serialized form of the Map * against the canonical version in SCM. */ + @Test public void testFullMapCompatibility() throws Exception { /* * Create canonical objects with this code @@ -775,6 +789,7 @@ public void testFullMapCompatibility() throws Exception { /** * Tests Map.put(Object, Object) */ + @Test public void testMapPut() { resetEmpty(); final K[] keys = getSampleKeys(); @@ -856,6 +871,7 @@ public void testMapPut() { /** * Tests Map.put(null, value) */ + @Test public void testMapPutNullKey() { resetFull(); final V[] values = getSampleValues(); @@ -875,6 +891,7 @@ public void testMapPutNullKey() { /** * Tests Map.put(null, value) */ + @Test public void testMapPutNullValue() { resetFull(); final K[] keys = getSampleKeys(); @@ -894,6 +911,7 @@ public void testMapPutNullValue() { /** * Tests Map.putAll(map) */ + @Test public void testMapPutAll() { if (!isPutAddSupported()) { if (!isPutChangeSupported()) { @@ -953,6 +971,7 @@ public void testMapPutAll() { /** * Tests Map.remove(Object) */ + @Test public void testMapRemove() { if (!isRemoveSupported()) { resetFull(); @@ -999,6 +1018,7 @@ public void testMapRemove() { * Tests that the {@link Map#values} collection is backed by * the underlying map for clear(). */ + @Test public void testValuesClearChangesMap() { if (!isRemoveSupported()) { return; @@ -1027,6 +1047,7 @@ public void testValuesClearChangesMap() { * Tests that the {@link Map#keySet} collection is backed by * the underlying map for clear(). */ + @Test public void testKeySetClearChangesMap() { if (!isRemoveSupported()) { return; @@ -1055,6 +1076,7 @@ public void testKeySetClearChangesMap() { * Tests that the {@link Map#entrySet()} collection is backed by * the underlying map for clear(). */ + @Test public void testEntrySetClearChangesMap() { if (!isRemoveSupported()) { return; @@ -1079,6 +1101,7 @@ public void testEntrySetClearChangesMap() { assertTrue(entrySet.isEmpty()); } + @Test public void testEntrySetContains1() { resetFull(); final Set> entrySet = getMap().entrySet(); @@ -1086,6 +1109,7 @@ public void testEntrySetContains1() { assertTrue(entrySet.contains(entry)); } + @Test public void testEntrySetContains2() { resetFull(); final Set> entrySet = getMap().entrySet(); @@ -1094,6 +1118,7 @@ public void testEntrySetContains2() { assertTrue(entrySet.contains(test)); } + @Test @SuppressWarnings("unchecked") public void testEntrySetContains3() { resetFull(); @@ -1105,6 +1130,7 @@ public void testEntrySetContains3() { assertFalse(entrySet.contains(test)); } + @Test public void testEntrySetRemove1() { if (!isRemoveSupported()) { return; @@ -1120,6 +1146,7 @@ public void testEntrySetRemove1() { assertEquals(size - 1, getMap().size()); } + @Test public void testEntrySetRemove2() { if (!isRemoveSupported()) { return; @@ -1136,6 +1163,7 @@ public void testEntrySetRemove2() { assertEquals(size - 1, getMap().size()); } + @Test @SuppressWarnings("unchecked") public void testEntrySetRemove3() { if (!isRemoveSupported()) { @@ -1170,6 +1198,7 @@ public void testEntrySetRemove3() { * 9573. *

*/ + @Test public void testValuesRemoveChangesMap() { resetFull(); final V[] sampleValues = getSampleValues(); @@ -1195,6 +1224,7 @@ public void testValuesRemoveChangesMap() { /** * Tests values.removeAll. */ + @Test public void testValuesRemoveAll() { resetFull(); final Collection values = getMap().values(); @@ -1221,6 +1251,7 @@ public void testValuesRemoveAll() { /** * Test values.retainAll. */ + @Test public void testValuesRetainAll() { resetFull(); final Collection values = getMap().values(); @@ -1247,6 +1278,7 @@ public void testValuesRetainAll() { /** * Verifies that values.iterator.remove changes the underlying map. */ + @Test @SuppressWarnings("boxing") // OK in test code public void testValuesIteratorRemoveChangesMap() { resetFull(); @@ -1280,6 +1312,7 @@ public void testValuesIteratorRemoveChangesMap() { * the underlying map by removing from the keySet set * and testing if the key was removed from the map. */ + @Test public void testKeySetRemoveChangesMap() { resetFull(); final K[] sampleKeys = getSampleKeys(); @@ -1298,6 +1331,7 @@ public void testKeySetRemoveChangesMap() { /** * Test keySet.removeAll. */ + @Test public void testKeySetRemoveAll() { resetFull(); final Set keys = getMap().keySet(); @@ -1322,6 +1356,7 @@ public void testKeySetRemoveAll() { /** * Test keySet.retainAll. */ + @Test public void testKeySetRetainAll() { resetFull(); final Set keys = getMap().keySet(); @@ -1346,6 +1381,7 @@ public void testKeySetRetainAll() { /** * Verify that keySet.iterator.remove changes the underlying map. */ + @Test public void testKeySetIteratorRemoveChangesMap() { resetFull(); for (final Iterator iter = getMap().keySet().iterator(); iter.hasNext();) { @@ -1364,6 +1400,7 @@ public void testKeySetIteratorRemoveChangesMap() { * the underlying map by removing from the entrySet set * and testing if the entry was removed from the map. */ + @Test public void testEntrySetRemoveChangesMap() { resetFull(); final K[] sampleKeys = getSampleKeys(); @@ -1383,6 +1420,7 @@ public void testEntrySetRemoveChangesMap() { /** * Test entrySet.removeAll. */ + @Test public void testEntrySetRemoveAll() { resetFull(); final K[] sampleKeys = getSampleKeys(); @@ -1418,6 +1456,7 @@ public void testEntrySetRemoveAll() { /** * Test entrySet.retainAll. */ + @Test public void testEntrySetRetainAll() { resetFull(); final K[] sampleKeys = getSampleKeys(); @@ -1453,6 +1492,7 @@ public void testEntrySetRetainAll() { /** * Verify that entrySet.iterator.remove changes the underlying map. */ + @Test public void testEntrySetIteratorRemoveChangesMap() { resetFull(); for (final Iterator> iter = getMap().entrySet().iterator(); iter.hasNext();) { @@ -1579,6 +1619,7 @@ public void resetEmpty() { TestMapEntrySet.this.setConfirmed(AbstractMapTest.this.getConfirmed().entrySet()); } + @Test public void testMapEntrySetIteratorEntry() { resetFull(); final Iterator> it = getCollection().iterator(); @@ -1595,6 +1636,7 @@ public void testMapEntrySetIteratorEntry() { assertEquals(getCollection().size(), count); } + @Test public void testMapEntrySetIteratorEntrySetValue() { final K key1 = getSampleKeys()[0]; final K key2 = getSampleKeys().length == 1 ? getSampleKeys()[0] : getSampleKeys()[1]; @@ -1665,6 +1707,7 @@ public Map.Entry getEntry(final Iterator> itConfirmed, fin return entry; } + @Test public void testMapEntrySetRemoveNonMapEntry() { if (!isRemoveSupported()) { return; 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 ece717f9e8..f34156b4e0 100644 --- a/src/test/java/org/apache/commons/collections4/map/AbstractOrderedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/AbstractOrderedMapTest.java @@ -32,6 +32,7 @@ import org.apache.commons.collections4.OrderedMapIterator; import org.apache.commons.collections4.comparators.NullComparator; import org.apache.commons.collections4.iterators.AbstractOrderedMapIteratorTest; +import org.junit.Test; /** * Abstract test class for {@link OrderedMap} methods and contracts. @@ -83,6 +84,7 @@ public K[] getSampleKeys() { return (K[]) list.toArray(); } + @Test public void testFirstKey() { resetEmpty(); OrderedMap ordered = getMap(); @@ -95,6 +97,7 @@ public void testFirstKey() { assertEquals(confirmedFirst, ordered.firstKey()); } + @Test public void testLastKey() { resetEmpty(); OrderedMap ordered = getMap(); @@ -110,6 +113,7 @@ public void testLastKey() { assertEquals(confirmedLast, ordered.lastKey()); } + @Test public void testNextKey() { resetEmpty(); OrderedMap ordered = getMap(); @@ -141,6 +145,7 @@ public void testNextKey() { } } + @Test public void testPreviousKey() { resetEmpty(); OrderedMap ordered = getMap(); diff --git a/src/test/java/org/apache/commons/collections4/map/AbstractSortedMapTest.java b/src/test/java/org/apache/commons/collections4/map/AbstractSortedMapTest.java index 051289d80c..b9eac3f5a5 100644 --- a/src/test/java/org/apache/commons/collections4/map/AbstractSortedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/AbstractSortedMapTest.java @@ -27,6 +27,7 @@ import java.util.TreeMap; import org.apache.commons.collections4.BulkTest; +import org.junit.Test; /** * Abstract test class for {@link java.util.SortedMap} methods and contracts. @@ -62,6 +63,7 @@ public SortedMap makeConfirmedMap() { return new TreeMap<>(); } + @Test public void testComparator() { // SortedMap sm = makeFullMap(); // no tests I can think of @@ -81,11 +83,13 @@ public SortedMap makeFullMap() { return (SortedMap) super.makeFullMap(); } + @Test public void testFirstKey() { final SortedMap sm = makeFullMap(); assertSame(sm.keySet().iterator().next(), sm.firstKey()); } + @Test public void testLastKey() { final SortedMap sm = makeFullMap(); K obj = null; @@ -231,6 +235,8 @@ public SortedMap makeObject() { public SortedMap makeFullMap() { return ((SortedMap) main.makeFullMap()).headMap(toKey); } + + @Test public void testHeadMapOutOfRange() { if (!isPutAddSupported()) { return; @@ -283,6 +289,8 @@ public SortedMap makeObject() { public SortedMap makeFullMap() { return ((SortedMap) main.makeFullMap()).tailMap(fromKey); } + + @Test public void testTailMapOutOfRange() { if (!isPutAddSupported()) { return; @@ -342,6 +350,8 @@ public SortedMap makeObject() { public SortedMap makeFullMap() { return ((SortedMap) main.makeFullMap()).subMap(fromKey, toKey); } + + @Test public void testSubMapOutOfRange() { if (!isPutAddSupported()) { return; diff --git a/src/test/java/org/apache/commons/collections4/map/CaseInsensitiveMapTest.java b/src/test/java/org/apache/commons/collections4/map/CaseInsensitiveMapTest.java index 1f6a0ef0b8..664112953c 100644 --- a/src/test/java/org/apache/commons/collections4/map/CaseInsensitiveMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/CaseInsensitiveMapTest.java @@ -21,9 +21,8 @@ import java.util.Map; import java.util.Set; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; +import org.junit.Test; /** * Tests for the {@link CaseInsensitiveMap} implementation. @@ -31,7 +30,7 @@ */ public class CaseInsensitiveMapTest extends AbstractIterableMapTest { - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(CaseInsensitiveMapTest.class); } @@ -49,6 +48,7 @@ public CaseInsensitiveMap makeObject() { return new CaseInsensitiveMap<>(); } + @Test @SuppressWarnings("unchecked") public void testCaseInsensitive() { final Map map = makeObject(); @@ -60,6 +60,7 @@ public void testCaseInsensitive() { assertEquals("Three", map.get("Two")); } + @Test @SuppressWarnings("unchecked") public void testClone() { final CaseInsensitiveMap map = new CaseInsensitiveMap<>(10); @@ -72,12 +73,14 @@ public void testClone() { /** * Test for COLLECTIONS-323. */ + @Test public void testInitialCapacityZero() { final CaseInsensitiveMap map = new CaseInsensitiveMap<>(0); assertEquals(1, map.data.length); } // COLLECTIONS-294 + @Test public void testLocaleIndependence() { final Locale orig = Locale.getDefault(); @@ -112,6 +115,7 @@ public void testLocaleIndependence() { // writeExternalFormToDisk((java.io.Serializable) map, "src/test/resources/data/test/CaseInsensitiveMap.fullCollection.version4.obj"); // } + @Test @SuppressWarnings("unchecked") public void testNullHandling() { final Map map = makeObject(); @@ -128,6 +132,7 @@ public void testNullHandling() { assertEquals(3, keys.size()); } + @Test public void testPutAll() { final Map map = new HashMap<>(); map.put("One", "One"); 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 a93a2e7732..4ae0600c08 100644 --- a/src/test/java/org/apache/commons/collections4/map/CompositeMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/CompositeMapTest.java @@ -22,6 +22,8 @@ import java.util.HashMap; import java.util.Collection; +import org.junit.Test; + /** * Extension of {@link AbstractMapTest} for exercising the * {@link CompositeMap} implementation. @@ -67,12 +69,14 @@ public Map buildTwo() { return map; } + @Test public void testGet() { final CompositeMap map = new CompositeMap<>(buildOne(), buildTwo()); assertEquals("one", map.get("1")); assertEquals("four", map.get("4")); } + @Test @SuppressWarnings("unchecked") public void testAddComposited() { final CompositeMap map = new CompositeMap<>(buildOne(), buildTwo()); @@ -85,6 +89,7 @@ public void testAddComposited() { assertThrows(IllegalArgumentException.class, () -> map.addComposited(three)); } + @Test @SuppressWarnings("unchecked") public void testRemoveComposited() { final CompositeMap map = new CompositeMap<>(buildOne(), buildTwo()); @@ -102,6 +107,7 @@ public void testRemoveComposited() { } + @Test @SuppressWarnings("unchecked") public void testRemoveFromUnderlying() { final CompositeMap map = new CompositeMap<>(buildOne(), buildTwo()); @@ -116,6 +122,7 @@ public void testRemoveFromUnderlying() { assertFalse(map.containsKey("5")); } + @Test @SuppressWarnings("unchecked") public void testRemoveFromComposited() { final CompositeMap map = new CompositeMap<>(buildOne(), buildTwo()); @@ -130,6 +137,7 @@ public void testRemoveFromComposited() { assertFalse(three.containsKey("5")); } + @Test public void testResolveCollision() { final CompositeMap map = new CompositeMap<>(buildOne(), buildTwo(), new CompositeMap.MapMutator() { @@ -159,6 +167,7 @@ public void putAll(final CompositeMap map, final Map[] composited, f assertTrue(pass); } + @Test @SuppressWarnings("unchecked") public void testPut() { final CompositeMap map = new CompositeMap<>(buildOne(), buildTwo(), @@ -189,6 +198,7 @@ public void putAll(final CompositeMap map, final Map[] composited, f assertTrue(pass); } + @Test public void testPutAll() { final CompositeMap map = new CompositeMap<>(buildOne(), buildTwo(), new CompositeMap.MapMutator() { diff --git a/src/test/java/org/apache/commons/collections4/map/DefaultedMapTest.java b/src/test/java/org/apache/commons/collections4/map/DefaultedMapTest.java index 78255c5314..037885846b 100644 --- a/src/test/java/org/apache/commons/collections4/map/DefaultedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/DefaultedMapTest.java @@ -28,6 +28,7 @@ import org.apache.commons.collections4.Transformer; import org.apache.commons.collections4.TransformerUtils; import org.apache.commons.collections4.functors.ConstantFactory; +import org.junit.Test; /** * Extension of {@link AbstractMapTest} for exercising the @@ -49,6 +50,7 @@ public IterableMap makeObject() { return DefaultedMap.defaultedMap(new HashMap(), nullFactory); } + @Test @Override @SuppressWarnings("unchecked") public void testMapGet() { @@ -66,6 +68,7 @@ public void testMapGet() { assertEquals("NULL", map.get("NotInMap")); } + @Test @SuppressWarnings("unchecked") public void testMapGet2() { final HashMap base = new HashMap<>(); @@ -85,6 +88,7 @@ public void testMapGet2() { assertEquals("NULL", map.get("NotInMap")); } + @Test @SuppressWarnings("unchecked") public void testMapGet3() { final HashMap base = new HashMap<>(); @@ -104,6 +108,7 @@ public void testMapGet3() { assertEquals("NULL", map.get("NotInMap")); } + @Test @SuppressWarnings("unchecked") public void testMapGet4() { final HashMap base = new HashMap<>(); @@ -130,6 +135,7 @@ public void testMapGet4() { assertEquals("NULL_OBJECT", map.get(Integer.valueOf(0))); } + @Test public void testFactoryMethods() { final HashMap base = new HashMap<>(); assertAll( diff --git a/src/test/java/org/apache/commons/collections4/map/FixedSizeSortedMapTest.java b/src/test/java/org/apache/commons/collections4/map/FixedSizeSortedMapTest.java index 62fab327fe..f497d06f17 100644 --- a/src/test/java/org/apache/commons/collections4/map/FixedSizeSortedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/FixedSizeSortedMapTest.java @@ -19,8 +19,6 @@ import java.util.SortedMap; import java.util.TreeMap; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; /** @@ -35,7 +33,7 @@ public FixedSizeSortedMapTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(FixedSizeSortedMapTest.class); } diff --git a/src/test/java/org/apache/commons/collections4/map/Flat3MapTest.java b/src/test/java/org/apache/commons/collections4/map/Flat3MapTest.java index 781f20dc35..c4425a5e63 100644 --- a/src/test/java/org/apache/commons/collections4/map/Flat3MapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/Flat3MapTest.java @@ -29,8 +29,7 @@ import org.apache.commons.collections4.IterableMap; import org.apache.commons.collections4.MapIterator; import org.apache.commons.collections4.iterators.AbstractMapIteratorTest; - -import junit.framework.Test; +import org.junit.Test; /** * JUnit tests. @@ -49,7 +48,7 @@ public Flat3MapTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(Flat3MapTest.class); } @@ -58,6 +57,7 @@ public Flat3Map makeObject() { return new Flat3Map<>(); } + @Test @SuppressWarnings("unchecked") public void testEquals1() { final Flat3Map map1 = makeObject(); @@ -69,6 +69,7 @@ public void testEquals1() { assertFalse(map1.equals(map2)); } + @Test @SuppressWarnings("unchecked") public void testEquals2() { final Flat3Map map1 = makeObject(); @@ -80,6 +81,7 @@ public void testEquals2() { assertFalse(map1.equals(map2)); } + @Test @SuppressWarnings("unchecked") public void testClone2() { final Flat3Map map = makeObject(); @@ -111,6 +113,7 @@ public void testClone2() { assertSame(TWENTY, cloned.get(TWO)); } + @Test @SuppressWarnings("unchecked") public void testClone4() { final Flat3Map map = makeObject(); @@ -147,6 +150,7 @@ public void testClone4() { assertSame(TWO, cloned.get(TWENTY)); } + @Test public void testSerialisation0() throws Exception { final Flat3Map map = makeObject(); final ByteArrayOutputStream bout = new ByteArrayOutputStream(); @@ -162,6 +166,7 @@ public void testSerialisation0() throws Exception { assertEquals(0, ser.size()); } + @Test @SuppressWarnings("unchecked") public void testSerialisation2() throws Exception { final Flat3Map map = makeObject(); @@ -185,6 +190,7 @@ public void testSerialisation2() throws Exception { assertEquals(TWENTY, ser.get(TWO)); } + @Test @SuppressWarnings("unchecked") public void testSerialisation4() throws Exception { final Flat3Map map = makeObject(); @@ -214,6 +220,7 @@ public void testSerialisation4() throws Exception { assertEquals(TWO, ser.get(TWENTY)); } + @Test @SuppressWarnings("unchecked") public void testEntryIteratorSetValue1() throws Exception { final Flat3Map map = makeObject(); @@ -233,6 +240,7 @@ public void testEntryIteratorSetValue1() throws Exception { assertEquals(THIRTY, map.get(THREE)); } + @Test @SuppressWarnings("unchecked") public void testEntryIteratorSetValue2() throws Exception { final Flat3Map map = makeObject(); @@ -253,6 +261,7 @@ public void testEntryIteratorSetValue2() throws Exception { assertEquals(THIRTY, map.get(THREE)); } + @Test @SuppressWarnings("unchecked") public void testEntryIteratorSetValue3() throws Exception { final Flat3Map map = makeObject(); @@ -274,6 +283,7 @@ public void testEntryIteratorSetValue3() throws Exception { assertEquals("NewValue", map.get(THREE)); } + @Test @SuppressWarnings("unchecked") public void testMapIteratorSetValue1() throws Exception { final Flat3Map map = makeObject(); @@ -293,6 +303,7 @@ public void testMapIteratorSetValue1() throws Exception { assertEquals(THIRTY, map.get(THREE)); } + @Test @SuppressWarnings("unchecked") public void testMapIteratorSetValue2() throws Exception { final Flat3Map map = makeObject(); @@ -313,6 +324,7 @@ public void testMapIteratorSetValue2() throws Exception { assertEquals(THIRTY, map.get(THREE)); } + @Test @SuppressWarnings("unchecked") public void testMapIteratorSetValue3() throws Exception { final Flat3Map map = makeObject(); @@ -334,6 +346,7 @@ public void testMapIteratorSetValue3() throws Exception { assertEquals("NewValue", map.get(THREE)); } + @Test public void testEntrySet() { // Sanity check putAndRemove(new LinkedHashMap<>()); @@ -429,6 +442,7 @@ public String getCompatibilityVersion() { // "src/test/resources/data/test/Flat3Map.fullCollection.version4.obj"); // } + @Test public void testCollections261() { final Flat3Map m = new Flat3Map<>(); m.put( Integer.valueOf(1), Integer.valueOf(1) ); @@ -444,6 +458,7 @@ public void testCollections261() { assertEquals( Integer.valueOf(0), m.remove( Integer.valueOf(0) ) ); } + @Test public void testToString() { final Flat3Map m = new Flat3Map<>(); final String string0 = m.toString(); @@ -465,6 +480,7 @@ public void testToString() { assertNotSame(string2, string3); } + @Test public void testRemove1() { final Flat3Map m = new Flat3Map<>(); @@ -494,6 +510,7 @@ public void testRemove1() { assertSame(TWO, obj); } + @Test public void testRemove2() { final Flat3Map m = new Flat3Map<>(); Object obj; @@ -513,6 +530,7 @@ public void testRemove2() { assertSame(THREE, obj); } + @Test public void testRemove3() { final Flat3Map m = new Flat3Map<>(); Object obj; @@ -532,6 +550,7 @@ public void testRemove3() { assertSame(THREE, obj); } + @Test public void testRemove4() { final Flat3Map m = new Flat3Map<>(); Object obj; @@ -551,6 +570,7 @@ public void testRemove4() { assertNull(obj); } + @Test public void testRemove5() { final Flat3Map m = new Flat3Map<>(); Object obj; @@ -564,6 +584,7 @@ public void testRemove5() { assertNull(obj); } + @Test public void testRemove6() { final Flat3Map m = new Flat3Map<>(); Object obj; @@ -580,6 +601,7 @@ public void testRemove6() { assertNull(obj); } + @Test public void testRemove7() { final Flat3Map m = new Flat3Map<>(); Object obj; @@ -596,6 +618,7 @@ public void testRemove7() { assertSame(TWO, obj); } + @Test public void testRemove8() { final Flat3Map m = new Flat3Map<>(); Object obj; @@ -615,6 +638,7 @@ public void testRemove8() { assertNull(obj); } + @Test public void testRemove9() { final Flat3Map m = new Flat3Map<>(); final Object obj; @@ -625,6 +649,7 @@ public void testRemove9() { assertNull(obj); } + @Test public void testRemove10() { final Flat3Map m = new Flat3Map<>(); final Object obj; @@ -636,6 +661,7 @@ public void testRemove10() { assertNull(obj); } + @Test public void testRemove11() { final Flat3Map m = new Flat3Map<>(); final Object obj; @@ -648,6 +674,7 @@ public void testRemove11() { assertNull(obj); } + @Test public void testRemove12() { final Flat3Map m = new Flat3Map<>(); final Object obj; @@ -660,6 +687,7 @@ public void testRemove12() { assertNull(obj); } + @Test public void testRemove13() { final Flat3Map m = new Flat3Map<>(); final Object obj; @@ -671,6 +699,7 @@ public void testRemove13() { assertNull(obj); } + @Test public void testNewInstance1() { final Map orig = new HashMap<>(); orig.put(ONE, ONE); @@ -682,6 +711,7 @@ public void testNewInstance1() { assertEquals(2, m.size()); } + @Test public void testGet1() { final Flat3Map m = new Flat3Map<>(); final Object obj; @@ -691,6 +721,7 @@ public void testGet1() { assertSame(ONE, obj); } + @Test public void testGet2() { final Flat3Map m = new Flat3Map<>(); final Object obj; @@ -701,6 +732,7 @@ public void testGet2() { assertSame(TWO, obj); } + @Test public void testGet3() { final Flat3Map m = new Flat3Map<>(); final Object obj; @@ -712,6 +744,7 @@ public void testGet3() { assertSame(THREE, obj); } + @Test public void testContainsKey1() { final Flat3Map m = new Flat3Map<>(); @@ -722,6 +755,7 @@ public void testContainsKey1() { assertTrue(contains); } + @Test public void testContainsKey2() { final Flat3Map m = new Flat3Map<>(); @@ -731,6 +765,7 @@ public void testContainsKey2() { assertTrue(contains); } + @Test public void testContainsKey3() { final Flat3Map m = new Flat3Map<>(); @@ -739,6 +774,7 @@ public void testContainsKey3() { assertTrue(contains); } + @Test public void testContainsValue1() { final Flat3Map m = new Flat3Map<>(); @@ -749,6 +785,7 @@ public void testContainsValue1() { assertTrue(contains); } + @Test public void testContainsValue2() { final Flat3Map m = new Flat3Map<>(); @@ -758,6 +795,7 @@ public void testContainsValue2() { assertTrue(contains); } + @Test public void testContainsValue3() { final Flat3Map m = new Flat3Map<>(); @@ -766,6 +804,7 @@ public void testContainsValue3() { assertTrue(contains); } + @Test public void testPut1() { final Flat3Map m = new Flat3Map<>(); @@ -777,6 +816,7 @@ public void testPut1() { assertEquals(ONE, m.get(null)); } + @Test public void testPut2() { final Flat3Map m = new Flat3Map<>(); @@ -787,6 +827,7 @@ public void testPut2() { assertEquals(ONE, m.get(null)); } + @Test public void testPut3() { final Flat3Map m = new Flat3Map<>(); @@ -796,6 +837,7 @@ public void testPut3() { assertNull(m.get(ONE)); } + @Test public void testPut4() { final Flat3Map m = new Flat3Map<>(); @@ -807,6 +849,7 @@ public void testPut4() { assertEquals(ONE, m.get(THREE)); } + @Test public void testPut5() { final Flat3Map m = new Flat3Map<>(); @@ -817,6 +860,7 @@ public void testPut5() { assertEquals(ONE, m.get(TWO)); } + @Test public void testPut6() { final Flat3Map m = new Flat3Map<>(); diff --git a/src/test/java/org/apache/commons/collections4/map/HashedMapTest.java b/src/test/java/org/apache/commons/collections4/map/HashedMapTest.java index 5dae0a3831..d9e1f4c4b3 100644 --- a/src/test/java/org/apache/commons/collections4/map/HashedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/HashedMapTest.java @@ -16,9 +16,8 @@ */ package org.apache.commons.collections4.map; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; +import org.junit.Test; /** * JUnit tests. @@ -30,7 +29,7 @@ public HashedMapTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(HashedMapTest.class); } @@ -44,6 +43,7 @@ public String getCompatibilityVersion() { return "4"; } + @Test @SuppressWarnings("unchecked") public void testClone() { final HashedMap map = new HashedMap<>(10); @@ -53,6 +53,7 @@ public void testClone() { assertSame(map.get("1"), cloned.get("1")); } + @Test public void testInternalState() { final HashedMap map = new HashedMap<>(42, 0.75f); assertEquals(0.75f, map.loadFactor, 0.1f); @@ -83,6 +84,7 @@ public void testInternalState() { /** * Test for COLLECTIONS-323. */ + @Test public void testInitialCapacityZero() { final HashedMap map = new HashedMap<>(0); assertEquals(1, map.data.length); diff --git a/src/test/java/org/apache/commons/collections4/map/LRUMapTest.java b/src/test/java/org/apache/commons/collections4/map/LRUMapTest.java index bdf2840dc0..aade15a6ae 100644 --- a/src/test/java/org/apache/commons/collections4/map/LRUMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/LRUMapTest.java @@ -25,12 +25,11 @@ import java.util.List; import java.util.Map; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.MapIterator; import org.apache.commons.collections4.OrderedMap; import org.apache.commons.collections4.ResettableIterator; +import org.junit.Test; /** * JUnit tests. @@ -41,7 +40,7 @@ public LRUMapTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(LRUMapTest.class); } @@ -71,6 +70,7 @@ public LRUMap getMap() { return (LRUMap) super.getMap(); } + @Test public void testCtors() { assertAll( () -> assertThrows(IllegalArgumentException.class, () -> new LRUMap(0), @@ -88,6 +88,7 @@ public void testCtors() { ); } + @Test public void testLRU() { if (!isPutAddSupported() || !isPutChangeSupported()) { return; @@ -152,6 +153,7 @@ public void testLRU() { assertSame(values[3], vit.next()); } + @Test @SuppressWarnings("unchecked") public void testReset() { resetEmpty(); @@ -168,6 +170,7 @@ public void testReset() { assertSame(list.get(0), it.next()); } + @Test public void testAccessOrder() { if (!isPutAddSupported() || !isPutChangeSupported()) { return; @@ -242,6 +245,7 @@ public void testAccessOrder() { assertSame(values[3], vit.next()); } + @Test public void testAccessOrder2() { if (!isPutAddSupported() || !isPutChangeSupported()) { return; @@ -291,6 +295,7 @@ public void testAccessOrder2() { assertSame(values[0], vit.next()); } + @Test @SuppressWarnings("unchecked") public void testClone() { final LRUMap map = new LRUMap<>(10); @@ -300,6 +305,7 @@ public void testClone() { assertSame(map.get("1"), cloned.get("1")); } + @Test @SuppressWarnings("unchecked") public void testRemoveLRU() { final MockLRUMapSubclass map = new MockLRUMapSubclass<>(2); @@ -343,6 +349,7 @@ protected boolean removeLRU(final LinkEntry entry) { } + @Test @SuppressWarnings("unchecked") public void testRemoveLRUBlocksRemove() { final MockLRUMapSubclassBlocksRemove map = new MockLRUMapSubclassBlocksRemove<>(2, false); @@ -359,6 +366,7 @@ public void testRemoveLRUBlocksRemove() { assertTrue(map.containsKey("C")); } + @Test @SuppressWarnings("unchecked") public void testRemoveLRUBlocksRemoveScan() { final MockLRUMapSubclassBlocksRemove map = new MockLRUMapSubclassBlocksRemove<>(2, true); @@ -393,6 +401,7 @@ protected boolean removeLRU(final LinkEntry entry) { } + @Test @SuppressWarnings("unchecked") public void testRemoveLRUFirstBlocksRemove() { final MockLRUMapSubclassFirstBlocksRemove map = new MockLRUMapSubclassFirstBlocksRemove<>(2); @@ -452,6 +461,7 @@ public String toString() { } + @Test @SuppressWarnings("unchecked") public void testInternalState_Buckets() { if (!isPutAddSupported() || !isPutChangeSupported()) { @@ -542,6 +552,7 @@ public void testInternalState_Buckets() { assertEquals(three, map.data[hashIndex].next.next.key); } + @Test @SuppressWarnings("unchecked") public void testInternalState_getEntry_int() { if (!isPutAddSupported() || !isPutChangeSupported()) { @@ -565,6 +576,7 @@ public void testInternalState_getEntry_int() { ); } + @Test public void testSynchronizedRemoveFromMapIterator() throws InterruptedException { final LRUMap map = new LRUMap<>(10000); @@ -648,6 +660,7 @@ public void run() { + counter[0] + " did succeed", counter[0] >= threads.length); } + @Test public void testSynchronizedRemoveFromEntrySet() throws InterruptedException { final Map map = new LRUMap<>(10000); @@ -726,6 +739,7 @@ public void run() { + counter[0] + " did succeed", counter[0] >= threads.length); } + @Test public void testSynchronizedRemoveFromKeySet() throws InterruptedException { final Map map = new LRUMap<>(10000); @@ -809,6 +823,7 @@ public void run() { + counter[0] + " did succeed", counter[0] >= threads.length); } + @Test public void testSynchronizedRemoveFromValues() throws InterruptedException { final Map map = new LRUMap<>(10000); diff --git a/src/test/java/org/apache/commons/collections4/map/LazyMapTest.java b/src/test/java/org/apache/commons/collections4/map/LazyMapTest.java index 700b3d157b..80b0faba15 100644 --- a/src/test/java/org/apache/commons/collections4/map/LazyMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/LazyMapTest.java @@ -46,6 +46,7 @@ public LazyMap makeObject() { return lazyMap(new HashMap(), FactoryUtils.nullFactory()); } + @Test @Override public void testMapGet() { //TODO eliminate need for this via superclass - see svn history. diff --git a/src/test/java/org/apache/commons/collections4/map/LazySortedMapTest.java b/src/test/java/org/apache/commons/collections4/map/LazySortedMapTest.java index e0b649f36a..279890c756 100644 --- a/src/test/java/org/apache/commons/collections4/map/LazySortedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/LazySortedMapTest.java @@ -69,6 +69,7 @@ public boolean isAllowNullKey() { } // from LazyMapTest + @Test @Override public void testMapGet() { //TODO eliminate need for this via superclass - see svn history. @@ -89,6 +90,7 @@ public void mapGet() { } + @Test public void testSortOrder() { final SortedMap map = lazySortedMap(new TreeMap(), oneFactory); map.put("A", 5); @@ -107,6 +109,7 @@ public void testSortOrder() { assertNull("natural order, so comparator should be null", c); } + @Test public void testReverseSortOrder() { final SortedMap map = lazySortedMap(new ConcurrentSkipListMap(reverseStringComparator), oneFactory); map.put("A", 5); @@ -125,6 +128,7 @@ public void testReverseSortOrder() { assertSame("natural order, so comparator should be null", c, reverseStringComparator); } + @Test public void testTransformerDecorate() { final Transformer transformer = TransformerUtils.asTransformer(oneFactory); SortedMap map = lazySortedMap(new TreeMap(), transformer); diff --git a/src/test/java/org/apache/commons/collections4/map/LinkedMapTest.java b/src/test/java/org/apache/commons/collections4/map/LinkedMapTest.java index 550586f7f9..8079b487a7 100644 --- a/src/test/java/org/apache/commons/collections4/map/LinkedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/LinkedMapTest.java @@ -21,13 +21,12 @@ import java.util.List; import java.util.Map; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.MapIterator; import org.apache.commons.collections4.OrderedMap; import org.apache.commons.collections4.ResettableIterator; import org.apache.commons.collections4.list.AbstractListTest; +import org.junit.Test; /** * JUnit tests. @@ -39,7 +38,7 @@ public LinkedMapTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(LinkedMapTest.class); } @@ -61,6 +60,7 @@ public String getCompatibilityVersion() { return "4"; } + @Test @SuppressWarnings("unchecked") public void testReset() { resetEmpty(); @@ -77,6 +77,7 @@ public void testReset() { assertSame(list.get(0), it.next()); } + @Test public void testInsertionOrder() { if (!isPutAddSupported() || !isPutChangeSupported()) { return; @@ -124,6 +125,7 @@ public void testInsertionOrder() { assertSame(values[2], valueIter.next()); } + @Test public void testGetByIndex() { resetEmpty(); LinkedMap lm = getMap(); @@ -149,6 +151,7 @@ public void testGetByIndex() { } } + @Test public void testGetValueByIndex() { resetEmpty(); LinkedMap lm = getMap(); @@ -175,6 +178,7 @@ public void testGetValueByIndex() { } } + @Test public void testIndexOf() { resetEmpty(); LinkedMap lm = getMap(); @@ -191,6 +195,7 @@ public void testIndexOf() { } } + @Test public void testRemoveByIndex() { resetEmpty(); LinkedMap lm = getMap(); @@ -269,6 +274,7 @@ public boolean isTestSerialization() { } } + @Test @SuppressWarnings("unchecked") public void testClone() { final LinkedMap map = new LinkedMap<>(10); @@ -296,6 +302,7 @@ public LinkedMap getMap() { /** * Test for COLLECTIONS-323. */ + @Test public void testInitialCapacityZero() { final LinkedMap map = new LinkedMap<>(0); assertEquals(1, map.data.length); diff --git a/src/test/java/org/apache/commons/collections4/map/ListOrderedMap2Test.java b/src/test/java/org/apache/commons/collections4/map/ListOrderedMap2Test.java index d45dc8f61b..65ba4c9a36 100644 --- a/src/test/java/org/apache/commons/collections4/map/ListOrderedMap2Test.java +++ b/src/test/java/org/apache/commons/collections4/map/ListOrderedMap2Test.java @@ -19,11 +19,10 @@ import java.util.ArrayList; import java.util.List; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.MapIterator; import org.apache.commons.collections4.list.AbstractListTest; +import org.junit.Test; /** * Extension of {@link AbstractOrderedMapTest} for exercising the {@link ListOrderedMap} @@ -37,7 +36,7 @@ public ListOrderedMap2Test(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(ListOrderedMap2Test.class); } @@ -54,6 +53,7 @@ public ListOrderedMap makeFullMap() { return (ListOrderedMap) super.makeFullMap(); } + @Test public void testGetByIndex() { resetEmpty(); ListOrderedMap lom = getMap(); @@ -79,6 +79,7 @@ public void testGetByIndex() { } } + @Test public void testGetValueByIndex() { resetEmpty(); ListOrderedMap lom = getMap(); @@ -105,6 +106,7 @@ public void testGetValueByIndex() { } } + @Test public void testIndexOf() { resetEmpty(); ListOrderedMap lom = getMap(); @@ -121,6 +123,7 @@ public void testIndexOf() { } } + @Test public void testRemoveByIndex() { resetEmpty(); ListOrderedMap lom = getMap(); diff --git a/src/test/java/org/apache/commons/collections4/map/ListOrderedMapTest.java b/src/test/java/org/apache/commons/collections4/map/ListOrderedMapTest.java index 30af47cbf8..5990bd7fbd 100644 --- a/src/test/java/org/apache/commons/collections4/map/ListOrderedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/ListOrderedMapTest.java @@ -25,11 +25,10 @@ import java.util.Map; import java.util.TreeMap; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.MapIterator; import org.apache.commons.collections4.list.AbstractListTest; +import org.junit.Test; /** * Extension of {@link AbstractOrderedMapTest} for exercising the {@link ListOrderedMap} @@ -43,7 +42,7 @@ public ListOrderedMapTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(ListOrderedMapTest.class); } @@ -60,6 +59,7 @@ public ListOrderedMap makeFullMap() { return (ListOrderedMap) super.makeFullMap(); } + @Test public void testGetByIndex() { resetEmpty(); ListOrderedMap lom = getMap(); @@ -85,6 +85,7 @@ public void testGetByIndex() { } } + @Test public void testGetValueByIndex() { resetEmpty(); ListOrderedMap lom = getMap(); @@ -111,6 +112,7 @@ public void testGetValueByIndex() { } } + @Test public void testIndexOf() { resetEmpty(); ListOrderedMap lom = getMap(); @@ -127,6 +129,7 @@ public void testIndexOf() { } } + @Test @SuppressWarnings("unchecked") public void testSetValueByIndex() { resetEmpty(); @@ -155,6 +158,7 @@ public void testSetValueByIndex() { } } + @Test public void testRemoveByIndex() { resetEmpty(); ListOrderedMap lom = getMap(); @@ -187,6 +191,7 @@ public void testRemoveByIndex() { } } + @Test @SuppressWarnings("unchecked") public void testPut_intObjectObject() { resetEmpty(); @@ -303,6 +308,7 @@ public void testPut_intObjectObject() { assertEquals("One", lom.getValue(2)); } + @Test public void testPutAllWithIndex() { resetEmpty(); @SuppressWarnings("unchecked") @@ -330,6 +336,7 @@ public void testPutAllWithIndex() { assertEquals("testInsert2v", lom.getValue(4)); } + @Test @SuppressWarnings("unchecked") public void testPutAllWithIndexBug441() { // see COLLECTIONS-441 @@ -354,6 +361,7 @@ public void testPutAllWithIndexBug441() { } } + @Test public void testValueList_getByIndex() { resetFull(); final ListOrderedMap lom = getMap(); @@ -363,6 +371,7 @@ public void testValueList_getByIndex() { } } + @Test @SuppressWarnings("unchecked") public void testValueList_setByIndex() { resetFull(); @@ -376,6 +385,7 @@ public void testValueList_setByIndex() { } } + @Test public void testValueList_removeByIndex() { resetFull(); final ListOrderedMap lom = getMap(); @@ -385,6 +395,7 @@ public void testValueList_removeByIndex() { } } + @Test public void testCOLLECTIONS_474_nullValues () { final Object key1 = new Object(); final Object key2 = new Object(); @@ -399,6 +410,7 @@ public void testCOLLECTIONS_474_nullValues () { listMap.putAll(2, hmap); } + @Test public void testCOLLECTIONS_474_nonNullValues () { final Object key1 = new Object(); final Object key2 = new Object(); diff --git a/src/test/java/org/apache/commons/collections4/map/MultiKeyMapTest.java b/src/test/java/org/apache/commons/collections4/map/MultiKeyMapTest.java index 58077ccdc7..620557b892 100644 --- a/src/test/java/org/apache/commons/collections4/map/MultiKeyMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/MultiKeyMapTest.java @@ -20,11 +20,10 @@ import java.util.Map; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.MapIterator; import org.apache.commons.collections4.keyvalue.MultiKey; +import org.junit.Test; /** * JUnit tests. @@ -44,7 +43,7 @@ public MultiKeyMapTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(MultiKeyMapTest.class); } @@ -114,6 +113,7 @@ public boolean isAllowNullKey() { return false; } + @Test @SuppressWarnings("unchecked") public void testNullHandling() { resetFull(); @@ -132,6 +132,7 @@ public void testNullHandling() { assertThrows(NullPointerException.class, () -> map.put(null, (V) new Object())); } + @Test public void testMultiKeyGet() { resetFull(); final MultiKeyMap multimap = getMap(); @@ -185,6 +186,7 @@ public void testMultiKeyGet() { } } + @Test public void testMultiKeyContainsKey() { resetFull(); final MultiKeyMap multimap = getMap(); @@ -234,6 +236,7 @@ public void testMultiKeyContainsKey() { } } + @Test public void testMultiKeyPut() { final MultiKey[] keys = getMultiKeyKeys(); final V[] values = getSampleValues(); @@ -295,6 +298,7 @@ public void testMultiKeyPut() { } } + @Test public void testMultiKeyPutWithNullKey() { final MultiKeyMap map = new MultiKeyMap<>(); map.put("a", null, "value1"); @@ -311,6 +315,7 @@ public void testMultiKeyPutWithNullKey() { assertEquals("value6", map.get(null, "a")); } + @Test public void testMultiKeyRemove() { final MultiKey[] keys = getMultiKeyKeys(); final V[] values = getSampleValues(); @@ -362,6 +367,7 @@ public void testMultiKeyRemove() { } } + @Test public void testMultiKeyRemoveAll1() { resetFull(); final MultiKeyMap multimap = getMap(); @@ -375,6 +381,7 @@ public void testMultiKeyRemoveAll1() { } } + @Test public void testMultiKeyRemoveAll2() { resetFull(); final MultiKeyMap multimap = getMap(); @@ -388,6 +395,7 @@ public void testMultiKeyRemoveAll2() { } } + @Test public void testMultiKeyRemoveAll3() { resetFull(); final MultiKeyMap multimap = getMap(); @@ -401,6 +409,7 @@ public void testMultiKeyRemoveAll3() { } } + @Test public void testMultiKeyRemoveAll4() { resetFull(); final MultiKeyMap multimap = getMap(); @@ -414,6 +423,7 @@ public void testMultiKeyRemoveAll4() { } } + @Test @SuppressWarnings("unchecked") public void testClone() { final MultiKeyMap map = new MultiKeyMap<>(); @@ -423,6 +433,7 @@ public void testClone() { assertSame(map.get(new MultiKey<>((K) I1, (K) I2)), cloned.get(new MultiKey<>((K) I1, (K) I2))); } + @Test @SuppressWarnings("unchecked") public void testLRUMultiKeyMap() { final MultiKeyMap map = MultiKeyMap.multiKeyMap(new LRUMap, V>(2)); diff --git a/src/test/java/org/apache/commons/collections4/map/MultiValueMapTest.java b/src/test/java/org/apache/commons/collections4/map/MultiValueMapTest.java index 35fa6e51a7..486f0e5fe7 100644 --- a/src/test/java/org/apache/commons/collections4/map/MultiValueMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/MultiValueMapTest.java @@ -35,6 +35,7 @@ import org.apache.commons.collections4.AbstractObjectTest; import org.apache.commons.collections4.IteratorUtils; import org.apache.commons.collections4.MultiMap; +import org.junit.Test; /** * TestMultiValueMap. @@ -48,17 +49,20 @@ public MultiValueMapTest(final String testName) { super(testName); } + @Test public void testNoMappingReturnsNull() { final MultiValueMap map = createTestMap(); assertNull(map.get("whatever")); } + @Test @SuppressWarnings("unchecked") public void testValueCollectionType() { final MultiValueMap map = createTestMap(LinkedList.class); assertTrue(map.get("one") instanceof LinkedList); } + @Test @SuppressWarnings("unchecked") public void testMultipleValues() { final MultiValueMap map = createTestMap(HashSet.class); @@ -68,6 +72,7 @@ public void testMultipleValues() { assertEquals(expected, map.get("one")); } + @Test @SuppressWarnings("unchecked") public void testContainsValue() { final MultiValueMap map = createTestMap(HashSet.class); @@ -80,6 +85,7 @@ public void testContainsValue() { assertFalse(map.containsValue("quatro")); } + @Test @SuppressWarnings("unchecked") public void testKeyContainsValue() { final MultiValueMap map = createTestMap(HashSet.class); @@ -92,6 +98,7 @@ public void testKeyContainsValue() { assertFalse(map.containsValue("four", "quatro")); } + @Test @SuppressWarnings("unchecked") public void testValues() { final MultiValueMap map = createTestMap(HashSet.class); @@ -124,6 +131,7 @@ private > MultiValueMap createTestMap(final Class< return map; } + @Test public void testKeyedIterator() { final MultiValueMap map = createTestMap(); final ArrayList actual = new ArrayList<>(IteratorUtils.toList(map.iterator("one"))); @@ -131,6 +139,7 @@ public void testKeyedIterator() { assertEquals(expected, actual); } + @Test public void testRemoveAllViaIterator() { final MultiValueMap map = createTestMap(); for (final Iterator i = map.values().iterator(); i.hasNext();) { @@ -141,6 +150,7 @@ public void testRemoveAllViaIterator() { assertTrue(map.isEmpty()); } + @Test public void testRemoveAllViaKeyedIterator() { final MultiValueMap map = createTestMap(); for (final Iterator i = map.iterator("one"); i.hasNext();) { @@ -151,6 +161,7 @@ public void testRemoveAllViaKeyedIterator() { assertEquals(4, map.totalSize()); } + @Test public void testIterator() { final MultiValueMap map = createTestMap(); @SuppressWarnings("unchecked") @@ -165,6 +176,7 @@ public void testIterator() { assertTrue(values.isEmpty()); } + @Test public void testRemoveAllViaEntryIterator() { final MultiValueMap map = createTestMap(); for (final Iterator i = map.iterator(); i.hasNext();) { @@ -175,10 +187,12 @@ public void testRemoveAllViaEntryIterator() { assertEquals(0, map.totalSize()); } + @Test public void testTotalSizeA() { assertEquals(6, createTestMap().totalSize()); } + @Test @SuppressWarnings("unchecked") public void testMapEquals() { final MultiValueMap one = new MultiValueMap<>(); @@ -190,6 +204,7 @@ public void testMapEquals() { assertEquals(two, one); } + @Test @SuppressWarnings("unchecked") public void testGetCollection() { final MultiValueMap map = new MultiValueMap<>(); @@ -197,6 +212,7 @@ public void testGetCollection() { assertSame(map.get("A"), map.getCollection("A")); } + @Test @SuppressWarnings("unchecked") public void testTotalSize() { final MultiValueMap map = new MultiValueMap<>(); @@ -215,6 +231,7 @@ public void testTotalSize() { assertEquals(2, map.totalSize()); } + @Test @SuppressWarnings("unchecked") public void testSize() { final MultiValueMap map = new MultiValueMap<>(); @@ -233,6 +250,7 @@ public void testSize() { assertEquals(1, map.size()); } + @Test @SuppressWarnings("unchecked") public void testSize_Key() { final MultiValueMap map = new MultiValueMap<>(); @@ -258,6 +276,7 @@ public void testSize_Key() { assertEquals(2, map.size("B")); } + @Test @SuppressWarnings("unchecked") public void testIterator_Key() { final MultiValueMap map = new MultiValueMap<>(); @@ -269,6 +288,7 @@ public void testIterator_Key() { assertFalse(it.hasNext()); } + @Test @SuppressWarnings("unchecked") public void testContainsValue_Key() { final MultiValueMap map = new MultiValueMap<>(); @@ -279,6 +299,7 @@ public void testContainsValue_Key() { assertFalse(map.containsValue("A", "AB")); } + @Test @SuppressWarnings("unchecked") public void testPutWithList() { @SuppressWarnings("rawtypes") @@ -290,6 +311,7 @@ public void testPutWithList() { assertEquals(2, test.totalSize()); } + @Test @SuppressWarnings("unchecked") public void testPutWithSet() { @SuppressWarnings("rawtypes") @@ -302,6 +324,7 @@ public void testPutWithSet() { assertEquals(2, test.totalSize()); } + @Test @SuppressWarnings("unchecked") public void testPutAll_Map1() { final MultiMap original = new MultiValueMap<>(); @@ -323,6 +346,7 @@ public void testPutAll_Map1() { assertTrue(test.containsValue("object2")); } + @Test @SuppressWarnings("unchecked") public void testPutAll_Map2() { final Map original = new HashMap<>(); @@ -345,6 +369,7 @@ public void testPutAll_Map2() { assertTrue(test.containsValue("object2")); } + @Test @SuppressWarnings("unchecked") public void testPutAll_KeyCollection() { final MultiValueMap map = new MultiValueMap<>(); @@ -377,6 +402,7 @@ public void testPutAll_KeyCollection() { assertTrue(map.containsValue("A", "M")); } + @Test @SuppressWarnings("unchecked") public void testRemove_KeyItem() { final MultiValueMap map = new MultiValueMap<>(); @@ -391,6 +417,7 @@ public void testRemove_KeyItem() { assertEquals(new MultiValueMap(), map); } + @Test public void testUnsafeDeSerialization() throws Exception { final MultiValueMap map1 = MultiValueMap.multiValueMap(new HashMap(), ArrayList.class); byte[] bytes = serialize(map1); @@ -447,12 +474,14 @@ private Map makeEmptyMap() { return new MultiValueMap(); } + @Test public void testEmptyMapCompatibility() throws Exception { final Map map = makeEmptyMap(); final Map map2 = (Map) readExternalFormFromDisk(getCanonicalEmptyCollectionName(map)); assertEquals("Map is empty", 0, map2.size()); } + @Test public void testFullMapCompatibility() throws Exception { final Map map = (Map) makeObject(); final Map map2 = (Map) readExternalFormFromDisk(getCanonicalFullCollectionName(map)); diff --git a/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java b/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java index e02372d5fb..7377fe69fd 100644 --- a/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java @@ -23,10 +23,9 @@ import java.util.Map; import java.util.concurrent.TimeUnit; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.map.PassiveExpiringMap.ExpirationPolicy; +import org.junit.Test; /** * JUnit tests. @@ -55,7 +54,7 @@ public long expirationTime(final Integer key, final String value) { } } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(PassiveExpiringMapTest.class); } @@ -104,6 +103,7 @@ private Map makeTestMap() { return m; } + @Test public void testConstructors() { assertAll( () -> assertThrows(NullPointerException.class, () -> { @@ -124,6 +124,7 @@ public void testConstructors() { ); } + @Test public void testContainsKey() { final Map m = makeTestMap(); assertFalse(m.containsKey(Integer.valueOf(1))); @@ -134,6 +135,7 @@ public void testContainsKey() { assertTrue(m.containsKey(Integer.valueOf(6))); } + @Test public void testContainsValue() { final Map m = makeTestMap(); assertFalse(m.containsValue("one")); @@ -144,6 +146,7 @@ public void testContainsValue() { assertTrue(m.containsValue("six")); } + @Test public void testDecoratedMap() { // entries shouldn't expire final Map m = makeDecoratedTestMap(); @@ -173,11 +176,13 @@ public void testDecoratedMap() { assertEquals("two", m.get(Integer.valueOf(2))); } + @Test public void testEntrySet() { final Map m = makeTestMap(); assertEquals(3, m.entrySet().size()); } + @Test public void testExpiration() { validateExpiration(new PassiveExpiringMap(500), 500); validateExpiration(new PassiveExpiringMap(1000), 1000); @@ -187,6 +192,7 @@ public void testExpiration() { new PassiveExpiringMap.ConstantTimeToLiveExpirationPolicy(1, TimeUnit.SECONDS)), 1000); } + @Test public void testGet() { final Map m = makeTestMap(); assertNull(m.get(Integer.valueOf(1))); @@ -197,6 +203,7 @@ public void testGet() { assertEquals("six", m.get(Integer.valueOf(6))); } + @Test public void testIsEmpty() { Map m = makeTestMap(); assertFalse(m.isEmpty()); @@ -209,11 +216,13 @@ public void testIsEmpty() { assertTrue(m.isEmpty()); } + @Test public void testKeySet() { final Map m = makeTestMap(); assertEquals(3, m.size()); } + @Test public void testPut() { final Map m = makeTestMap(); assertNull(m.put(Integer.valueOf(1), "ONE")); @@ -224,16 +233,19 @@ public void testPut() { assertEquals("six", m.put(Integer.valueOf(6), "SIX")); } + @Test public void testSize() { final Map m = makeTestMap(); assertEquals(3, m.size()); } + @Test public void testValues() { final Map m = makeTestMap(); assertEquals(3, m.size()); } + @Test public void testZeroTimeToLive() { // item should not be available final PassiveExpiringMap m = new PassiveExpiringMap<>(0L); diff --git a/src/test/java/org/apache/commons/collections4/map/PredicatedMapTest.java b/src/test/java/org/apache/commons/collections4/map/PredicatedMapTest.java index 0feb6399a2..01dfa587a9 100644 --- a/src/test/java/org/apache/commons/collections4/map/PredicatedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/PredicatedMapTest.java @@ -25,6 +25,7 @@ import org.apache.commons.collections4.IterableMap; import org.apache.commons.collections4.Predicate; import org.apache.commons.collections4.functors.TruePredicate; +import org.junit.Test; /** * Extension of {@link AbstractMapTest} for exercising the @@ -56,6 +57,7 @@ public IterableMap makeTestMap() { return decorateMap(new HashMap(), testPredicate, testPredicate); } + @Test @SuppressWarnings("unchecked") public void testEntrySet() { Map map = makeTestMap(); @@ -66,6 +68,7 @@ public void testEntrySet() { map = decorateMap(map, null, null); } + @Test @SuppressWarnings("unchecked") public void testPut() { final Map map = makeTestMap(); diff --git a/src/test/java/org/apache/commons/collections4/map/PredicatedSortedMapTest.java b/src/test/java/org/apache/commons/collections4/map/PredicatedSortedMapTest.java index 29a732d16e..3285f3d200 100644 --- a/src/test/java/org/apache/commons/collections4/map/PredicatedSortedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/PredicatedSortedMapTest.java @@ -28,6 +28,7 @@ import org.apache.commons.collections4.Predicate; import org.apache.commons.collections4.functors.TruePredicate; +import org.junit.Test; /** * Extension of {@link PredicatedMapTest} for exercising the @@ -84,6 +85,7 @@ public boolean isAllowNullKey() { } // from TestPredicatedMap + @Test @SuppressWarnings("unchecked") public void testEntrySet() { SortedMap map = makeTestMap(); @@ -94,6 +96,7 @@ public void testEntrySet() { map = decorateMap(map, null, null); } + @Test @SuppressWarnings("unchecked") public void testPut() { final Map map = makeTestMap(); @@ -129,6 +132,7 @@ public void testPut() { } + @Test @SuppressWarnings("unchecked") public void testSortOrder() { final SortedMap map = makeTestMap(); @@ -152,6 +156,7 @@ public void testSortOrder() { assertNull("natural order, so comparator should be null", c); } + @Test @SuppressWarnings("unchecked") public void testReverseSortOrder() { final SortedMap map = makeTestMapWithComparator(); diff --git a/src/test/java/org/apache/commons/collections4/map/ReferenceIdentityMapTest.java b/src/test/java/org/apache/commons/collections4/map/ReferenceIdentityMapTest.java index a35e2b0fa7..c25dd3c130 100644 --- a/src/test/java/org/apache/commons/collections4/map/ReferenceIdentityMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/ReferenceIdentityMapTest.java @@ -22,11 +22,10 @@ import java.util.Iterator; import java.util.Map; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.IterableMap; import org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength; +import org.junit.Test; /** * Tests for ReferenceIdentityMap. @@ -49,7 +48,7 @@ private static void gc() { } } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(ReferenceIdentityMapTest.class); } @@ -115,6 +114,7 @@ public Map makeConfirmedMap() { /* // Tests often fail because gc is uncontrollable + @Test public void testPurge() { ReferenceIdentityMap map = new ReferenceIdentityMap(ReferenceIdentityMap.WEAK, ReferenceIdentityMap.WEAK); Object[] hard = new Object[10]; @@ -140,7 +140,7 @@ public void testPurge() { assertTrue("map should be empty after purge of weak keys and values", map.isEmpty()); } - + @Test public void testGetAfterGC() { ReferenceIdentityMap map = new ReferenceIdentityMap(ReferenceIdentityMap.WEAK, ReferenceIdentityMap.WEAK); for (int i = 0; i < 10; i++) { @@ -155,7 +155,7 @@ public void testGetAfterGC() { } } - + @Test public void testEntrySetIteratorAfterGC() { ReferenceIdentityMap map = new ReferenceIdentityMap(ReferenceIdentityMap.WEAK, ReferenceIdentityMap.WEAK); Object[] hard = new Object[10]; @@ -177,6 +177,7 @@ public void testEntrySetIteratorAfterGC() { } + @Test public void testMapIteratorAfterGC() { ReferenceIdentityMap map = new ReferenceIdentityMap(ReferenceIdentityMap.WEAK, ReferenceIdentityMap.WEAK); Object[] hard = new Object[10]; @@ -199,6 +200,7 @@ public void testMapIteratorAfterGC() { } + @Test public void testMapIteratorAfterGC2() { ReferenceIdentityMap map = new ReferenceIdentityMap(ReferenceIdentityMap.WEAK, ReferenceIdentityMap.WEAK); Object[] hard = new Object[10]; @@ -227,6 +229,7 @@ public ReferenceIdentityMap makeObject() { return new ReferenceIdentityMap<>(ReferenceStrength.WEAK, ReferenceStrength.WEAK); } + @Test @SuppressWarnings("unchecked") public void testBasics() { final IterableMap map = new ReferenceIdentityMap<>(ReferenceStrength.HARD, ReferenceStrength.HARD); @@ -260,6 +263,7 @@ public void testBasics() { assertTrue(map.containsValue(I2B)); } + @Test @SuppressWarnings("unchecked") public void testHashEntry() { final IterableMap map = new ReferenceIdentityMap<>(ReferenceStrength.HARD, ReferenceStrength.HARD); @@ -277,6 +281,7 @@ public void testHashEntry() { assertFalse(entry1.equals(entry3)); } + @Test @SuppressWarnings("unchecked") public void testNullHandling() { resetFull(); @@ -293,6 +298,7 @@ public void testNullHandling() { } /** Tests whether purge values setting works */ + @Test public void testPurgeValues() throws Exception { // many thanks to Juozas Baliuka for suggesting this method final Map testMap = buildRefMap(); diff --git a/src/test/java/org/apache/commons/collections4/map/ReferenceMapTest.java b/src/test/java/org/apache/commons/collections4/map/ReferenceMapTest.java index a2ea3f0f5c..df771bc89c 100644 --- a/src/test/java/org/apache/commons/collections4/map/ReferenceMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/ReferenceMapTest.java @@ -34,8 +34,7 @@ import org.apache.commons.collections4.map.AbstractHashedMap.HashEntry; import org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceEntry; import org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength; - -import junit.framework.Test; +import org.junit.Test; /** * Tests for ReferenceMap. @@ -46,7 +45,7 @@ public ReferenceMapTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(ReferenceMapTest.class); } @@ -81,6 +80,7 @@ public String getCompatibilityVersion() { // "src/test/resources/data/test/ReferenceMap.fullCollection.version4.obj"); // } + @Test @SuppressWarnings("unchecked") public void testNullHandling() { resetFull(); @@ -99,6 +99,7 @@ public void testNullHandling() { /* // Tests often fail because gc is uncontrollable + @Test public void testPurge() { ReferenceMap map = new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK); Object[] hard = new Object[10]; @@ -124,7 +125,7 @@ public void testPurge() { assertTrue("map should be empty after purge of weak keys and values", map.isEmpty()); } - + @Test public void testGetAfterGC() { ReferenceMap map = new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK); for (int i = 0; i < 10; i++) { @@ -139,7 +140,7 @@ public void testGetAfterGC() { } } - + @Test public void testEntrySetIteratorAfterGC() { ReferenceMap map = new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK); Object[] hard = new Object[10]; @@ -161,6 +162,7 @@ public void testEntrySetIteratorAfterGC() { } + @Test public void testMapIteratorAfterGC() { ReferenceMap map = new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK); Object[] hard = new Object[10]; @@ -183,6 +185,7 @@ public void testMapIteratorAfterGC() { } + @Test public void testMapIteratorAfterGC2() { ReferenceMap map = new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK); Object[] hard = new Object[10]; @@ -227,6 +230,7 @@ public Map buildRefMap() { } /** Tests whether purge values setting works */ + @Test public void testPurgeValues() throws Exception { // many thanks to Juozas Baliuka for suggesting this method final Map testMap = buildRefMap(); @@ -250,6 +254,7 @@ public void testPurgeValues() throws Exception { } } + @Test public void testCustomPurge() { final List expiredValues = new ArrayList<>(); @SuppressWarnings("unchecked") @@ -289,6 +294,7 @@ protected ReferenceEntry createEntry(final HashEntryCOLLECTIONS-599: HashEntry array object naming data initialized with double the size during deserialization */ + @Test public void testDataSizeAfterSerialization() throws IOException, ClassNotFoundException { final ReferenceMap serializeMap = new ReferenceMap<>(ReferenceStrength.WEAK, ReferenceStrength.WEAK, true); diff --git a/src/test/java/org/apache/commons/collections4/map/SingletonMapTest.java b/src/test/java/org/apache/commons/collections4/map/SingletonMapTest.java index 81441fae1f..fa73be2ffd 100644 --- a/src/test/java/org/apache/commons/collections4/map/SingletonMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/SingletonMapTest.java @@ -18,11 +18,11 @@ import java.util.HashMap; -import junit.framework.Test; import org.apache.commons.collections4.BoundedMap; import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.KeyValue; import org.apache.commons.collections4.OrderedMap; +import org.junit.Test; /** * JUnit tests. @@ -38,7 +38,7 @@ public SingletonMapTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(SingletonMapTest.class); } @@ -93,6 +93,7 @@ public V[] getNewSampleValues() { return (V[]) new Object[] { TEN }; } + @Test public void testClone() { final SingletonMap map = makeFullMap(); assertEquals(1, map.size()); @@ -102,6 +103,7 @@ public void testClone() { assertTrue(cloned.containsValue(TWO)); } + @Test public void testKeyValue() { final SingletonMap map = makeFullMap(); assertEquals(1, map.size()); @@ -110,6 +112,7 @@ public void testKeyValue() { assertTrue(map instanceof KeyValue); } + @Test public void testBoundedMap() { final SingletonMap map = makeFullMap(); assertEquals(1, map.size()); diff --git a/src/test/java/org/apache/commons/collections4/map/StaticBucketMapTest.java b/src/test/java/org/apache/commons/collections4/map/StaticBucketMapTest.java index aec45eee73..8164c73e54 100644 --- a/src/test/java/org/apache/commons/collections4/map/StaticBucketMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/StaticBucketMapTest.java @@ -16,9 +16,8 @@ */ package org.apache.commons.collections4.map; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; +import org.junit.Test; /** * Unit tests. @@ -31,7 +30,7 @@ public StaticBucketMapTest(final String name) { super(name); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(StaticBucketMapTest.class); } @@ -60,6 +59,7 @@ public String[] ignoredTests() { } // Bugzilla 37567 + @Test @SuppressWarnings("unchecked") public void test_get_nullMatchesIncorrectly() { final StaticBucketMap map = new StaticBucketMap<>(17); @@ -72,6 +72,7 @@ public void test_get_nullMatchesIncorrectly() { } } + @Test @SuppressWarnings("unchecked") public void test_containsKey_nullMatchesIncorrectly() { final StaticBucketMap map = new StaticBucketMap<>(17); @@ -84,6 +85,7 @@ public void test_containsKey_nullMatchesIncorrectly() { } } + @Test @SuppressWarnings("unchecked") public void test_containsValue_nullMatchesIncorrectly() { final StaticBucketMap map = new StaticBucketMap<>(17); diff --git a/src/test/java/org/apache/commons/collections4/map/TransformedMapTest.java b/src/test/java/org/apache/commons/collections4/map/TransformedMapTest.java index ffb282898a..dc8e6b1d27 100644 --- a/src/test/java/org/apache/commons/collections4/map/TransformedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/TransformedMapTest.java @@ -24,6 +24,7 @@ import org.apache.commons.collections4.Transformer; import org.apache.commons.collections4.TransformerUtils; import org.apache.commons.collections4.collection.TransformedCollectionTest; +import org.junit.Test; /** * Extension of {@link AbstractMapTest} for exercising the {@link TransformedMap} @@ -44,6 +45,7 @@ public IterableMap makeObject() { } @SuppressWarnings({ "unchecked", "rawtypes" }) + @Test public void testTransformedMap() { final Object[] els = { "1", "3", "5", "7", "2", "4", "6" }; @@ -92,6 +94,7 @@ public void testTransformedMap() { assertEquals(Integer.valueOf(88), map.get(entry.getKey())); } + @Test @SuppressWarnings("unchecked") public void testFactory_Decorate() { final Map base = new HashMap<>(); @@ -112,6 +115,7 @@ public void testFactory_Decorate() { assertEquals(Integer.valueOf(4), trans.get("D")); } + @Test @SuppressWarnings("unchecked") public void testFactory_decorateTransform() { final Map base = new HashMap<>(); diff --git a/src/test/java/org/apache/commons/collections4/map/TransformedSortedMapTest.java b/src/test/java/org/apache/commons/collections4/map/TransformedSortedMapTest.java index a3ba3342d2..bb6ce48507 100644 --- a/src/test/java/org/apache/commons/collections4/map/TransformedSortedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/TransformedSortedMapTest.java @@ -23,12 +23,11 @@ import java.util.SortedMap; import java.util.TreeMap; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.Transformer; import org.apache.commons.collections4.TransformerUtils; import org.apache.commons.collections4.collection.TransformedCollectionTest; +import org.junit.Test; /** * Extension of {@link AbstractSortedMapTest} for exercising the {@link TransformedSortedMap} @@ -42,7 +41,7 @@ public TransformedSortedMapTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(TransformedSortedMapTest.class); } @@ -65,6 +64,7 @@ public boolean isSubMapViewsSerializable() { return false; } + @Test @SuppressWarnings("unchecked") public void testTransformedMap() { final Object[] els = { "1", "3", "5", "7", "2", "4", "6" }; @@ -119,6 +119,7 @@ public void testTransformedMap() { assertEquals(Integer.valueOf(88), map.get(entry.getKey())); } + @Test @SuppressWarnings("unchecked") public void testFactory_Decorate() { final SortedMap base = new TreeMap<>(); @@ -139,6 +140,7 @@ public void testFactory_Decorate() { assertEquals(Integer.valueOf(4), trans.get("D")); } + @Test @SuppressWarnings("unchecked") public void testFactory_decorateTransform() { final SortedMap base = new TreeMap<>(); diff --git a/src/test/java/org/apache/commons/collections4/map/UnmodifiableMapTest.java b/src/test/java/org/apache/commons/collections4/map/UnmodifiableMapTest.java index 56bf8e0de5..a1792a412a 100644 --- a/src/test/java/org/apache/commons/collections4/map/UnmodifiableMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/UnmodifiableMapTest.java @@ -23,6 +23,7 @@ import org.apache.commons.collections4.IterableMap; import org.apache.commons.collections4.Unmodifiable; +import org.junit.Test; /** * Extension of {@link AbstractMapTest} for exercising the @@ -65,11 +66,13 @@ public IterableMap makeFullMap() { return (IterableMap) UnmodifiableMap.unmodifiableMap(m); } + @Test public void testUnmodifiable() { assertTrue(makeObject() instanceof Unmodifiable); assertTrue(makeFullMap() instanceof Unmodifiable); } + @Test public void testDecorateFactory() { final Map map = makeFullMap(); assertSame(map, UnmodifiableMap.unmodifiableMap(map)); diff --git a/src/test/java/org/apache/commons/collections4/map/UnmodifiableOrderedMapTest.java b/src/test/java/org/apache/commons/collections4/map/UnmodifiableOrderedMapTest.java index dc2313fd3a..a391253573 100644 --- a/src/test/java/org/apache/commons/collections4/map/UnmodifiableOrderedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/UnmodifiableOrderedMapTest.java @@ -22,6 +22,7 @@ import org.apache.commons.collections4.OrderedMap; import org.apache.commons.collections4.Unmodifiable; +import org.junit.Test; /** * Extension of {@link AbstractOrderedMapTest} for exercising the @@ -64,11 +65,13 @@ public OrderedMap makeFullMap() { return UnmodifiableOrderedMap.unmodifiableOrderedMap(m); } + @Test public void testUnmodifiable() { assertTrue(makeObject() instanceof Unmodifiable); assertTrue(makeFullMap() instanceof Unmodifiable); } + @Test public void testDecorateFactory() { final OrderedMap map = makeFullMap(); assertSame(map, UnmodifiableOrderedMap.unmodifiableOrderedMap(map)); diff --git a/src/test/java/org/apache/commons/collections4/map/UnmodifiableSortedMapTest.java b/src/test/java/org/apache/commons/collections4/map/UnmodifiableSortedMapTest.java index 0c5fccaf97..629a93596e 100644 --- a/src/test/java/org/apache/commons/collections4/map/UnmodifiableSortedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/UnmodifiableSortedMapTest.java @@ -22,6 +22,7 @@ import java.util.TreeMap; import org.apache.commons.collections4.Unmodifiable; +import org.junit.Test; /** * Extension of {@link AbstractSortedMapTest} for exercising the @@ -64,11 +65,13 @@ public SortedMap makeFullMap() { return UnmodifiableSortedMap.unmodifiableSortedMap(m); } + @Test public void testUnmodifiable() { assertTrue(makeObject() instanceof Unmodifiable); assertTrue(makeFullMap() instanceof Unmodifiable); } + @Test public void testDecorateFactory() { final SortedMap map = makeFullMap(); assertSame(map, UnmodifiableSortedMap.unmodifiableSortedMap(map)); @@ -76,6 +79,7 @@ public void testDecorateFactory() { assertThrows(NullPointerException.class, () -> UnmodifiableSortedMap.unmodifiableSortedMap(null)); } + @Test public void testHeadMap() { final SortedMap map = makeFullMap(); final SortedMap m = new TreeMap<>(); @@ -88,6 +92,7 @@ public void testHeadMap() { assertSame(16, map.headMap((K) "we'll").size()); } + @Test public void testTailMap() { final SortedMap map = makeFullMap(); @@ -100,6 +105,7 @@ public void testTailMap() { assertSame(18, map.tailMap((K) "again").size()); } + @Test public void testSubMap() { final SortedMap map = makeFullMap(); diff --git a/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java index 45d426a37d..2748d78f03 100644 --- a/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java @@ -42,6 +42,7 @@ import org.apache.commons.collections4.map.AbstractMapTest; import org.apache.commons.collections4.multiset.AbstractMultiSetTest; import org.apache.commons.collections4.set.AbstractSetTest; +import org.junit.Test; /** * Abstract test class for {@link MultiValuedMap} contract and methods. @@ -210,12 +211,14 @@ public void resetFull() { } } + @Test @SuppressWarnings("unchecked") public void testNoMappingReturnsEmptyCol() { final MultiValuedMap map = makeFullMap(); assertTrue(map.get((K) "whatever").isEmpty()); } + @Test public void testMultipleValues() { final MultiValuedMap map = makeFullMap(); @SuppressWarnings("unchecked") @@ -224,6 +227,7 @@ public void testMultipleValues() { assertTrue(col.contains("un")); } + @Test @SuppressWarnings("unchecked") public void testGet() { final MultiValuedMap map = makeFullMap(); @@ -235,6 +239,7 @@ public void testGet() { assertTrue(map.get((K) "three").contains("trois")); } + @Test @SuppressWarnings("unchecked") public void testAddMappingThroughGet(){ if (!isAddSupported()) { @@ -258,6 +263,7 @@ public void testAddMappingThroughGet(){ assertTrue(col2.contains("uno")); } + @Test public void testRemoveMappingThroughGet() { if (!isRemoveSupported()) { return; @@ -281,6 +287,7 @@ public void testRemoveMappingThroughGet() { assertEquals(0, col.size()); } + @Test public void testRemoveMappingThroughGetIterator() { if (!isRemoveSupported()) { return; @@ -304,6 +311,7 @@ public void testRemoveMappingThroughGetIterator() { assertEquals(0, coll.size()); } + @Test public void testContainsValue() { final MultiValuedMap map = makeFullMap(); assertTrue(map.containsValue("uno")); @@ -315,6 +323,7 @@ public void testContainsValue() { assertFalse(map.containsValue("quatro")); } + @Test public void testKeyContainsValue() { final MultiValuedMap map = makeFullMap(); assertTrue(map.containsMapping("one", "uno")); @@ -326,6 +335,7 @@ public void testKeyContainsValue() { assertFalse(map.containsMapping("four", "quatro")); } + @Test @SuppressWarnings("unchecked") public void testValues() { final MultiValuedMap map = makeFullMap(); @@ -348,6 +358,7 @@ public void testValues() { // assertEquals(expected, actual); // } + @Test @SuppressWarnings("unchecked") public void testRemoveAllViaValuesIterator() { if (!isRemoveSupported()) { @@ -362,6 +373,7 @@ public void testRemoveAllViaValuesIterator() { assertTrue(map.isEmpty()); } + @Test public void testRemoveViaValuesRemove() { if (!isRemoveSupported()) { return; @@ -399,6 +411,7 @@ public void testRemoveViaValuesRemove() { // assertEquals(4, map.size()); // } + @Test public void testEntriesCollectionIterator() { final MultiValuedMap map = makeFullMap(); final Collection values = new ArrayList<>(map.values()); @@ -416,6 +429,7 @@ public void testEntriesCollectionIterator() { } } + @Test @SuppressWarnings("unchecked") public void testRemoveAllViaEntriesIterator() { if (!isRemoveSupported()) { @@ -430,11 +444,13 @@ public void testRemoveAllViaEntriesIterator() { assertEquals(0, map.size()); } + @Test public void testSize() { assertEquals(6, makeFullMap().size()); } // ----------------------------------------------------------------------- + @Test @SuppressWarnings("unchecked") public void testMapEquals() { if (!isAddSupported()) { @@ -449,6 +465,7 @@ public void testMapEquals() { assertEquals(two, one); } + @Test @SuppressWarnings("unchecked") public void testSizeWithPutRemove() { if (!isRemoveSupported() || !isAddSupported()) { @@ -470,11 +487,13 @@ public void testSizeWithPutRemove() { assertEquals(2, map.size()); } + @Test public void testKeySetSize() { final MultiValuedMap map = makeFullMap(); assertEquals(3, map.keySet().size()); } + @Test @SuppressWarnings("unchecked") public void testSize_Key() { final MultiValuedMap map = makeFullMap(); @@ -530,6 +549,7 @@ public void testSize_Key() { // assertEquals(false, it.hasNext()); // } + @Test @SuppressWarnings("unchecked") public void testContainsValue_Key() { final MultiValuedMap map = makeFullMap(); @@ -543,6 +563,7 @@ public void testContainsValue_Key() { assertFalse(map.containsMapping("A", "AB")); } + @Test @SuppressWarnings("unchecked") public void testPutAll_Map1() { if (!isAddSupported()) { @@ -571,6 +592,7 @@ public void testPutAll_Map1() { assertTrue(test.containsValue("object2")); } + @Test @SuppressWarnings("unchecked") public void testPutAll_Map2() { if (!isAddSupported()) { @@ -600,6 +622,7 @@ public void testPutAll_Map2() { assertTrue(test.containsValue("object2")); } + @Test @SuppressWarnings("unchecked") public void testPutAll_KeyIterable() { if (!isAddSupported()) { @@ -637,6 +660,7 @@ public void testPutAll_KeyIterable() { assertTrue(map.containsMapping("A", "M")); } + @Test @SuppressWarnings("unchecked") public void testRemove_KeyItem() { if (!isRemoveSupported() || !isAddSupported()) { @@ -654,6 +678,7 @@ public void testRemove_KeyItem() { //assertEquals(new MultiValuedHashMap(), map); } + @Test public void testToString(){ if (!isAddSupported()) { return; @@ -683,6 +708,7 @@ public void testToString(){ assertEquals("{}", map.toString()); } + @Test public void testKeysMultiSet() { final MultiValuedMap map = makeFullMap(); final MultiSet keyMultiSet = map.keys(); @@ -693,6 +719,7 @@ public void testKeysMultiSet() { assertEquals(6, keyMultiSet.size()); } + @Test public void testKeysBagIterator() { final MultiValuedMap map = makeFullMap(); final Collection col = new ArrayList<>(); @@ -707,6 +734,7 @@ public void testKeysBagIterator() { assertEquals(6, bag.size()); } + @Test @SuppressWarnings("unchecked") public void testKeysBagContainsAll() { final MultiValuedMap map = makeFullMap(); @@ -715,6 +743,7 @@ public void testKeysBagContainsAll() { assertTrue(keyMultiSet.containsAll(col)); } + @Test public void testAsMapGet() { resetEmpty(); Map> mapCol = getMap().asMap(); @@ -729,6 +758,7 @@ public void testAsMapGet() { assertTrue(col.contains("uno")); } + @Test public void testAsMapRemove() { if (!isRemoveSupported()) { return; @@ -740,6 +770,7 @@ public void testAsMapRemove() { assertEquals(4, getMap().size()); } + @Test public void testMapIterator() { resetEmpty(); MapIterator mapIt = getMap().mapIterator(); @@ -754,6 +785,7 @@ public void testMapIterator() { } } + @Test public void testMapIteratorRemove() { if (!isRemoveSupported()) { return; @@ -767,6 +799,7 @@ public void testMapIteratorRemove() { assertTrue(getMap().isEmpty()); } + @Test @SuppressWarnings("unchecked") public void testMapIteratorUnsupportedSet() { resetFull(); @@ -775,6 +808,7 @@ public void testMapIteratorUnsupportedSet() { assertThrows(UnsupportedOperationException.class, () -> mapIt.setValue((V) "some value")); } + @Test public void testMultiValuedMapIterator() { final MultiValuedMap map = makeFullMap(); final MapIterator it = map.mapIterator(); @@ -814,6 +848,7 @@ public void testMultiValuedMapIterator() { // extend the AbstractTestMap // ----------------------------------------------------------------------- + @Test public void testEmptyMapCompatibility() throws Exception { final MultiValuedMap map = makeObject(); final MultiValuedMap map2 = @@ -822,6 +857,7 @@ public void testEmptyMapCompatibility() throws Exception { } @SuppressWarnings({ "rawtypes", "unchecked" }) + @Test public void testFullMapCompatibility() throws Exception { final MultiValuedMap map = makeFullMap(); final MultiValuedMap map2 = diff --git a/src/test/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMapTest.java index 63cc6c6649..0a61b9368e 100644 --- a/src/test/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMapTest.java +++ b/src/test/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMapTest.java @@ -23,11 +23,10 @@ import java.util.Arrays; import java.util.ArrayList; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.ListValuedMap; import org.apache.commons.collections4.MultiValuedMap; +import org.junit.Test; /** * Test ArrayListValuedHashMap @@ -40,7 +39,7 @@ public ArrayListValuedHashMapTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(ArrayListValuedHashMapTest.class); } @@ -51,6 +50,7 @@ public ListValuedMap makeObject() { } // ----------------------------------------------------------------------- + @Test @SuppressWarnings("unchecked") public void testListValuedMapAdd() { final ListValuedMap listMap = makeObject(); @@ -61,6 +61,7 @@ public void testListValuedMapAdd() { assertTrue(listMap.containsKey("A")); } + @Test @SuppressWarnings("unchecked") public void testListValuedMapAddViaListIterator() { final ListValuedMap listMap = makeObject(); @@ -75,6 +76,7 @@ public void testListValuedMapAddViaListIterator() { assertFalse(listIt.hasNext()); } + @Test @SuppressWarnings("unchecked") public void testListValuedMapRemove() { final ListValuedMap listMap = makeObject(); @@ -92,6 +94,7 @@ public void testListValuedMapRemove() { assertFalse(listMap.containsKey("A")); } + @Test @SuppressWarnings("unchecked") public void testListValuedMapRemoveViaListIterator() { final ListValuedMap listMap = makeObject(); @@ -113,6 +116,7 @@ public void testListValuedMapRemoveViaListIterator() { } @SuppressWarnings({ "unchecked", "rawtypes" }) + @Test public void testEqualsHashCodeContract() { final MultiValuedMap map1 = makeObject(); final MultiValuedMap map2 = makeObject(); @@ -130,6 +134,7 @@ public void testEqualsHashCodeContract() { } @SuppressWarnings({ "unchecked", "rawtypes" }) + @Test public void testListValuedMapEqualsHashCodeContract() { final ListValuedMap map1 = makeObject(); final ListValuedMap map2 = makeObject(); @@ -149,6 +154,7 @@ public void testListValuedMapEqualsHashCodeContract() { assertNotSame(map1.hashCode(), map2.hashCode()); } + @Test public void testArrayListValuedHashMap() { final ListValuedMap listMap; final ListValuedMap listMap1; @@ -167,6 +173,7 @@ public void testArrayListValuedHashMap() { assertEquals("{}", listMap1.toString()); } + @Test public void testTrimToSize(){ final ArrayListValuedHashMap listMap = new ArrayListValuedHashMap<>(4); @@ -182,6 +189,7 @@ public void testTrimToSize(){ assertEquals(1, listMap.get((K) "B").size()); } + @Test public void testWrappedListAdd() { final ListValuedMap listMap = makeObject(); final List listA = listMap.get((K) "A"); @@ -193,6 +201,7 @@ public void testWrappedListAdd() { assertEquals("{A=[W, Q, F]}", listMap.toString()); } + @Test public void testWrappedListAddAll() { final ListValuedMap listMap = makeObject(); final List listA = listMap.get((K) "A"); @@ -224,6 +233,7 @@ public void testWrappedListAddAll() { assertEquals("Q", list3.get(2)); } + @Test public void testValuesListIteratorMethods(){ final ListValuedMap listMap = makeObject(); final List listA = listMap.get((K) "A"); diff --git a/src/test/java/org/apache/commons/collections4/multimap/HashSetValuedHashMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/HashSetValuedHashMapTest.java index 1993de5af0..828ad5aab9 100644 --- a/src/test/java/org/apache/commons/collections4/multimap/HashSetValuedHashMapTest.java +++ b/src/test/java/org/apache/commons/collections4/multimap/HashSetValuedHashMapTest.java @@ -21,11 +21,10 @@ import java.util.Map; import java.util.Set; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.MultiValuedMap; import org.apache.commons.collections4.SetValuedMap; +import org.junit.Test; /** * Test HashSetValuedHashMap @@ -38,7 +37,7 @@ public HashSetValuedHashMapTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(HashSetValuedHashMapTest.class); } @@ -59,6 +58,7 @@ public boolean isHashSetValue() { } // ----------------------------------------------------------------------- + @Test @SuppressWarnings("unchecked") public void testSetValuedMapAdd() { final SetValuedMap setMap = makeObject(); @@ -72,6 +72,7 @@ public void testSetValuedMapAdd() { assertTrue(setMap.containsKey("A")); } + @Test @SuppressWarnings("unchecked") public void testSetValuedMapRemove() { final SetValuedMap setMap = makeObject(); @@ -92,6 +93,7 @@ public void testSetValuedMapRemove() { assertFalse(setMap.containsKey("A")); } + @Test @SuppressWarnings("unchecked") public void testSetValuedMapRemoveViaIterator() { final SetValuedMap setMap = makeObject(); @@ -112,6 +114,7 @@ public void testSetValuedMapRemoveViaIterator() { } @SuppressWarnings({ "unchecked", "rawtypes" }) + @Test public void testSetValuedMapEqualsHashCodeContract() { final SetValuedMap map1 = makeObject(); final SetValuedMap map2 = makeObject(); @@ -132,6 +135,7 @@ public void testSetValuedMapEqualsHashCodeContract() { assertNotSame(map1.hashCode(), map2.hashCode()); } + @Test public void testHashSetValueHashMap() { final SetValuedMap setMap = new HashSetValuedHashMap<>(4); assertEquals(0, setMap.get((K) "whatever").size()); @@ -143,6 +147,7 @@ public void testHashSetValueHashMap() { assertEquals(3, setMap.get((K) "A").size()); } + @Test public void testHashSetValueHashMap_1() { final MultiValuedMap map = new ArrayListValuedHashMap<>(); final SetValuedMap map1; @@ -165,6 +170,7 @@ public void testHashSetValueHashMap_1() { assertEquals("{}", map3.toString()); } + @Test public void testHashSetValuedHashMap_2(){ final Map map = new HashMap<>(); final SetValuedMap map1; diff --git a/src/test/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMapTest.java index 7c7d9cd85f..f8c2438fb8 100644 --- a/src/test/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMapTest.java @@ -18,13 +18,12 @@ import java.util.Collection; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.MultiValuedMap; import org.apache.commons.collections4.Transformer; import org.apache.commons.collections4.TransformerUtils; import org.apache.commons.collections4.collection.TransformedCollectionTest; +import org.junit.Test; /** * Tests for TransformedMultiValuedMap @@ -37,7 +36,7 @@ public TransformedMultiValuedMapTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(TransformedMultiValuedMapTest.class); } @@ -49,6 +48,7 @@ public MultiValuedMap makeObject() { } // ----------------------------------------------------------------------- + @Test @SuppressWarnings("unchecked") public void testKeyTransformedMap() { final Object[] els = { "1", "3", "5", "7", "2", "4", "6" }; @@ -73,6 +73,7 @@ public void testKeyTransformedMap() { assertTrue(map.remove(Integer.valueOf((String) els[0])).contains(els[0])); } + @Test @SuppressWarnings("unchecked") public void testValueTransformedMap() { final Object[] els = { "1", "3", "5", "7", "2", "4", "6" }; @@ -93,6 +94,7 @@ public void testValueTransformedMap() { } // ----------------------------------------------------------------------- + @Test @SuppressWarnings("unchecked") public void testFactory_Decorate() { final MultiValuedMap base = new ArrayListValuedHashMap<>(); @@ -113,6 +115,7 @@ public void testFactory_Decorate() { assertTrue(trans.get((K) "D").contains(Integer.valueOf(4))); } + @Test @SuppressWarnings("unchecked") public void testFactory_decorateTransform() { final MultiValuedMap base = new ArrayListValuedHashMap<>(); diff --git a/src/test/java/org/apache/commons/collections4/multimap/UnmodifiableMultiValuedMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/UnmodifiableMultiValuedMapTest.java index efbce78531..e4af045764 100644 --- a/src/test/java/org/apache/commons/collections4/multimap/UnmodifiableMultiValuedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/multimap/UnmodifiableMultiValuedMapTest.java @@ -26,13 +26,12 @@ import java.util.Collection; import java.util.Iterator; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.MapIterator; import org.apache.commons.collections4.MultiSet; import org.apache.commons.collections4.MultiValuedMap; import org.apache.commons.collections4.Unmodifiable; +import org.junit.Test; /** * Tests for UnmodifiableMultiValuedMap @@ -45,7 +44,7 @@ public UnmodifiableMultiValuedMapTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(UnmodifiableMultiValuedMapTest.class); } @@ -84,27 +83,32 @@ protected MultiValuedMap makeFullMap() { } // ----------------------------------------------------------------------- + @Test public void testUnmodifiable() { assertTrue(makeObject() instanceof Unmodifiable); assertTrue(makeFullMap() instanceof Unmodifiable); } + @Test public void testDecorateFactory() { final MultiValuedMap map = makeFullMap(); assertSame(map, UnmodifiableMultiValuedMap.unmodifiableMultiValuedMap(map)); } + @Test public void testDecoratorFactoryNullMap() { assertThrows(NullPointerException.class, () -> UnmodifiableMultiValuedMap.unmodifiableMultiValuedMap(null), "map must not be null"); } + @Test @SuppressWarnings("unchecked") public void testAddException() { final MultiValuedMap map = makeObject(); assertThrows(UnsupportedOperationException.class, () -> map.put((K) "one", (V) "uno")); } + @Test public void testRemoveException() { final MultiValuedMap map = makeFullMap(); assertThrows(UnsupportedOperationException.class, () -> map.remove("one"), @@ -112,6 +116,7 @@ public void testRemoveException() { this.assertMapContainsAllValues(map); } + @Test public void testRemoveMappingException() { final MultiValuedMap map = makeFullMap(); assertThrows(UnsupportedOperationException.class, () -> map.removeMapping("one", "uno"), @@ -119,6 +124,7 @@ public void testRemoveMappingException() { this.assertMapContainsAllValues(map); } + @Test public void testClearException() { final MultiValuedMap map = makeFullMap(); assertThrows(UnsupportedOperationException.class, () -> map.clear(), @@ -126,6 +132,7 @@ public void testClearException() { this.assertMapContainsAllValues(map); } + @Test public void testPutAllException() { final MultiValuedMap map = makeObject(); final MultiValuedMap original = new ArrayListValuedHashMap<>(); @@ -147,6 +154,7 @@ public void testPutAllException() { assertEquals("{}", map.toString()); } + @Test @SuppressWarnings("unchecked") public void testUnmodifiableEntries() { resetFull(); @@ -160,6 +168,7 @@ public void testUnmodifiableEntries() { assertThrows(UnsupportedOperationException.class, () -> entry.setValue((V) "three")); } + @Test @SuppressWarnings("unchecked") public void testUnmodifiableMapIterator() { resetFull(); @@ -169,6 +178,7 @@ public void testUnmodifiableMapIterator() { assertThrows(UnsupportedOperationException.class, () -> mapIt.setValue((V) "three")); } + @Test @SuppressWarnings("unchecked") public void testUnmodifiableKeySet() { resetFull(); @@ -183,6 +193,7 @@ public void testUnmodifiableKeySet() { assertThrows(UnsupportedOperationException.class, () -> it.remove()); } + @Test @SuppressWarnings("unchecked") public void testUnmodifiableValues() { resetFull(); @@ -197,6 +208,7 @@ public void testUnmodifiableValues() { assertThrows(UnsupportedOperationException.class, () -> it.remove()); } + @Test @SuppressWarnings("unchecked") public void testUnmodifiableAsMap() { resetFull(); @@ -210,6 +222,7 @@ public void testUnmodifiableAsMap() { assertThrows(UnsupportedOperationException.class, () -> mapCol.clear()); } + @Test @SuppressWarnings("unchecked") public void testUnmodifiableKeys() { resetFull(); diff --git a/src/test/java/org/apache/commons/collections4/multiset/AbstractMultiSetTest.java b/src/test/java/org/apache/commons/collections4/multiset/AbstractMultiSetTest.java index 8463c754e9..678c0742af 100644 --- a/src/test/java/org/apache/commons/collections4/multiset/AbstractMultiSetTest.java +++ b/src/test/java/org/apache/commons/collections4/multiset/AbstractMultiSetTest.java @@ -34,6 +34,7 @@ import org.apache.commons.collections4.MultiSet; import org.apache.commons.collections4.collection.AbstractCollectionTest; import org.apache.commons.collections4.set.AbstractSetTest; +import org.junit.Test; /** * Abstract test class for {@link org.apache.commons.collections4.MultiSet MultiSet} @@ -128,6 +129,7 @@ public MultiSet getCollection() { return (MultiSet) super.getCollection(); } + @Test @SuppressWarnings("unchecked") public void testMultiSetAdd() { if (!isAddSupported()) { @@ -146,6 +148,7 @@ public void testMultiSetAdd() { assertTrue(multiset.contains("B")); } + @Test @SuppressWarnings("unchecked") public void testMultiSetEqualsSelf() { final MultiSet multiset = makeObject(); @@ -163,6 +166,7 @@ public void testMultiSetEqualsSelf() { assertEquals(multiset, multiset); } + @Test @SuppressWarnings("unchecked") public void testMultiSetRemove() { if (!isRemoveSupported()) { @@ -187,6 +191,7 @@ public void testMultiSetRemove() { assertEquals("Should have count of 1", 1, multiset.getCount("A")); } + @Test @SuppressWarnings("unchecked") public void testMultiSetRemoveAll() { if (!isRemoveSupported()) { @@ -209,6 +214,7 @@ public void testMultiSetRemoveAll() { assertEquals("Should have count of 1", 1, multiset.size()); } + @Test @SuppressWarnings("unchecked") public void testMultiSetContains() { if (!isAddSupported()) { @@ -233,6 +239,7 @@ public void testMultiSetContains() { assertTrue("MultiSet has at least 1 'B'", multiset.contains("B")); } + @Test @SuppressWarnings("unchecked") public void testMultiSetContainsAll() { if (!isAddSupported()) { @@ -287,6 +294,7 @@ public void testMultiSetContainsAll() { assertTrue("MultiSet containsAll of 1 'A' 1 'B'", multiset.containsAll(known1A1B)); } + @Test @SuppressWarnings("unchecked") public void testMultiSetSize() { if (!isAddSupported()) { @@ -312,6 +320,7 @@ public void testMultiSetSize() { assertEquals("Should have 2 total item", 2, multiset.size()); } + @Test @SuppressWarnings("unchecked") public void testMultiSetRetainAll() { if (!isAddSupported()) { @@ -332,6 +341,7 @@ public void testMultiSetRetainAll() { assertEquals("Should have 3 total items", 3, multiset.size()); } + @Test @SuppressWarnings("unchecked") public void testMultiSetIterator() { if (!isAddSupported()) { @@ -363,6 +373,7 @@ public void testMultiSetIterator() { assertEquals("MultiSet should have 1 'A'", 1, multiset.getCount("A")); } + @Test @SuppressWarnings("unchecked") public void testMultiSetIteratorFail() { if (!isAddSupported()) { @@ -380,6 +391,7 @@ public void testMultiSetIteratorFail() { "Should throw ConcurrentModificationException"); } + @Test @SuppressWarnings("unchecked") public void testMultiSetIteratorFailNoMore() { if (!isAddSupported()) { @@ -398,6 +410,7 @@ public void testMultiSetIteratorFailNoMore() { "Should throw NoSuchElementException"); } + @Test @SuppressWarnings("unchecked") public void testMultiSetIteratorFailDoubleRemove() { if (!isAddSupported()) { @@ -422,6 +435,7 @@ public void testMultiSetIteratorFailDoubleRemove() { assertEquals(1, multiset.size()); } + @Test @SuppressWarnings("unchecked") public void testMultiSetIteratorRemoveProtectsInvariants() { if (!isAddSupported()) { @@ -448,6 +462,7 @@ public void testMultiSetIteratorRemoveProtectsInvariants() { assertFalse(it2.hasNext()); } + @Test @SuppressWarnings("unchecked") public void testMultiSetEntrySetUpdatedToZero() { if (!isAddSupported()) { @@ -464,6 +479,7 @@ public void testMultiSetEntrySetUpdatedToZero() { assertEquals(0, entry.getCount()); } + @Test @SuppressWarnings("unchecked") public void testMultiSetToArray() { if (!isAddSupported()) { @@ -488,6 +504,7 @@ public void testMultiSetToArray() { assertEquals(1, c); } + @Test @SuppressWarnings("unchecked") public void testMultiSetToArrayPopulate() { if (!isAddSupported()) { @@ -512,6 +529,7 @@ public void testMultiSetToArrayPopulate() { assertEquals(1, c); } + @Test @SuppressWarnings("unchecked") public void testMultiSetEquals() { if (!isAddSupported()) { @@ -536,6 +554,7 @@ public void testMultiSetEquals() { assertTrue(multiset.equals(multiset2)); } + @Test @SuppressWarnings("unchecked") public void testMultiSetEqualsHashMultiSet() { if (!isAddSupported()) { @@ -560,6 +579,7 @@ public void testMultiSetEqualsHashMultiSet() { assertTrue(multiset.equals(multiset2)); } + @Test @SuppressWarnings("unchecked") public void testMultiSetHashCode() { if (!isAddSupported()) { @@ -674,6 +694,7 @@ public void verify() { * Compare the current serialized form of the MultiSet * against the canonical version in SCM. */ + @Test public void testEmptyMultiSetCompatibility() throws IOException, ClassNotFoundException { // test to make sure the canonical form has been preserved final MultiSet multiset = makeObject(); @@ -688,6 +709,7 @@ public void testEmptyMultiSetCompatibility() throws IOException, ClassNotFoundEx * Compare the current serialized form of the MultiSet * against the canonical version in SCM. */ + @Test public void testFullMultiSetCompatibility() throws IOException, ClassNotFoundException { // test to make sure the canonical form has been preserved final MultiSet multiset = makeFullCollection(); diff --git a/src/test/java/org/apache/commons/collections4/multiset/HashMultiSetTest.java b/src/test/java/org/apache/commons/collections4/multiset/HashMultiSetTest.java index c0d040c189..39e5048e81 100644 --- a/src/test/java/org/apache/commons/collections4/multiset/HashMultiSetTest.java +++ b/src/test/java/org/apache/commons/collections4/multiset/HashMultiSetTest.java @@ -16,8 +16,6 @@ */ package org.apache.commons.collections4.multiset; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.MultiSet; @@ -33,7 +31,7 @@ public HashMultiSetTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(HashMultiSetTest.class); } diff --git a/src/test/java/org/apache/commons/collections4/multiset/PredicatedMultiSetTest.java b/src/test/java/org/apache/commons/collections4/multiset/PredicatedMultiSetTest.java index 4dca4d990b..4012846470 100644 --- a/src/test/java/org/apache/commons/collections4/multiset/PredicatedMultiSetTest.java +++ b/src/test/java/org/apache/commons/collections4/multiset/PredicatedMultiSetTest.java @@ -20,12 +20,11 @@ import java.util.Set; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.MultiSet; import org.apache.commons.collections4.Predicate; import org.apache.commons.collections4.functors.TruePredicate; +import org.junit.Test; /** * Extension of {@link AbstractMultiSetTest} for exercising the @@ -39,7 +38,7 @@ public PredicatedMultiSetTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(PredicatedMultiSetTest.class); } @@ -66,6 +65,7 @@ protected MultiSet makeTestMultiSet() { //-------------------------------------------------------------------------- + @Test @SuppressWarnings("unchecked") public void testLegalAddRemove() { final MultiSet multiset = makeTestMultiSet(); @@ -84,6 +84,7 @@ public void testLegalAddRemove() { set.contains(els[0])); } + @Test @SuppressWarnings("unchecked") public void testIllegalAdd() { final MultiSet multiset = makeTestMultiSet(); @@ -93,6 +94,7 @@ public void testIllegalAdd() { assertFalse("Collection shouldn't contain illegal element", multiset.contains(i)); } + @Test @SuppressWarnings("unchecked") public void testIllegalDecorate() { final HashMultiSet elements = new HashMultiSet<>(); diff --git a/src/test/java/org/apache/commons/collections4/multiset/SynchronizedMultiSetTest.java b/src/test/java/org/apache/commons/collections4/multiset/SynchronizedMultiSetTest.java index 11f3f4c989..7fbe3465ea 100644 --- a/src/test/java/org/apache/commons/collections4/multiset/SynchronizedMultiSetTest.java +++ b/src/test/java/org/apache/commons/collections4/multiset/SynchronizedMultiSetTest.java @@ -16,8 +16,6 @@ */ package org.apache.commons.collections4.multiset; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.MultiSet; @@ -33,7 +31,7 @@ public SynchronizedMultiSetTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(SynchronizedMultiSetTest.class); } diff --git a/src/test/java/org/apache/commons/collections4/multiset/UnmodifiableMultiSetTest.java b/src/test/java/org/apache/commons/collections4/multiset/UnmodifiableMultiSetTest.java index 84f1d4fa53..72287f3fe3 100644 --- a/src/test/java/org/apache/commons/collections4/multiset/UnmodifiableMultiSetTest.java +++ b/src/test/java/org/apache/commons/collections4/multiset/UnmodifiableMultiSetTest.java @@ -20,11 +20,10 @@ import java.util.Arrays; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.MultiSet; import org.apache.commons.collections4.Unmodifiable; +import org.junit.Test; /** * Extension of {@link AbstractMultiSetTest} for exercising the @@ -38,7 +37,7 @@ public UnmodifiableMultiSetTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(UnmodifiableMultiSetTest.class); } @@ -74,12 +73,13 @@ public boolean isNullSupported() { return false; } - + @Test public void testUnmodifiable() { assertTrue(makeObject() instanceof Unmodifiable); assertTrue(makeFullCollection() instanceof Unmodifiable); } + @Test public void testDecorateFactory() { final MultiSet multiset = makeFullCollection(); assertSame(multiset, UnmodifiableMultiSet.unmodifiableMultiSet(multiset)); @@ -87,25 +87,28 @@ public void testDecorateFactory() { assertThrows(NullPointerException.class, () -> UnmodifiableMultiSet.unmodifiableMultiSet(null)); } - + @Test public void testAdd() { final MultiSet multiset = makeFullCollection(); final MultiSet unmodifiableMultiSet = UnmodifiableMultiSet.unmodifiableMultiSet(multiset); assertThrows(UnsupportedOperationException.class, () -> unmodifiableMultiSet.add((E) "One", 1)); } + @Test public void testRemove() { final MultiSet multiset = makeFullCollection(); final MultiSet unmodifiableMultiSet = UnmodifiableMultiSet.unmodifiableMultiSet(multiset); assertThrows(UnsupportedOperationException.class, () -> unmodifiableMultiSet.remove("One", 1)); } + @Test public void testSetCount() { final MultiSet multiset = makeFullCollection(); final MultiSet unmodifiableMultiSet = UnmodifiableMultiSet.unmodifiableMultiSet(multiset); assertThrows(UnsupportedOperationException.class, () -> unmodifiableMultiSet.setCount((E) "One", 2)); } + @Test public void testEntrySet() { final MultiSet multiset = makeFullCollection(); final MultiSet unmodifiableMultiSet = UnmodifiableMultiSet.unmodifiableMultiSet(multiset); diff --git a/src/test/java/org/apache/commons/collections4/properties/EmptyPropertiesTest.java b/src/test/java/org/apache/commons/collections4/properties/EmptyPropertiesTest.java index 03e30331e5..5bb614d5b8 100644 --- a/src/test/java/org/apache/commons/collections4/properties/EmptyPropertiesTest.java +++ b/src/test/java/org/apache/commons/collections4/properties/EmptyPropertiesTest.java @@ -107,6 +107,7 @@ public void testEquals() { assertNotEquals(p, PropertiesFactory.EMPTY_PROPERTIES); } + @Test public void testForEach() { PropertiesFactory.EMPTY_PROPERTIES.forEach((k, v) -> fail()); } diff --git a/src/test/java/org/apache/commons/collections4/properties/PropertiesFactoryTest.java b/src/test/java/org/apache/commons/collections4/properties/PropertiesFactoryTest.java index 92ae8b9a03..14bf37c177 100644 --- a/src/test/java/org/apache/commons/collections4/properties/PropertiesFactoryTest.java +++ b/src/test/java/org/apache/commons/collections4/properties/PropertiesFactoryTest.java @@ -28,8 +28,8 @@ public PropertiesFactoryTest(final String fileExtension) { super(PropertiesFactory.INSTANCE, fileExtension); } - @Override @Test + @Override public void testInstance() { Assertions.assertNotNull(PropertiesFactory.INSTANCE); } diff --git a/src/test/java/org/apache/commons/collections4/properties/SortedPropertiesFactoryTest.java b/src/test/java/org/apache/commons/collections4/properties/SortedPropertiesFactoryTest.java index 8a90e4fbac..46fa35a062 100644 --- a/src/test/java/org/apache/commons/collections4/properties/SortedPropertiesFactoryTest.java +++ b/src/test/java/org/apache/commons/collections4/properties/SortedPropertiesFactoryTest.java @@ -25,8 +25,8 @@ public SortedPropertiesFactoryTest(final String fileExtension) { super(SortedPropertiesFactory.INSTANCE, fileExtension); } - @Override @Test + @Override public void testInstance() { Assertions.assertNotNull(SortedPropertiesFactory.INSTANCE); } diff --git a/src/test/java/org/apache/commons/collections4/queue/AbstractQueueTest.java b/src/test/java/org/apache/commons/collections4/queue/AbstractQueueTest.java index 273cfd3d30..279c016b9f 100644 --- a/src/test/java/org/apache/commons/collections4/queue/AbstractQueueTest.java +++ b/src/test/java/org/apache/commons/collections4/queue/AbstractQueueTest.java @@ -28,6 +28,7 @@ import java.util.Queue; import org.apache.commons.collections4.collection.AbstractCollectionTest; +import org.junit.Test; /** * Abstract test class for {@link java.util.Queue} methods and contracts. @@ -128,6 +129,7 @@ public Queue getCollection() { /** * Tests {@link Queue#offer(Object)}. */ + @Test public void testQueueOffer() { if (!isAddSupported()) { return; @@ -160,6 +162,7 @@ public void testQueueOffer() { /** * Tests {@link Queue#element()}. */ + @Test public void testQueueElement() { resetEmpty(); @@ -197,6 +200,7 @@ public void testQueueElement() { /** * Tests {@link Queue#peek()}. */ + @Test public void testQueuePeek() { if (!isRemoveSupported()) { return; @@ -232,6 +236,7 @@ public void testQueuePeek() { /** * Tests {@link Queue#remove()}. */ + @Test public void testQueueRemove() { if (!isRemoveSupported()) { return; @@ -259,6 +264,7 @@ public void testQueueRemove() { /** * Tests {@link Queue#poll()}. */ + @Test public void testQueuePoll() { if (!isRemoveSupported()) { return; @@ -283,6 +289,7 @@ public void testQueuePoll() { assertNull(element); } + @Test @SuppressWarnings("unchecked") public void testEmptyQueueSerialization() throws IOException, ClassNotFoundException { final Queue queue = makeObject(); @@ -297,6 +304,7 @@ public void testEmptyQueueSerialization() throws IOException, ClassNotFoundExcep assertEquals("Both queues are empty", 0, queue2.size()); } + @Test @SuppressWarnings("unchecked") public void testFullQueueSerialization() throws IOException, ClassNotFoundException { final Queue queue = makeFullCollection(); @@ -316,6 +324,7 @@ public void testFullQueueSerialization() throws IOException, ClassNotFoundExcept * Compare the current serialized form of the Queue * against the canonical version in SCM. */ + @Test @SuppressWarnings("unchecked") public void testEmptyQueueCompatibility() throws IOException, ClassNotFoundException { /* @@ -339,6 +348,7 @@ && isTestSerialization()) { * Compare the current serialized form of the Queue * against the canonical version in SCM. */ + @Test @SuppressWarnings("unchecked") public void testFullQueueCompatibility() throws IOException, ClassNotFoundException { /* diff --git a/src/test/java/org/apache/commons/collections4/queue/CircularFifoQueueTest.java b/src/test/java/org/apache/commons/collections4/queue/CircularFifoQueueTest.java index 4980cbb1f0..b46ff5030d 100644 --- a/src/test/java/org/apache/commons/collections4/queue/CircularFifoQueueTest.java +++ b/src/test/java/org/apache/commons/collections4/queue/CircularFifoQueueTest.java @@ -29,6 +29,8 @@ import java.util.NoSuchElementException; import java.util.Queue; +import org.junit.Test; + /** * Test cases for CircularFifoQueue. * @@ -110,6 +112,7 @@ public Queue makeObject() { /** * Tests that the removal operation actually removes the first element. */ + @Test @SuppressWarnings("unchecked") public void testCircularFifoQueueCircular() { final List list = new ArrayList<>(); @@ -138,6 +141,7 @@ public void testCircularFifoQueueCircular() { /** * Tests that the removal operation actually removes the first element. */ + @Test public void testCircularFifoQueueRemove() { resetFull(); final int size = getConfirmed().size(); @@ -155,6 +159,7 @@ public void testCircularFifoQueueRemove() { /** * Tests that the constructor correctly throws an exception. */ + @Test public void testConstructorException1() { assertThrows(IllegalArgumentException.class, () -> new CircularFifoQueue(0)); } @@ -162,6 +167,7 @@ public void testConstructorException1() { /** * Tests that the constructor correctly throws an exception. */ + @Test public void testConstructorException2() { assertThrows(IllegalArgumentException.class, () -> new CircularFifoQueue(-20)); } @@ -169,10 +175,12 @@ public void testConstructorException2() { /** * Tests that the constructor correctly throws an exception. */ + @Test public void testConstructorException3() { assertThrows(NullPointerException.class, () -> new CircularFifoQueue(null)); } + @Test @SuppressWarnings("unchecked") public void testRemoveError1() throws Exception { // based on bug 33071 @@ -192,6 +200,7 @@ public void testRemoveError1() throws Exception { assertEquals("[1, 2, 5]", fifo.toString()); } + @Test @SuppressWarnings("unchecked") public void testRemoveError2() throws Exception { // based on bug 33071 @@ -213,6 +222,7 @@ public void testRemoveError2() throws Exception { assertEquals("[2, 5, 6]", fifo.toString()); } + @Test @SuppressWarnings("unchecked") public void testRemoveError3() throws Exception { // based on bug 33071 @@ -236,6 +246,7 @@ public void testRemoveError3() throws Exception { assertEquals("[2, 5, 6, 7]", fifo.toString()); } + @Test @SuppressWarnings("unchecked") public void testRemoveError4() throws Exception { // based on bug 33071 @@ -254,6 +265,7 @@ public void testRemoveError4() throws Exception { assertEquals("[3, 5, 6, 7]", fifo.toString()); } + @Test @SuppressWarnings("unchecked") public void testRemoveError5() throws Exception { // based on bug 33071 @@ -272,6 +284,7 @@ public void testRemoveError5() throws Exception { assertEquals("[3, 4, 6, 7]", fifo.toString()); } + @Test @SuppressWarnings("unchecked") public void testRemoveError6() throws Exception { // based on bug 33071 @@ -290,6 +303,7 @@ public void testRemoveError6() throws Exception { assertEquals("[3, 4, 5, 7]", fifo.toString()); } + @Test @SuppressWarnings("unchecked") public void testRemoveError7() throws Exception { // based on bug 33071 @@ -308,6 +322,7 @@ public void testRemoveError7() throws Exception { assertEquals("[3, 4, 5, 6]", fifo.toString()); } + @Test @SuppressWarnings("unchecked") public void testRemoveError8() throws Exception { // based on bug 33071 @@ -327,6 +342,7 @@ public void testRemoveError8() throws Exception { assertEquals("[4, 5, 6, 8]", fifo.toString()); } + @Test @SuppressWarnings("unchecked") public void testRemoveError9() throws Exception { // based on bug 33071 @@ -346,6 +362,7 @@ public void testRemoveError9() throws Exception { assertEquals("[4, 5, 6, 7]", fifo.toString()); } + @Test @SuppressWarnings("unchecked") public void testRepeatedSerialization() throws Exception { // bug 31433 @@ -382,6 +399,7 @@ public void testRepeatedSerialization() throws Exception { assertTrue(b3.contains("c")); } + @Test public void testGetIndex() { resetFull(); @@ -400,11 +418,13 @@ public void testGetIndex() { } } + @Test public void testAddNull() { final CircularFifoQueue b = new CircularFifoQueue<>(2); assertThrows(NullPointerException.class, () -> b.add(null)); } + @Test public void testDefaultSizeAndGetError1() { final CircularFifoQueue fifo = new CircularFifoQueue<>(); assertEquals(32, fifo.maxSize()); @@ -417,6 +437,7 @@ public void testDefaultSizeAndGetError1() { assertThrows(NoSuchElementException.class, () -> fifo.get(5)); } + @Test public void testDefaultSizeAndGetError2() { final CircularFifoQueue fifo = new CircularFifoQueue<>(); assertEquals(32, fifo.maxSize()); diff --git a/src/test/java/org/apache/commons/collections4/queue/PredicatedQueueTest.java b/src/test/java/org/apache/commons/collections4/queue/PredicatedQueueTest.java index e365b3fe40..c4c3c19fe2 100644 --- a/src/test/java/org/apache/commons/collections4/queue/PredicatedQueueTest.java +++ b/src/test/java/org/apache/commons/collections4/queue/PredicatedQueueTest.java @@ -25,6 +25,7 @@ import org.apache.commons.collections4.Predicate; import org.apache.commons.collections4.collection.PredicatedCollectionTest; import org.apache.commons.collections4.functors.TruePredicate; +import org.junit.Test; /** * Extension of {@link PredicatedCollectionTest} for exercising the @@ -76,6 +77,7 @@ public Queue makeTestQueue() { return decorateCollection(new LinkedList(), testPredicate); } + @Test @SuppressWarnings("unchecked") public void testGet() { final Queue queue = makeTestQueue(); @@ -88,6 +90,7 @@ public void testGet() { assertEquals("Queue get", "one", queue.peek()); } + @Test @SuppressWarnings("unchecked") public void testRemove() { final Queue queue = makeTestQueue(); diff --git a/src/test/java/org/apache/commons/collections4/queue/SynchronizedQueueTest.java b/src/test/java/org/apache/commons/collections4/queue/SynchronizedQueueTest.java index 898291e1ee..738bcf63d9 100644 --- a/src/test/java/org/apache/commons/collections4/queue/SynchronizedQueueTest.java +++ b/src/test/java/org/apache/commons/collections4/queue/SynchronizedQueueTest.java @@ -21,8 +21,7 @@ import org.apache.commons.collections4.BulkTest; import org.junit.Ignore; - -import junit.framework.Test; +import org.junit.Test; /** * Extension of {@link AbstractQueueTest} for exercising the {@link SynchronizedQueue} implementation. @@ -31,7 +30,7 @@ */ public class SynchronizedQueueTest extends AbstractQueueTest { - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(SynchronizedQueueTest.class); } @@ -51,6 +50,7 @@ public Queue makeObject() { return SynchronizedQueue.synchronizedQueue(new LinkedList()); } + @Test @Ignore("Run once") public void testCreate() throws Exception { Queue queue = makeObject(); diff --git a/src/test/java/org/apache/commons/collections4/queue/TransformedQueueTest.java b/src/test/java/org/apache/commons/collections4/queue/TransformedQueueTest.java index 1e71a4f981..4f53742583 100644 --- a/src/test/java/org/apache/commons/collections4/queue/TransformedQueueTest.java +++ b/src/test/java/org/apache/commons/collections4/queue/TransformedQueueTest.java @@ -24,6 +24,7 @@ import org.apache.commons.collections4.Transformer; import org.apache.commons.collections4.collection.AbstractCollectionTest; import org.apache.commons.collections4.collection.TransformedCollectionTest; +import org.junit.Test; /** * Extension of {@link AbstractCollectionTest} for exercising the @@ -61,6 +62,7 @@ public Queue makeFullCollection() { return TransformedQueue.transformingQueue(list, (Transformer) TransformedCollectionTest.NOOP_TRANSFORMER); } + @Test public void testTransformedQueue() { final Queue queue = TransformedQueue.transformingQueue(new LinkedList<>(), TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER); @@ -79,6 +81,7 @@ public void testTransformedQueue() { } @SuppressWarnings({ "rawtypes", "unchecked" }) + @Test public void testTransformedQueue_decorateTransform() { final Queue originalQueue = new LinkedList(); final Object[] elements = {"1", "3", "5", "7", "2", "4", "6"}; diff --git a/src/test/java/org/apache/commons/collections4/queue/UnmodifiableQueueTest.java b/src/test/java/org/apache/commons/collections4/queue/UnmodifiableQueueTest.java index 5c99ff3070..8bb2d7c748 100644 --- a/src/test/java/org/apache/commons/collections4/queue/UnmodifiableQueueTest.java +++ b/src/test/java/org/apache/commons/collections4/queue/UnmodifiableQueueTest.java @@ -25,6 +25,7 @@ import org.apache.commons.collections4.Unmodifiable; import org.apache.commons.collections4.collection.AbstractCollectionTest; +import org.junit.Test; /** * Extension of {@link AbstractCollectionTest} for exercising the @@ -79,17 +80,20 @@ public boolean isNullSupported() { return false; } + @Test @Override public void testQueueRemove() { resetEmpty(); assertThrows(UnsupportedOperationException.class, () -> getCollection().remove()); } + @Test public void testUnmodifiable() { assertTrue(makeObject() instanceof Unmodifiable); assertTrue(makeFullCollection() instanceof Unmodifiable); } + @Test public void testDecorateFactory() { final Queue queue = makeFullCollection(); assertSame(queue, UnmodifiableQueue.unmodifiableQueue(queue)); @@ -97,12 +101,14 @@ public void testDecorateFactory() { assertThrows(NullPointerException.class, () -> UnmodifiableQueue.unmodifiableQueue(null)); } + @Test public void testOffer() { final Queue queue = makeFullCollection(); final E e = null; assertThrows(UnsupportedOperationException.class, () -> queue.offer(e)); } + @Test public void testPoll() { final Queue queue = makeFullCollection(); assertThrows(UnsupportedOperationException.class, () -> queue.poll()); diff --git a/src/test/java/org/apache/commons/collections4/set/AbstractSetTest.java b/src/test/java/org/apache/commons/collections4/set/AbstractSetTest.java index e9a10ea620..03840c883e 100644 --- a/src/test/java/org/apache/commons/collections4/set/AbstractSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/AbstractSetTest.java @@ -22,6 +22,7 @@ import java.util.Set; import org.apache.commons.collections4.collection.AbstractCollectionTest; +import org.junit.Test; /** * Abstract test class for {@link Set} methods and contracts. @@ -138,6 +139,7 @@ public Set getConfirmed() { /** * Tests {@link Set#equals(Object)}. */ + @Test @SuppressWarnings("unchecked") public void testSetEquals() { resetEmpty(); @@ -160,6 +162,7 @@ public void testSetEquals() { /** * Tests {@link Set#hashCode()}. */ + @Test public void testSetHashCode() { resetEmpty(); assertEquals("Empty sets have equal hashCodes", diff --git a/src/test/java/org/apache/commons/collections4/set/CompositeSetTest.java b/src/test/java/org/apache/commons/collections4/set/CompositeSetTest.java index 26ce6c79b5..a63357421b 100644 --- a/src/test/java/org/apache/commons/collections4/set/CompositeSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/CompositeSetTest.java @@ -24,6 +24,7 @@ import java.util.Set; import org.apache.commons.collections4.set.CompositeSet.SetMutator; +import org.junit.Test; /** * Extension of {@link AbstractSetTest} for exercising the @@ -61,24 +62,28 @@ public Set buildTwo() { return set; } + @Test @SuppressWarnings("unchecked") public void testContains() { final CompositeSet set = new CompositeSet<>(buildOne(), buildTwo()); assertTrue(set.contains("1")); } + @Test @SuppressWarnings("unchecked") public void testContainsAll() { final CompositeSet set = new CompositeSet<>(buildOne(), buildTwo()); assertFalse(set.containsAll(null)); } + @Test @SuppressWarnings("unchecked") public void testRemoveAll() { final CompositeSet set = new CompositeSet<>(buildOne(), buildTwo()); assertFalse(set.removeAll(null)); } + @Test @SuppressWarnings("unchecked") public void testRemoveUnderlying() { final Set one = buildOne(); @@ -91,6 +96,7 @@ public void testRemoveUnderlying() { assertFalse(set.contains("3")); } + @Test @SuppressWarnings("unchecked") public void testRemoveComposited() { final Set one = buildOne(); @@ -103,6 +109,7 @@ public void testRemoveComposited() { assertFalse(one.contains("3")); } + @Test @SuppressWarnings("unchecked") public void testFailedCollisionResolution() { final Set one = buildOne(); @@ -136,6 +143,7 @@ public boolean addAll(final CompositeSet composite, "IllegalArgumentException should have been thrown"); } + @Test @SuppressWarnings("unchecked") public void testAddComposited() { final Set one = buildOne(); @@ -162,6 +170,7 @@ public void testAddComposited() { "Expecting UnsupportedOperationException."); } + @Test @SuppressWarnings("unchecked") public void testAddCompositedCollision() { final HashSet set1 = new HashSet<>(); diff --git a/src/test/java/org/apache/commons/collections4/set/ListOrderedSet2Test.java b/src/test/java/org/apache/commons/collections4/set/ListOrderedSet2Test.java index 71b814899f..c51be89151 100644 --- a/src/test/java/org/apache/commons/collections4/set/ListOrderedSet2Test.java +++ b/src/test/java/org/apache/commons/collections4/set/ListOrderedSet2Test.java @@ -20,6 +20,8 @@ import java.util.Iterator; import java.util.List; +import org.junit.Test; + /** * Extension of {@link AbstractSetTest} for exercising the {@link ListOrderedSet} * implementation. @@ -52,6 +54,7 @@ protected ListOrderedSet setupSet() { return set; } + @Test @SuppressWarnings("unchecked") public void testOrdering() { final ListOrderedSet set = setupSet(); @@ -85,6 +88,7 @@ public void testOrdering() { } } + @Test @SuppressWarnings("unchecked") public void testListAddRemove() { final ListOrderedSet set = makeObject(); @@ -115,6 +119,7 @@ public void testListAddRemove() { assertSame(TWO, view.get(1)); } + @Test @SuppressWarnings("unchecked") public void testListAddIndexed() { final ListOrderedSet set = makeObject(); diff --git a/src/test/java/org/apache/commons/collections4/set/ListOrderedSetTest.java b/src/test/java/org/apache/commons/collections4/set/ListOrderedSetTest.java index 53c35890a1..4981087a9a 100644 --- a/src/test/java/org/apache/commons/collections4/set/ListOrderedSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/ListOrderedSetTest.java @@ -27,6 +27,7 @@ import java.util.Set; import org.apache.commons.collections4.IteratorUtils; +import org.junit.Test; /** * Extension of {@link AbstractSetTest} for exercising the @@ -64,6 +65,7 @@ protected ListOrderedSet setupSet() { return set; } + @Test @SuppressWarnings("unchecked") public void testOrdering() { final ListOrderedSet set = setupSet(); @@ -99,6 +101,7 @@ public void testOrdering() { } } + @Test @SuppressWarnings("unchecked") public void testListAddRemove() { final ListOrderedSet set = makeObject(); @@ -129,6 +132,7 @@ public void testListAddRemove() { assertSame(TWO, view.get(1)); } + @Test @SuppressWarnings("unchecked") public void testListAddIndexed() { final ListOrderedSet set = makeObject(); @@ -167,6 +171,7 @@ public void testListAddIndexed() { assertSame(ONE, set.get(3)); } + @Test @SuppressWarnings("unchecked") public void testListAddReplacing() { final ListOrderedSet set = makeObject(); @@ -182,6 +187,7 @@ public void testListAddReplacing() { assertSame(a, set.asList().get(0)); } + @Test @SuppressWarnings("unchecked") public void testRetainAll() { final List list = new ArrayList<>(10); @@ -206,6 +212,7 @@ public void testRetainAll() { assertEquals(Integer.valueOf(0), orderedSet.get(4)); } + @Test @SuppressWarnings("unchecked") public void testDuplicates() { final List list = new ArrayList<>(10); @@ -251,6 +258,7 @@ public int hashCode() { } } + @Test public void testDecorator() { assertAll( () -> assertThrows(NullPointerException.class, () -> ListOrderedSet.listOrderedSet((List) null)), diff --git a/src/test/java/org/apache/commons/collections4/set/MapBackedSet2Test.java b/src/test/java/org/apache/commons/collections4/set/MapBackedSet2Test.java index d5322a573f..349d0a5d0c 100644 --- a/src/test/java/org/apache/commons/collections4/set/MapBackedSet2Test.java +++ b/src/test/java/org/apache/commons/collections4/set/MapBackedSet2Test.java @@ -20,6 +20,7 @@ import java.util.Set; import org.apache.commons.collections4.map.LinkedMap; +import org.junit.Test; /** * JUnit test. @@ -47,6 +48,7 @@ protected Set setupSet() { return set; } + @Test @SuppressWarnings("unchecked") public void testOrdering() { final Set set = setupSet(); @@ -80,10 +82,12 @@ public void testOrdering() { } } + @Test @Override public void testCanonicalEmptyCollectionExists() { } + @Test @Override public void testCanonicalFullCollectionExists() { } diff --git a/src/test/java/org/apache/commons/collections4/set/PredicatedNavigableSetTest.java b/src/test/java/org/apache/commons/collections4/set/PredicatedNavigableSetTest.java index 908c99be1f..4bbdb515e4 100644 --- a/src/test/java/org/apache/commons/collections4/set/PredicatedNavigableSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/PredicatedNavigableSetTest.java @@ -24,11 +24,10 @@ import java.util.Set; import java.util.TreeSet; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.Predicate; import org.apache.commons.collections4.functors.TruePredicate; +import org.junit.Test; /** * Extension of {@link AbstractNavigableSetTest} for exercising the @@ -42,7 +41,7 @@ public PredicatedNavigableSetTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(PredicatedNavigableSetTest.class); } @@ -69,11 +68,13 @@ protected PredicatedNavigableSet makeTestSet() { return PredicatedNavigableSet.predicatedNavigableSet(new TreeSet(), testPredicate); } + @Test public void testGetSet() { final PredicatedNavigableSet set = makeTestSet(); assertNotNull("returned set should not be null", set.decorated()); } + @Test @SuppressWarnings("unchecked") public void testIllegalAdd() { final NavigableSet set = makeTestSet(); @@ -83,6 +84,7 @@ public void testIllegalAdd() { assertFalse("Collection shouldn't contain illegal element", set.contains(testString)); } + @Test @SuppressWarnings("unchecked") public void testIllegalAddAll() { final NavigableSet set = makeTestSet(); @@ -99,6 +101,7 @@ public void testIllegalAddAll() { assertFalse("Set shouldn't contain illegal element", set.contains("Afour")); } + @Test public void testComparator() { final NavigableSet set = makeTestSet(); final Comparator c = set.comparator(); diff --git a/src/test/java/org/apache/commons/collections4/set/PredicatedSetTest.java b/src/test/java/org/apache/commons/collections4/set/PredicatedSetTest.java index 0df42430c7..515b23beef 100644 --- a/src/test/java/org/apache/commons/collections4/set/PredicatedSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/PredicatedSetTest.java @@ -23,6 +23,7 @@ import org.apache.commons.collections4.Predicate; import org.apache.commons.collections4.functors.TruePredicate; +import org.junit.Test; /** * Extension of {@link AbstractSetTest} for exercising the @@ -64,11 +65,13 @@ protected PredicatedSet makeTestSet() { return decorateSet(new HashSet(), testPredicate); } + @Test public void testGetSet() { final PredicatedSet set = makeTestSet(); assertNotNull("returned set should not be null", set.decorated()); } + @Test @SuppressWarnings("unchecked") public void testIllegalAdd() { final Set set = makeTestSet(); @@ -78,6 +81,7 @@ public void testIllegalAdd() { assertFalse("Collection shouldn't contain illegal element", set.contains(i)); } + @Test @SuppressWarnings("unchecked") public void testIllegalAddAll() { final Set set = makeTestSet(); diff --git a/src/test/java/org/apache/commons/collections4/set/PredicatedSortedSetTest.java b/src/test/java/org/apache/commons/collections4/set/PredicatedSortedSetTest.java index 97fcfc4d6b..976bbf3290 100644 --- a/src/test/java/org/apache/commons/collections4/set/PredicatedSortedSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/PredicatedSortedSetTest.java @@ -24,11 +24,10 @@ import java.util.SortedSet; import java.util.TreeSet; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.Predicate; import org.apache.commons.collections4.functors.TruePredicate; +import org.junit.Test; /** * Extension of {@link AbstractSortedSetTest} for exercising the @@ -42,7 +41,7 @@ public PredicatedSortedSetTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(PredicatedSortedSetTest.class); } @@ -66,11 +65,13 @@ protected PredicatedSortedSet makeTestSet() { return PredicatedSortedSet.predicatedSortedSet(new TreeSet(), testPredicate); } + @Test public void testGetSet() { final PredicatedSortedSet set = makeTestSet(); assertNotNull("returned set should not be null", set.decorated()); } + @Test @SuppressWarnings("unchecked") public void testIllegalAdd() { final SortedSet set = makeTestSet(); @@ -80,6 +81,7 @@ public void testIllegalAdd() { assertFalse("Collection shouldn't contain illegal element", set.contains(testString)); } + @Test @SuppressWarnings("unchecked") public void testIllegalAddAll() { final SortedSet set = makeTestSet(); @@ -96,6 +98,7 @@ public void testIllegalAddAll() { assertFalse("Set shouldn't contain illegal element", set.contains("Afour")); } + @Test public void testComparator() { final SortedSet set = makeTestSet(); final Comparator c = set.comparator(); diff --git a/src/test/java/org/apache/commons/collections4/set/TransformedNavigableSetTest.java b/src/test/java/org/apache/commons/collections4/set/TransformedNavigableSetTest.java index 12fe709290..32a54ace28 100644 --- a/src/test/java/org/apache/commons/collections4/set/TransformedNavigableSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/TransformedNavigableSetTest.java @@ -22,11 +22,10 @@ import java.util.TreeSet; import java.util.Set; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.Transformer; import org.apache.commons.collections4.collection.TransformedCollectionTest; +import org.junit.Test; /** * Extension of {@link AbstractNavigableSetTest} for exercising the @@ -40,7 +39,7 @@ public TransformedNavigableSetTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(TransformedNavigableSetTest.class); } @@ -59,6 +58,7 @@ public NavigableSet makeFullCollection() { (Transformer) TransformedCollectionTest.NOOP_TRANSFORMER); } + @Test @SuppressWarnings("unchecked") public void testTransformedSet() { final NavigableSet set = TransformedNavigableSet.transformingNavigableSet(new TreeSet(), @@ -74,6 +74,7 @@ public void testTransformedSet() { assertTrue(set.remove(Integer.valueOf((String) els[0]))); } + @Test public void testTransformedSet_decorateTransform() { final Set originalSet = new TreeSet<>(); final Object[] els = {"1", "3", "5", "7", "2", "4", "6"}; diff --git a/src/test/java/org/apache/commons/collections4/set/TransformedSetTest.java b/src/test/java/org/apache/commons/collections4/set/TransformedSetTest.java index e309d1dddc..ac07b99f6c 100644 --- a/src/test/java/org/apache/commons/collections4/set/TransformedSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/TransformedSetTest.java @@ -23,6 +23,7 @@ import org.apache.commons.collections4.Transformer; import org.apache.commons.collections4.collection.TransformedCollectionTest; +import org.junit.Test; /** * Extension of {@link AbstractSetTest} for exercising the {@link TransformedSet} @@ -61,6 +62,7 @@ public Set makeFullCollection() { (Transformer) TransformedCollectionTest.NOOP_TRANSFORMER); } + @Test @SuppressWarnings("unchecked") public void testTransformedSet() { final Set set = TransformedSet.transformingSet(new HashSet(), @@ -79,6 +81,7 @@ public void testTransformedSet() { } + @Test public void testTransformedSet_decorateTransform() { final Set originalSet = new HashSet<>(); final Object[] els = {"1", "3", "5", "7", "2", "4", "6"}; diff --git a/src/test/java/org/apache/commons/collections4/set/TransformedSortedSetTest.java b/src/test/java/org/apache/commons/collections4/set/TransformedSortedSetTest.java index f04f484dfd..0398309b17 100644 --- a/src/test/java/org/apache/commons/collections4/set/TransformedSortedSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/TransformedSortedSetTest.java @@ -22,11 +22,10 @@ import java.util.Set; import java.util.SortedSet; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.Transformer; import org.apache.commons.collections4.collection.TransformedCollectionTest; +import org.junit.Test; /** * Extension of {@link AbstractSortedSetTest} for exercising the {@link TransformedSortedSet} @@ -40,7 +39,7 @@ public TransformedSortedSetTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(TransformedSortedSetTest.class); } @@ -57,6 +56,7 @@ public SortedSet makeFullCollection() { return TransformedSortedSet.transformingSortedSet(set, (Transformer) TransformedCollectionTest.NOOP_TRANSFORMER); } + @Test @SuppressWarnings("unchecked") public void testTransformedSet() { final SortedSet set = TransformedSortedSet.transformingSortedSet(new TreeSet(), @@ -72,6 +72,7 @@ public void testTransformedSet() { assertTrue(set.remove(Integer.valueOf((String) els[0]))); } + @Test public void testTransformedSet_decorateTransform() { final Set originalSet = new TreeSet<>(); final Object[] els = {"1", "3", "5", "7", "2", "4", "6"}; diff --git a/src/test/java/org/apache/commons/collections4/set/UnmodifiableNavigableSetTest.java b/src/test/java/org/apache/commons/collections4/set/UnmodifiableNavigableSetTest.java index 51e3792468..760e75bb42 100644 --- a/src/test/java/org/apache/commons/collections4/set/UnmodifiableNavigableSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/UnmodifiableNavigableSetTest.java @@ -23,9 +23,8 @@ import java.util.Set; import java.util.TreeSet; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; +import org.junit.Test; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -43,7 +42,7 @@ public UnmodifiableNavigableSetTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(UnmodifiableNavigableSetTest.class); } @@ -80,6 +79,7 @@ protected void setupSet() { /** * Verify that base set and subsets are not modifiable */ + @Test @SuppressWarnings("unchecked") public void testUnmodifiable() { setupSet(); @@ -94,6 +94,7 @@ public void testUnmodifiable() { verifyUnmodifiable(set.subSet((E) Integer.valueOf(1), true, (E) Integer.valueOf(3), true)); } + @Test public void testDecorateFactory() { final NavigableSet set = makeFullCollection(); assertSame(set, UnmodifiableNavigableSet.unmodifiableNavigableSet(set)); @@ -121,6 +122,7 @@ public void verifyUnmodifiable(final Set set) { } } + @Test public void testComparator() { setupSet(); final Comparator c = set.comparator(); 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 b6850dd5b3..29fb1c7ac7 100644 --- a/src/test/java/org/apache/commons/collections4/set/UnmodifiableSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/UnmodifiableSetTest.java @@ -22,10 +22,9 @@ import java.util.HashSet; import java.util.Set; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.Unmodifiable; +import org.junit.Test; /** * Extension of {@link AbstractSetTest} for exercising the @@ -39,7 +38,7 @@ public UnmodifiableSetTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(UnmodifiableSetTest.class); } @@ -65,11 +64,13 @@ public boolean isRemoveSupported() { return false; } + @Test public void testUnmodifiable() { assertTrue(makeObject() instanceof Unmodifiable); assertTrue(makeFullCollection() instanceof Unmodifiable); } + @Test public void testDecorateFactory() { final Set set = makeFullCollection(); assertSame(set, UnmodifiableSet.unmodifiableSet(set)); diff --git a/src/test/java/org/apache/commons/collections4/set/UnmodifiableSortedSetTest.java b/src/test/java/org/apache/commons/collections4/set/UnmodifiableSortedSetTest.java index 39400f8707..1330ae172e 100644 --- a/src/test/java/org/apache/commons/collections4/set/UnmodifiableSortedSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/UnmodifiableSortedSetTest.java @@ -26,9 +26,8 @@ import java.util.SortedSet; import java.util.TreeSet; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; +import org.junit.Test; /** * Extension of {@link AbstractSortedSetTest} for exercising the @@ -44,7 +43,7 @@ public UnmodifiableSortedSetTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(UnmodifiableSortedSetTest.class); } @@ -81,6 +80,7 @@ protected void setupSet() { /** * Verify that base set and subsets are not modifiable */ + @Test @SuppressWarnings("unchecked") public void testUnmodifiable() { setupSet(); @@ -90,6 +90,7 @@ public void testUnmodifiable() { verifyUnmodifiable(set.subSet((E) Integer.valueOf(1), (E) Integer.valueOf(3))); } + @Test public void testDecorateFactory() { final SortedSet set = makeFullCollection(); assertSame(set, UnmodifiableSortedSet.unmodifiableSortedSet(set)); @@ -118,6 +119,7 @@ public void verifyUnmodifiable(final Set set) { ); } + @Test public void testComparator() { setupSet(); final Comparator c = set.comparator(); diff --git a/src/test/java/org/apache/commons/collections4/splitmap/TransformedSplitMapTest.java b/src/test/java/org/apache/commons/collections4/splitmap/TransformedSplitMapTest.java index 37f016677e..b0b8005ba2 100644 --- a/src/test/java/org/apache/commons/collections4/splitmap/TransformedSplitMapTest.java +++ b/src/test/java/org/apache/commons/collections4/splitmap/TransformedSplitMapTest.java @@ -26,6 +26,7 @@ import org.apache.commons.collections4.MapIterator; import org.apache.commons.collections4.Transformer; import org.apache.commons.collections4.functors.NOPTransformer; +import org.junit.Test; /** * Tests for {@link TransformedSplitMap} @@ -46,6 +47,7 @@ public TransformedSplitMapTest(final String testName) { } // ----------------------------------------------------------------------- + @Test public void testTransformedMap() { final TransformedSplitMap> map = TransformedSplitMap.transformingMap( new HashMap>(), intToString, objectToClass); @@ -90,6 +92,7 @@ public void testTransformedMap() { // ----------------------------------------------------------------------- + @Test public void testMapIterator() { final TransformedSplitMap map = TransformedSplitMap.transformingMap(new HashMap(), @@ -106,6 +109,7 @@ public void testMapIterator() { } } + @Test public void testEmptyMap() throws IOException, ClassNotFoundException { final TransformedSplitMap map = TransformedSplitMap.transformingMap(new HashMap(), @@ -122,6 +126,7 @@ public void testEmptyMap() throws IOException, ClassNotFoundException { assertEquals( map.entrySet(), readMap.entrySet() ); } + @Test public void testFullMap() throws IOException, ClassNotFoundException { final TransformedSplitMap map = TransformedSplitMap.transformingMap( new HashMap(), diff --git a/src/test/java/org/apache/commons/collections4/trie/PatriciaTrie2Test.java b/src/test/java/org/apache/commons/collections4/trie/PatriciaTrie2Test.java index 8778b71466..230e9fa5c4 100644 --- a/src/test/java/org/apache/commons/collections4/trie/PatriciaTrie2Test.java +++ b/src/test/java/org/apache/commons/collections4/trie/PatriciaTrie2Test.java @@ -16,8 +16,6 @@ */ package org.apache.commons.collections4.trie; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.OrderedMap; import org.apache.commons.collections4.map.AbstractOrderedMapTest; @@ -33,7 +31,7 @@ public PatriciaTrie2Test(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(PatriciaTrie2Test.class); } 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 0596d6cef3..e1580be593 100755 --- a/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java +++ b/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java @@ -26,12 +26,11 @@ import java.util.Set; import java.util.SortedMap; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.Trie; import org.apache.commons.collections4.map.AbstractSortedMapTest; import org.junit.jupiter.api.Assertions; +import org.junit.Test; /** * JUnit tests for the PatriciaTrie. @@ -44,7 +43,7 @@ public PatriciaTrieTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(PatriciaTrieTest.class); } @@ -58,6 +57,7 @@ public boolean isAllowNullKey() { return false; } + @Test public void testPrefixMap() { final PatriciaTrie trie = new PatriciaTrie<>(); @@ -286,6 +286,7 @@ public void testPrefixMap() { Assertions.assertFalse(iterator.hasNext()); } + @Test public void testPrefixMapRemoval() { final PatriciaTrie trie = new PatriciaTrie<>(); @@ -329,6 +330,7 @@ public void testPrefixMapRemoval() { Assertions.assertFalse(iter.hasNext()); } + @Test public void testPrefixMapSizes() { // COLLECTIONS-525 final PatriciaTrie aTree = new PatriciaTrie<>(); @@ -349,6 +351,7 @@ public void testPrefixMapSizes() { assertEquals(2, aTree.prefixMap("点").size()); } + @Test public void testPrefixMapSizes2() { final char u8000 = Character.toChars(32768)[0]; // U+8000 (1000000000000000) final char char_b = 'b'; // 1100010 @@ -369,6 +372,7 @@ public void testPrefixMapSizes2() { assertTrue(trie.prefixMap(prefixString).containsKey(longerString)); } + @Test public void testPrefixMapClear() { final Trie trie = new PatriciaTrie<>(); trie.put("Anna", 1); @@ -390,6 +394,7 @@ public void testPrefixMapClear() { assertEquals(Arrays.asList(2, 3, 7, 1), new ArrayList<>(trie.values())); } + @Test public void testPrefixMapClearNothing() { final Trie trie = new PatriciaTrie<>(); final SortedMap prefixMap = trie.prefixMap("And"); @@ -404,6 +409,7 @@ public void testPrefixMapClearNothing() { assertEquals(new ArrayList(0), new ArrayList<>(trie.values())); } + @Test public void testPrefixMapClearUsingRemove() { final Trie trie = new PatriciaTrie<>(); trie.put("Anna", 1); 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 1d16384e96..41da7d3d52 100644 --- a/src/test/java/org/apache/commons/collections4/trie/UnmodifiableTrieTest.java +++ b/src/test/java/org/apache/commons/collections4/trie/UnmodifiableTrieTest.java @@ -18,12 +18,11 @@ import static org.junit.jupiter.api.Assertions.assertThrows; -import junit.framework.Test; - import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.Trie; import org.apache.commons.collections4.Unmodifiable; import org.apache.commons.collections4.map.AbstractSortedMapTest; +import org.junit.Test; /** * Extension of {@link AbstractSortedMapTest} for exercising the @@ -37,7 +36,7 @@ public UnmodifiableTrieTest(final String testName) { super(testName); } - public static Test suite() { + public static junit.framework.Test suite() { return BulkTest.makeSuite(UnmodifiableTrieTest.class); } @@ -70,11 +69,13 @@ public Trie makeFullMap() { return UnmodifiableTrie.unmodifiableTrie(m); } + @Test public void testUnmodifiable() { assertTrue(makeObject() instanceof Unmodifiable); assertTrue(makeFullMap() instanceof Unmodifiable); } + @Test public void testDecorateFactory() { final Trie trie = makeFullMap(); assertSame(trie, UnmodifiableTrie.unmodifiableTrie(trie));