Fix up generics and other warnings

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@966367 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2010-07-21 19:06:17 +00:00
parent 3d86019dad
commit fb3daab4fd
22 changed files with 75 additions and 83 deletions

View File

@ -415,7 +415,7 @@ class BulkTestSuiteMaker {
private static <T extends BulkTest> BulkTest makeTestCase(Class<T> c, Method m) { private static <T extends BulkTest> BulkTest makeTestCase(Class<T> c, Method m) {
Constructor<T> con = getTestCaseConstructor(c); Constructor<T> con = getTestCaseConstructor(c);
try { try {
return (BulkTest) con.newInstance(new Object[] { m.getName() }); return con.newInstance(new Object[] { m.getName() });
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
e.printStackTrace(); e.printStackTrace();
throw new RuntimeException(); // FIXME; throw new RuntimeException(); // FIXME;

View File

@ -73,7 +73,7 @@ class LocalTestNode<K extends Comparable<K>, V extends Comparable<V>> implements
/** /**
* Method compareTo * Method compareTo
* *
* @param o * @param other
* *
* @return a negative integer, zero, or a positive integer * @return a negative integer, zero, or a positive integer
* as this object is less than, equal to, or greater than the specified object. * as this object is less than, equal to, or greater than the specified object.
@ -97,7 +97,6 @@ class LocalTestNode<K extends Comparable<K>, V extends Comparable<V>> implements
* @return true if equal * @return true if equal
*/ */
@Override @Override
@SuppressWarnings("unchecked")
public boolean equals(Object o) { public boolean equals(Object o) {
if (o == null) { if (o == null) {

View File

@ -115,8 +115,8 @@ public class TestListUtils extends BulkTest {
* Tests intersecting two lists in different orders. * Tests intersecting two lists in different orders.
*/ */
public void testIntersectionOrderInsensitivity() { public void testIntersectionOrderInsensitivity() {
List one = new ArrayList(); List<String> one = new ArrayList<String>();
List two = new ArrayList(); List<String> two = new ArrayList<String>();
one.add("a"); one.add("a");
one.add("b"); one.add("b");
two.add("a"); two.add("a");
@ -237,7 +237,7 @@ public class TestListUtils extends BulkTest {
*/ */
// TODO: Generics // TODO: Generics
public void testIndexOf() { public void testIndexOf() {
Predicate testPredicate = PredicateUtils.equalPredicate("d"); Predicate<String> testPredicate = PredicateUtils.equalPredicate("d");
int index = ListUtils.indexOf(fullList, testPredicate); int index = ListUtils.indexOf(fullList, testPredicate);
assertEquals(d, fullList.get(index)); assertEquals(d, fullList.get(index));

View File

@ -374,7 +374,7 @@ public abstract class AbstractTestBag<T> extends AbstractTestObject {
bag.add((T) "B"); bag.add((T) "B");
bag.add((T) "B"); bag.add((T) "B");
bag.add((T) "C"); bag.add((T) "C");
String[] array = (String[]) bag.toArray(new String[0]); String[] array = bag.toArray(new String[0]);
int a = 0, b = 0, c = 0; int a = 0, b = 0, c = 0;
for (int i = 0; i < array.length; i++) { for (int i = 0; i < array.length; i++) {
a += (array[i].equals("A") ? 1 : 0); a += (array[i].equals("A") ? 1 : 0);
@ -455,13 +455,12 @@ public abstract class AbstractTestBag<T> extends AbstractTestObject {
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@SuppressWarnings("unchecked")
public void testEmptyBagSerialization() throws IOException, ClassNotFoundException { public void testEmptyBagSerialization() throws IOException, ClassNotFoundException {
Bag<T> bag = makeObject(); Bag<T> bag = makeObject();
if (!(bag instanceof Serializable && isTestSerialization())) return; if (!(bag instanceof Serializable && isTestSerialization())) return;
byte[] objekt = writeExternalFormToBytes((Serializable) bag); byte[] objekt = writeExternalFormToBytes((Serializable) bag);
Bag bag2 = (Bag) readExternalFormFromBytes(objekt); Bag<?> bag2 = (Bag<?>) readExternalFormFromBytes(objekt);
assertEquals("Bag should be empty",0, bag.size()); assertEquals("Bag should be empty",0, bag.size());
assertEquals("Bag should be empty",0, bag2.size()); assertEquals("Bag should be empty",0, bag2.size());
@ -479,7 +478,7 @@ public abstract class AbstractTestBag<T> extends AbstractTestObject {
if (!(bag instanceof Serializable && isTestSerialization())) return; if (!(bag instanceof Serializable && isTestSerialization())) return;
byte[] objekt = writeExternalFormToBytes((Serializable) bag); byte[] objekt = writeExternalFormToBytes((Serializable) bag);
Bag bag2 = (Bag) readExternalFormFromBytes(objekt); Bag<?> bag2 = (Bag<?>) readExternalFormFromBytes(objekt);
assertEquals("Bag should be same size", size, bag.size()); assertEquals("Bag should be same size", size, bag.size());
assertEquals("Bag should be same size", size, bag2.size()); assertEquals("Bag should be same size", size, bag2.size());
@ -501,12 +500,11 @@ public abstract class AbstractTestBag<T> extends AbstractTestObject {
* Compare the current serialized form of the Bag * Compare the current serialized form of the Bag
* against the canonical version in SVN. * against the canonical version in SVN.
*/ */
@SuppressWarnings("unchecked")
public void testEmptyBagCompatibility() throws IOException, ClassNotFoundException { public void testEmptyBagCompatibility() throws IOException, ClassNotFoundException {
// test to make sure the canonical form has been preserved // test to make sure the canonical form has been preserved
Bag<T> bag = makeObject(); Bag<T> bag = makeObject();
if (bag instanceof Serializable && !skipSerializedCanonicalTests() && isTestSerialization()) { if (bag instanceof Serializable && !skipSerializedCanonicalTests() && isTestSerialization()) {
Bag bag2 = (Bag) readExternalFormFromDisk(getCanonicalEmptyCollectionName(bag)); Bag<?> bag2 = (Bag<?>) readExternalFormFromDisk(getCanonicalEmptyCollectionName(bag));
assertTrue("Bag is empty",bag2.size() == 0); assertTrue("Bag is empty",bag2.size() == 0);
assertEquals(bag, bag2); assertEquals(bag, bag2);
} }

View File

@ -70,12 +70,12 @@ public class TestTransformedSortedBag<T> extends AbstractTestSortedBag<T> {
} }
public void testTransformedBag_decorateTransform() { public void testTransformedBag_decorateTransform() {
Bag originalBag = new TreeBag(); Bag<Object> originalBag = new TreeBag<Object>();
Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"}; Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
for (int i = 0; i < els.length; i++) { for (int i = 0; i < els.length; i++) {
originalBag.add(els[i]); originalBag.add(els[i]);
} }
Bag bag = TransformedBag.decorateTransform(originalBag, TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER); Bag<?> bag = TransformedBag.decorateTransform(originalBag, TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
assertEquals(els.length, bag.size()); assertEquals(els.length, bag.size());
for (int i = 0; i < els.length; i++) { for (int i = 0; i < els.length; i++) {
assertEquals(true, bag.contains(new Integer((String) els[i]))); assertEquals(true, bag.contains(new Integer((String) els[i])));

View File

@ -17,7 +17,6 @@
package org.apache.commons.collections.bidimap; package org.apache.commons.collections.bidimap;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;

View File

@ -21,7 +21,6 @@ import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.io.Serializable; import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -77,9 +76,8 @@ public class TestDualTreeBidiMap2<K extends Comparable<K>, V extends Comparable<
assertTrue(bidi.comparator() instanceof ReverseComparator); assertTrue(bidi.comparator() instanceof ReverseComparator);
} }
@SuppressWarnings("unchecked")
public void testSerializeDeserializeCheckComparator() throws Exception { public void testSerializeDeserializeCheckComparator() throws Exception {
SortedBidiMap obj = (SortedBidiMap) makeObject(); SortedBidiMap<?, ?> obj = makeObject();
if (obj instanceof Serializable && isTestSerialization()) { if (obj instanceof Serializable && isTestSerialization()) {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(buffer); ObjectOutputStream out = new ObjectOutputStream(buffer);

View File

@ -283,8 +283,8 @@ public abstract class AbstractTestList<E> extends AbstractTestCollection<E> {
for (int i = 0; i <= max; i++) { for (int i = 0; i <= max; i++) {
resetFull(); resetFull();
((List<E>) getCollection()).add(i, element); getCollection().add(i, element);
((List<E>) getConfirmed()).add(i, element); getConfirmed().add(i, element);
verify(); verify();
} }
} }
@ -621,9 +621,9 @@ public abstract class AbstractTestList<E> extends AbstractTestCollection<E> {
for (int i = 0; i < elements.length; i++) { for (int i = 0; i < elements.length; i++) {
E n = other[i % other.length]; E n = other[i % other.length];
E v = ((List<E>) getCollection()).set(i, n); E v = (getCollection()).set(i, n);
assertEquals("Set should return correct element", elements[i], v); assertEquals("Set should return correct element", elements[i], v);
((List<E>) getConfirmed()).set(i, n); (getConfirmed()).set(i, n);
verify(); verify();
} }
} }
@ -637,7 +637,7 @@ public abstract class AbstractTestList<E> extends AbstractTestCollection<E> {
resetFull(); resetFull();
try { try {
((List<E>) getCollection()).set(0, getFullElements()[0]); (getCollection()).set(0, getFullElements()[0]);
fail("Emtpy collection should not support set."); fail("Emtpy collection should not support set.");
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
// expected // expected
@ -742,8 +742,8 @@ public abstract class AbstractTestList<E> extends AbstractTestCollection<E> {
int max = getFullElements().length; int max = getFullElements().length;
for (int i = 0; i < max; i++) { for (int i = 0; i < max; i++) {
resetFull(); resetFull();
E o1 = ((List<E>) getCollection()).remove(i); E o1 = (getCollection()).remove(i);
E o2 = ((List<E>) getConfirmed()).remove(i); E o2 = (getConfirmed()).remove(i);
assertEquals("remove should return correct element", o1, o2); assertEquals("remove should return correct element", o1, o2);
verify(); verify();
} }

View File

@ -745,7 +745,6 @@ public abstract class AbstractTestMap<K, V> extends AbstractTestObject {
* Compare the current serialized form of the Map * Compare the current serialized form of the Map
* against the canonical version in SVN. * against the canonical version in SVN.
*/ */
@SuppressWarnings("unchecked")
public void testEmptyMapCompatibility() throws Exception { public void testEmptyMapCompatibility() throws Exception {
/** /**
* Create canonical objects with this code * Create canonical objects with this code
@ -756,9 +755,10 @@ public abstract class AbstractTestMap<K, V> extends AbstractTestObject {
*/ */
// test to make sure the canonical form has been preserved // test to make sure the canonical form has been preserved
Map map = makeObject(); Map<K, V> map = makeObject();
if (map instanceof Serializable && !skipSerializedCanonicalTests() && isTestSerialization()) { if (map instanceof Serializable && !skipSerializedCanonicalTests() && isTestSerialization()) {
Map map2 = (Map) readExternalFormFromDisk(getCanonicalEmptyCollectionName(map)); @SuppressWarnings("unchecked")
Map<K, V> map2 = (Map<K, V>) readExternalFormFromDisk(getCanonicalEmptyCollectionName(map));
assertEquals("Map is empty", 0, map2.size()); assertEquals("Map is empty", 0, map2.size());
} }
} }
@ -767,7 +767,6 @@ public abstract class AbstractTestMap<K, V> extends AbstractTestObject {
* Compare the current serialized form of the Map * Compare the current serialized form of the Map
* against the canonical version in SVN. * against the canonical version in SVN.
*/ */
@SuppressWarnings("unchecked")
public void testFullMapCompatibility() throws Exception { public void testFullMapCompatibility() throws Exception {
/** /**
* Create canonical objects with this code * Create canonical objects with this code
@ -778,9 +777,10 @@ public abstract class AbstractTestMap<K, V> extends AbstractTestObject {
*/ */
// test to make sure the canonical form has been preserved // test to make sure the canonical form has been preserved
Map map = makeFullMap(); Map<K, V> map = makeFullMap();
if (map instanceof Serializable && !skipSerializedCanonicalTests() && isTestSerialization()) { if (map instanceof Serializable && !skipSerializedCanonicalTests() && isTestSerialization()) {
Map map2 = (Map) readExternalFormFromDisk(getCanonicalFullCollectionName(map)); @SuppressWarnings("unchecked")
Map<K, V> map2 = (Map<K, V>) readExternalFormFromDisk(getCanonicalFullCollectionName(map));
assertEquals("Map is the right size", getSampleKeys().length, map2.size()); assertEquals("Map is the right size", getSampleKeys().length, map2.size());
} }
} }

View File

@ -142,7 +142,7 @@ public class TestCaseInsensitiveMap<K, V> extends AbstractTestIterableMap<K, V>
Locale.setDefault(locales[i]); Locale.setDefault(locales[i]);
for (int j = 0; j < data.length; j++) { for (int j = 0; j < data.length; j++) {
assertTrue("Test data corrupt: " + j, data[j][0].equalsIgnoreCase(data[j][1])); assertTrue("Test data corrupt: " + j, data[j][0].equalsIgnoreCase(data[j][1]));
CaseInsensitiveMap map = new CaseInsensitiveMap(); CaseInsensitiveMap<String, String> map = new CaseInsensitiveMap<String, String>();
map.put(data[j][0], "value"); map.put(data[j][0], "value");
assertEquals(Locale.getDefault() + ": " + j, "value", map.get(data[j][1])); assertEquals(Locale.getDefault() + ": " + j, "value", map.get(data[j][1]));
} }

View File

@ -154,7 +154,6 @@ public class TestFlat3Map<K, V> extends AbstractTestIterableMap<K, V> {
assertSame(TWO, cloned.get(TWENTY)); assertSame(TWO, cloned.get(TWENTY));
} }
@SuppressWarnings("unchecked")
public void testSerialisation0() throws Exception { public void testSerialisation0() throws Exception {
Flat3Map<K, V> map = makeObject(); Flat3Map<K, V> map = makeObject();
ByteArrayOutputStream bout = new ByteArrayOutputStream(); ByteArrayOutputStream bout = new ByteArrayOutputStream();
@ -164,7 +163,7 @@ public class TestFlat3Map<K, V> extends AbstractTestIterableMap<K, V> {
out.close(); out.close();
ByteArrayInputStream bin = new ByteArrayInputStream(bytes); ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
ObjectInputStream in = new ObjectInputStream(bin); ObjectInputStream in = new ObjectInputStream(bin);
Flat3Map ser = (Flat3Map) in.readObject(); Flat3Map<?, ?> ser = (Flat3Map<?, ?>) in.readObject();
in.close(); in.close();
assertEquals(0, map.size()); assertEquals(0, map.size());
assertEquals(0, ser.size()); assertEquals(0, ser.size());
@ -183,7 +182,7 @@ public class TestFlat3Map<K, V> extends AbstractTestIterableMap<K, V> {
out.close(); out.close();
ByteArrayInputStream bin = new ByteArrayInputStream(bytes); ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
ObjectInputStream in = new ObjectInputStream(bin); ObjectInputStream in = new ObjectInputStream(bin);
Flat3Map ser = (Flat3Map) in.readObject(); Flat3Map<?, ?> ser = (Flat3Map<?, ?>) in.readObject();
in.close(); in.close();
assertEquals(2, map.size()); assertEquals(2, map.size());
assertEquals(2, ser.size()); assertEquals(2, ser.size());
@ -208,7 +207,7 @@ public class TestFlat3Map<K, V> extends AbstractTestIterableMap<K, V> {
out.close(); out.close();
ByteArrayInputStream bin = new ByteArrayInputStream(bytes); ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
ObjectInputStream in = new ObjectInputStream(bin); ObjectInputStream in = new ObjectInputStream(bin);
Flat3Map ser = (Flat3Map) in.readObject(); Flat3Map<?, ?> ser = (Flat3Map<?, ?>) in.readObject();
in.close(); in.close();
assertEquals(4, map.size()); assertEquals(4, map.size());
assertEquals(4, ser.size()); assertEquals(4, ser.size());
@ -418,7 +417,7 @@ public class TestFlat3Map<K, V> extends AbstractTestIterableMap<K, V> {
// } // }
public void testCollections261() { public void testCollections261() {
Flat3Map m = new Flat3Map(); Flat3Map<Integer, Integer> m = new Flat3Map<Integer, Integer>();
m.put( new Integer(1), new Integer(1) ); m.put( new Integer(1), new Integer(1) );
m.put( new Integer(0), new Integer(0) ); m.put( new Integer(0), new Integer(0) );
assertEquals( new Integer(1), m.remove( new Integer(1) ) ); assertEquals( new Integer(1), m.remove( new Integer(1) ) );

View File

@ -121,12 +121,12 @@ public class TestIdentityMap<K, V> extends AbstractTestObject {
* Compare the current serialized form of the Map * Compare the current serialized form of the Map
* against the canonical version in SVN. * against the canonical version in SVN.
*/ */
@SuppressWarnings("unchecked")
public void testEmptyMapCompatibility() throws IOException, ClassNotFoundException { public void testEmptyMapCompatibility() throws IOException, ClassNotFoundException {
// test to make sure the canonical form has been preserved // test to make sure the canonical form has been preserved
Map<K, V> map = makeObject(); Map<K, V> map = makeObject();
if (map instanceof Serializable && !skipSerializedCanonicalTests()) { if (map instanceof Serializable && !skipSerializedCanonicalTests()) {
Map map2 = (Map) readExternalFormFromDisk(getCanonicalEmptyCollectionName(map)); @SuppressWarnings("unchecked")
Map<K, V> map2 = (Map<K, V>) readExternalFormFromDisk(getCanonicalEmptyCollectionName(map));
assertEquals("Map is empty", 0, map2.size()); assertEquals("Map is empty", 0, map2.size());
} }
} }

View File

@ -238,7 +238,7 @@ public class TestLRUMap<K, V> extends AbstractTestOrderedMap<K, V> {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testRemoveLRU() { public void testRemoveLRU() {
MockLRUMapSubclass map = new MockLRUMapSubclass(2); MockLRUMapSubclass<K, String> map = new MockLRUMapSubclass<K, String>(2);
assertNull(map.entry); assertNull(map.entry);
map.put((K) "A", "a"); map.put((K) "A", "a");
assertNull(map.entry); assertNull(map.entry);
@ -484,9 +484,9 @@ public class TestLRUMap<K, V> extends AbstractTestOrderedMap<K, V> {
// TODO: COLLECTIONS-330 // TODO: COLLECTIONS-330
public void todoTestSynchronizedRemoveFromMapIterator() throws InterruptedException { public void todoTestSynchronizedRemoveFromMapIterator() throws InterruptedException {
final LRUMap map = new LRUMap(10000); final LRUMap<Object, Thread> map = new LRUMap<Object, Thread>(10000);
final Map exceptions = new HashMap(); final Map<Throwable, String> exceptions = new HashMap<Throwable, String>();
final ThreadGroup tg = new ThreadGroup(getName()) { final ThreadGroup tg = new ThreadGroup(getName()) {
@Override @Override
public void uncaughtException(Thread t, Throwable e) { public void uncaughtException(Thread t, Throwable e) {
@ -516,7 +516,7 @@ public class TestLRUMap<K, V> extends AbstractTestOrderedMap<K, V> {
} }
} }
synchronized (map) { synchronized (map) {
for (MapIterator iter = map.mapIterator(); iter.hasNext();) { for (MapIterator<Object, Thread> iter = map.mapIterator(); iter.hasNext();) {
String name = (String)iter.next(); String name = (String)iter.next();
if (map.get(name) == this) { if (map.get(name) == this) {
iter.remove(); iter.remove();
@ -567,9 +567,9 @@ public class TestLRUMap<K, V> extends AbstractTestOrderedMap<K, V> {
public void testSynchronizedRemoveFromEntrySet() throws InterruptedException { public void testSynchronizedRemoveFromEntrySet() throws InterruptedException {
final Map map = new LRUMap(10000); final Map<Object, Thread> map = new LRUMap<Object, Thread>(10000);
final Map exceptions = new HashMap(); final Map<Throwable, String> exceptions = new HashMap<Throwable, String>();
final ThreadGroup tg = new ThreadGroup(getName()) { final ThreadGroup tg = new ThreadGroup(getName()) {
@Override @Override
public void uncaughtException(Thread t, Throwable e) { public void uncaughtException(Thread t, Throwable e) {
@ -599,8 +599,8 @@ public class TestLRUMap<K, V> extends AbstractTestOrderedMap<K, V> {
} }
} }
synchronized (map) { synchronized (map) {
for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) { for (Iterator<Map.Entry<Object, Thread>> iter = map.entrySet().iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry)iter.next(); Map.Entry<Object, Thread> entry = iter.next();
if (entry.getValue() == this) { if (entry.getValue() == this) {
iter.remove(); iter.remove();
} }
@ -651,9 +651,9 @@ public class TestLRUMap<K, V> extends AbstractTestOrderedMap<K, V> {
// TODO: COLLECTIONS-330 // TODO: COLLECTIONS-330
public void todoTestSynchronizedRemoveFromKeySet() throws InterruptedException { public void todoTestSynchronizedRemoveFromKeySet() throws InterruptedException {
final Map map = new LRUMap(10000); final Map<Object, Thread> map = new LRUMap<Object, Thread>(10000);
final Map exceptions = new HashMap(); final Map<Throwable, String> exceptions = new HashMap<Throwable, String>();
final ThreadGroup tg = new ThreadGroup(getName()) { final ThreadGroup tg = new ThreadGroup(getName()) {
@Override @Override
public void uncaughtException(Thread t, Throwable e) { public void uncaughtException(Thread t, Throwable e) {
@ -683,7 +683,7 @@ public class TestLRUMap<K, V> extends AbstractTestOrderedMap<K, V> {
} }
} }
synchronized (map) { synchronized (map) {
for (Iterator iter = map.keySet().iterator(); iter.hasNext();) { for (Iterator<Object> iter = map.keySet().iterator(); iter.hasNext();) {
String name = (String)iter.next(); String name = (String)iter.next();
if (map.get(name) == this) { if (map.get(name) == this) {
iter.remove(); iter.remove();
@ -734,9 +734,9 @@ public class TestLRUMap<K, V> extends AbstractTestOrderedMap<K, V> {
public void testSynchronizedRemoveFromValues() throws InterruptedException { public void testSynchronizedRemoveFromValues() throws InterruptedException {
final Map map = new LRUMap(10000); final Map<Object, Thread> map = new LRUMap<Object, Thread>(10000);
final Map exceptions = new HashMap(); final Map<Throwable, String> exceptions = new HashMap<Throwable, String>();
final ThreadGroup tg = new ThreadGroup(getName()) { final ThreadGroup tg = new ThreadGroup(getName()) {
@Override @Override
public void uncaughtException(Thread t, Throwable e) { public void uncaughtException(Thread t, Throwable e) {
@ -766,7 +766,7 @@ public class TestLRUMap<K, V> extends AbstractTestOrderedMap<K, V> {
} }
} }
synchronized (map) { synchronized (map) {
for (Iterator iter = map.values().iterator(); iter.hasNext();) { for (Iterator<Thread> iter = map.values().iterator(); iter.hasNext();) {
if (iter.next() == this) { if (iter.next() == this) {
iter.remove(); iter.remove();
} }

View File

@ -68,18 +68,18 @@ public class TestMultiKeyMap<K, V> extends AbstractTestIterableMap<MultiKey<? ex
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private MultiKey<K>[] getMultiKeyKeys() { private MultiKey<K>[] getMultiKeyKeys() {
return new MultiKey[] { return new MultiKey[] {
new MultiKey(I1, I2), new MultiKey<Integer>(I1, I2),
new MultiKey(I2, I3), new MultiKey<Integer>(I2, I3),
new MultiKey(I3, I4), new MultiKey<Integer>(I3, I4),
new MultiKey(I1, I1, I2), new MultiKey<Integer>(I1, I1, I2),
new MultiKey(I2, I3, I4), new MultiKey<Integer>(I2, I3, I4),
new MultiKey(I3, I7, I6), new MultiKey<Integer>(I3, I7, I6),
new MultiKey(I1, I1, I2, I3), new MultiKey<Integer>(I1, I1, I2, I3),
new MultiKey(I2, I4, I5, I6), new MultiKey<Integer>(I2, I4, I5, I6),
new MultiKey(I3, I6, I7, I8), new MultiKey<Integer>(I3, I6, I7, I8),
new MultiKey(I1, I1, I2, I3, I4), new MultiKey<Integer>(I1, I1, I2, I3, I4),
new MultiKey(I2, I3, I4, I5, I6), new MultiKey<Integer>(I2, I3, I4, I5, I6),
new MultiKey(I3, I5, I6, I7, I8), new MultiKey<Integer>(I3, I5, I6, I7, I8),
}; };
} }
@ -108,11 +108,11 @@ public class TestMultiKeyMap<K, V> extends AbstractTestIterableMap<MultiKey<? ex
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public MultiKey<K>[] getOtherKeys() { public MultiKey<K>[] getOtherKeys() {
return (MultiKey<K>[]) new MultiKey[] { return new MultiKey[] {
new MultiKey(I1, I7), new MultiKey<Integer>(I1, I7),
new MultiKey(I1, I8), new MultiKey<Integer>(I1, I8),
new MultiKey(I2, I4), new MultiKey<Integer>(I2, I4),
new MultiKey(I2, I5), new MultiKey<Integer>(I2, I5),
}; };
} }

View File

@ -101,7 +101,7 @@ public class TestTransformedMap<K, V> extends AbstractTestIterableMap<K, V> {
assertEquals(new Integer(66), array[0].getValue()); assertEquals(new Integer(66), array[0].getValue());
assertEquals(new Integer(66), map.get(array[0].getKey())); assertEquals(new Integer(66), map.get(array[0].getKey()));
Map.Entry entry = (Map.Entry) entrySet.iterator().next(); Map.Entry entry = entrySet.iterator().next();
entry.setValue("88"); entry.setValue("88");
assertEquals(new Integer(88), entry.getValue()); assertEquals(new Integer(88), entry.getValue());
assertEquals(new Integer(88), map.get(entry.getKey())); assertEquals(new Integer(88), map.get(entry.getKey()));

View File

@ -114,7 +114,7 @@ public class TestTransformedSortedMap<K, V> extends AbstractTestSortedMap<K, V>
assertEquals(new Integer((String) els[0]), map.remove(els[0])); assertEquals(new Integer((String) els[0]), map.remove(els[0]));
Set<Map.Entry<K, V>> entrySet = map.entrySet(); Set<Map.Entry<K, V>> entrySet = map.entrySet();
Map.Entry<K, V>[] array = (Map.Entry<K, V>[]) entrySet.toArray(new Map.Entry[0]); Map.Entry<K, V>[] array = entrySet.toArray(new Map.Entry[0]);
array[0].setValue((V) "66"); array[0].setValue((V) "66");
assertEquals(new Integer(66), array[0].getValue()); assertEquals(new Integer(66), array[0].getValue());
assertEquals(new Integer(66), map.get(array[0].getKey())); assertEquals(new Integer(66), map.get(array[0].getKey()));

View File

@ -28,7 +28,7 @@ import org.apache.commons.collections.BulkTest;
* To use, subclass and override the {@link #makeEmptySet()} * To use, subclass and override the {@link #makeEmptySet()}
* method. You may have to override other protected methods if your * method. You may have to override other protected methods if your
* set is not modifiable, or if your set restricts what kinds of * set is not modifiable, or if your set restricts what kinds of
* elements may be added; see {@link AbstractTestCollection} for more details. * elements may be added; see {@link AbstractTestSet} for more details.
* *
* @since Commons Collections 3.0 * @since Commons Collections 3.0
* @version $Revision$ $Date$ * @version $Revision$ $Date$

View File

@ -28,9 +28,9 @@ import org.apache.commons.collections.collection.CompositeCollection;
* class also has to be serialized. * class also has to be serialized.
*/ */
class EmptySetMutator<E> implements CompositeSet.SetMutator<E> { class EmptySetMutator<E> implements CompositeSet.SetMutator<E> {
private Set contained; private Set<E> contained;
public EmptySetMutator(Set set) { public EmptySetMutator(Set<E> set) {
this.contained = set; this.contained = set;
} }

View File

@ -50,7 +50,7 @@ public class TestCompositeSet<E> extends AbstractTestSet<E> {
public CompositeSet<E> makeObject() { public CompositeSet<E> makeObject() {
final HashSet<E> contained = new HashSet<E>(); final HashSet<E> contained = new HashSet<E>();
CompositeSet<E> set = new CompositeSet<E>(contained); CompositeSet<E> set = new CompositeSet<E>(contained);
set.setMutator( new EmptySetMutator(contained) ); set.setMutator( new EmptySetMutator<E>(contained) );
return set; return set;
} }

View File

@ -97,12 +97,12 @@ public class TestTransformedSet<E> extends AbstractTestSet<E> {
} }
public void testTransformedSet_decorateTransform() { public void testTransformedSet_decorateTransform() {
Set originalSet = new HashSet(); Set<Object> originalSet = new HashSet<Object>();
Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"}; Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
for (int i = 0; i < els.length; i++) { for (int i = 0; i < els.length; i++) {
originalSet.add(els[i]); originalSet.add(els[i]);
} }
Set set = TransformedSet.decorateTransform(originalSet, TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER); Set<?> set = TransformedSet.decorateTransform(originalSet, TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
assertEquals(els.length, set.size()); assertEquals(els.length, set.size());
for (int i = 0; i < els.length; i++) { for (int i = 0; i < els.length; i++) {
assertEquals(true, set.contains(new Integer((String) els[i]))); assertEquals(true, set.contains(new Integer((String) els[i])));

View File

@ -83,12 +83,12 @@ public class TestTransformedSortedSet<E> extends AbstractTestSortedSet<E> {
} }
public void testTransformedSet_decorateTransform() { public void testTransformedSet_decorateTransform() {
Set originalSet = new TreeSet(); Set<Object> originalSet = new TreeSet<Object>();
Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"}; Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
for (int i = 0; i < els.length; i++) { for (int i = 0; i < els.length; i++) {
originalSet.add(els[i]); originalSet.add(els[i]);
} }
Set set = TransformedSortedSet.decorateTransform(originalSet, TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER); Set<?> set = TransformedSortedSet.decorateTransform(originalSet, TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
assertEquals(els.length, set.size()); assertEquals(els.length, set.size());
for (int i = 0; i < els.length; i++) { for (int i = 0; i < els.length; i++) {
assertEquals(true, set.contains(new Integer((String) els[i]))); assertEquals(true, set.contains(new Integer((String) els[i])));

View File

@ -42,7 +42,7 @@ public class TestTransformedMap extends BulkTest {
private Transformer<Integer, String> intToString = new Transformer<Integer, String>() { private Transformer<Integer, String> intToString = new Transformer<Integer, String>() {
public String transform(Integer input) { public String transform(Integer input) {
return String.valueOf(input); return String.valueOf(input);
}; }
}; };
private Transformer<Object, Class<?>> objectToClass = new Transformer<Object, Class<?>>() { private Transformer<Object, Class<?>> objectToClass = new Transformer<Object, Class<?>>() {
@ -71,13 +71,12 @@ public class TestTransformedMap extends BulkTest {
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@SuppressWarnings("unchecked")
public void testTransformedMap() { public void testTransformedMap() {
TransformedMap<Integer, String, Object, Class<?>> map = TransformedMap.decorate( TransformedMap<Integer, String, Object, Class<?>> map = TransformedMap.decorate(
new HashMap<String, Class<?>>(), intToString, objectToClass); new HashMap<String, Class<?>>(), intToString, objectToClass);
Integer[] k = new Integer[] { 0, 1, 2, 3, 4, 5, 6 }; Integer[] k = new Integer[] { 0, 1, 2, 3, 4, 5, 6 };
Object[] v = new Object[] { "", new Object(), new HashMap(), 0, BigInteger.TEN, null, Object[] v = new Object[] { "", new Object(), new HashMap<Object, Object>(), 0, BigInteger.TEN, null,
new Object[0] }; new Object[0] };
assertEquals(0, map.size()); assertEquals(0, map.size());