http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/set/SynchronizedSortedSet.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/commons/collections/set/SynchronizedSortedSet.java b/src/java/org/apache/commons/collections/set/SynchronizedSortedSet.java index 388639e..59a3e16 100644 --- a/src/java/org/apache/commons/collections/set/SynchronizedSortedSet.java +++ b/src/java/org/apache/commons/collections/set/SynchronizedSortedSet.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,7 +31,7 @@ import org.apache.commons.collections.collection.SynchronizedCollection; * * @since Commons Collections 3.0 * @version $Revision$ $Date$ - * + * * @author Stephen Colebourne */ public class SynchronizedSortedSet<E> extends SynchronizedCollection<E> implements SortedSet<E> { @@ -41,18 +41,18 @@ public class SynchronizedSortedSet<E> extends SynchronizedCollection<E> implemen /** * Factory method to create a synchronized set. - * + * * @param set the set to decorate, must not be null * @throws IllegalArgumentException if set is null */ public static <T> SortedSet<T> decorate(SortedSet<T> set) { return new SynchronizedSortedSet<T>(set); } - + //----------------------------------------------------------------------- /** * Constructor that wraps (not copies). - * + * * @param set the set to decorate, must not be null * @throws IllegalArgumentException if set is null */ @@ -62,7 +62,7 @@ public class SynchronizedSortedSet<E> extends SynchronizedCollection<E> implemen /** * Constructor that wraps (not copies). - * + * * @param set the set to decorate, must not be null * @param lock the lock object to use, must not be null * @throws IllegalArgumentException if set is null @@ -73,7 +73,7 @@ public class SynchronizedSortedSet<E> extends SynchronizedCollection<E> implemen /** * Gets the decorated set. - * + * * @return the decorated set */ protected SortedSet<E> getSortedSet() { @@ -83,28 +83,28 @@ public class SynchronizedSortedSet<E> extends SynchronizedCollection<E> implemen //----------------------------------------------------------------------- public SortedSet<E> subSet(E fromElement, E toElement) { synchronized (lock) { - SortedSet set = getSortedSet().subSet(fromElement, toElement); + SortedSet<E> set = getSortedSet().subSet(fromElement, toElement); // the lock is passed into the constructor here to ensure that the // subset is synchronized on the same lock as the parent - return new SynchronizedSortedSet(set, lock); + return new SynchronizedSortedSet<E>(set, lock); } } public SortedSet<E> headSet(E toElement) { synchronized (lock) { - SortedSet set = getSortedSet().headSet(toElement); + SortedSet<E> set = getSortedSet().headSet(toElement); // the lock is passed into the constructor here to ensure that the // headset is synchronized on the same lock as the parent - return new SynchronizedSortedSet(set, lock); + return new SynchronizedSortedSet<E>(set, lock); } } public SortedSet<E> tailSet(E fromElement) { synchronized (lock) { - SortedSet set = getSortedSet().tailSet(fromElement); + SortedSet<E> set = getSortedSet().tailSet(fromElement); // the lock is passed into the constructor here to ensure that the // tailset is synchronized on the same lock as the parent - return new SynchronizedSortedSet(set, lock); + return new SynchronizedSortedSet<E>(set, lock); } } @@ -120,7 +120,7 @@ public class SynchronizedSortedSet<E> extends SynchronizedCollection<E> implemen } } - public Comparator comparator() { + public Comparator<? super E> comparator() { synchronized (lock) { return getSortedSet().comparator(); }
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/set/TransformedSet.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/commons/collections/set/TransformedSet.java b/src/java/org/apache/commons/collections/set/TransformedSet.java index 7f4b32b..2a90556 100644 --- a/src/java/org/apache/commons/collections/set/TransformedSet.java +++ b/src/java/org/apache/commons/collections/set/TransformedSet.java @@ -36,7 +36,7 @@ import org.apache.commons.collections.collection.TransformedCollection; * * @author Stephen Colebourne */ -public class TransformedSet extends TransformedCollection implements Set { +public class TransformedSet<E> extends TransformedCollection<E> implements Set<E> { /** Serialization version */ private static final long serialVersionUID = 306127383500410386L; @@ -51,8 +51,8 @@ public class TransformedSet extends TransformedCollection implements Set { * @param transformer the transformer to use for conversion, must not be null * @throws IllegalArgumentException if set or transformer is null */ - public static Set decorate(Set set, Transformer transformer) { - return new TransformedSet(set, transformer); + public static <E> Set<E> decorate(Set<E> set, Transformer<? super E, ? extends E> transformer) { + return new TransformedSet<E>(set, transformer); } //----------------------------------------------------------------------- @@ -66,7 +66,7 @@ public class TransformedSet extends TransformedCollection implements Set { * @param transformer the transformer to use for conversion, must not be null * @throws IllegalArgumentException if set or transformer is null */ - protected TransformedSet(Set set, Transformer transformer) { + protected TransformedSet(Set<E> set, Transformer<? super E, ? extends E> transformer) { super(set, transformer); } http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/set/TransformedSortedSet.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/commons/collections/set/TransformedSortedSet.java b/src/java/org/apache/commons/collections/set/TransformedSortedSet.java index 64f26aa..7961faa 100644 --- a/src/java/org/apache/commons/collections/set/TransformedSortedSet.java +++ b/src/java/org/apache/commons/collections/set/TransformedSortedSet.java @@ -36,7 +36,7 @@ import org.apache.commons.collections.Transformer; * * @author Stephen Colebourne */ -public class TransformedSortedSet extends TransformedSet implements SortedSet { +public class TransformedSortedSet<E> extends TransformedSet<E> implements SortedSet<E> { /** Serialization version */ private static final long serialVersionUID = -1675486811351124386L; @@ -51,8 +51,8 @@ public class TransformedSortedSet extends TransformedSet implements SortedSet { * @param transformer the transformer to use for conversion, must not be null * @throws IllegalArgumentException if set or transformer is null */ - public static SortedSet decorate(SortedSet set, Transformer transformer) { - return new TransformedSortedSet(set, transformer); + public static <E> SortedSet<E> decorate(SortedSet<E> set, Transformer<? super E, ? extends E> transformer) { + return new TransformedSortedSet<E>(set, transformer); } //----------------------------------------------------------------------- @@ -66,7 +66,7 @@ public class TransformedSortedSet extends TransformedSet implements SortedSet { * @param transformer the transformer to use for conversion, must not be null * @throws IllegalArgumentException if set or transformer is null */ - protected TransformedSortedSet(SortedSet set, Transformer transformer) { + protected TransformedSortedSet(SortedSet<E> set, Transformer<? super E, ? extends E> transformer) { super(set, transformer); } @@ -75,37 +75,37 @@ public class TransformedSortedSet extends TransformedSet implements SortedSet { * * @return the decorated set */ - protected SortedSet getSortedSet() { - return (SortedSet) collection; + protected SortedSet<E> getSortedSet() { + return (SortedSet<E>) collection; } //----------------------------------------------------------------------- - public Object first() { + public E first() { return getSortedSet().first(); } - public Object last() { + public E last() { return getSortedSet().last(); } - public Comparator comparator() { + public Comparator<? super E> comparator() { return getSortedSet().comparator(); } //----------------------------------------------------------------------- - public SortedSet subSet(Object fromElement, Object toElement) { - SortedSet set = getSortedSet().subSet(fromElement, toElement); - return new TransformedSortedSet(set, transformer); + public SortedSet<E> subSet(E fromElement, E toElement) { + SortedSet<E> set = getSortedSet().subSet(fromElement, toElement); + return new TransformedSortedSet<E>(set, transformer); } - public SortedSet headSet(Object toElement) { - SortedSet set = getSortedSet().headSet(toElement); - return new TransformedSortedSet(set, transformer); + public SortedSet<E> headSet(E toElement) { + SortedSet<E> set = getSortedSet().headSet(toElement); + return new TransformedSortedSet<E>(set, transformer); } - public SortedSet tailSet(Object fromElement) { - SortedSet set = getSortedSet().tailSet(fromElement); - return new TransformedSortedSet(set, transformer); + public SortedSet<E> tailSet(E fromElement) { + SortedSet<E> set = getSortedSet().tailSet(fromElement); + return new TransformedSortedSet<E>(set, transformer); } } http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/set/UnmodifiableSet.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/commons/collections/set/UnmodifiableSet.java b/src/java/org/apache/commons/collections/set/UnmodifiableSet.java index 29df1cc..c3e126c 100644 --- a/src/java/org/apache/commons/collections/set/UnmodifiableSet.java +++ b/src/java/org/apache/commons/collections/set/UnmodifiableSet.java @@ -33,8 +33,8 @@ import org.apache.commons.collections.iterators.UnmodifiableIterator; * * @author Stephen Colebourne */ -public final class UnmodifiableSet - extends AbstractSerializableSetDecorator +public final class UnmodifiableSet<E> + extends AbstractSerializableSetDecorator<E> implements Unmodifiable { /** Serialization version */ @@ -46,11 +46,11 @@ public final class UnmodifiableSet * @param set the set to decorate, must not be null * @throws IllegalArgumentException if set is null */ - public static Set decorate(Set set) { + public static <E> Set<E> decorate(Set<E> set) { if (set instanceof Unmodifiable) { return set; } - return new UnmodifiableSet(set); + return new UnmodifiableSet<E>(set); } //----------------------------------------------------------------------- @@ -60,20 +60,20 @@ public final class UnmodifiableSet * @param set the set to decorate, must not be null * @throws IllegalArgumentException if set is null */ - private UnmodifiableSet(Set set) { + private UnmodifiableSet(Set<E> set) { super(set); } //----------------------------------------------------------------------- - public Iterator iterator() { - return UnmodifiableIterator.decorate(decorated().iterator()); + public Iterator<E> iterator() { + return UnmodifiableIterator.<E>decorate(decorated().iterator()); } - public boolean add(Object object) { + public boolean add(E object) { throw new UnsupportedOperationException(); } - public boolean addAll(Collection coll) { + public boolean addAll(Collection<? extends E> coll) { throw new UnsupportedOperationException(); } @@ -85,11 +85,11 @@ public final class UnmodifiableSet throw new UnsupportedOperationException(); } - public boolean removeAll(Collection coll) { + public boolean removeAll(Collection<?> coll) { throw new UnsupportedOperationException(); } - public boolean retainAll(Collection coll) { + public boolean retainAll(Collection<?> coll) { throw new UnsupportedOperationException(); } http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java b/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java index 2fd72e0..58cec6b 100644 --- a/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java +++ b/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java @@ -54,7 +54,7 @@ public final class UnmodifiableSortedSet<E> if (set instanceof Unmodifiable) { return set; } - return new UnmodifiableSortedSet(set); + return new UnmodifiableSortedSet<T>(set); } //----------------------------------------------------------------------- @@ -76,6 +76,7 @@ public final class UnmodifiableSortedSet<E> * @throws IOException * @throws ClassNotFoundException */ + @SuppressWarnings("unchecked") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); collection = (Collection) in.readObject(); @@ -93,7 +94,7 @@ public final class UnmodifiableSortedSet<E> } //----------------------------------------------------------------------- - public Iterator iterator() { + public Iterator<E> iterator() { return UnmodifiableIterator.decorate(decorated().iterator()); } @@ -124,17 +125,17 @@ public final class UnmodifiableSortedSet<E> //----------------------------------------------------------------------- public SortedSet<E> subSet(E fromElement, E toElement) { SortedSet<E> sub = decorated().subSet(fromElement, toElement); - return new UnmodifiableSortedSet(sub); + return new UnmodifiableSortedSet<E>(sub); } public SortedSet<E> headSet(E toElement) { SortedSet<E> sub = decorated().headSet(toElement); - return new UnmodifiableSortedSet(sub); + return new UnmodifiableSortedSet<E>(sub); } public SortedSet<E> tailSet(E fromElement) { SortedSet<E> sub = decorated().tailSet(fromElement); - return new UnmodifiableSortedSet(sub); + return new UnmodifiableSortedSet<E>(sub); } } http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/test/org/apache/commons/collections/AbstractTestObject.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/commons/collections/AbstractTestObject.java b/src/test/org/apache/commons/collections/AbstractTestObject.java index a8ad06c..f692def 100644 --- a/src/test/org/apache/commons/collections/AbstractTestObject.java +++ b/src/test/org/apache/commons/collections/AbstractTestObject.java @@ -167,7 +167,7 @@ public abstract class AbstractTestObject extends BulkTest { Object o = makeObject(); if (o instanceof Serializable && isTestSerialization()) { byte[] objekt = writeExternalFormToBytes((Serializable) o); - Object p = readExternalFormFromBytes(objekt); + readExternalFormFromBytes(objekt); } } http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/test/org/apache/commons/collections/BulkTest.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/commons/collections/BulkTest.java b/src/test/org/apache/commons/collections/BulkTest.java index 648b9b5..fd19542 100644 --- a/src/test/org/apache/commons/collections/BulkTest.java +++ b/src/test/org/apache/commons/collections/BulkTest.java @@ -246,7 +246,7 @@ public class BulkTest extends TestCase implements Cloneable { * @return a {@link TestSuite} containing all the simple and bulk tests * defined by that class */ - public static TestSuite makeSuite(Class c) { + public static TestSuite makeSuite(Class<? extends BulkTest> c) { if (Modifier.isAbstract(c.getModifiers())) { throw new IllegalArgumentException("Class must not be abstract."); } @@ -265,10 +265,10 @@ public class BulkTest extends TestCase implements Cloneable { class BulkTestSuiteMaker { /** The class that defines simple and bulk tests methods. */ - private Class startingClass; + private Class<? extends BulkTest> startingClass; /** List of ignored simple test names. */ - private List ignored; + private List<String> ignored; /** The TestSuite we're currently populating. Can change over time. */ private TestSuite result; @@ -284,7 +284,7 @@ class BulkTestSuiteMaker { * * @param startingClass the starting class */ - public BulkTestSuiteMaker(Class startingClass) { + public BulkTestSuiteMaker(Class<? extends BulkTest> startingClass) { this.startingClass = startingClass; } @@ -299,7 +299,7 @@ class BulkTestSuiteMaker { result.setName(prefix); BulkTest bulk = makeFirstTestCase(startingClass); - ignored = new ArrayList(); + ignored = new ArrayList<String>(); String[] s = bulk.ignoredTests(); if (s != null) { ignored.addAll(Arrays.asList(s)); @@ -316,7 +316,7 @@ class BulkTestSuiteMaker { * tests for us to append */ void make(BulkTest bulk) { - Class c = bulk.getClass(); + Class<? extends BulkTest> c = bulk.getClass(); Method[] all = c.getMethods(); for (int i = 0; i < all.length; i++) { if (isTest(all[i])) addTest(bulk, all[i]); @@ -388,7 +388,7 @@ class BulkTestSuiteMaker { * @param c the class * @return the name of that class, minus any package names */ - private static String getBaseName(Class c) { + private static String getBaseName(Class<?> c) { String name = c.getName(); int p = name.lastIndexOf('.'); if (p > 0) { @@ -401,7 +401,7 @@ class BulkTestSuiteMaker { // These three methods are used to create a valid BulkTest instance // from a class. - private static Constructor getTestCaseConstructor(Class c) { + private static <T> Constructor<T> getTestCaseConstructor(Class<T> c) { try { return c.getConstructor(new Class[] { String.class }); } catch (NoSuchMethodException e) { @@ -410,10 +410,10 @@ class BulkTestSuiteMaker { } } - private static BulkTest makeTestCase(Class c, Method m) { - Constructor con = getTestCaseConstructor(c); + private static <T extends BulkTest> BulkTest makeTestCase(Class<T> c, Method m) { + Constructor<T> con = getTestCaseConstructor(c); try { - return (BulkTest)con.newInstance(new Object[] {m.getName()}); + return (BulkTest) con.newInstance(new Object[] { m.getName() }); } catch (InvocationTargetException e) { e.printStackTrace(); throw new RuntimeException(); // FIXME; @@ -424,7 +424,7 @@ class BulkTestSuiteMaker { } } - private static BulkTest makeFirstTestCase(Class c) { + private static <T extends BulkTest> BulkTest makeFirstTestCase(Class<T> c) { Method[] all = c.getMethods(); for (int i = 0; i < all.length; i++) { if (isTest(all[i])) return makeTestCase(c, all[i]); http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/test/org/apache/commons/collections/LocalTestNode.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/commons/collections/LocalTestNode.java b/src/test/org/apache/commons/collections/LocalTestNode.java index ec31aeb..6eb0138 100644 --- a/src/test/org/apache/commons/collections/LocalTestNode.java +++ b/src/test/org/apache/commons/collections/LocalTestNode.java @@ -23,46 +23,50 @@ package org.apache.commons.collections; * * @author Marc Johnson (marcj at users dot sourceforge dot net) */ -class LocalTestNode implements Comparable { +class LocalTestNode<K extends Comparable<K>, V extends Comparable<V>> implements Comparable<LocalTestNode<K, V>> { - private Comparable key; - private Comparable value; + private K key; + private V value; + + static LocalTestNode<Integer, String> createLocalTestNode(final int key) { + return new LocalTestNode<Integer, String>(key, String.valueOf(key)); + } /** * construct a LocalTestNode * * @param key value used to create the key and value */ - LocalTestNode(final int key) { - this.key = new Integer(key); - this.value = String.valueOf(key); + private LocalTestNode(K key, V value) { + this.key = key; + this.value = value; } /** * @param key the unique key associated with the current node. */ - void setKey(Comparable key) { + void setKey(K key) { this.key = key; } /** * @return the unique key associated with the current node */ - Comparable getKey() { + K getKey() { return key; } /** * @param value the unique value associated with the current node. */ - void setValue(Comparable value) { + void setValue(V value) { this.value = value; } /** * @return the unique value associated with the current node */ - Comparable getValue() { + V getValue() { return value; } @@ -73,10 +77,9 @@ class LocalTestNode implements Comparable { * * @return */ - public int compareTo(Object o) { + public int compareTo(LocalTestNode<K, V> other) { - LocalTestNode other = (LocalTestNode) o; - int rval = getKey().compareTo(other.getKey()); + int rval = getKey().compareTo(other.getKey()); if (rval == 0) { rval = getValue().compareTo(other.getValue()); @@ -92,6 +95,7 @@ class LocalTestNode implements Comparable { * * @return true if equal */ + @SuppressWarnings("unchecked") public boolean equals(Object o) { if (o == null) { http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/test/org/apache/commons/collections/MapPerformance.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/commons/collections/MapPerformance.java b/src/test/org/apache/commons/collections/MapPerformance.java index 85596f0..a7f6e0a 100644 --- a/src/test/org/apache/commons/collections/MapPerformance.java +++ b/src/test/org/apache/commons/collections/MapPerformance.java @@ -17,11 +17,11 @@ package org.apache.commons.collections; import java.util.Collection; -import java.util.Collections; +//import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Set; -import java.util.TreeMap; +//import java.util.TreeMap; import org.apache.commons.collections.map.Flat3Map; @@ -43,17 +43,17 @@ public class MapPerformance { } private static void testAll() { - Map dummyMap = new DummyMap(); - Map hashMap = new HashMap(); + Map<String, String> dummyMap = new DummyMap<String, String>(); + Map<String, String> hashMap = new HashMap<String, String>(); // hashMap.put("Alpha", "A"); // hashMap.put("Beta", "B"); // hashMap.put("Gamma", "C"); // hashMap.put("Delta", "D"); - Map flatMap = new Flat3Map(hashMap); + Map<String, String> flatMap = new Flat3Map<String, String>(hashMap); System.out.println(flatMap); - Map unmodHashMap = Collections.unmodifiableMap(new HashMap(hashMap)); +// Map<String, String> unmodHashMap = Collections.unmodifiableMap(new HashMap<String, String>(hashMap)); // Map fastHashMap = new FastHashMap(hashMap); - Map treeMap = new TreeMap(hashMap); +// Map<String, String> treeMap = new TreeMap<String, String>(hashMap); // Map linkedMap = new LinkedHashMap(hashMap); // Map syncMap = Collections.unmodifiableMap(new HashMap(hashMap)); // Map bucketMap = new StaticBucketMap(); @@ -109,9 +109,9 @@ public class MapPerformance { // test(doubleMap, " DoubleMap "); } - private static void test(Map map, String name) { + private static void test(Map<String, String> map, String name) { long start = 0, end = 0; - int total = 0; +// int total = 0; start = System.currentTimeMillis(); for (int i = RUNS; i > 0; i--) { // if (map.get("Alpha") != null) total++; @@ -133,7 +133,7 @@ public class MapPerformance { // ---------------------------------------------------------------------- - private static class DummyMap implements Map { + private static class DummyMap<K, V> implements Map<K, V> { public void clear() { } public boolean containsKey(Object key) { @@ -142,30 +142,30 @@ public class MapPerformance { public boolean containsValue(Object value) { return false; } - public Set entrySet() { + public Set<Map.Entry<K, V>> entrySet() { return null; } - public Object get(Object key) { + public V get(Object key) { return null; } public boolean isEmpty() { return false; } - public Set keySet() { + public Set<K> keySet() { return null; } - public Object put(Object key, Object value) { + public V put(K key, V value) { return null; } - public void putAll(Map t) { + public void putAll(Map<? extends K, ? extends V> t) { } - public Object remove(Object key) { + public V remove(Object key) { return null; } public int size() { return 0; } - public Collection values() { + public Collection<V> values() { return null; } } http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/test/org/apache/commons/collections/MockTestCase.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/commons/collections/MockTestCase.java b/src/test/org/apache/commons/collections/MockTestCase.java index c1b47f2..9362fcd 100644 --- a/src/test/org/apache/commons/collections/MockTestCase.java +++ b/src/test/org/apache/commons/collections/MockTestCase.java @@ -17,7 +17,6 @@ package org.apache.commons.collections; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.ListIterator; @@ -50,13 +49,13 @@ public abstract class MockTestCase { } protected final void replay() { - for (Iterator i = mockObjects.iterator(); i.hasNext();) { - EasyMock.replay(i.next()); + for (Object o : mockObjects) { + EasyMock.replay(o); } } protected final void verify() { - for (ListIterator i = mockObjects.listIterator(); i.hasNext();) { + for (ListIterator<Object> i = mockObjects.listIterator(); i.hasNext();) { try { EasyMock.verify(i.next()); } catch (AssertionError e) { http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/test/org/apache/commons/collections/TestArrayList.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/commons/collections/TestArrayList.java b/src/test/org/apache/commons/collections/TestArrayList.java index 7107add..8251663 100644 --- a/src/test/org/apache/commons/collections/TestArrayList.java +++ b/src/test/org/apache/commons/collections/TestArrayList.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,15 +25,13 @@ import org.apache.commons.collections.list.AbstractTestList; /** * Abstract test class for ArrayList. - * + * * @version $Revision$ $Date$ - * + * * @author Jason van Zyl */ -public abstract class TestArrayList extends AbstractTestList { - - protected ArrayList list = null; - +public abstract class TestArrayList<E> extends AbstractTestList<E> { + public TestArrayList(String testName) { super(testName); } @@ -47,12 +45,15 @@ public abstract class TestArrayList extends AbstractTestList { junit.textui.TestRunner.main(testCaseName); } - public void setUp() { - list = (ArrayList) makeEmptyList(); - } + /** + * {@inheritDoc} + */ + @Override + public abstract ArrayList<E> makeObject(); //----------------------------------------------------------------------- public void testNewArrayList() { + ArrayList<E> list = makeObject(); assertTrue("New list is empty", list.isEmpty()); assertEquals("New list has size zero", list.size(), 0); @@ -64,9 +65,11 @@ public abstract class TestArrayList extends AbstractTestList { } } + @SuppressWarnings("unchecked") public void testSearch() { - list.add("First Item"); - list.add("Last Item"); + ArrayList<E> list = makeObject(); + list.add((E) "First Item"); + list.add((E) "Last Item"); assertEquals("First item is 'First Item'", list.get(0), "First Item"); assertEquals("Last Item is 'Last Item'", list.get(1), "Last Item"); } http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/test/org/apache/commons/collections/TestArrayStack.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/commons/collections/TestArrayStack.java b/src/test/org/apache/commons/collections/TestArrayStack.java index 54e8122..03a826a 100644 --- a/src/test/org/apache/commons/collections/TestArrayStack.java +++ b/src/test/org/apache/commons/collections/TestArrayStack.java @@ -17,7 +17,6 @@ package org.apache.commons.collections; import java.util.EmptyStackException; -import java.util.List; import junit.framework.Test; @@ -28,10 +27,8 @@ import junit.framework.Test; * * @author Craig McClanahan */ -public class TestArrayStack extends TestArrayList { +public class TestArrayStack<E> extends TestArrayList<E> { - protected ArrayStack stack = null; - public TestArrayStack(String testName) { super(testName); } @@ -45,18 +42,13 @@ public class TestArrayStack extends TestArrayList { junit.textui.TestRunner.main(testCaseName); } - public List makeEmptyList() { - return new ArrayStack(); - } - - public void setUp() { - stack = (ArrayStack) makeEmptyList(); - list = stack; + public ArrayStack<E> makeObject() { + return new ArrayStack<E>(); } //----------------------------------------------------------------------- public void testNewStack() { - + ArrayStack<E> stack = makeObject(); assertTrue("New stack is empty", stack.empty()); assertEquals("New stack has size zero", stack.size(), 0); @@ -76,16 +68,18 @@ public class TestArrayStack extends TestArrayList { } + @SuppressWarnings("unchecked") public void testPushPeekPop() { + ArrayStack<E> stack = makeObject(); - stack.push("First Item"); + stack.push((E) "First Item"); assertTrue("Stack is not empty", !stack.empty()); assertEquals("Stack size is one", stack.size(), 1); assertEquals("Top item is 'First Item'", (String) stack.peek(), "First Item"); assertEquals("Stack size is one", stack.size(), 1); - stack.push("Second Item"); + stack.push((E) "Second Item"); assertEquals("Stack size is two", stack.size(), 2); assertEquals("Top item is 'Second Item'", (String) stack.peek(), "Second Item"); @@ -103,10 +97,12 @@ public class TestArrayStack extends TestArrayList { } + @SuppressWarnings("unchecked") public void testSearch() { + ArrayStack<E> stack = makeObject(); - stack.push("First Item"); - stack.push("Second Item"); + stack.push((E) "First Item"); + stack.push((E) "Second Item"); assertEquals("Top item is 'Second Item'", stack.search("Second Item"), 1); assertEquals("Next Item is 'First Item'", http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/test/org/apache/commons/collections/TestBagUtils.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/commons/collections/TestBagUtils.java b/src/test/org/apache/commons/collections/TestBagUtils.java index 54600a4..ed0b351 100644 --- a/src/test/org/apache/commons/collections/TestBagUtils.java +++ b/src/test/org/apache/commons/collections/TestBagUtils.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,10 +28,11 @@ import org.apache.commons.collections.bag.TransformedSortedBag; import org.apache.commons.collections.bag.TreeBag; import org.apache.commons.collections.bag.UnmodifiableBag; import org.apache.commons.collections.bag.UnmodifiableSortedBag; +import org.apache.commons.collections.functors.TruePredicate; /** * Tests for BagUtils factory methods. - * + * * @version $Revision$ $Date$ * * @author Phil Steitz @@ -46,17 +47,17 @@ public class TestBagUtils extends BulkTest { public static Test suite() { return BulkTest.makeSuite(TestBagUtils.class); } - + //---------------------------------------------------------------------- - protected Class stringClass = this.getName().getClass(); - protected Predicate truePredicate = PredicateUtils.truePredicate(); - protected Transformer nopTransformer = TransformerUtils.nopTransformer(); - + protected Class<?> stringClass = this.getName().getClass(); + protected Predicate<Object> truePredicate = TruePredicate.truePredicate(); + protected Transformer<Object, Object> nopTransformer = TransformerUtils.nopTransformer(); + //---------------------------------------------------------------------- - + public void testSynchronizedBag() { - Bag bag = BagUtils.synchronizedBag(new HashBag()); + Bag<Object> bag = BagUtils.synchronizedBag(new HashBag<Object>()); assertTrue("Returned object should be a SynchronizedBag.", bag instanceof SynchronizedBag); try { @@ -64,11 +65,11 @@ public class TestBagUtils extends BulkTest { fail("Expecting IllegalArgumentException for null bag."); } catch (IllegalArgumentException ex) { // expected - } + } } - + public void testUnmodifiableBag() { - Bag bag = BagUtils.unmodifiableBag(new HashBag()); + Bag<Object> bag = BagUtils.unmodifiableBag(new HashBag<Object>()); assertTrue("Returned object should be an UnmodifiableBag.", bag instanceof UnmodifiableBag); try { @@ -76,11 +77,11 @@ public class TestBagUtils extends BulkTest { fail("Expecting IllegalArgumentException for null bag."); } catch (IllegalArgumentException ex) { // expected - } + } } - + public void testPredicatedBag() { - Bag bag = BagUtils.predicatedBag(new HashBag(), truePredicate); + Bag<Object> bag = BagUtils.predicatedBag(new HashBag<Object>(), truePredicate); assertTrue("Returned object should be a PredicatedBag.", bag instanceof PredicatedBag); try { @@ -88,35 +89,35 @@ public class TestBagUtils extends BulkTest { fail("Expecting IllegalArgumentException for null bag."); } catch (IllegalArgumentException ex) { // expected - } + } try { - bag = BagUtils.predicatedBag(new HashBag(), null); + bag = BagUtils.predicatedBag(new HashBag<Object>(), null); fail("Expecting IllegalArgumentException for null predicate."); } catch (IllegalArgumentException ex) { // expected - } + } } - + public void testTransformedBag() { - Bag bag = BagUtils.transformedBag(new HashBag(), nopTransformer); + Bag<Object> bag = BagUtils.transformedBag(new HashBag<Object>(), nopTransformer); assertTrue("Returned object should be an TransformedBag.", bag instanceof TransformedBag); try { - bag = BagUtils.transformedBag(null, nopTransformer); + bag = BagUtils.transformedBag(null, nopTransformer); fail("Expecting IllegalArgumentException for null bag."); } catch (IllegalArgumentException ex) { // expected - } + } try { - bag = BagUtils.transformedBag(new HashBag(), null); + bag = BagUtils.transformedBag(new HashBag<Object>(), null); fail("Expecting IllegalArgumentException for null transformer."); } catch (IllegalArgumentException ex) { // expected - } + } } - + public void testSynchronizedSortedBag() { - Bag bag = BagUtils.synchronizedSortedBag(new TreeBag()); + Bag<Object> bag = BagUtils.synchronizedSortedBag(new TreeBag<Object>()); assertTrue("Returned object should be a SynchronizedSortedBag.", bag instanceof SynchronizedSortedBag); try { @@ -124,11 +125,11 @@ public class TestBagUtils extends BulkTest { fail("Expecting IllegalArgumentException for null bag."); } catch (IllegalArgumentException ex) { // expected - } + } } - + public void testUnmodifiableSortedBag() { - Bag bag = BagUtils.unmodifiableSortedBag(new TreeBag()); + Bag<Object> bag = BagUtils.unmodifiableSortedBag(new TreeBag<Object>()); assertTrue("Returned object should be an UnmodifiableSortedBag.", bag instanceof UnmodifiableSortedBag); try { @@ -136,11 +137,11 @@ public class TestBagUtils extends BulkTest { fail("Expecting IllegalArgumentException for null bag."); } catch (IllegalArgumentException ex) { // expected - } + } } - + public void testPredicatedSortedBag() { - Bag bag = BagUtils.predicatedSortedBag(new TreeBag(), truePredicate); + Bag<Object> bag = BagUtils.predicatedSortedBag(new TreeBag<Object>(), truePredicate); assertTrue("Returned object should be a PredicatedSortedBag.", bag instanceof PredicatedSortedBag); try { @@ -148,31 +149,31 @@ public class TestBagUtils extends BulkTest { fail("Expecting IllegalArgumentException for null bag."); } catch (IllegalArgumentException ex) { // expected - } + } try { - bag = BagUtils.predicatedSortedBag(new TreeBag(), null); + bag = BagUtils.predicatedSortedBag(new TreeBag<Object>(), null); fail("Expecting IllegalArgumentException for null predicate."); } catch (IllegalArgumentException ex) { // expected - } + } } - + public void testTransformedSortedBag() { - Bag bag = BagUtils.transformedSortedBag(new TreeBag(), nopTransformer); + Bag<Object> bag = BagUtils.transformedSortedBag(new TreeBag<Object>(), nopTransformer); assertTrue("Returned object should be an TransformedSortedBag", bag instanceof TransformedSortedBag); try { - bag = BagUtils.transformedSortedBag(null, nopTransformer); + bag = BagUtils.transformedSortedBag(null, nopTransformer); fail("Expecting IllegalArgumentException for null bag."); } catch (IllegalArgumentException ex) { // expected - } + } try { - bag = BagUtils.transformedSortedBag(new TreeBag(), null); + bag = BagUtils.transformedSortedBag(new TreeBag<Object>(), null); fail("Expecting IllegalArgumentException for null transformer."); } catch (IllegalArgumentException ex) { // expected - } + } } } http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/test/org/apache/commons/collections/TestBufferUtils.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/commons/collections/TestBufferUtils.java b/src/test/org/apache/commons/collections/TestBufferUtils.java index 503e5f0..5d860b2 100644 --- a/src/test/org/apache/commons/collections/TestBufferUtils.java +++ b/src/test/org/apache/commons/collections/TestBufferUtils.java @@ -42,16 +42,16 @@ public class TestBufferUtils extends BulkTest { } public void testpredicatedBuffer() { - Predicate predicate = new Predicate() { + Predicate<Object> predicate = new Predicate<Object>() { public boolean evaluate(Object o) { return o instanceof String; } }; - Buffer buffer = BufferUtils.predicatedBuffer(new ArrayStack(), predicate); + Buffer<Object> buffer = BufferUtils.predicatedBuffer(new ArrayStack<Object>(), predicate); assertTrue("returned object should be a PredicatedBuffer", buffer instanceof PredicatedBuffer); try { - buffer = BufferUtils.predicatedBuffer(new ArrayStack(), null); + buffer = BufferUtils.predicatedBuffer(new ArrayStack<Object>(), null); fail("Expecting IllegalArgumentException for null predicate."); } catch (IllegalArgumentException ex) { // expected http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/test/org/apache/commons/collections/TestClosureUtils.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/commons/collections/TestClosureUtils.java b/src/test/org/apache/commons/collections/TestClosureUtils.java index 297e5db..dc2de5d 100644 --- a/src/test/org/apache/commons/collections/TestClosureUtils.java +++ b/src/test/org/apache/commons/collections/TestClosureUtils.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,11 +27,13 @@ import junit.framework.TestSuite; import junit.textui.TestRunner; import org.apache.commons.collections.functors.EqualPredicate; +import org.apache.commons.collections.functors.FalsePredicate; import org.apache.commons.collections.functors.NOPClosure; +import org.apache.commons.collections.functors.TruePredicate; /** * Tests the org.apache.commons.collections.ClosureUtils class. - * + * * @since Commons Collections 3.0 * @version $Revision$ $Date$ * @@ -51,7 +53,7 @@ public class TestClosureUtils extends junit.framework.TestCase { /** * Main. * @param args - */ + */ public static void main(String[] args) { TestRunner.run(suite()); } @@ -74,18 +76,23 @@ public class TestClosureUtils extends junit.framework.TestCase { */ public void tearDown() { } - - static class MockClosure implements Closure { + + static class MockClosure<T> implements Closure<T> { int count = 0; - - public void execute(Object object) { + + public void execute(T object) { count++; } + + public void reset() { + count = 0; + } } - static class MockTransformer implements Transformer { + + static class MockTransformer<T> implements Transformer<T, T> { int count = 0; - - public Object transform(Object object) { + + public T transform(T object) { count++; return object; } @@ -108,7 +115,7 @@ public class TestClosureUtils extends junit.framework.TestCase { } fail(); } - + // nopClosure //------------------------------------------------------------------ @@ -136,11 +143,11 @@ public class TestClosureUtils extends junit.framework.TestCase { //------------------------------------------------------------------ public void testForClosure() { - MockClosure cmd = new MockClosure(); + MockClosure<Object> cmd = new MockClosure<Object>(); ClosureUtils.forClosure(5, cmd).execute(null); assertEquals(5, cmd.count); - assertSame(NOPClosure.INSTANCE, ClosureUtils.forClosure(0, new MockClosure())); - assertSame(NOPClosure.INSTANCE, ClosureUtils.forClosure(-1, new MockClosure())); + assertSame(NOPClosure.INSTANCE, ClosureUtils.forClosure(0, new MockClosure<Object>())); + assertSame(NOPClosure.INSTANCE, ClosureUtils.forClosure(-1, new MockClosure<Object>())); assertSame(NOPClosure.INSTANCE, ClosureUtils.forClosure(1, null)); assertSame(NOPClosure.INSTANCE, ClosureUtils.forClosure(3, null)); assertSame(cmd, ClosureUtils.forClosure(1, cmd)); @@ -150,20 +157,20 @@ public class TestClosureUtils extends junit.framework.TestCase { //------------------------------------------------------------------ public void testWhileClosure() { - MockClosure cmd = new MockClosure(); - ClosureUtils.whileClosure(PredicateUtils.falsePredicate(), cmd).execute(null); + MockClosure<Object> cmd = new MockClosure<Object>(); + ClosureUtils.whileClosure(FalsePredicate.falsePredicate(), cmd).execute(null); assertEquals(0, cmd.count); - - cmd = new MockClosure(); + + cmd = new MockClosure<Object>(); ClosureUtils.whileClosure(PredicateUtils.uniquePredicate(), cmd).execute(null); assertEquals(1, cmd.count); - + try { ClosureUtils.whileClosure(null, ClosureUtils.nopClosure()); fail(); } catch (IllegalArgumentException ex) {} try { - ClosureUtils.whileClosure(PredicateUtils.falsePredicate(), null); + ClosureUtils.whileClosure(FalsePredicate.falsePredicate(), null); fail(); } catch (IllegalArgumentException ex) {} try { @@ -176,14 +183,14 @@ public class TestClosureUtils extends junit.framework.TestCase { //------------------------------------------------------------------ public void testDoWhileClosure() { - MockClosure cmd = new MockClosure(); - ClosureUtils.doWhileClosure(cmd, PredicateUtils.falsePredicate()).execute(null); + MockClosure<Object> cmd = new MockClosure<Object>(); + ClosureUtils.doWhileClosure(cmd, FalsePredicate.falsePredicate()).execute(null); assertEquals(1, cmd.count); - - cmd = new MockClosure(); + + cmd = new MockClosure<Object>(); ClosureUtils.doWhileClosure(cmd, PredicateUtils.uniquePredicate()).execute(null); assertEquals(2, cmd.count); - + try { ClosureUtils.doWhileClosure(null, null); fail(); @@ -193,135 +200,137 @@ public class TestClosureUtils extends junit.framework.TestCase { // chainedClosure //------------------------------------------------------------------ + @SuppressWarnings("unchecked") public void testChainedClosure() { - MockClosure a = new MockClosure(); - MockClosure b = new MockClosure(); + MockClosure<Object> a = new MockClosure<Object>(); + MockClosure<Object> b = new MockClosure<Object>(); ClosureUtils.chainedClosure(a, b).execute(null); assertEquals(1, a.count); assertEquals(1, b.count); - - a = new MockClosure(); - b = new MockClosure(); - ClosureUtils.chainedClosure(new Closure[] {a, b, a}).execute(null); + + a = new MockClosure<Object>(); + b = new MockClosure<Object>(); + ClosureUtils.<Object>chainedClosure(new Closure[] {a, b, a}).execute(null); assertEquals(2, a.count); assertEquals(1, b.count); - - a = new MockClosure(); - b = new MockClosure(); - Collection coll = new ArrayList(); + + a = new MockClosure<Object>(); + b = new MockClosure<Object>(); + Collection<Closure<Object>> coll = new ArrayList<Closure<Object>>(); coll.add(b); coll.add(a); coll.add(b); - ClosureUtils.chainedClosure(coll).execute(null); + ClosureUtils.<Object>chainedClosure(coll).execute(null); assertEquals(1, a.count); assertEquals(2, b.count); - - assertSame(NOPClosure.INSTANCE, ClosureUtils.chainedClosure(new Closure[0])); - assertSame(NOPClosure.INSTANCE, ClosureUtils.chainedClosure(Collections.EMPTY_LIST)); - + + assertSame(NOPClosure.INSTANCE, ClosureUtils.<Object>chainedClosure(new Closure[0])); + assertSame(NOPClosure.INSTANCE, ClosureUtils.<Object>chainedClosure(Collections.<Closure<Object>>emptyList())); + try { ClosureUtils.chainedClosure(null, null); fail(); } catch (IllegalArgumentException ex) {} try { - ClosureUtils.chainedClosure((Closure[]) null); + ClosureUtils.<Object>chainedClosure((Closure[]) null); fail(); } catch (IllegalArgumentException ex) {} try { - ClosureUtils.chainedClosure((Collection) null); + ClosureUtils.<Object>chainedClosure((Collection<Closure<Object>>) null); fail(); } catch (IllegalArgumentException ex) {} try { - ClosureUtils.chainedClosure(new Closure[] {null, null}); + ClosureUtils.<Object>chainedClosure(new Closure[] {null, null}); fail(); } catch (IllegalArgumentException ex) {} try { - coll = new ArrayList(); + coll = new ArrayList<Closure<Object>>(); coll.add(null); coll.add(null); ClosureUtils.chainedClosure(coll); fail(); } catch (IllegalArgumentException ex) {} } - + // ifClosure //------------------------------------------------------------------ public void testIfClosure() { - MockClosure a = new MockClosure(); - MockClosure b = null; - ClosureUtils.ifClosure(PredicateUtils.truePredicate(), a).execute(null); + MockClosure<Object> a = new MockClosure<Object>(); + MockClosure<Object> b = null; + ClosureUtils.ifClosure(TruePredicate.truePredicate(), a).execute(null); assertEquals(1, a.count); - a = new MockClosure(); - ClosureUtils.ifClosure(PredicateUtils.falsePredicate(), a).execute(null); + a = new MockClosure<Object>(); + ClosureUtils.ifClosure(FalsePredicate.<Object>falsePredicate(), a).execute(null); assertEquals(0, a.count); - a = new MockClosure(); - b = new MockClosure(); - ClosureUtils.ifClosure(PredicateUtils.truePredicate(), a, b).execute(null); + a = new MockClosure<Object>(); + b = new MockClosure<Object>(); + ClosureUtils.ifClosure(TruePredicate.<Object>truePredicate(), a, b).execute(null); assertEquals(1, a.count); assertEquals(0, b.count); - - a = new MockClosure(); - b = new MockClosure(); - ClosureUtils.ifClosure(PredicateUtils.falsePredicate(), a, b).execute(null); + + a = new MockClosure<Object>(); + b = new MockClosure<Object>(); + ClosureUtils.ifClosure(FalsePredicate.<Object>falsePredicate(), a, b).execute(null); assertEquals(0, a.count); assertEquals(1, b.count); - } + } // switchClosure //------------------------------------------------------------------ + @SuppressWarnings("unchecked") public void testSwitchClosure() { - MockClosure a = new MockClosure(); - MockClosure b = new MockClosure(); - ClosureUtils.switchClosure( - new Predicate[] {EqualPredicate.equalPredicate("HELLO"), EqualPredicate.equalPredicate("THERE")}, - new Closure[] {a, b}).execute("WELL"); + MockClosure<String> a = new MockClosure<String>(); + MockClosure<String> b = new MockClosure<String>(); + ClosureUtils.<String>switchClosure( + new Predicate[] { EqualPredicate.equalPredicate("HELLO"), EqualPredicate.equalPredicate("THERE") }, + new Closure[] { a, b }).execute("WELL"); assertEquals(0, a.count); assertEquals(0, b.count); - - a = new MockClosure(); - b = new MockClosure(); - ClosureUtils.switchClosure( - new Predicate[] {EqualPredicate.equalPredicate("HELLO"), EqualPredicate.equalPredicate("THERE")}, - new Closure[] {a, b}).execute("HELLO"); + + a.reset(); + b.reset(); + ClosureUtils.<String>switchClosure( + new Predicate[] { EqualPredicate.equalPredicate("HELLO"), EqualPredicate.equalPredicate("THERE") }, + new Closure[] { a, b }).execute("HELLO"); assertEquals(1, a.count); assertEquals(0, b.count); - - a = new MockClosure(); - b = new MockClosure(); - MockClosure c = new MockClosure(); - ClosureUtils.switchClosure( - new Predicate[] {EqualPredicate.equalPredicate("HELLO"), EqualPredicate.equalPredicate("THERE")}, - new Closure[] {a, b}, c).execute("WELL"); + + a.reset(); + b.reset(); + MockClosure<String> c = new MockClosure<String>(); + ClosureUtils.<String>switchClosure( + new Predicate[] { EqualPredicate.equalPredicate("HELLO"), EqualPredicate.equalPredicate("THERE") }, + new Closure[] { a, b }, c).execute("WELL"); assertEquals(0, a.count); assertEquals(0, b.count); assertEquals(1, c.count); - - a = new MockClosure(); - b = new MockClosure(); - Map map = new HashMap(); + + a.reset(); + b.reset(); + Map<Predicate<String>, Closure<String>> map = new HashMap<Predicate<String>, Closure<String>>(); map.put(EqualPredicate.equalPredicate("HELLO"), a); map.put(EqualPredicate.equalPredicate("THERE"), b); - ClosureUtils.switchClosure(map).execute(null); + ClosureUtils.<String>switchClosure(map).execute(null); assertEquals(0, a.count); assertEquals(0, b.count); - a = new MockClosure(); - b = new MockClosure(); - map = new HashMap(); + a.reset(); + b.reset(); + map.clear(); map.put(EqualPredicate.equalPredicate("HELLO"), a); map.put(EqualPredicate.equalPredicate("THERE"), b); ClosureUtils.switchClosure(map).execute("THERE"); assertEquals(0, a.count); assertEquals(1, b.count); - a = new MockClosure(); - b = new MockClosure(); - c = new MockClosure(); - map = new HashMap(); + a.reset(); + b.reset(); + c.reset(); + map.clear(); map.put(EqualPredicate.equalPredicate("HELLO"), a); map.put(EqualPredicate.equalPredicate("THERE"), b); map.put(null, c); @@ -329,63 +338,63 @@ public class TestClosureUtils extends junit.framework.TestCase { assertEquals(0, a.count); assertEquals(0, b.count); assertEquals(1, c.count); - - assertSame(NOPClosure.INSTANCE, ClosureUtils.switchClosure(new Predicate[0], new Closure[0])); - assertSame(NOPClosure.INSTANCE, ClosureUtils.switchClosure(new HashMap())); - map = new HashMap(); + + assertEquals(NOPClosure.INSTANCE, ClosureUtils.<String>switchClosure(new Predicate[0], new Closure[0])); + assertEquals(NOPClosure.INSTANCE, ClosureUtils.<String>switchClosure(new HashMap<Predicate<String>, Closure<String>>())); + map.clear(); map.put(null, null); - assertSame(NOPClosure.INSTANCE, ClosureUtils.switchClosure(map)); + assertEquals(NOPClosure.INSTANCE, ClosureUtils.switchClosure(map)); try { ClosureUtils.switchClosure(null, null); fail(); } catch (IllegalArgumentException ex) {} try { - ClosureUtils.switchClosure((Predicate[]) null, (Closure[]) null); + ClosureUtils.<String>switchClosure((Predicate<String>[]) null, (Closure<String>[]) null); fail(); } catch (IllegalArgumentException ex) {} try { - ClosureUtils.switchClosure((Map) null); + ClosureUtils.<String>switchClosure((Map<Predicate<String>, Closure<String>>) null); fail(); } catch (IllegalArgumentException ex) {} try { - ClosureUtils.switchClosure(new Predicate[2], new Closure[2]); + ClosureUtils.<String>switchClosure(new Predicate[2], new Closure[2]); fail(); } catch (IllegalArgumentException ex) {} try { - ClosureUtils.switchClosure( - new Predicate[] {PredicateUtils.truePredicate()}, - new Closure[] {a,b}); + ClosureUtils.<String>switchClosure( + new Predicate[] { TruePredicate.<String>truePredicate() }, + new Closure[] { a, b }); fail(); } catch (IllegalArgumentException ex) {} } - + // switchMapClosure //------------------------------------------------------------------ public void testSwitchMapClosure() { - MockClosure a = new MockClosure(); - MockClosure b = new MockClosure(); - Map map = new HashMap(); + MockClosure<String> a = new MockClosure<String>(); + MockClosure<String> b = new MockClosure<String>(); + Map<String, Closure<String>> map = new HashMap<String, Closure<String>>(); map.put("HELLO", a); map.put("THERE", b); ClosureUtils.switchMapClosure(map).execute(null); assertEquals(0, a.count); assertEquals(0, b.count); - a = new MockClosure(); - b = new MockClosure(); - map = new HashMap(); + a.reset(); + b.reset(); + map.clear(); map.put("HELLO", a); map.put("THERE", b); ClosureUtils.switchMapClosure(map).execute("THERE"); assertEquals(0, a.count); assertEquals(1, b.count); - a = new MockClosure(); - b = new MockClosure(); - MockClosure c = new MockClosure(); - map = new HashMap(); + a.reset(); + b.reset(); + map.clear(); + MockClosure<String> c = new MockClosure<String>(); map.put("HELLO", a); map.put("THERE", b); map.put(null, c); @@ -394,26 +403,26 @@ public class TestClosureUtils extends junit.framework.TestCase { assertEquals(0, b.count); assertEquals(1, c.count); - assertSame(NOPClosure.INSTANCE, ClosureUtils.switchMapClosure(new HashMap())); - + assertEquals(NOPClosure.INSTANCE, ClosureUtils.switchMapClosure(new HashMap<String, Closure<String>>())); + try { ClosureUtils.switchMapClosure(null); fail(); } catch (IllegalArgumentException ex) {} } - + // asClosure //------------------------------------------------------------------ public void testTransformerClosure() { - MockTransformer mock = new MockTransformer(); - Closure closure = ClosureUtils.asClosure(mock); + MockTransformer<Object> mock = new MockTransformer<Object>(); + Closure<Object> closure = ClosureUtils.asClosure(mock); closure.execute(null); assertEquals(1, mock.count); closure.execute(null); assertEquals(2, mock.count); - - assertSame(ClosureUtils.nopClosure(), ClosureUtils.asClosure(null)); + + assertEquals(ClosureUtils.nopClosure(), ClosureUtils.asClosure(null)); } - + } http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/test/org/apache/commons/collections/TestCollectionUtils.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/commons/collections/TestCollectionUtils.java b/src/test/org/apache/commons/collections/TestCollectionUtils.java index 9d792df..02732fc 100644 --- a/src/test/org/apache/commons/collections/TestCollectionUtils.java +++ b/src/test/org/apache/commons/collections/TestCollectionUtils.java @@ -31,7 +31,6 @@ import org.apache.commons.collections.collection.PredicatedCollection; import org.apache.commons.collections.collection.SynchronizedCollection; import org.apache.commons.collections.collection.TransformedCollection; import org.apache.commons.collections.collection.UnmodifiableCollection; -import org.apache.commons.collections.functors.EqualPredicate; import org.junit.Before; import org.junit.Test; @@ -139,7 +138,7 @@ public class TestCollectionUtils extends MockTestCase { @Test public void getCardinalityMap() { - Map<Number, Integer> freqA = CollectionUtils.<Number, Integer>getCardinalityMap(iterableA); + Map<Number, Integer> freqA = CollectionUtils.<Number>getCardinalityMap(iterableA); assertEquals(1, (int) freqA.get(1)); assertEquals(2, (int) freqA.get(2)); assertEquals(3, (int) freqA.get(3)); @@ -185,7 +184,7 @@ public class TestCollectionUtils extends MockTestCase { assertEquals(0, CollectionUtils.cardinality("D", set)); assertEquals(1, CollectionUtils.cardinality("E", set)); - Bag<String> bag = new HashBag(); + Bag<String> bag = new HashBag<String>(); bag.add("A", 3); bag.add("C"); bag.add("E"); @@ -202,43 +201,43 @@ public class TestCollectionUtils extends MockTestCase { List<String> list = new ArrayList<String>(); assertEquals(0, CollectionUtils.cardinality(null, list)); { - Map freq = CollectionUtils.getCardinalityMap(list); + Map<String, Integer> freq = CollectionUtils.getCardinalityMap(list); assertNull(freq.get(null)); } list.add("A"); assertEquals(0, CollectionUtils.cardinality(null, list)); { - Map freq = CollectionUtils.getCardinalityMap(list); + Map<String, Integer> freq = CollectionUtils.getCardinalityMap(list); assertNull(freq.get(null)); } list.add(null); assertEquals(1, CollectionUtils.cardinality(null, list)); { - Map freq = CollectionUtils.getCardinalityMap(list); + Map<String, Integer> freq = CollectionUtils.getCardinalityMap(list); assertEquals(1, freq.get(null)); } list.add("B"); assertEquals(1, CollectionUtils.cardinality(null, list)); { - Map freq = CollectionUtils.getCardinalityMap(list); + Map<String, Integer> freq = CollectionUtils.getCardinalityMap(list); assertEquals(1, freq.get(null)); } list.add(null); assertEquals(2, CollectionUtils.cardinality(null, list)); { - Map freq = CollectionUtils.getCardinalityMap(list); + Map<String, Integer> freq = CollectionUtils.getCardinalityMap(list); assertEquals(2, freq.get(null)); } list.add("B"); assertEquals(2, CollectionUtils.cardinality(null, list)); { - Map freq = CollectionUtils.getCardinalityMap(list); + Map<String, Integer> freq = CollectionUtils.getCardinalityMap(list); assertEquals(2, freq.get(null)); } list.add(null); assertEquals(3, CollectionUtils.cardinality(null, list)); { - Map freq = CollectionUtils.getCardinalityMap(list); + Map<String, Integer> freq = CollectionUtils.getCardinalityMap(list); assertEquals(3, freq.get(null)); } } @@ -275,7 +274,7 @@ public class TestCollectionUtils extends MockTestCase { @Test public void union() { Collection<Integer> col = CollectionUtils.union(iterableA, iterableC); - Map freq = CollectionUtils.getCardinalityMap(col); + Map<Integer, Integer> freq = CollectionUtils.getCardinalityMap(col); assertEquals(1, freq.get(1)); assertEquals(4, freq.get(2)); assertEquals(3, freq.get(3)); @@ -283,7 +282,7 @@ public class TestCollectionUtils extends MockTestCase { assertEquals(1, freq.get(5)); Collection<Number> col2 = CollectionUtils.union(collectionC2, iterableA); - Map freq2 = CollectionUtils.getCardinalityMap(col2); + Map<Number, Integer> freq2 = CollectionUtils.getCardinalityMap(col2); assertEquals(1, freq2.get(1)); assertEquals(4, freq2.get(2)); assertEquals(3, freq2.get(3)); @@ -294,7 +293,7 @@ public class TestCollectionUtils extends MockTestCase { @Test public void intersection() { Collection<Integer> col = CollectionUtils.intersection(iterableA, iterableC); - Map freq = CollectionUtils.getCardinalityMap(col); + Map<Integer, Integer> freq = CollectionUtils.getCardinalityMap(col); assertNull(freq.get(1)); assertEquals(2, freq.get(2)); assertEquals(3, freq.get(3)); @@ -302,7 +301,7 @@ public class TestCollectionUtils extends MockTestCase { assertNull(freq.get(5)); Collection<Number> col2 = CollectionUtils.intersection(collectionC2, collectionA); - Map freq2 = CollectionUtils.getCardinalityMap(col2); + Map<Number, Integer> freq2 = CollectionUtils.getCardinalityMap(col2); assertNull(freq2.get(1)); assertEquals(2, freq2.get(2)); assertEquals(3, freq2.get(3)); @@ -313,7 +312,7 @@ public class TestCollectionUtils extends MockTestCase { @Test public void disjunction() { Collection<Integer> col = CollectionUtils.disjunction(iterableA, iterableC); - Map freq = CollectionUtils.getCardinalityMap(col); + Map<Integer, Integer> freq = CollectionUtils.getCardinalityMap(col); assertEquals(1, freq.get(1)); assertEquals(2, freq.get(2)); assertNull(freq.get(3)); @@ -321,7 +320,7 @@ public class TestCollectionUtils extends MockTestCase { assertEquals(1, freq.get(5)); Collection<Number> col2 = CollectionUtils.disjunction(collectionC2, collectionA); - Map freq2 = CollectionUtils.getCardinalityMap(col2); + Map<Number, Integer> freq2 = CollectionUtils.getCardinalityMap(col2); assertEquals(1, freq2.get(1)); assertEquals(2, freq2.get(2)); assertNull(freq2.get(3)); @@ -348,7 +347,7 @@ public class TestCollectionUtils extends MockTestCase { @Test public void testSubtract() { Collection<Integer> col = CollectionUtils.subtract(iterableA, iterableC); - Map freq = CollectionUtils.getCardinalityMap(col); + Map<Integer, Integer> freq = CollectionUtils.getCardinalityMap(col); assertEquals(1, freq.get(1)); assertNull(freq.get(2)); assertNull(freq.get(3)); @@ -356,7 +355,7 @@ public class TestCollectionUtils extends MockTestCase { assertNull(freq.get(5)); Collection<Number> col2 = CollectionUtils.subtract(collectionC2, collectionA); - Map freq2 = CollectionUtils.getCardinalityMap(col2); + Map<Number, Integer> freq2 = CollectionUtils.getCardinalityMap(col2); assertEquals(1, freq2.get(5)); assertNull(freq2.get(4)); assertNull(freq2.get(3)); @@ -500,8 +499,8 @@ public class TestCollectionUtils extends MockTestCase { @Test public void forAllDo() { - Closure<Collection> testClosure = ClosureUtils.invokerClosure("clear"); - Collection<List> col = new ArrayList<List>(); + Closure<List<? extends Number>> testClosure = ClosureUtils.invokerClosure("clear"); + Collection<List<? extends Number>> col = new ArrayList<List<? extends Number>>(); col.add(collectionA); col.add(collectionB); CollectionUtils.forAllDo(col, testClosure); @@ -601,10 +600,10 @@ public class TestCollectionUtils extends MockTestCase { @Test public void getFromEnumeration() throws Exception { // Enumeration, entry exists - Vector vector = new Vector(); + Vector<String> vector = new Vector<String>(); vector.addElement("zero"); vector.addElement("one"); - Enumeration en = vector.elements(); + Enumeration<String> en = vector.elements(); assertEquals("zero", CollectionUtils.get(en, 0)); en = vector.elements(); assertEquals("one", CollectionUtils.get(en, 1)); @@ -622,7 +621,7 @@ public class TestCollectionUtils extends MockTestCase { @Test(expected = IndexOutOfBoundsException.class) public void getFromIterable() throws Exception { // Collection, entry exists - Bag bag = new HashBag(); + Bag<String> bag = new HashBag<String>(); bag.add("element", 1); assertEquals("element", CollectionUtils.get(bag, 0)); @@ -714,7 +713,7 @@ public class TestCollectionUtils extends MockTestCase { @Test public void testSize_Enumeration() { - Vector list = new Vector(); + Vector<String> list = new Vector<String>(); assertEquals(0, CollectionUtils.size(list.elements())); list.add("a"); assertEquals(1, CollectionUtils.size(list.elements())); @@ -724,7 +723,7 @@ public class TestCollectionUtils extends MockTestCase { @Test public void testSize_Iterator() { - List list = new ArrayList(); + List<String> list = new ArrayList<String>(); assertEquals(0, CollectionUtils.size(list.iterator())); list.add("a"); assertEquals(1, CollectionUtils.size(list.iterator())); @@ -795,7 +794,7 @@ public class TestCollectionUtils extends MockTestCase { assertEquals(true, CollectionUtils.sizeIsEmpty(list.elements())); list.add("a"); assertEquals(false, CollectionUtils.sizeIsEmpty(list.elements())); - Enumeration en = list.elements(); + Enumeration<String> en = list.elements(); en.nextElement(); assertEquals(true, CollectionUtils.sizeIsEmpty(en)); } @@ -806,7 +805,7 @@ public class TestCollectionUtils extends MockTestCase { assertEquals(true, CollectionUtils.sizeIsEmpty(list.iterator())); list.add("a"); assertEquals(false, CollectionUtils.sizeIsEmpty(list.iterator())); - Iterator it = list.iterator(); + Iterator<String> it = list.iterator(); it.next(); assertEquals(true, CollectionUtils.sizeIsEmpty(it)); } @@ -828,7 +827,7 @@ public class TestCollectionUtils extends MockTestCase { // ----------------------------------------------------------------------- @Test public void testIsEmptyWithEmptyCollection() { - Collection coll = new ArrayList(); + Collection<Object> coll = new ArrayList<Object>(); assertEquals(true, CollectionUtils.isEmpty(coll)); } @@ -841,13 +840,13 @@ public class TestCollectionUtils extends MockTestCase { @Test public void testIsEmptyWithNull() { - Collection coll = null; + Collection<?> coll = null; assertEquals(true, CollectionUtils.isEmpty(coll)); } @Test public void testIsNotEmptyWithEmptyCollection() { - Collection coll = new ArrayList(); + Collection<Object> coll = new ArrayList<Object>(); assertEquals(false, CollectionUtils.isNotEmpty(coll)); } @@ -860,7 +859,7 @@ public class TestCollectionUtils extends MockTestCase { @Test public void testIsNotEmptyWithNull() { - Collection coll = null; + Collection<?> coll = null; assertEquals(false, CollectionUtils.isNotEmpty(coll)); } @@ -930,7 +929,7 @@ public class TestCollectionUtils extends MockTestCase { list.add(4); // Ensure that the collection is the input type or a super type Collection<Integer> output1 = CollectionUtils.select(list, EQUALS_TWO); - Collection<Number> output2 = CollectionUtils.<Number, Integer>select(list, EQUALS_TWO); + Collection<Number> output2 = CollectionUtils.<Number>select(list, EQUALS_TWO); HashSet<Number> output3 = CollectionUtils.select(list, EQUALS_TWO, new HashSet<Number>()); assertTrue(CollectionUtils.isEqualCollection(output1, output3)); assertEquals(4, list.size()); @@ -946,7 +945,7 @@ public class TestCollectionUtils extends MockTestCase { list.add(3L); list.add(4L); Collection<Long> output1 = CollectionUtils.selectRejected(list, EQUALS_TWO); - Collection<Number> output2 = CollectionUtils.<Number, Long>selectRejected(list, EQUALS_TWO); + Collection<? extends Number> output2 = CollectionUtils.selectRejected(list, EQUALS_TWO); HashSet<Number> output3 = CollectionUtils.selectRejected(list, EQUALS_TWO, new HashSet<Number>()); assertTrue(CollectionUtils.isEqualCollection(output1, output2)); assertTrue(CollectionUtils.isEqualCollection(output1, output3)); @@ -1091,7 +1090,7 @@ public class TestCollectionUtils extends MockTestCase { } assertFalse(CollectionUtils.isFull(set)); - BoundedFifoBuffer buf = new BoundedFifoBuffer(set); + BoundedFifoBuffer<String> buf = new BoundedFifoBuffer<String>(set); assertEquals(true, CollectionUtils.isFull(buf)); buf.remove("2"); assertFalse(CollectionUtils.isFull(buf)); @@ -1125,7 +1124,7 @@ public class TestCollectionUtils extends MockTestCase { } assertEquals(-1, CollectionUtils.maxSize(set)); - Buffer<String> buf = new BoundedFifoBuffer(set); + Buffer<String> buf = new BoundedFifoBuffer<String>(set); assertEquals(3, CollectionUtils.maxSize(buf)); buf.remove("2"); assertEquals(3, CollectionUtils.maxSize(buf)); @@ -1217,16 +1216,16 @@ public class TestCollectionUtils extends MockTestCase { @Test public void testRemoveAll() { - List base = new ArrayList(); + List<String> base = new ArrayList<String>(); base.add("A"); base.add("B"); base.add("C"); - List sub = new ArrayList(); + List<String> sub = new ArrayList<String>(); sub.add("A"); sub.add("C"); sub.add("X"); - Collection result = CollectionUtils.removeAll(base, sub); + Collection<String> result = CollectionUtils.removeAll(base, sub); assertEquals(1, result.size()); assertFalse(result.contains("A")); assertEquals(true, result.contains("B")); @@ -1250,11 +1249,11 @@ public class TestCollectionUtils extends MockTestCase { // ----------------------------------------------------------------------- @Test public void testTransformedCollection() { - Transformer transformer = TransformerUtils.nopTransformer(); - Collection collection = CollectionUtils.transformedCollection(new ArrayList(), transformer); + Transformer<Object, Object> transformer = TransformerUtils.nopTransformer(); + Collection<Object> collection = CollectionUtils.transformedCollection(new ArrayList<Object>(), transformer); assertTrue("returned object should be a TransformedCollection", collection instanceof TransformedCollection); try { - collection = CollectionUtils.transformedCollection(new ArrayList(), null); + collection = CollectionUtils.transformedCollection(new ArrayList<Object>(), null); fail("Expecting IllegalArgumentException for null transformer."); } catch (IllegalArgumentException ex) { // expected @@ -1269,11 +1268,11 @@ public class TestCollectionUtils extends MockTestCase { @Test public void testTransformedCollection_2() { - List list = new ArrayList(); + List<Object> list = new ArrayList<Object>(); list.add("1"); list.add("2"); list.add("3"); - Collection result = CollectionUtils.transformedCollection(list, TRANSFORM_TO_INTEGER); + Collection<Object> result = CollectionUtils.transformedCollection(list, TRANSFORM_TO_INTEGER); assertEquals(true, result.contains("1")); // untransformed assertEquals(true, result.contains("2")); // untransformed assertEquals(true, result.contains("3")); // untransformed @@ -1281,7 +1280,7 @@ public class TestCollectionUtils extends MockTestCase { @Test public void testSynchronizedCollection() { - Collection col = CollectionUtils.synchronizedCollection(new ArrayList()); + Collection<Object> col = CollectionUtils.synchronizedCollection(new ArrayList<Object>()); assertTrue("Returned object should be a SynchronizedCollection.", col instanceof SynchronizedCollection); try { col = CollectionUtils.synchronizedCollection(null); @@ -1293,7 +1292,7 @@ public class TestCollectionUtils extends MockTestCase { @Test public void testUnmodifiableCollection() { - Collection col = CollectionUtils.unmodifiableCollection(new ArrayList()); + Collection<Object> col = CollectionUtils.unmodifiableCollection(new ArrayList<Object>()); assertTrue("Returned object should be a UnmodifiableCollection.", col instanceof UnmodifiableCollection); try { col = CollectionUtils.unmodifiableCollection(null); @@ -1353,7 +1352,7 @@ public class TestCollectionUtils extends MockTestCase { @Test public void addAllForEnumeration() { - Hashtable<Integer, Integer> h = new Hashtable(); + Hashtable<Integer, Integer> h = new Hashtable<Integer, Integer>(); h.put(5, 5); Enumeration<? extends Integer> enumeration = h.keys(); CollectionUtils.addAll(collectionA, enumeration); http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/test/org/apache/commons/collections/TestEnumerationUtils.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/commons/collections/TestEnumerationUtils.java b/src/test/org/apache/commons/collections/TestEnumerationUtils.java index 90c202a..649ce0a 100644 --- a/src/test/org/apache/commons/collections/TestEnumerationUtils.java +++ b/src/test/org/apache/commons/collections/TestEnumerationUtils.java @@ -39,46 +39,46 @@ public class TestEnumerationUtils extends BulkTest { public static final String TO_LIST_FIXTURE = "this is a test"; public void testToListWithStringTokenizer() { - List expectedList1 = new ArrayList(); + List<String> expectedList1 = new ArrayList<String>(); StringTokenizer st = new StringTokenizer(TO_LIST_FIXTURE); while (st.hasMoreTokens()) { expectedList1.add(st.nextToken()); - } - List expectedList2 = new ArrayList(); + } + List<String> expectedList2 = new ArrayList<String>(); expectedList2.add("this"); expectedList2.add("is"); expectedList2.add("a"); expectedList2.add("test"); - List actualList = EnumerationUtils.toList(new StringTokenizer(TO_LIST_FIXTURE)); + List<String> actualList = EnumerationUtils.toList(new StringTokenizer(TO_LIST_FIXTURE)); Assert.assertEquals(expectedList1, expectedList2); Assert.assertEquals(expectedList1, actualList); Assert.assertEquals(expectedList2, actualList); } public void testToListWithHashtable() { - Hashtable expected = new Hashtable(); + Hashtable<String, Integer> expected = new Hashtable<String, Integer>(); expected.put("one", new Integer(1)); expected.put("two", new Integer(2)); expected.put("three", new Integer(3)); // validate elements. - List actualEltList = EnumerationUtils.toList(expected.elements()); + 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))); - List expectedEltList = new ArrayList(); + 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)); // validate keys. - List actualKeyList = EnumerationUtils.toList(expected.keys()); + 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")); - List expectedKeyList = new ArrayList(); + List<String> expectedKeyList = new ArrayList<String>(); expectedKeyList.add("one"); expectedKeyList.add("two"); expectedKeyList.add("three");
