Fix some warnings wrt deprecated junit methods.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1443623 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
045fda850a
commit
34b43799de
|
@ -16,12 +16,12 @@
|
|||
*/
|
||||
package org.apache.commons.collections;
|
||||
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static org.apache.commons.collections.functors.EqualPredicate.equalPredicate;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.*;
|
||||
|
|
|
@ -21,7 +21,6 @@ import java.util.Hashtable;
|
|||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.Test;
|
||||
|
||||
/**
|
||||
|
@ -50,9 +49,9 @@ public class EnumerationUtilsTest extends BulkTest {
|
|||
expectedList2.add("a");
|
||||
expectedList2.add("test");
|
||||
final List<String> actualList = EnumerationUtils.toList(new StringTokenizer(TO_LIST_FIXTURE));
|
||||
Assert.assertEquals(expectedList1, expectedList2);
|
||||
Assert.assertEquals(expectedList1, actualList);
|
||||
Assert.assertEquals(expectedList2, actualList);
|
||||
assertEquals(expectedList1, expectedList2);
|
||||
assertEquals(expectedList1, actualList);
|
||||
assertEquals(expectedList2, actualList);
|
||||
}
|
||||
|
||||
public void testToListWithHashtable() {
|
||||
|
@ -62,27 +61,27 @@ public class EnumerationUtilsTest extends BulkTest {
|
|||
expected.put("three", new Integer(3));
|
||||
// validate elements.
|
||||
final List<Integer> actualEltList = EnumerationUtils.toList(expected.elements());
|
||||
Assert.assertEquals(expected.size(), actualEltList.size());
|
||||
Assert.assertTrue(actualEltList.contains(new Integer(1)));
|
||||
Assert.assertTrue(actualEltList.contains(new Integer(2)));
|
||||
Assert.assertTrue(actualEltList.contains(new Integer(3)));
|
||||
assertEquals(expected.size(), actualEltList.size());
|
||||
assertTrue(actualEltList.contains(new Integer(1)));
|
||||
assertTrue(actualEltList.contains(new Integer(2)));
|
||||
assertTrue(actualEltList.contains(new Integer(3)));
|
||||
final List<Integer> expectedEltList = new ArrayList<Integer>();
|
||||
expectedEltList.add(new Integer(1));
|
||||
expectedEltList.add(new Integer(2));
|
||||
expectedEltList.add(new Integer(3));
|
||||
Assert.assertTrue(actualEltList.containsAll(expectedEltList));
|
||||
assertTrue(actualEltList.containsAll(expectedEltList));
|
||||
|
||||
// validate keys.
|
||||
final List<String> actualKeyList = EnumerationUtils.toList(expected.keys());
|
||||
Assert.assertEquals(expected.size(), actualEltList.size());
|
||||
Assert.assertTrue(actualKeyList.contains("one"));
|
||||
Assert.assertTrue(actualKeyList.contains("two"));
|
||||
Assert.assertTrue(actualKeyList.contains("three"));
|
||||
assertEquals(expected.size(), actualEltList.size());
|
||||
assertTrue(actualKeyList.contains("one"));
|
||||
assertTrue(actualKeyList.contains("two"));
|
||||
assertTrue(actualKeyList.contains("three"));
|
||||
final List<String> expectedKeyList = new ArrayList<String>();
|
||||
expectedKeyList.add("one");
|
||||
expectedKeyList.add("two");
|
||||
expectedKeyList.add("three");
|
||||
Assert.assertTrue(actualKeyList.containsAll(expectedKeyList));
|
||||
assertTrue(actualKeyList.containsAll(expectedKeyList));
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
|
|
|
@ -69,7 +69,7 @@ public class IteratorUtilsTest extends BulkTest {
|
|||
assertTrue(expected > 0);
|
||||
|
||||
// single use iterator
|
||||
for(final Integer actual : iterable) {
|
||||
for(@SuppressWarnings("unused") final Integer actual : iterable) {
|
||||
fail("should not be able to iterate twice");
|
||||
}
|
||||
}
|
||||
|
@ -809,7 +809,7 @@ public class IteratorUtilsTest extends BulkTest {
|
|||
assertTrue(expectedNodeIndex > 0);
|
||||
|
||||
// single use iterator
|
||||
for (final Node actual : IteratorUtils.asIterable(iterator)) {
|
||||
for (@SuppressWarnings("unused") final Node actual : IteratorUtils.asIterable(iterator)) {
|
||||
fail("should not be able to iterate twice");
|
||||
}
|
||||
}
|
||||
|
@ -834,7 +834,7 @@ public class IteratorUtilsTest extends BulkTest {
|
|||
assertTrue(expectedNodeIndex > 0);
|
||||
|
||||
// single use iterator
|
||||
for (final Node actual : IteratorUtils.asIterable(iterator)) {
|
||||
for (@SuppressWarnings("unused") final Node actual : IteratorUtils.asIterable(iterator)) {
|
||||
fail("should not be able to iterate twice");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.util.Collections;
|
|||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.apache.commons.collections.functors.EqualPredicate;
|
||||
|
@ -315,17 +314,17 @@ public class ListUtilsTest extends BulkTest {
|
|||
|
||||
try {
|
||||
ListUtils.partition(null, 3);
|
||||
Assert.fail("failed to check for null argument");
|
||||
fail("failed to check for null argument");
|
||||
} catch (final IllegalArgumentException e) {}
|
||||
|
||||
try {
|
||||
ListUtils.partition(strings, 0);
|
||||
Assert.fail("failed to check for size argument");
|
||||
fail("failed to check for size argument");
|
||||
} catch (final IllegalArgumentException e) {}
|
||||
|
||||
try {
|
||||
ListUtils.partition(strings, -10);
|
||||
Assert.fail("failed to check for size argument");
|
||||
fail("failed to check for size argument");
|
||||
} catch (final IllegalArgumentException e) {}
|
||||
|
||||
}
|
||||
|
@ -346,10 +345,10 @@ public class ListUtilsTest extends BulkTest {
|
|||
final List<Integer> output1 = ListUtils.select(list, EQUALS_TWO);
|
||||
final List<Number> output2 = ListUtils.<Number>select(list, EQUALS_TWO);
|
||||
final HashSet<Number> output3 = CollectionUtils.select(list, EQUALS_TWO, new HashSet<Number>());
|
||||
Assert.assertTrue(CollectionUtils.isEqualCollection(output1, output3));
|
||||
Assert.assertEquals(4, list.size());
|
||||
Assert.assertEquals(1, output1.size());
|
||||
Assert.assertEquals(2, output2.iterator().next());
|
||||
assertTrue(CollectionUtils.isEqualCollection(output1, output3));
|
||||
assertEquals(4, list.size());
|
||||
assertEquals(1, output1.size());
|
||||
assertEquals(2, output2.iterator().next());
|
||||
}
|
||||
|
||||
public void testSelectRejected() {
|
||||
|
@ -361,12 +360,12 @@ public class ListUtilsTest extends BulkTest {
|
|||
final List<Long> output1 = ListUtils.selectRejected(list, EQUALS_TWO);
|
||||
final List<? extends Number> output2 = ListUtils.selectRejected(list, EQUALS_TWO);
|
||||
final HashSet<Number> output3 = CollectionUtils.selectRejected(list, EQUALS_TWO, new HashSet<Number>());
|
||||
Assert.assertTrue(CollectionUtils.isEqualCollection(output1, output2));
|
||||
Assert.assertTrue(CollectionUtils.isEqualCollection(output1, output3));
|
||||
Assert.assertEquals(4, list.size());
|
||||
Assert.assertEquals(3, output1.size());
|
||||
Assert.assertTrue(output1.contains(1L));
|
||||
Assert.assertTrue(output1.contains(3L));
|
||||
Assert.assertTrue(output1.contains(4L));
|
||||
assertTrue(CollectionUtils.isEqualCollection(output1, output2));
|
||||
assertTrue(CollectionUtils.isEqualCollection(output1, output3));
|
||||
assertEquals(4, list.size());
|
||||
assertEquals(3, output1.size());
|
||||
assertTrue(output1.contains(1L));
|
||||
assertTrue(output1.contains(3L));
|
||||
assertTrue(output1.contains(4L));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue