From 34b43799deb48882596bf5d2e91a8425b71d74fb Mon Sep 17 00:00:00 2001 From: Thomas Neidhart Date: Thu, 7 Feb 2013 17:46:17 +0000 Subject: [PATCH] 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 --- .../collections/CollectionUtilsTest.java | 2 +- .../collections/EnumerationUtilsTest.java | 27 +++++++++-------- .../collections/IteratorUtilsTest.java | 6 ++-- .../commons/collections/ListUtilsTest.java | 29 +++++++++---------- 4 files changed, 31 insertions(+), 33 deletions(-) diff --git a/src/test/java/org/apache/commons/collections/CollectionUtilsTest.java b/src/test/java/org/apache/commons/collections/CollectionUtilsTest.java index 6add4a512..8dc7433c5 100644 --- a/src/test/java/org/apache/commons/collections/CollectionUtilsTest.java +++ b/src/test/java/org/apache/commons/collections/CollectionUtilsTest.java @@ -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.*; diff --git a/src/test/java/org/apache/commons/collections/EnumerationUtilsTest.java b/src/test/java/org/apache/commons/collections/EnumerationUtilsTest.java index 5ff73d2ba..d6a30968d 100644 --- a/src/test/java/org/apache/commons/collections/EnumerationUtilsTest.java +++ b/src/test/java/org/apache/commons/collections/EnumerationUtilsTest.java @@ -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 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 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 expectedEltList = new ArrayList(); 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 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 expectedKeyList = new ArrayList(); expectedKeyList.add("one"); expectedKeyList.add("two"); expectedKeyList.add("three"); - Assert.assertTrue(actualKeyList.containsAll(expectedKeyList)); + assertTrue(actualKeyList.containsAll(expectedKeyList)); } public static Test suite() { diff --git a/src/test/java/org/apache/commons/collections/IteratorUtilsTest.java b/src/test/java/org/apache/commons/collections/IteratorUtilsTest.java index e326f42f0..138f58096 100644 --- a/src/test/java/org/apache/commons/collections/IteratorUtilsTest.java +++ b/src/test/java/org/apache/commons/collections/IteratorUtilsTest.java @@ -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"); } } diff --git a/src/test/java/org/apache/commons/collections/ListUtilsTest.java b/src/test/java/org/apache/commons/collections/ListUtilsTest.java index bbf564794..101971fe5 100644 --- a/src/test/java/org/apache/commons/collections/ListUtilsTest.java +++ b/src/test/java/org/apache/commons/collections/ListUtilsTest.java @@ -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 output1 = ListUtils.select(list, EQUALS_TWO); final List output2 = ListUtils.select(list, EQUALS_TWO); final HashSet output3 = CollectionUtils.select(list, EQUALS_TWO, new HashSet()); - 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 output1 = ListUtils.selectRejected(list, EQUALS_TWO); final List output2 = ListUtils.selectRejected(list, EQUALS_TWO); final HashSet output3 = CollectionUtils.selectRejected(list, EQUALS_TWO, new HashSet()); - 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)); } }