From c07f213114cc5c3a1fac4017a14f3290a2b53544 Mon Sep 17 00:00:00 2001 From: Thomas Neidhart Date: Thu, 7 Feb 2013 18:59:43 +0000 Subject: [PATCH] Test cleanups. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1443661 13f79535-47bb-0310-9956-ffa450edef68 --- .../buffer/TransformedBufferTest.java | 2 +- .../buffer/UnboundedFifoBufferTest.java | 1 + .../iterators/FilterIteratorTest.java | 2 +- .../collections/keyvalue/MultiKeyTest.java | 97 +++++++++---------- 4 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/test/java/org/apache/commons/collections/buffer/TransformedBufferTest.java b/src/test/java/org/apache/commons/collections/buffer/TransformedBufferTest.java index f4a35621e..be8da9309 100644 --- a/src/test/java/org/apache/commons/collections/buffer/TransformedBufferTest.java +++ b/src/test/java/org/apache/commons/collections/buffer/TransformedBufferTest.java @@ -56,7 +56,7 @@ public class TransformedBufferTest extends TestCase { for (final Object el : els) { originalBuffer.add(el); } - final Buffer buffer = TransformedBuffer.transformedBuffer(originalBuffer, TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER); + final Buffer buffer = TransformedBuffer.transformedBuffer(originalBuffer, TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER); assertEquals(els.length, buffer.size()); for (final Object el : els) { assertEquals(true, buffer.contains(new Integer((String) el))); diff --git a/src/test/java/org/apache/commons/collections/buffer/UnboundedFifoBufferTest.java b/src/test/java/org/apache/commons/collections/buffer/UnboundedFifoBufferTest.java index 9d8cdb845..3a4548037 100644 --- a/src/test/java/org/apache/commons/collections/buffer/UnboundedFifoBufferTest.java +++ b/src/test/java/org/apache/commons/collections/buffer/UnboundedFifoBufferTest.java @@ -430,6 +430,7 @@ public class UnboundedFifoBufferTest extends AbstractCollectionTest { } //----------------------------------------------------------------------- + @SuppressWarnings("unchecked") public void testCollections220() throws Exception { UnboundedFifoBuffer buffer = new UnboundedFifoBuffer(); diff --git a/src/test/java/org/apache/commons/collections/iterators/FilterIteratorTest.java b/src/test/java/org/apache/commons/collections/iterators/FilterIteratorTest.java index 0758439e3..39d2c4fe3 100644 --- a/src/test/java/org/apache/commons/collections/iterators/FilterIteratorTest.java +++ b/src/test/java/org/apache/commons/collections/iterators/FilterIteratorTest.java @@ -92,7 +92,7 @@ public class FilterIteratorTest extends AbstractIteratorTest { } public void testRepeatedNext() { - for (final String element : array) { + for (@SuppressWarnings("unused") final String element : array) { iterator.next(); } verifyNoMoreElements(); diff --git a/src/test/java/org/apache/commons/collections/keyvalue/MultiKeyTest.java b/src/test/java/org/apache/commons/collections/keyvalue/MultiKeyTest.java index 7081a8eb3..600a68f19 100644 --- a/src/test/java/org/apache/commons/collections/keyvalue/MultiKeyTest.java +++ b/src/test/java/org/apache/commons/collections/keyvalue/MultiKeyTest.java @@ -26,7 +26,6 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import junit.framework.Assert; import junit.framework.TestCase; /** @@ -60,46 +59,46 @@ public class MultiKeyTest extends TestCase { public void testConstructors() throws Exception { MultiKey mk = null; mk = new MultiKey(ONE, TWO); - Assert.assertTrue(Arrays.equals(new Object[] { ONE, TWO }, mk.getKeys())); + assertTrue(Arrays.equals(new Object[] { ONE, TWO }, mk.getKeys())); mk = new MultiKey(ONE, TWO, THREE); - Assert.assertTrue(Arrays.equals(new Object[] { ONE, TWO, THREE }, mk.getKeys())); + assertTrue(Arrays.equals(new Object[] { ONE, TWO, THREE }, mk.getKeys())); mk = new MultiKey(ONE, TWO, THREE, FOUR); - Assert.assertTrue(Arrays.equals(new Object[] { ONE, TWO, THREE, FOUR }, mk.getKeys())); + assertTrue(Arrays.equals(new Object[] { ONE, TWO, THREE, FOUR }, mk.getKeys())); mk = new MultiKey(ONE, TWO, THREE, FOUR, FIVE); - Assert.assertTrue(Arrays.equals(new Object[] { ONE, TWO, THREE, FOUR, FIVE }, mk.getKeys())); + assertTrue(Arrays.equals(new Object[] { ONE, TWO, THREE, FOUR, FIVE }, mk.getKeys())); mk = new MultiKey(new Integer[] { THREE, FOUR, ONE, TWO }, false); - Assert.assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys())); + assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys())); } public void testConstructorsByArray() throws Exception { MultiKey mk = null; Integer[] keys = new Integer[] { THREE, FOUR, ONE, TWO }; mk = new MultiKey(keys); - Assert.assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys())); + assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys())); keys[3] = FIVE; // no effect - Assert.assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys())); + assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys())); keys = new Integer[] {}; mk = new MultiKey(keys); - Assert.assertTrue(Arrays.equals(new Object[] {}, mk.getKeys())); + assertTrue(Arrays.equals(new Object[] {}, mk.getKeys())); keys = new Integer[] { THREE, FOUR, ONE, TWO }; mk = new MultiKey(keys, true); - Assert.assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys())); + assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys())); keys[3] = FIVE; // no effect - Assert.assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys())); + assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys())); keys = new Integer[] { THREE, FOUR, ONE, TWO }; mk = new MultiKey(keys, false); - Assert.assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys())); + assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys())); // change key - don't do this! // the hashcode of the MultiKey is now broken keys[3] = FIVE; - Assert.assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, FIVE }, mk.getKeys())); + assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, FIVE }, mk.getKeys())); } public void testConstructorsByArrayNull() throws Exception { @@ -119,25 +118,25 @@ public class MultiKeyTest extends TestCase { } public void testSize() { - Assert.assertEquals(2, new MultiKey(ONE, TWO).size()); - Assert.assertEquals(2, new MultiKey(null, null).size()); - Assert.assertEquals(3, new MultiKey(ONE, TWO, THREE).size()); - Assert.assertEquals(3, new MultiKey(null, null, null).size()); - Assert.assertEquals(4, new MultiKey(ONE, TWO, THREE, FOUR).size()); - Assert.assertEquals(4, new MultiKey(null, null, null, null).size()); - Assert.assertEquals(5, new MultiKey(ONE, TWO, THREE, FOUR, FIVE).size()); - Assert.assertEquals(5, new MultiKey(null, null, null, null, null).size()); + assertEquals(2, new MultiKey(ONE, TWO).size()); + assertEquals(2, new MultiKey(null, null).size()); + assertEquals(3, new MultiKey(ONE, TWO, THREE).size()); + assertEquals(3, new MultiKey(null, null, null).size()); + assertEquals(4, new MultiKey(ONE, TWO, THREE, FOUR).size()); + assertEquals(4, new MultiKey(null, null, null, null).size()); + assertEquals(5, new MultiKey(ONE, TWO, THREE, FOUR, FIVE).size()); + assertEquals(5, new MultiKey(null, null, null, null, null).size()); - Assert.assertEquals(0, new MultiKey(new Object[] {}).size()); - Assert.assertEquals(1, new MultiKey(new Integer[] { ONE }).size()); - Assert.assertEquals(2, new MultiKey(new Integer[] { ONE, TWO }).size()); - Assert.assertEquals(7, new MultiKey(new Integer[] { ONE, TWO, ONE, TWO, ONE, TWO, ONE }).size()); + assertEquals(0, new MultiKey(new Object[] {}).size()); + assertEquals(1, new MultiKey(new Integer[] { ONE }).size()); + assertEquals(2, new MultiKey(new Integer[] { ONE, TWO }).size()); + assertEquals(7, new MultiKey(new Integer[] { ONE, TWO, ONE, TWO, ONE, TWO, ONE }).size()); } public void testGetIndexed() { final MultiKey mk = new MultiKey(ONE, TWO); - Assert.assertSame(ONE, mk.getKey(0)); - Assert.assertSame(TWO, mk.getKey(1)); + assertSame(ONE, mk.getKey(0)); + assertSame(TWO, mk.getKey(1)); try { mk.getKey(-1); fail(); @@ -151,31 +150,31 @@ public class MultiKeyTest extends TestCase { public void testGetKeysSimpleConstructor() { final MultiKey mk = new MultiKey(ONE, TWO); final Object[] array = mk.getKeys(); - Assert.assertSame(ONE, array[0]); - Assert.assertSame(TWO, array[1]); - Assert.assertEquals(2, array.length); + assertSame(ONE, array[0]); + assertSame(TWO, array[1]); + assertEquals(2, array.length); } public void testGetKeysArrayConstructorCloned() { final Integer[] keys = new Integer[] { ONE, TWO }; final MultiKey mk = new MultiKey(keys, true); final Object[] array = mk.getKeys(); - Assert.assertTrue(array != keys); - Assert.assertTrue(Arrays.equals(array, keys)); - Assert.assertSame(ONE, array[0]); - Assert.assertSame(TWO, array[1]); - Assert.assertEquals(2, array.length); + assertTrue(array != keys); + assertTrue(Arrays.equals(array, keys)); + assertSame(ONE, array[0]); + assertSame(TWO, array[1]); + assertEquals(2, array.length); } public void testGetKeysArrayConstructorNonCloned() { final Integer[] keys = new Integer[] { ONE, TWO }; final MultiKey mk = new MultiKey(keys, false); final Object[] array = mk.getKeys(); - Assert.assertTrue(array != keys); // still not equal - Assert.assertTrue(Arrays.equals(array, keys)); - Assert.assertSame(ONE, array[0]); - Assert.assertSame(TWO, array[1]); - Assert.assertEquals(2, array.length); + assertTrue(array != keys); // still not equal + assertTrue(Arrays.equals(array, keys)); + assertSame(ONE, array[0]); + assertSame(TWO, array[1]); + assertEquals(2, array.length); } public void testHashCode() { @@ -183,12 +182,12 @@ public class MultiKeyTest extends TestCase { final MultiKey mk2 = new MultiKey(ONE, TWO); final MultiKey mk3 = new MultiKey(ONE, "TWO"); - Assert.assertTrue(mk1.hashCode() == mk1.hashCode()); - Assert.assertTrue(mk1.hashCode() == mk2.hashCode()); - Assert.assertTrue(mk1.hashCode() != mk3.hashCode()); + assertTrue(mk1.hashCode() == mk1.hashCode()); + assertTrue(mk1.hashCode() == mk2.hashCode()); + assertTrue(mk1.hashCode() != mk3.hashCode()); final int total = (0 ^ ONE.hashCode()) ^ TWO.hashCode(); - Assert.assertEquals(total, mk1.hashCode()); + assertEquals(total, mk1.hashCode()); } public void testEquals() { @@ -196,11 +195,11 @@ public class MultiKeyTest extends TestCase { final MultiKey mk2 = new MultiKey(ONE, TWO); final MultiKey mk3 = new MultiKey(ONE, "TWO"); - Assert.assertEquals(mk1, mk1); - Assert.assertEquals(mk1, mk2); - Assert.assertTrue(mk1.equals(mk3) == false); - Assert.assertTrue(mk1.equals("") == false); - Assert.assertTrue(mk1.equals(null) == false); + assertEquals(mk1, mk1); + assertEquals(mk1, mk2); + assertTrue(mk1.equals(mk3) == false); + assertTrue(mk1.equals("") == false); + assertTrue(mk1.equals(null) == false); } static class SystemHashCodeSimulatingKey implements Serializable {