You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ba...@apache.org on 2009/09/15 07:30:02 UTC

svn commit: r814997 [15/18] - in /commons/proper/collections/trunk/src: java/org/apache/commons/collections/ java/org/apache/commons/collections/bag/ java/org/apache/commons/collections/bidimap/ java/org/apache/commons/collections/buffer/ java/org/apac...

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestObjectGraphIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestObjectGraphIterator.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestObjectGraphIterator.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestObjectGraphIterator.java Tue Sep 15 05:29:56 2009
@@ -35,14 +35,14 @@
  *
  * @author Stephen Colebourne
  */
-public class TestObjectGraphIterator extends AbstractTestIterator {
+public class TestObjectGraphIterator extends AbstractTestIterator<Object> {
 
     protected String[] testArray = { "One", "Two", "Three", "Four", "Five", "Six" };
 
-    protected List list1 = null;
-    protected List list2 = null;
-    protected List list3 = null;
-    protected List iteratorList = null;
+    protected List<String> list1 = null;
+    protected List<String> list2 = null;
+    protected List<String> list3 = null;
+    protected List<Iterator<String>> iteratorList = null;
 
     public TestObjectGraphIterator(String testName) {
         super(testName);
@@ -57,34 +57,34 @@
     }
 
     public void setUp() {
-        list1 = new ArrayList();
+        list1 = new ArrayList<String>();
         list1.add("One");
         list1.add("Two");
         list1.add("Three");
-        list2 = new ArrayList();
+        list2 = new ArrayList<String>();
         list2.add("Four");
-        list3 = new ArrayList();
+        list3 = new ArrayList<String>();
         list3.add("Five");
         list3.add("Six");
-        iteratorList = new ArrayList();
+        iteratorList = new ArrayList<Iterator<String>>();
         iteratorList.add(list1.iterator());
         iteratorList.add(list2.iterator());
         iteratorList.add(list3.iterator());
     }
 
     //-----------------------------------------------------------------------
-    public Iterator makeEmptyIterator() {
-        ArrayList list = new ArrayList();
-        return new ObjectGraphIterator(list.iterator(), null);
+    public ObjectGraphIterator<Object> makeEmptyIterator() {
+        ArrayList<Object> list = new ArrayList<Object>();
+        return new ObjectGraphIterator<Object>(list.iterator());
     }
 
-    public Iterator makeFullIterator() {
-        return new ObjectGraphIterator(iteratorList.iterator(), null);
+    public ObjectGraphIterator<Object> makeObject() {
+        return new ObjectGraphIterator<Object>(iteratorList.iterator());
     }
 
     //-----------------------------------------------------------------------
     public void testIteratorConstructor_null1() {
-        Iterator it = new ObjectGraphIterator(null);
+        Iterator<Object> it = new ObjectGraphIterator<Object>(null);
 
         assertEquals(false, it.hasNext());
         try {
@@ -100,7 +100,7 @@
     }
 
     public void testIteratorConstructor_null_next() {
-        Iterator it = new ObjectGraphIterator(null);
+        Iterator<Object> it = new ObjectGraphIterator<Object>(null);
         try {
             it.next();
             fail();
@@ -109,7 +109,7 @@
     }
 
     public void testIteratorConstructor_null_remove() {
-        Iterator it = new ObjectGraphIterator(null);
+        Iterator<Object> it = new ObjectGraphIterator<Object>(null);
         try {
             it.remove();
             fail();
@@ -119,8 +119,8 @@
 
     //-----------------------------------------------------------------------
     public void testIteratorConstructorIteration_Empty() {
-        List iteratorList = new ArrayList();
-        Iterator it = new ObjectGraphIterator(iteratorList.iterator());
+        List<Iterator<Object>> iteratorList = new ArrayList<Iterator<Object>>();
+        Iterator<Object> it = new ObjectGraphIterator<Object>(iteratorList.iterator());
 
         assertEquals(false, it.hasNext());
         try {
@@ -136,11 +136,11 @@
     }
 
     public void testIteratorConstructorIteration_Simple() {
-        List iteratorList = new ArrayList();
+        List<Iterator<String>> iteratorList = new ArrayList<Iterator<String>>();
         iteratorList.add(list1.iterator());
         iteratorList.add(list2.iterator());
         iteratorList.add(list3.iterator());
-        Iterator it = new ObjectGraphIterator(iteratorList.iterator());
+        Iterator<Object> it = new ObjectGraphIterator<Object>(iteratorList.iterator());
 
         for (int i = 0; i < 6; i++) {
             assertEquals(true, it.hasNext());
@@ -155,11 +155,11 @@
     }
 
     public void testIteratorConstructorIteration_SimpleNoHasNext() {
-        List iteratorList = new ArrayList();
+        List<Iterator<String>> iteratorList = new ArrayList<Iterator<String>>();
         iteratorList.add(list1.iterator());
         iteratorList.add(list2.iterator());
         iteratorList.add(list3.iterator());
-        Iterator it = new ObjectGraphIterator(iteratorList.iterator());
+        Iterator<Object> it = new ObjectGraphIterator<Object>(iteratorList.iterator());
 
         for (int i = 0; i < 6; i++) {
             assertEquals(testArray[i], it.next());
@@ -172,15 +172,15 @@
     }
 
     public void testIteratorConstructorIteration_WithEmptyIterators() {
-        List iteratorList = new ArrayList();
-        iteratorList.add(IteratorUtils.EMPTY_ITERATOR);
+        List<Iterator<String>> iteratorList = new ArrayList<Iterator<String>>();
+        iteratorList.add(IteratorUtils.<String>emptyIterator());
         iteratorList.add(list1.iterator());
-        iteratorList.add(IteratorUtils.EMPTY_ITERATOR);
+        iteratorList.add(IteratorUtils.<String>emptyIterator());
         iteratorList.add(list2.iterator());
-        iteratorList.add(IteratorUtils.EMPTY_ITERATOR);
+        iteratorList.add(IteratorUtils.<String>emptyIterator());
         iteratorList.add(list3.iterator());
-        iteratorList.add(IteratorUtils.EMPTY_ITERATOR);
-        Iterator it = new ObjectGraphIterator(iteratorList.iterator());
+        iteratorList.add(IteratorUtils.<String>emptyIterator());
+        Iterator<Object> it = new ObjectGraphIterator<Object>(iteratorList.iterator());
 
         for (int i = 0; i < 6; i++) {
             assertEquals(true, it.hasNext());
@@ -195,11 +195,11 @@
     }
 
     public void testIteratorConstructorRemove() {
-        List iteratorList = new ArrayList();
+        List<Iterator<String>> iteratorList = new ArrayList<Iterator<String>>();
         iteratorList.add(list1.iterator());
         iteratorList.add(list2.iterator());
         iteratorList.add(list3.iterator());
-        Iterator it = new ObjectGraphIterator(iteratorList.iterator());
+        Iterator<Object> it = new ObjectGraphIterator<Object>(iteratorList.iterator());
 
         for (int i = 0; i < 6; i++) {
             assertEquals(testArray[i], it.next());
@@ -213,11 +213,11 @@
 
     //-----------------------------------------------------------------------
     public void testIteration_IteratorOfIterators() {
-        List iteratorList = new ArrayList();
+        List<Iterator<String>> iteratorList = new ArrayList<Iterator<String>>();
         iteratorList.add(list1.iterator());
         iteratorList.add(list2.iterator());
         iteratorList.add(list3.iterator());
-        Iterator it = new ObjectGraphIterator(iteratorList.iterator(), null);
+        Iterator<Object> it = new ObjectGraphIterator<Object>(iteratorList.iterator(), null);
 
         for (int i = 0; i < 6; i++) {
             assertEquals(true, it.hasNext());
@@ -227,15 +227,15 @@
     }
 
     public void testIteration_IteratorOfIteratorsWithEmptyIterators() {
-        List iteratorList = new ArrayList();
-        iteratorList.add(IteratorUtils.EMPTY_ITERATOR);
+        List<Iterator<String>> iteratorList = new ArrayList<Iterator<String>>();
+        iteratorList.add(IteratorUtils.<String>emptyIterator());
         iteratorList.add(list1.iterator());
-        iteratorList.add(IteratorUtils.EMPTY_ITERATOR);
+        iteratorList.add(IteratorUtils.<String>emptyIterator());
         iteratorList.add(list2.iterator());
-        iteratorList.add(IteratorUtils.EMPTY_ITERATOR);
+        iteratorList.add(IteratorUtils.<String>emptyIterator());
         iteratorList.add(list3.iterator());
-        iteratorList.add(IteratorUtils.EMPTY_ITERATOR);
-        Iterator it = new ObjectGraphIterator(iteratorList.iterator(), null);
+        iteratorList.add(IteratorUtils.<String>emptyIterator());
+        Iterator<Object> it = new ObjectGraphIterator<Object>(iteratorList.iterator(), null);
 
         for (int i = 0; i < 6; i++) {
             assertEquals(true, it.hasNext());
@@ -246,7 +246,7 @@
 
     //-----------------------------------------------------------------------
     public void testIteration_RootNull() {
-        Iterator it = new ObjectGraphIterator(null, null);
+        Iterator<Object> it = new ObjectGraphIterator<Object>(null, null);
 
         assertEquals(false, it.hasNext());
         try {
@@ -263,7 +263,7 @@
 
     public void testIteration_RootNoTransformer() {
         Forest forest = new Forest();
-        Iterator it = new ObjectGraphIterator(forest, null);
+        Iterator<Object> it = new ObjectGraphIterator<Object>(forest, null);
 
         assertEquals(true, it.hasNext());
         assertSame(forest, it.next());
@@ -278,7 +278,7 @@
     public void testIteration_Transformed1() {
         Forest forest = new Forest();
         Leaf l1 = forest.addTree().addBranch().addLeaf();
-        Iterator it = new ObjectGraphIterator(forest, new LeafFinder());
+        Iterator<Object> it = new ObjectGraphIterator<Object>(forest, new LeafFinder());
 
         assertEquals(true, it.hasNext());
         assertSame(l1, it.next());
@@ -298,7 +298,7 @@
         Branch b1 = forest.getTree(0).addBranch();
         Branch b2 = forest.getTree(0).addBranch();
         Branch b3 = forest.getTree(2).addBranch();
-        Branch b4 = forest.getTree(2).addBranch();
+        /* Branch b4 = */ forest.getTree(2).addBranch();
         Branch b5 = forest.getTree(2).addBranch();
         Leaf l1 = b1.addLeaf();
         Leaf l2 = b1.addLeaf();
@@ -306,7 +306,7 @@
         Leaf l4 = b3.addLeaf();
         Leaf l5 = b5.addLeaf();
 
-        Iterator it = new ObjectGraphIterator(forest, new LeafFinder());
+        Iterator<Object> it = new ObjectGraphIterator<Object>(forest, new LeafFinder());
 
         assertEquals(true, it.hasNext());
         assertSame(l1, it.next());
@@ -335,14 +335,14 @@
         Branch b2 = forest.getTree(1).addBranch();
         Branch b3 = forest.getTree(2).addBranch();
         Branch b4 = forest.getTree(2).addBranch();
-        Branch b5 = forest.getTree(2).addBranch();
+        /* Branch b5 = */ forest.getTree(2).addBranch();
         Leaf l1 = b1.addLeaf();
         Leaf l2 = b1.addLeaf();
         Leaf l3 = b2.addLeaf();
         Leaf l4 = b3.addLeaf();
         Leaf l5 = b4.addLeaf();
 
-        Iterator it = new ObjectGraphIterator(forest, new LeafFinder());
+        Iterator<Object> it = new ObjectGraphIterator<Object>(forest, new LeafFinder());
 
         assertEquals(true, it.hasNext());
         assertSame(l1, it.next());
@@ -363,7 +363,7 @@
     }
 
     //-----------------------------------------------------------------------
-    static class LeafFinder implements Transformer {
+    static class LeafFinder implements Transformer<Object, Object> {
         public Object transform(Object input) {
             if (input instanceof Forest) {
                 return ((Forest) input).treeIterator();
@@ -383,7 +383,7 @@
 
     //-----------------------------------------------------------------------
     static class Forest {
-        List trees = new ArrayList();
+        List<Tree> trees = new ArrayList<Tree>();
 
         Tree addTree() {
             trees.add(new Tree());
@@ -394,13 +394,13 @@
             return (Tree) trees.get(index);
         }
 
-        Iterator treeIterator() {
+        Iterator<Tree> treeIterator() {
             return trees.iterator();
         }
     }
 
     static class Tree {
-        List branches = new ArrayList();
+        List<Branch> branches = new ArrayList<Branch>();
 
         Branch addBranch() {
             branches.add(new Branch());
@@ -411,13 +411,13 @@
             return (Branch) branches.get(index);
         }
 
-        Iterator branchIterator() {
+        Iterator<Branch> branchIterator() {
             return branches.iterator();
         }
     }
 
     static class Branch {
-        List leaves = new ArrayList();
+        List<Leaf> leaves = new ArrayList<Leaf>();
 
         Leaf addLeaf() {
             leaves.add(new Leaf());
@@ -428,7 +428,7 @@
             return (Leaf) leaves.get(index);
         }
 
-        Iterator leafIterator() {
+        Iterator<Leaf> leafIterator() {
             return leaves.iterator();
         }
     }

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestReverseListIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestReverseListIterator.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestReverseListIterator.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestReverseListIterator.java Tue Sep 15 05:29:56 2009
@@ -33,7 +33,7 @@
  *
  * @version $Revision: $ $Date$
  */
-public class TestReverseListIterator extends AbstractTestListIterator {
+public class TestReverseListIterator<E> extends AbstractTestListIterator<E> {
 
     protected String[] testArray = { "One", "Two", "Three", "Four" };
 
@@ -50,33 +50,33 @@
         super(testName);
     }
 
-    public ListIterator makeEmptyListIterator() {
-        List list = new ArrayList();
-        return new ReverseListIterator(list);
+    public ListIterator<E> makeEmptyIterator() {
+        return new ReverseListIterator<E>(new ArrayList<E>());
     }
 
-    public ListIterator makeFullListIterator() {
-        List list = new ArrayList(Arrays.asList(testArray));
-        return new ReverseListIterator(list);
+    @SuppressWarnings("unchecked")
+    public ReverseListIterator<E> makeObject() {
+        List<E> list = new ArrayList<E>(Arrays.asList((E[]) testArray));
+        return new ReverseListIterator<E>(list);
     }
 
     // overrides
     //-----------------------------------------------------------------------
     public void testEmptyListIteratorIsIndeedEmpty() {
-        ListIterator it = makeEmptyListIterator();
-        
+        ListIterator<E> it = makeEmptyIterator();
+
         assertEquals(false, it.hasNext());
         assertEquals(-1, it.nextIndex());  // reversed index
         assertEquals(false, it.hasPrevious());
         assertEquals(0, it.previousIndex());  // reversed index
-        
+
         // next() should throw a NoSuchElementException
         try {
             it.next();
             fail("NoSuchElementException must be thrown from empty ListIterator");
         } catch (NoSuchElementException e) {
         }
-        
+
         // previous() should throw a NoSuchElementException
         try {
             it.previous();
@@ -86,16 +86,16 @@
     }
 
     public void testWalkForwardAndBack() {
-        ArrayList list = new ArrayList();
-        ListIterator it = makeFullListIterator();
+        ArrayList<E> list = new ArrayList<E>();
+        ListIterator<E> it = makeObject();
         while (it.hasNext()) {
             list.add(it.next());
         }
-        
+
         // check state at end
         assertEquals(false, it.hasNext());
         assertEquals(true, it.hasPrevious());
-        
+
         // this had to be commented out, as there is a bug in the JDK before JDK1.5
         // where calling previous at the start of an iterator would push the cursor
         // back to an invalid negative value
@@ -104,16 +104,16 @@
 //            fail("NoSuchElementException must be thrown from next at end of ListIterator");
 //        } catch (NoSuchElementException e) {
 //        }
-        
+
         // loop back through comparing
         for (int i = list.size() - 1; i >= 0; i--) {
             assertEquals("" + i, list.size() - i - 2, it.nextIndex());  // reversed index
             assertEquals(list.size() - i - 1, it.previousIndex());  // reversed index
-            
+
             Object obj = list.get(i);
             assertEquals(obj, it.previous());
         }
-        
+
         // check state at start
         assertEquals(true, it.hasNext());
         assertEquals(false, it.hasPrevious());
@@ -126,7 +126,7 @@
 
     //-----------------------------------------------------------------------
     public void testReverse() {
-        ListIterator it = makeFullListIterator();
+        ListIterator<E> it = makeObject();
         assertEquals(true, it.hasNext());
         assertEquals(3, it.nextIndex());
         assertEquals(false, it.hasPrevious());
@@ -158,7 +158,7 @@
     }
 
     public void testReset() {
-        ResettableListIterator it = (ResettableListIterator) makeFullListIterator();
+        ResettableListIterator<E> it = makeObject();
         assertEquals("Four", it.next());
         it.reset();
         assertEquals("Four", it.next());

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestSingletonIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestSingletonIterator.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestSingletonIterator.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestSingletonIterator.java Tue Sep 15 05:29:56 2009
@@ -32,32 +32,33 @@
  *
  * @author James Strachan
  */
-public class TestSingletonIterator extends AbstractTestIterator {
+public class TestSingletonIterator<E> extends AbstractTestIterator<E> {
 
     private static final Object testValue = "foo";
-    
+
     public static Test suite() {
         return new TestSuite(TestSingletonIterator.class);
     }
-    
+
     public TestSingletonIterator(String testName) {
         super(testName);
     }
-    
+
     /**
-     * Returns a SingletonIterator from which 
+     * Returns a SingletonIterator from which
      * the element has already been removed.
      */
-    public Iterator makeEmptyIterator() {
-        SingletonIterator iter = (SingletonIterator)makeFullIterator();
+    public SingletonIterator<E> makeEmptyIterator() {
+        SingletonIterator<E> iter = makeObject();
         iter.next();
-        iter.remove();        
+        iter.remove();
         iter.reset();
         return iter;
     }
 
-    public Iterator makeFullIterator() {
-        return new SingletonIterator( testValue );
+    @SuppressWarnings("unchecked")
+    public SingletonIterator<E> makeObject() {
+        return new SingletonIterator<E>((E) testValue);
     }
 
     public boolean supportsRemove() {
@@ -69,10 +70,10 @@
     }
 
     public void testIterator() {
-        Iterator iter = (Iterator) makeObject();
+        Iterator<E> iter = makeObject();
         assertTrue("Iterator has a first item", iter.hasNext());
 
-        Object iterValue = iter.next();
+        E iterValue = iter.next();
         assertEquals("Iteration value is correct", testValue, iterValue);
 
         assertTrue("Iterator should now be empty", !iter.hasNext());
@@ -85,33 +86,34 @@
                 e.getClass().equals((new NoSuchElementException()).getClass()));
         }
     }
-    
+
+    @SuppressWarnings("unchecked")
     public void testSingletonIteratorRemove() {
-        ResettableIterator iter = new SingletonIterator("xyzzy");
+        ResettableIterator<E> iter = new SingletonIterator<E>((E) "xyzzy");
         assertTrue(iter.hasNext());
         assertEquals("xyzzy",iter.next());
         iter.remove();
         iter.reset();
         assertTrue(! iter.hasNext());
     }
-    
+
     public void testReset() {
-        ResettableIterator it = (ResettableIterator) makeObject();
-        
+        ResettableIterator<E> it = makeObject();
+
         assertEquals(true, it.hasNext());
         assertEquals(testValue, it.next());
         assertEquals(false, it.hasNext());
 
         it.reset();
-        
+
         assertEquals(true, it.hasNext());
         assertEquals(testValue, it.next());
         assertEquals(false, it.hasNext());
-        
+
         it.reset();
         it.reset();
-        
+
         assertEquals(true, it.hasNext());
     }
-    
+
 }

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestSingletonIterator2.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestSingletonIterator2.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestSingletonIterator2.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestSingletonIterator2.java Tue Sep 15 05:29:56 2009
@@ -32,7 +32,7 @@
  *
  * @author James Strachan
  */
-public class TestSingletonIterator2 extends AbstractTestIterator {
+public class TestSingletonIterator2<E> extends AbstractTestIterator<E> {
 
     private static final Object testValue = "foo";
 
@@ -45,16 +45,18 @@
     }
 
     //-----------------------------------------------------------------------
-    public Iterator makeEmptyIterator() {
-        SingletonIterator iter = new SingletonIterator(testValue);
+    @SuppressWarnings("unchecked")
+    public SingletonIterator<E> makeEmptyIterator() {
+        SingletonIterator<E> iter = new SingletonIterator<E>((E) testValue);
         iter.next();
         iter.remove();
         iter.reset();
         return iter;
     }
 
-    public Iterator makeFullIterator() {
-        return new SingletonIterator(testValue, false);
+    @SuppressWarnings("unchecked")
+    public SingletonIterator<E> makeObject() {
+        return new SingletonIterator<E>((E) testValue, false);
     }
 
     public boolean supportsRemove() {
@@ -67,10 +69,10 @@
 
     //-----------------------------------------------------------------------
     public void testIterator() {
-        Iterator iter = (Iterator) makeObject();
+        Iterator<E> iter = makeObject();
         assertTrue("Iterator has a first item", iter.hasNext());
 
-        Object iterValue = iter.next();
+        E iterValue = iter.next();
         assertEquals("Iteration value is correct", testValue, iterValue);
 
         assertTrue("Iterator should now be empty", !iter.hasNext());
@@ -85,7 +87,7 @@
     }
 
     public void testReset() {
-        ResettableIterator it = (ResettableIterator) makeObject();
+        ResettableIterator<E> it = makeObject();
 
         assertEquals(true, it.hasNext());
         assertEquals(testValue, it.next());

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUniqueFilterIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUniqueFilterIterator.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUniqueFilterIterator.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUniqueFilterIterator.java Tue Sep 15 05:29:56 2009
@@ -34,13 +34,13 @@
  * @author Morgan Delagrange
  * @author Stephen Colebourne
  */
-public class TestUniqueFilterIterator extends AbstractTestIterator {
+public class TestUniqueFilterIterator<E> extends AbstractTestIterator<E> {
 
     protected String[] testArray = {
         "One", "Two", "Three", "Four", "Five", "Six"
     };
 
-    protected List list1 = null;
+    protected List<E> list1 = null;
 
     public static Test suite() {
         return new TestSuite(TestUniqueFilterIterator.class);
@@ -50,36 +50,36 @@
         super(testName);
     }
 
+    @SuppressWarnings("unchecked")
     public void setUp() {
-        list1 = new ArrayList();
-        list1.add("One");
-        list1.add("Two");
-        list1.add("Three");
-        list1.add("Two");
-        list1.add("One");
-        list1.add("Four");
-        list1.add("Five");
-        list1.add("Five");
-        list1.add("Six");
-        list1.add("Five");
-    }
-
-    public Iterator makeEmptyIterator() {
-        ArrayList list = new ArrayList();
-        return new UniqueFilterIterator(list.iterator());
-    }
-
-    public Iterator makeFullIterator() {
-        Iterator i = list1.iterator();
-
-        return new UniqueFilterIterator(i);
+        list1 = new ArrayList<E>();
+        list1.add((E) "One");
+        list1.add((E) "Two");
+        list1.add((E) "Three");
+        list1.add((E) "Two");
+        list1.add((E) "One");
+        list1.add((E) "Four");
+        list1.add((E) "Five");
+        list1.add((E) "Five");
+        list1.add((E) "Six");
+        list1.add((E) "Five");
+    }
+
+    public UniqueFilterIterator<E> makeEmptyIterator() {
+        ArrayList<E> list = new ArrayList<E>();
+        return new UniqueFilterIterator<E>(list.iterator());
+    }
+
+    public UniqueFilterIterator<E> makeObject() {
+        Iterator<E> i = list1.iterator();
+        return new UniqueFilterIterator<E>(i);
     }
 
     public void testIterator() {
-        Iterator iter = (Iterator) makeFullIterator();
-        for ( int i = 0; i < testArray.length; i++ ) {
+        Iterator<E> iter = makeObject();
+        for (int i = 0; i < testArray.length; i++) {
             Object testValue = testArray[i];            
-            Object iterValue = iter.next();
+            E iterValue = iter.next();
 
             assertEquals( "Iteration value is correct", testValue, iterValue );
         }
@@ -87,7 +87,7 @@
         assertTrue("Iterator should now be empty", ! iter.hasNext() );
 
         try {
-            Object testValue = iter.next();
+            iter.next();
         } catch (Exception e) {
             assertTrue("NoSuchElementException must be thrown", 
                        e.getClass().equals((new NoSuchElementException()).getClass()));

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUnmodifiableIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUnmodifiableIterator.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUnmodifiableIterator.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUnmodifiableIterator.java Tue Sep 15 05:29:56 2009
@@ -34,10 +34,10 @@
  *
  * @author Stephen Colebourne
  */
-public class TestUnmodifiableIterator extends AbstractTestIterator {
+public class TestUnmodifiableIterator<E> extends AbstractTestIterator<E> {
 
     protected String[] testArray = { "One", "Two", "Three" };
-    protected List testList = new ArrayList(Arrays.asList(testArray));
+    protected List<E> testList;
 
     public static Test suite() {
         return new TestSuite(TestUnmodifiableIterator.class);
@@ -47,11 +47,21 @@
         super(testName);
     }
 
-    public Iterator makeEmptyIterator() {
-        return UnmodifiableIterator.decorate(Collections.EMPTY_LIST.iterator());
+    /**
+     * {@inheritDoc}
+     */
+    @SuppressWarnings("unchecked")
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        testList = new ArrayList<E>(Arrays.asList((E[]) testArray));
     }
 
-    public Iterator makeFullIterator() {
+    public Iterator<E> makeEmptyIterator() {
+        return UnmodifiableIterator.decorate(Collections.<E>emptyList().iterator());
+    }
+
+    public Iterator<E> makeObject() {
         return UnmodifiableIterator.decorate(testList.iterator());
     }
 
@@ -63,14 +73,14 @@
     public void testIterator() {
         assertTrue(makeEmptyIterator() instanceof Unmodifiable);
     }
-    
+
     public void testDecorateFactory() {
-        Iterator it = makeFullIterator();
+        Iterator<E> it = makeObject();
         assertSame(it, UnmodifiableIterator.decorate(it));
-        
+
         it = testList.iterator();
         assertTrue(it != UnmodifiableIterator.decorate(it));
-        
+
         try {
             UnmodifiableIterator.decorate(null);
             fail();

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUnmodifiableListIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUnmodifiableListIterator.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUnmodifiableListIterator.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUnmodifiableListIterator.java Tue Sep 15 05:29:56 2009
@@ -34,10 +34,10 @@
  *
  * @author Stephen Colebourne
  */
-public class TestUnmodifiableListIterator extends AbstractTestListIterator {
+public class TestUnmodifiableListIterator<E> extends AbstractTestListIterator<E> {
 
     protected String[] testArray = { "One", "Two", "Three" };
-    protected List testList = new ArrayList(Arrays.asList(testArray));
+    protected List<E> testList;
 
     public static Test suite() {
         return new TestSuite(TestUnmodifiableListIterator.class);
@@ -47,11 +47,21 @@
         super(testName);
     }
 
-    public ListIterator makeEmptyListIterator() {
-        return UnmodifiableListIterator.decorate(Collections.EMPTY_LIST.listIterator());
+    /**
+     * {@inheritDoc}
+     */
+    @SuppressWarnings("unchecked")
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        testList = new ArrayList<E>(Arrays.asList((E[]) testArray));
     }
 
-    public ListIterator makeFullListIterator() {
+    public ListIterator<E> makeEmptyIterator() {
+        return UnmodifiableListIterator.decorate(Collections.<E>emptyList().listIterator());
+    }
+
+    public ListIterator<E> makeObject() {
         return UnmodifiableListIterator.decorate(testList.listIterator());
     }
 
@@ -69,16 +79,16 @@
 
     //-----------------------------------------------------------------------
     public void testListIterator() {
-        assertTrue(makeEmptyListIterator() instanceof Unmodifiable);
+        assertTrue(makeEmptyIterator() instanceof Unmodifiable);
     }
-    
+
     public void testDecorateFactory() {
-        ListIterator it = makeFullListIterator();
+        ListIterator<E> it = makeObject();
         assertSame(it, UnmodifiableListIterator.decorate(it));
-        
+
         it = testList.listIterator();
         assertTrue(it != UnmodifiableListIterator.decorate(it));
-        
+
         try {
             UnmodifiableListIterator.decorate(null);
             fail();

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUnmodifiableMapIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUnmodifiableMapIterator.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUnmodifiableMapIterator.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUnmodifiableMapIterator.java Tue Sep 15 05:29:56 2009
@@ -22,7 +22,7 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
-import org.apache.commons.collections.BidiMap;
+import org.apache.commons.collections.IterableMap;
 import org.apache.commons.collections.MapIterator;
 import org.apache.commons.collections.Unmodifiable;
 import org.apache.commons.collections.bidimap.DualHashBidiMap;
@@ -34,7 +34,7 @@
  *
  * @author Stephen Colebourne
  */
-public class TestUnmodifiableMapIterator extends AbstractTestMapIterator {
+public class TestUnmodifiableMapIterator<K, V> extends AbstractTestMapIterator<K, V> {
 
     public static Test suite() {
         return new TestSuite(TestUnmodifiableMapIterator.class);
@@ -44,27 +44,29 @@
         super(testName);
     }
 
-    public MapIterator makeEmptyMapIterator() {
-        return UnmodifiableMapIterator.decorate(new DualHashBidiMap().mapIterator());
+    public MapIterator<K, V> makeEmptyIterator() {
+        return UnmodifiableMapIterator.decorate(new DualHashBidiMap<K, V>().mapIterator());
     }
 
-    public MapIterator makeFullMapIterator() {
-        return UnmodifiableMapIterator.decorate(((BidiMap) getMap()).mapIterator());
+    public MapIterator<K, V> makeObject() {
+        return UnmodifiableMapIterator.decorate(getMap().mapIterator());
     }
-    
-    public Map getMap() {
-        Map testMap = new DualHashBidiMap();
-        testMap.put("A", "a");
-        testMap.put("B", "b");
-        testMap.put("C", "c");
+
+    @SuppressWarnings("unchecked")
+    public IterableMap<K, V> getMap() {
+        IterableMap<K, V> testMap = new DualHashBidiMap<K, V>();
+        testMap.put((K) "A", (V) "a");
+        testMap.put((K) "B", (V)"b");
+        testMap.put((K) "C", (V) "c");
         return testMap;
     }
 
-    public Map getConfirmedMap() {
-        Map testMap = new HashMap();
-        testMap.put("A", "a");
-        testMap.put("B", "b");
-        testMap.put("C", "c");
+    @SuppressWarnings("unchecked")
+    public Map<K, V> getConfirmedMap() {
+        Map<K, V> testMap = new HashMap<K, V>();
+        testMap.put((K) "A", (V) "a");
+        testMap.put((K) "B", (V)"b");
+        testMap.put((K) "C", (V) "c");
         return testMap;
     }
 
@@ -75,19 +77,19 @@
     public boolean supportsSetValue() {
         return false;
     }
-    
+
     //-----------------------------------------------------------------------
     public void testMapIterator() {
-        assertTrue(makeEmptyMapIterator() instanceof Unmodifiable);
+        assertTrue(makeEmptyIterator() instanceof Unmodifiable);
     }
-    
+
     public void testDecorateFactory() {
-        MapIterator it = makeFullMapIterator();
+        MapIterator<K, V> it = makeObject();
         assertSame(it, UnmodifiableMapIterator.decorate(it));
-        
-        it = ((BidiMap) getMap()).mapIterator() ;
+
+        it = getMap().mapIterator() ;
         assertTrue(it != UnmodifiableMapIterator.decorate(it));
-        
+
         try {
             UnmodifiableMapIterator.decorate(null);
             fail();

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUnmodifiableOrderedMapIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUnmodifiableOrderedMapIterator.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUnmodifiableOrderedMapIterator.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/iterators/TestUnmodifiableOrderedMapIterator.java Tue Sep 15 05:29:56 2009
@@ -23,7 +23,6 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
-import org.apache.commons.collections.MapIterator;
 import org.apache.commons.collections.OrderedMap;
 import org.apache.commons.collections.OrderedMapIterator;
 import org.apache.commons.collections.Unmodifiable;
@@ -36,7 +35,7 @@
  *
  * @author Stephen Colebourne
  */
-public class TestUnmodifiableOrderedMapIterator extends AbstractTestOrderedMapIterator {
+public class TestUnmodifiableOrderedMapIterator<K, V> extends AbstractTestOrderedMapIterator<K, V> {
 
     public static Test suite() {
         return new TestSuite(TestUnmodifiableOrderedMapIterator.class);
@@ -46,29 +45,30 @@
         super(testName);
     }
 
-    public MapIterator makeEmptyMapIterator() {
+    public OrderedMapIterator<K, V> makeEmptyIterator() {
         return UnmodifiableOrderedMapIterator.decorate(
-            ListOrderedMap.decorate(new HashMap()).orderedMapIterator());
+                ListOrderedMap.decorate(new HashMap<K, V>()).mapIterator());
     }
 
-    public MapIterator makeFullMapIterator() {
-        return UnmodifiableOrderedMapIterator.decorate(
-            ((OrderedMap) getMap()).orderedMapIterator());
+    public OrderedMapIterator<K, V> makeObject() {
+        return UnmodifiableOrderedMapIterator.decorate(getMap().mapIterator());
     }
-    
-    public Map getMap() {
-        Map testMap = ListOrderedMap.decorate(new HashMap());
-        testMap.put("A", "a");
-        testMap.put("B", "b");
-        testMap.put("C", "c");
+
+    @SuppressWarnings("unchecked")
+    public OrderedMap<K, V> getMap() {
+        OrderedMap<K, V> testMap = ListOrderedMap.decorate(new HashMap<K, V>());
+        testMap.put((K) "A", (V) "a");
+        testMap.put((K) "B", (V) "b");
+        testMap.put((K) "C", (V) "c");
         return testMap;
     }
 
-    public Map getConfirmedMap() {
-        Map testMap = new TreeMap();
-        testMap.put("A", "a");
-        testMap.put("B", "b");
-        testMap.put("C", "c");
+    @SuppressWarnings("unchecked")
+    public Map<K, V> getConfirmedMap() {
+        Map<K, V> testMap = new TreeMap<K, V>();
+        testMap.put((K) "A", (V) "a");
+        testMap.put((K) "B", (V) "b");
+        testMap.put((K) "C", (V) "c");
         return testMap;
     }
 
@@ -79,19 +79,19 @@
     public boolean supportsSetValue() {
         return false;
     }
-    
+
     //-----------------------------------------------------------------------
     public void testOrderedMapIterator() {
-        assertTrue(makeEmptyOrderedMapIterator() instanceof Unmodifiable);
+        assertTrue(makeEmptyIterator() instanceof Unmodifiable);
     }
-    
+
     public void testDecorateFactory() {
-        OrderedMapIterator it = makeFullOrderedMapIterator();
+        OrderedMapIterator<K, V> it = makeObject();
         assertSame(it, UnmodifiableOrderedMapIterator.decorate(it));
-        
-        it = ((OrderedMap) getMap()).orderedMapIterator() ;
+
+        it = getMap().mapIterator() ;
         assertTrue(it != UnmodifiableOrderedMapIterator.decorate(it));
-        
+
         try {
             UnmodifiableOrderedMapIterator.decorate(null);
             fail();

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/AbstractTestMapEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/AbstractTestMapEntry.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/AbstractTestMapEntry.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/AbstractTestMapEntry.java Tue Sep 15 05:29:56 2009
@@ -33,7 +33,7 @@
  *
  * @author Neil O'Toole
  */
-public abstract class AbstractTestMapEntry extends TestCase {
+public abstract class AbstractTestMapEntry<K, V> extends TestCase {
     
     protected final String key = "name";
     protected final String value = "duke";
@@ -53,7 +53,7 @@
      * This implementation simply calls {@link #makeMapEntry(Object, Object)}
      * with null for key and value. Subclasses can override this method if desired.
      */
-    public Map.Entry makeMapEntry() {
+    public Map.Entry<K, V> makeMapEntry() {
         return makeMapEntry(null, null);
     }
 
@@ -62,32 +62,33 @@
      * Subclasses should override this method to return a Map.Entry
      * of the type being tested.
      */
-    public abstract Map.Entry makeMapEntry(Object key, Object value);
+    public abstract Map.Entry<K, V> makeMapEntry(K key, V value);
 
     /**
      * Makes a Map.Entry of a type that's known to work correctly.
      */
-    public Map.Entry makeKnownMapEntry() {
+    public Map.Entry<K, V> makeKnownMapEntry() {
         return makeKnownMapEntry(null, null);
     }
 
     /**
      * Makes a Map.Entry of a type that's known to work correctly.
      */
-    public Map.Entry makeKnownMapEntry(Object key, Object value) {
-        Map map = new HashMap(1);
+    public Map.Entry<K, V> makeKnownMapEntry(K key, V value) {
+        Map<K, V> map = new HashMap<K, V>(1);
         map.put(key, value);
-        Map.Entry entry = (Map.Entry) map.entrySet().iterator().next();
+        Map.Entry<K, V> entry = map.entrySet().iterator().next();
         return entry;
     }
 
     //-----------------------------------------------------------------------
+    @SuppressWarnings("unchecked")
     public void testAccessorsAndMutators() {
-        Map.Entry entry = makeMapEntry(key, value);
+        Map.Entry<K, V> entry = makeMapEntry((K) key, (V) value);
 
         assertTrue(entry.getKey() == key);
 
-        entry.setValue(value);
+        entry.setValue((V) value);
         assertTrue(entry.getValue() == value);
 
         // check that null doesn't do anything funny
@@ -105,15 +106,16 @@
      *
      */
 
+    @SuppressWarnings("unchecked")
     public void testSelfReferenceHandling() {
         // test that #setValue does not permit
         //  the MapEntry to contain itself (and thus cause infinite recursion
         //  in #hashCode and #toString)
 
-        Map.Entry entry = makeMapEntry();
+        Map.Entry<K, V> entry = makeMapEntry();
 
         try {
-            entry.setValue(entry);
+            entry.setValue((V) entry);
             fail("Should throw an IllegalArgumentException");
         } catch (IllegalArgumentException iae) {
             // expected to happen...
@@ -129,10 +131,11 @@
      */
     public abstract void testConstructors();
 
+    @SuppressWarnings("unchecked")
     public void testEqualsAndHashCode() {
         // 1. test with object data
-        Map.Entry e1 = makeMapEntry(key, value);
-        Map.Entry e2 = makeKnownMapEntry(key, value);
+        Map.Entry<K, V> e1 = makeMapEntry((K) key, (V) value);
+        Map.Entry<K, V> e2 = makeKnownMapEntry((K) key, (V) value);
 
         assertTrue(e1.equals(e1));
         assertTrue(e2.equals(e1));
@@ -149,8 +152,9 @@
         assertTrue(e1.hashCode() == e2.hashCode());
     }
 
+    @SuppressWarnings("unchecked")
     public void testToString() {
-        Map.Entry entry = makeMapEntry(key, value);
+        Map.Entry<K, V> entry = makeMapEntry((K) key, (V) value);
         assertTrue(entry.toString().equals(entry.getKey() + "=" + entry.getValue()));
 
         // test with nulls

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestDefaultKeyValue.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestDefaultKeyValue.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestDefaultKeyValue.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestDefaultKeyValue.java Tue Sep 15 05:29:56 2009
@@ -31,7 +31,7 @@
  *
  * @author Neil O'Toole
  */
-public class TestDefaultKeyValue extends TestCase {
+public class TestDefaultKeyValue<K, V> extends TestCase {
     
     private final String key = "name";
     private final String value = "duke";
@@ -60,8 +60,8 @@
      * Subclasses should override this method to return a DefaultKeyValue
      * of the type being tested.
      */
-    protected DefaultKeyValue makeDefaultKeyValue() {
-        return new DefaultKeyValue(null, null);
+    protected DefaultKeyValue<K, V> makeDefaultKeyValue() {
+        return new DefaultKeyValue<K, V>(null, null);
     }
 
     /**
@@ -69,18 +69,19 @@
      * Subclasses should override this method to return a DefaultKeyValue
      * of the type being tested.
      */
-    protected DefaultKeyValue makeDefaultKeyValue(Object key, Object value) {
-        return new DefaultKeyValue(key, value);
+    protected DefaultKeyValue<K, V> makeDefaultKeyValue(K key, V value) {
+        return new DefaultKeyValue<K, V>(key, value);
     }
 
     //-----------------------------------------------------------------------
+    @SuppressWarnings("unchecked")
     public void testAccessorsAndMutators() {
-        DefaultKeyValue kv = makeDefaultKeyValue();
+        DefaultKeyValue<K, V> kv = makeDefaultKeyValue();
 
-        kv.setKey(key);
+        kv.setKey((K) key);
         assertTrue(kv.getKey() == key);
 
-        kv.setValue(value);
+        kv.setValue((V) value);
         assertTrue(kv.getValue() == value);
 
         // check that null doesn't do anything funny
@@ -92,15 +93,16 @@
 
     }
 
+    @SuppressWarnings("unchecked")
     public void testSelfReferenceHandling() {
         // test that #setKey and #setValue do not permit
         //  the KVP to contain itself (and thus cause infinite recursion
         //  in #hashCode and #toString)
 
-        DefaultKeyValue kv = makeDefaultKeyValue();
+        DefaultKeyValue<K, V> kv = makeDefaultKeyValue();
 
         try {
-            kv.setKey(kv);
+            kv.setKey((K) kv);
             fail("Should throw an IllegalArgumentException");
         } catch (IllegalArgumentException iae) {
             // expected to happen...
@@ -110,7 +112,7 @@
         }
 
         try {
-            kv.setValue(kv);
+            kv.setValue((V) kv);
             fail("Should throw an IllegalArgumentException");
         } catch (IllegalArgumentException iae) {
             // expected to happen...
@@ -123,17 +125,18 @@
     /**
      * Subclasses should override this method to test their own constructors.
      */
+    @SuppressWarnings("unchecked")
     public void testConstructors() {
         // 1. test default constructor
-        DefaultKeyValue kv = new DefaultKeyValue();
+        DefaultKeyValue<K, V> kv = new DefaultKeyValue<K, V>();
         assertTrue(kv.getKey() == null && kv.getValue() == null);
 
         // 2. test key-value constructor
-        kv = new DefaultKeyValue(key, value);
+        kv = new DefaultKeyValue<K, V>((K) key, (V) value);
         assertTrue(kv.getKey() == key && kv.getValue() == value);
 
         // 3. test copy constructor
-        DefaultKeyValue kv2 = new DefaultKeyValue(kv);
+        DefaultKeyValue<K, V> kv2 = new DefaultKeyValue<K, V>(kv);
         assertTrue(kv2.getKey() == key && kv2.getValue() == value);
 
         // test that the KVPs are independent
@@ -143,11 +146,11 @@
         assertTrue(kv2.getKey() == key && kv2.getValue() == value);
 
         // 4. test Map.Entry constructor
-        Map map = new HashMap();
-        map.put(key, value);
-        Map.Entry entry = (Map.Entry) map.entrySet().iterator().next();
+        Map<K, V> map = new HashMap<K, V>();
+        map.put((K) key, (V) value);
+        Map.Entry<K, V> entry = map.entrySet().iterator().next();
 
-        kv = new DefaultKeyValue(entry);
+        kv = new DefaultKeyValue<K, V>(entry);
         assertTrue(kv.getKey() == key && kv.getValue() == value);
 
         // test that the KVP is independent of the Map.Entry
@@ -156,10 +159,11 @@
 
     }
 
+    @SuppressWarnings("unchecked")
     public void testEqualsAndHashCode() {
         // 1. test with object data
-        DefaultKeyValue kv = makeDefaultKeyValue(key, value);
-        DefaultKeyValue kv2 = makeDefaultKeyValue(key, value);
+        DefaultKeyValue<K, V> kv = makeDefaultKeyValue((K) key, (V) value);
+        DefaultKeyValue<K, V> kv2 = makeDefaultKeyValue((K) key, (V) value);
 
         assertTrue(kv.equals(kv));
         assertTrue(kv.equals(kv2));
@@ -174,8 +178,9 @@
         assertTrue(kv.hashCode() == kv2.hashCode());
     }
 
+    @SuppressWarnings("unchecked")
     public void testToString() {
-        DefaultKeyValue kv = makeDefaultKeyValue(key, value);
+        DefaultKeyValue<K, V> kv = makeDefaultKeyValue((K) key, (V) value);
         assertTrue(kv.toString().equals(kv.getKey() + "=" + kv.getValue()));
 
         // test with nulls
@@ -183,12 +188,13 @@
         assertTrue(kv.toString().equals(kv.getKey() + "=" + kv.getValue()));
     }
 
+    @SuppressWarnings("unchecked")
     public void testToMapEntry() {
-        DefaultKeyValue kv = makeDefaultKeyValue(key, value);
+        DefaultKeyValue<K, V> kv = makeDefaultKeyValue((K) key, (V) value);
 
-        Map map = new HashMap();
+        Map<K, V> map = new HashMap<K, V>();
         map.put(kv.getKey(), kv.getValue());
-        Map.Entry entry = (Map.Entry) map.entrySet().iterator().next();
+        Map.Entry<K, V> entry = map.entrySet().iterator().next();
 
         assertTrue(entry.equals(kv.toMapEntry()));
         assertTrue(entry.hashCode() == kv.hashCode());

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestDefaultMapEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestDefaultMapEntry.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestDefaultMapEntry.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestDefaultMapEntry.java Tue Sep 15 05:29:56 2009
@@ -31,11 +31,10 @@
  *
  * @author Neil O'Toole
  */
-public class TestDefaultMapEntry extends AbstractTestMapEntry {
+public class TestDefaultMapEntry<K, V> extends AbstractTestMapEntry<K, V> {
 
     public TestDefaultMapEntry(String testName) {
         super(testName);
-
     }
 
     public static void main(String[] args) {
@@ -52,8 +51,8 @@
      * Subclasses should override this method to return a Map.Entry
      * of the type being tested.
      */
-    public Map.Entry makeMapEntry() {
-        return new DefaultMapEntry(null, null);
+    public Map.Entry<K, V> makeMapEntry() {
+        return new DefaultMapEntry<K, V>(null, null);
     }
 
     /**
@@ -61,8 +60,8 @@
      * Subclasses should override this method to return a Map.Entry
      * of the type being tested.
      */
-    public Map.Entry makeMapEntry(Object key, Object value) {
-        return new DefaultMapEntry(key, value);
+    public Map.Entry<K, V> makeMapEntry(K key, V value) {
+        return new DefaultMapEntry<K, V>(key, value);
     }
 
     //-----------------------------------------------------------------------
@@ -70,19 +69,20 @@
      * Subclasses should override this method.
      *
      */
+    @SuppressWarnings("unchecked")
     public void testConstructors() {
         // 1. test key-value constructor
-        Map.Entry entry = new DefaultMapEntry(key, value);
+        Map.Entry<K, V> entry = new DefaultMapEntry<K, V>((K) key, (V) value);
         assertSame(key, entry.getKey());
         assertSame(value, entry.getValue());
 
         // 2. test pair constructor
-        KeyValue pair = new DefaultKeyValue(key, value);
+        KeyValue<K, V> pair = new DefaultKeyValue<K, V>((K) key, (V) value);
         assertSame(key, pair.getKey());
         assertSame(value, pair.getValue());
 
         // 3. test copy constructor
-        Map.Entry entry2 = new DefaultMapEntry(entry);
+        Map.Entry<K, V> entry2 = new DefaultMapEntry<K, V>(entry);
         assertSame(key, entry2.getKey());
         assertSame(value, entry2.getValue());
 
@@ -91,11 +91,12 @@
         assertSame(value, entry2.getValue());
     }
 
+    @SuppressWarnings("unchecked")
     public void testSelfReferenceHandling() {
-        Map.Entry entry = makeMapEntry();
+        Map.Entry<K, V> entry = makeMapEntry();
 
         try {
-            entry.setValue(entry);
+            entry.setValue((V) entry);
             assertSame(entry, entry.getValue());
 
         } catch (Exception e) {

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestTiedMapEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestTiedMapEntry.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestTiedMapEntry.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestTiedMapEntry.java Tue Sep 15 05:29:56 2009
@@ -30,11 +30,10 @@
  *
  * @author Stephen Colebourne
  */
-public class TestTiedMapEntry extends AbstractTestMapEntry {
+public class TestTiedMapEntry<K, V> extends AbstractTestMapEntry<K, V> {
 
     public TestTiedMapEntry(String testName) {
         super(testName);
-
     }
 
     public static void main(String[] args) {
@@ -49,10 +48,10 @@
     /**
      * Gets the instance to test
      */
-    public Map.Entry makeMapEntry(Object key, Object value) {
-        Map map = new HashMap();
+    public Map.Entry<K, V> makeMapEntry(K key, V value) {
+        Map<K, V> map = new HashMap<K, V>();
         map.put(key, value);
-        return new TiedMapEntry(map, key);
+        return new TiedMapEntry<K, V>(map, key);
     }
 
     //-----------------------------------------------------------------------
@@ -66,29 +65,30 @@
     /**
      * Tests the constructors.
      */
+    @SuppressWarnings("unchecked")
     public void testSetValue() {
-        Map map = new HashMap();
-        map.put("A", "a");
-        map.put("B", "b");
-        map.put("C", "c");
-        Map.Entry entry = new TiedMapEntry(map, "A");
+        Map<K, V> map = new HashMap<K, V>();
+        map.put((K) "A", (V) "a");
+        map.put((K) "B", (V) "b");
+        map.put((K) "C", (V) "c");
+        Map.Entry<K, V> entry = new TiedMapEntry<K, V>(map, (K) "A");
         assertSame("A", entry.getKey());
         assertSame("a", entry.getValue());
-        assertSame("a", entry.setValue("x"));
+        assertSame("a", entry.setValue((V) "x"));
         assertSame("A", entry.getKey());
         assertSame("x", entry.getValue());
-        
-        entry = new TiedMapEntry(map, "B");
+
+        entry = new TiedMapEntry<K, V>(map, (K) "B");
         assertSame("B", entry.getKey());
         assertSame("b", entry.getValue());
-        assertSame("b", entry.setValue("y"));
+        assertSame("b", entry.setValue((V) "y"));
         assertSame("B", entry.getKey());
         assertSame("y", entry.getValue());
-        
-        entry = new TiedMapEntry(map, "C");
+
+        entry = new TiedMapEntry<K, V>(map, (K) "C");
         assertSame("C", entry.getKey());
         assertSame("c", entry.getValue());
-        assertSame("c", entry.setValue("z"));
+        assertSame("c", entry.setValue((V) "z"));
         assertSame("C", entry.getKey());
         assertSame("z", entry.getValue());
     }

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestUnmodifiableMapEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestUnmodifiableMapEntry.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestUnmodifiableMapEntry.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/keyvalue/TestUnmodifiableMapEntry.java Tue Sep 15 05:29:56 2009
@@ -32,11 +32,10 @@
  *
  * @author Neil O'Toole
  */
-public class TestUnmodifiableMapEntry extends AbstractTestMapEntry {
+public class TestUnmodifiableMapEntry<K, V> extends AbstractTestMapEntry<K, V> {
 
     public TestUnmodifiableMapEntry(String testName) {
         super(testName);
-
     }
 
     public static void main(String[] args) {
@@ -53,8 +52,8 @@
      * Subclasses should override this method to return a Map.Entry
      * of the type being tested.
      */
-    public Map.Entry makeMapEntry() {
-        return new UnmodifiableMapEntry(null, null);
+    public Map.Entry<K, V> makeMapEntry() {
+        return new UnmodifiableMapEntry<K, V>(null, null);
     }
 
     /**
@@ -62,8 +61,8 @@
      * Subclasses should override this method to return a Map.Entry
      * of the type being tested.
      */
-    public Map.Entry makeMapEntry(Object key, Object value) {
-        return new UnmodifiableMapEntry(key, value);
+    public Map.Entry<K, V> makeMapEntry(K key, V value) {
+        return new UnmodifiableMapEntry<K, V>(key, value);
     }
 
     //-----------------------------------------------------------------------
@@ -71,28 +70,30 @@
      * Subclasses should override this method.
      *
      */
+    @SuppressWarnings("unchecked")
     public void testConstructors() {
         // 1. test key-value constructor
-        Map.Entry entry = new UnmodifiableMapEntry(key, value);
+        Map.Entry<K, V> entry = new UnmodifiableMapEntry<K, V>((K) key, (V) value);
         assertSame(key, entry.getKey());
         assertSame(value, entry.getValue());
 
         // 2. test pair constructor
-        KeyValue pair = new DefaultKeyValue(key, value);
-        entry = new UnmodifiableMapEntry(pair);
+        KeyValue<K, V> pair = new DefaultKeyValue<K, V>((K) key, (V) value);
+        entry = new UnmodifiableMapEntry<K, V>(pair);
         assertSame(key, entry.getKey());
         assertSame(value, entry.getValue());
 
         // 3. test copy constructor
-        Map.Entry entry2 = new UnmodifiableMapEntry(entry);
+        Map.Entry<K, V> entry2 = new UnmodifiableMapEntry<K, V>(entry);
         assertSame(key, entry2.getKey());
         assertSame(value, entry2.getValue());
 
         assertTrue(entry instanceof Unmodifiable);
     }
 
+    @SuppressWarnings("unchecked")
     public void testAccessorsAndMutators() {
-        Map.Entry entry = makeMapEntry(key, value);
+        Map.Entry<K, V> entry = makeMapEntry((K) key, (V) value);
 
         assertSame(key, entry.getKey());
         assertSame(value, entry.getValue());
@@ -108,11 +109,10 @@
     }
 
     public void testUnmodifiable() {
-        Map.Entry entry = makeMapEntry();
+        Map.Entry<K, V> entry = makeMapEntry();
         try {
             entry.setValue(null);
             fail();
-
         } catch (UnsupportedOperationException ex) {}
     }
 

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestAbstractLinkedList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestAbstractLinkedList.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestAbstractLinkedList.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestAbstractLinkedList.java Tue Sep 15 05:29:56 2009
@@ -27,100 +27,104 @@
  * @author David Hay
  * @author Phil Steitz
  */
-public abstract class TestAbstractLinkedList extends AbstractTestList {
-    
+public abstract class TestAbstractLinkedList<E> extends AbstractTestList<E> {
+
     public TestAbstractLinkedList(String testName) {
         super(testName);
     }
 
-    //-----------------------------------------------------------------------    
+    //-----------------------------------------------------------------------
+    @SuppressWarnings("unchecked")
     public void testRemoveFirst() {
         resetEmpty();
-        AbstractLinkedList list = (AbstractLinkedList) collection;
+        AbstractLinkedList<E> list = getCollection();
         if (isRemoveSupported() == false) {
             try {
                 list.removeFirst();
             } catch (UnsupportedOperationException ex) {}
-        } 
-        
-        list.addAll( Arrays.asList( new String[]{"value1", "value2"}));
-        assertEquals( "value1", list.removeFirst() );
+        }
+
+        list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
+        assertEquals("value1", list.removeFirst());
         checkNodes();
-        list.addLast( "value3");
+        list.addLast((E) "value3");
         checkNodes();
-        assertEquals( "value2", list.removeFirst() );
-        assertEquals( "value3", list.removeFirst() );
+        assertEquals("value2", list.removeFirst());
+        assertEquals("value3", list.removeFirst());
         checkNodes();
-        list.addLast( "value4" );
+        list.addLast((E) "value4");
         checkNodes();
-        assertEquals( "value4", list.removeFirst() );
+        assertEquals("value4", list.removeFirst());
         checkNodes();
     }
-    
+
+    @SuppressWarnings("unchecked")
     public void testRemoveLast() {
         resetEmpty();
-        AbstractLinkedList list = (AbstractLinkedList) collection;
+        AbstractLinkedList<E> list = getCollection();
         if (isRemoveSupported() == false) {
             try {
                 list.removeLast();
             } catch (UnsupportedOperationException ex) {}
-        } 
-        
-        list.addAll( Arrays.asList( new String[]{"value1", "value2"}));
-        assertEquals( "value2", list.removeLast() );
-        list.addFirst( "value3");
-        checkNodes();
-        assertEquals( "value1", list.removeLast() );
-        assertEquals( "value3", list.removeLast() );
-        list.addFirst( "value4" );
+        }
+
+        list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
+        assertEquals("value2", list.removeLast());
+        list.addFirst((E) "value3");
+        checkNodes();
+        assertEquals("value1", list.removeLast());
+        assertEquals("value3", list.removeLast());
+        list.addFirst((E) "value4");
         checkNodes();
-        assertEquals( "value4", list.removeFirst() );
+        assertEquals("value4", list.removeFirst());
     }
-    
+
+    @SuppressWarnings("unchecked")
     public void testAddNodeAfter() {
         resetEmpty();
-        AbstractLinkedList list = (AbstractLinkedList) collection;
+        AbstractLinkedList<E> list = getCollection();
         if (isAddSupported() == false) {
             try {
                 list.addFirst(null);
             } catch (UnsupportedOperationException ex) {}
-        } 
-        
-        list.addFirst("value1");
-        list.addNodeAfter(list.getNode(0,false),"value2");
+        }
+
+        list.addFirst((E) "value1");
+        list.addNodeAfter(list.getNode(0, false), (E) "value2");
         assertEquals("value1", list.getFirst());
         assertEquals("value2", list.getLast());
         list.removeFirst();
         checkNodes();
-        list.addNodeAfter(list.getNode(0,false),"value3");
+        list.addNodeAfter(list.getNode(0, false), (E) "value3");
         checkNodes();
         assertEquals("value2", list.getFirst());
         assertEquals("value3", list.getLast());
-        list.addNodeAfter(list.getNode(0, false),"value4");
+        list.addNodeAfter(list.getNode(0, false), (E) "value4");
         checkNodes();
         assertEquals("value2", list.getFirst());
         assertEquals("value3", list.getLast());
         assertEquals("value4", list.get(1));
-        list.addNodeAfter(list.getNode(2, false), "value5");
+        list.addNodeAfter(list.getNode(2, false), (E) "value5");
         checkNodes();
         assertEquals("value2", list.getFirst());
         assertEquals("value4", list.get(1));
         assertEquals("value3", list.get(2));
         assertEquals("value5", list.getLast());
     }
-    
+
+    @SuppressWarnings("unchecked")
     public void testRemoveNode() {
         resetEmpty();
         if (isAddSupported() == false || isRemoveSupported() == false) return;
-        AbstractLinkedList list = (AbstractLinkedList) collection;
-        
-        list.addAll( Arrays.asList( new String[]{"value1", "value2"}));
+        AbstractLinkedList<E> list = getCollection();
+
+        list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
         list.removeNode(list.getNode(0, false));
         checkNodes();
         assertEquals("value2", list.getFirst());
         assertEquals("value2", list.getLast());
-        list.addFirst("value1");
-        list.addFirst("value0");
+        list.addFirst((E) "value1");
+        list.addFirst((E) "value0");
         checkNodes();
         list.removeNode(list.getNode(1, false));
         assertEquals("value0", list.getFirst());
@@ -131,53 +135,61 @@
         assertEquals("value0", list.getLast());
         checkNodes();
     }
-    
+
+    @SuppressWarnings("unchecked")
     public void testGetNode() {
         resetEmpty();
-        AbstractLinkedList list = (AbstractLinkedList) collection;
+        AbstractLinkedList<E> list = getCollection();
         // get marker
         assertEquals(list.getNode(0, true).previous, list.getNode(0, true).next);
         try {
-            Object obj = list.getNode(0, false);
+            list.getNode(0, false);
             fail("Expecting IndexOutOfBoundsException.");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
-        list.addAll( Arrays.asList( new String[]{"value1", "value2"}));
+        list.addAll( Arrays.asList((E[]) new String[]{"value1", "value2"}));
         checkNodes();
-        list.addFirst("value0");
+        list.addFirst((E) "value0");
         checkNodes();
         list.removeNode(list.getNode(1, false));
         checkNodes();
         try {
-            Object obj = list.getNode(2, false);
+            list.getNode(2, false);
             fail("Expecting IndexOutOfBoundsException.");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
-            Object obj = list.getNode(-1, false);
+            list.getNode(-1, false);
             fail("Expecting IndexOutOfBoundsException.");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
          try {
-            Object obj = list.getNode(3, true);
+            list.getNode(3, true);
             fail("Expecting IndexOutOfBoundsException.");
         } catch (IndexOutOfBoundsException ex) {
             // expected
-        }       
+        }
     }
-    
+
     protected void checkNodes() {
-        AbstractLinkedList list = (AbstractLinkedList) collection;
+        AbstractLinkedList<E> list = getCollection();
         for (int i = 0; i < list.size; i++) {
             assertEquals(list.getNode(i, false).next, list.getNode(i + 1, true));
             if (i < list.size - 1) {
-                assertEquals(list.getNode(i + 1, false).previous, 
-                    list.getNode(i, false));  
+                assertEquals(list.getNode(i + 1, false).previous,
+                    list.getNode(i, false));
             }
         }
     }
-        
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public AbstractLinkedList<E> getCollection() {
+        return (AbstractLinkedList<E>) super.getCollection();
+    }
 }

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestFixedSizeList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestFixedSizeList.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestFixedSizeList.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestFixedSizeList.java Tue Sep 15 05:29:56 2009
@@ -32,7 +32,7 @@
  *
  * @author Stephen Colebourne
  */
-public class TestFixedSizeList extends AbstractTestList {
+public class TestFixedSizeList<E> extends AbstractTestList<E> {
 
     public TestFixedSizeList(String testName) {
         super(testName);
@@ -47,16 +47,16 @@
         junit.textui.TestRunner.main(testCaseName);
     }
 
-    public List makeEmptyList() {
-        return FixedSizeList.decorate(new ArrayList());
+    public List<E> makeObject() {
+        return FixedSizeList.decorate(new ArrayList<E>());
     }
 
-    public List makeFullList() {
-        List list = new ArrayList();
+    public List<E> makeFullCollection() {
+        List<E> list = new ArrayList<E>();
         list.addAll(Arrays.asList(getFullElements()));
         return FixedSizeList.decorate(list);
     }
-    
+
     public boolean isAddSupported() {
         return false;
     }

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestGrowthList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestGrowthList.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestGrowthList.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestGrowthList.java Tue Sep 15 05:29:56 2009
@@ -32,7 +32,7 @@
  *
  * @author Stephen Colebourne
  */
-public class TestGrowthList extends AbstractTestList {
+public class TestGrowthList<E> extends AbstractTestList<E> {
 
     public TestGrowthList(String testName) {
         super(testName);
@@ -47,12 +47,12 @@
         junit.textui.TestRunner.main(testCaseName);
     }
 
-    public List makeEmptyList() {
-        return new GrowthList();
+    public List<E> makeObject() {
+        return new GrowthList<E>();
     }
 
-    public List makeFullList() {
-        List list = new ArrayList();
+    public List<E> makeFullCollection() {
+        List<E> list = new ArrayList<E>();
         list.addAll(Arrays.asList(getFullElements()));
         return GrowthList.decorate(list);
     }
@@ -60,7 +60,7 @@
     //-----------------------------------------------------------------------
     public void testGrowthAdd() {
         Integer one = new Integer(1);
-        GrowthList grower = new GrowthList();
+        GrowthList<Integer> grower = new GrowthList<Integer>();
         assertEquals(0, grower.size());
         grower.add(1, one);
         assertEquals(2, grower.size());
@@ -71,10 +71,10 @@
     public void testGrowthAddAll() {
         Integer one = new Integer(1);
         Integer two = new Integer(2);
-        Collection coll = new ArrayList();
+        Collection<Integer> coll = new ArrayList<Integer>();
         coll.add(one);
         coll.add(two);
-        GrowthList grower = new GrowthList();
+        GrowthList<Integer> grower = new GrowthList<Integer>();
         assertEquals(0, grower.size());
         grower.addAll(1, coll);
         assertEquals(3, grower.size());
@@ -85,7 +85,7 @@
 
     public void testGrowthSet1() {
         Integer one = new Integer(1);
-        GrowthList grower = new GrowthList();
+        GrowthList<Integer> grower = new GrowthList<Integer>();
         assertEquals(0, grower.size());
         grower.set(1, one);
         assertEquals(2, grower.size());
@@ -95,7 +95,7 @@
 
     public void testGrowthSet2() {
         Integer one = new Integer(1);
-        GrowthList grower = new GrowthList();
+        GrowthList<Integer> grower = new GrowthList<Integer>();
         assertEquals(0, grower.size());
         grower.set(0, one);
         assertEquals(1, grower.size());
@@ -107,10 +107,10 @@
      * Override.
      */
     public void testListAddByIndexBoundsChecking() {
-        List list;
-        Object element = getOtherElements()[0];
+        List<E> list;
+        E element = getOtherElements()[0];
         try {
-            list = makeEmptyList();
+            list = makeObject();
             list.add(-1, element);
             fail("List.add should throw IndexOutOfBoundsException [-1]");
         } catch (IndexOutOfBoundsException e) {
@@ -122,10 +122,10 @@
      * Override.
      */
     public void testListAddByIndexBoundsChecking2() {
-        List list;
-        Object element = getOtherElements()[0];
+        List<E> list;
+        E element = getOtherElements()[0];
         try {
-            list = makeFullList();
+            list = makeFullCollection();
             list.add(-1, element);
             fail("List.add should throw IndexOutOfBoundsException [-1]");
         } catch (IndexOutOfBoundsException e) {
@@ -137,8 +137,8 @@
      * Override.
      */
     public void testListSetByIndexBoundsChecking() {
-        List list = makeEmptyList();
-        Object element = getOtherElements()[0];
+        List<E> list = makeObject();
+        E element = getOtherElements()[0];
         try {
             list.set(-1, element);
             fail("List.set should throw IndexOutOfBoundsException [-1]");
@@ -151,8 +151,8 @@
      * Override.
      */
     public void testListSetByIndexBoundsChecking2() {
-        List list = makeFullList();
-        Object element = getOtherElements()[0];
+        List<E> list = makeFullCollection();
+        E element = getOtherElements()[0];
         try {
             list.set(-1, element);
             fail("List.set should throw IndexOutOfBoundsException [-1]");

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestNodeCachingLinkedList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestNodeCachingLinkedList.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestNodeCachingLinkedList.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestNodeCachingLinkedList.java Tue Sep 15 05:29:56 2009
@@ -18,7 +18,6 @@
 
 import java.util.Arrays;
 import java.util.LinkedList;
-import java.util.List;
 
 import junit.framework.Test;
 
@@ -32,7 +31,7 @@
  * @author Jeff Varszegi
  * @author Phil Steitz
  */
-public class TestNodeCachingLinkedList extends TestAbstractLinkedList {
+public class TestNodeCachingLinkedList<E> extends TestAbstractLinkedList<E> {
 
     public TestNodeCachingLinkedList(String testName) {
         super(testName);
@@ -48,49 +47,50 @@
         return BulkTest.makeSuite(TestNodeCachingLinkedList.class);
     }
 
-    //-----------------------------------------------------------------------    
-    public List makeEmptyList() {
-        return new NodeCachingLinkedList();
+    //-----------------------------------------------------------------------
+    public NodeCachingLinkedList<E> makeObject() {
+        return new NodeCachingLinkedList<E>();
     }
 
     public String getCompatibilityVersion() {
         return "3";
     }
-    
+
     //-----------------------------------------------------------------------
+    @SuppressWarnings("unchecked")
     public void testShrinkCache() {
         if (isRemoveSupported() == false || isAddSupported() == false) return;
         resetEmpty();
-        NodeCachingLinkedList list = (NodeCachingLinkedList) collection;
-        
-        list.addAll( Arrays.asList( new String[]{"1", "2", "3", "4"}));
-        list.removeAllNodes();        // Will dump all 4 elements into cache
-        ((NodeCachingLinkedList) list).setMaximumCacheSize(2); // shrink cache
-        list.addAll( Arrays.asList( new String[]{"1", "2", "3", "4"}));
+        NodeCachingLinkedList<E> list = getCollection();
+
+        list.addAll(Arrays.asList((E[]) new String[] { "1", "2", "3", "4" }));
+        list.removeAllNodes(); // Will dump all 4 elements into cache
+        list.setMaximumCacheSize(2); // shrink cache
+        list.addAll(Arrays.asList((E[]) new String[] { "1", "2", "3", "4" }));
         checkNodes();
         list.removeNode(list.getNode(0, false)); // no room in cache
-        list.removeNode(list.getNode(0, false)); 
-        list.removeNode(list.getNode(0, false)); 
-        checkNodes();    
-        list.addAll( Arrays.asList( new String[]{"1", "2", "3", "4"}));
-        checkNodes();     
-    }       
-    
+        list.removeNode(list.getNode(0, false));
+        list.removeNode(list.getNode(0, false));
+        checkNodes();
+        list.addAll(Arrays.asList((E[]) new String[] { "1", "2", "3", "4" }));
+        checkNodes();
+    }
+
     //-----------------------------------------------------------------------
     public static void compareSpeed() {
-        NodeCachingLinkedList ncll = new NodeCachingLinkedList();
-        LinkedList ll = new LinkedList();
-        
+        NodeCachingLinkedList<Object> ncll = new NodeCachingLinkedList<Object>();
+        LinkedList<Object> ll = new LinkedList<Object>();
+
         Object o1 = new Object();
         Object o2 = new Object();
-        
+
         int loopCount = 4000000;
-        
+
         long startTime, endTime;
-        
+
         System.out.println("Testing relative execution time of commonly-used methods...");
-        
-        startTime = System.currentTimeMillis();   
+
+        startTime = System.currentTimeMillis();
         for(int x = loopCount; x > 0; x--) {
             // unrolled a few times to minimize effect of loop
             ll.addFirst(o1);
@@ -114,10 +114,10 @@
             ll.add(o1);
             ll.remove(0);
         }
-        endTime = System.currentTimeMillis();   
+        endTime = System.currentTimeMillis();
         System.out.println("Time with LinkedList: " + (endTime - startTime) + " ms");
 
-        startTime = System.currentTimeMillis();   
+        startTime = System.currentTimeMillis();
         for(int x = loopCount; x > 0; x--) {
             ncll.addFirst(o1);
             ncll.addLast(o2);
@@ -140,11 +140,11 @@
             ncll.add(o1);
             ncll.remove(0);
         }
-        endTime = System.currentTimeMillis();   
+        endTime = System.currentTimeMillis();
         System.out.println("Time with NodeCachingLinkedList: " + (endTime - startTime) + " ms");
 
     }
-    
+
 //    public void testCreate() throws Exception {
 //        resetEmpty();
 //        writeExternalFormToDisk((java.io.Serializable) collection,
@@ -153,4 +153,12 @@
 //        writeExternalFormToDisk((java.io.Serializable) collection,
 //            "D:/dev/collections/data/test/NodeCachingLinkedList.fullCollection.version3.obj");
 //    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public NodeCachingLinkedList<E> getCollection() {
+        return (NodeCachingLinkedList<E>) super.getCollection();
+    }
 }

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestPredicatedList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestPredicatedList.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestPredicatedList.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/list/TestPredicatedList.java Tue Sep 15 05:29:56 2009
@@ -23,7 +23,7 @@
 import junit.framework.TestSuite;
 
 import org.apache.commons.collections.Predicate;
-import org.apache.commons.collections.PredicateUtils;
+import org.apache.commons.collections.functors.TruePredicate;
 
 /**
  * Extension of {@link AbstractTestList} for exercising the 
@@ -34,113 +34,118 @@
  *
  * @author Phil Steitz
  */
-public class TestPredicatedList extends AbstractTestList {
-    
+public class TestPredicatedList<E> extends AbstractTestList<E> {
+
     public TestPredicatedList(String testName) {
         super(testName);
     }
-    
+
     public static Test suite() {
         return new TestSuite(TestPredicatedList.class);
     }
-    
+
     public static void main(String args[]) {
         String[] testCaseName = { TestPredicatedList.class.getName()};
         junit.textui.TestRunner.main(testCaseName);
     }
-    
+
  //-------------------------------------------------------------------
-    
-    protected Predicate truePredicate = PredicateUtils.truePredicate();
-    
-    protected List decorateList(List list, Predicate predicate) {
+
+    protected Predicate<E> truePredicate = TruePredicate.<E>truePredicate();
+
+    protected List<E> decorateList(List<E> list, Predicate<E> predicate) {
         return PredicatedList.decorate(list, predicate);
     }
-    
-    public List makeEmptyList() {
-        return decorateList(new ArrayList(), truePredicate);
-    }
-    
-    public Object[] getFullElements() {
-        return new Object[] {"1", "3", "5", "7", "2", "4", "6"};
-    }
-    
-//--------------------------------------------------------------------   
-    
-     protected Predicate testPredicate =  
-        new Predicate() {
-            public boolean evaluate(Object o) {
+
+    public List<E> makeObject() {
+        return decorateList(new ArrayList<E>(), truePredicate);
+    }
+
+    @SuppressWarnings("unchecked")
+    public E[] getFullElements() {
+        return (E[]) new Object[] { "1", "3", "5", "7", "2", "4", "6" };
+    }
+
+//--------------------------------------------------------------------
+
+    protected Predicate<E> testPredicate =
+        new Predicate<E>() {
+            public boolean evaluate(E o) {
                 return o instanceof String;
             }
-        };      
-    
-    public List makeTestList() {
-        return decorateList(new ArrayList(), testPredicate);
+        };
+
+    public List<E> makeTestList() {
+        return decorateList(new ArrayList<E>(), testPredicate);
     }
-    
+
+    @SuppressWarnings("unchecked")
     public void testIllegalAdd() {
-        List list = makeTestList();
+        List<E> list = makeTestList();
         Integer i = new Integer(3);
         try {
-            list.add(i);
+            list.add((E) i);
             fail("Integer should fail string predicate.");
         } catch (IllegalArgumentException e) {
             // expected
         }
-        assertTrue("Collection shouldn't contain illegal element", 
-         !list.contains(i));   
+        assertTrue("Collection shouldn't contain illegal element",
+         !list.contains(i));
     }
 
+    @SuppressWarnings("unchecked")
     public void testIllegalAddAll() {
-        List list = makeTestList();
-        List elements = new ArrayList();
-        elements.add("one");
-        elements.add("two");
-        elements.add(new Integer(3));
-        elements.add("four");
+        List<E> list = makeTestList();
+        List<E> elements = new ArrayList<E>();
+        elements.add((E) "one");
+        elements.add((E) "two");
+        elements.add((E) new Integer(3));
+        elements.add((E) "four");
         try {
-            list.addAll(0,elements);
+            list.addAll(0, elements);
             fail("Integer should fail string predicate.");
         } catch (IllegalArgumentException e) {
             // expected
         }
-        assertTrue("List shouldn't contain illegal element", 
-         !list.contains("one"));   
-        assertTrue("List shouldn't contain illegal element", 
-         !list.contains("two"));   
-        assertTrue("List shouldn't contain illegal element", 
-         !list.contains(new Integer(3)));   
-        assertTrue("List shouldn't contain illegal element", 
-         !list.contains("four"));   
+        assertTrue("List shouldn't contain illegal element",
+         !list.contains("one"));
+        assertTrue("List shouldn't contain illegal element",
+         !list.contains("two"));
+        assertTrue("List shouldn't contain illegal element",
+         !list.contains(new Integer(3)));
+        assertTrue("List shouldn't contain illegal element",
+         !list.contains("four"));
     }
-    
+
+    @SuppressWarnings("unchecked")
     public void testIllegalSet() {
-        List list = makeTestList();
+        List<E> list = makeTestList();
         try {
-            list.set(0,new Integer(3));
+            list.set(0, (E) new Integer(3));
             fail("Integer should fail string predicate.");
         } catch (IllegalArgumentException e) {
             // expected
         }
     }
-    
+
+    @SuppressWarnings("unchecked")
     public void testLegalAddAll() {
-        List list = makeTestList();
-        list.add("zero");
-        List elements = new ArrayList();
-        elements.add("one");
-        elements.add("two");
-        elements.add("three");
+        List<E> list = makeTestList();
+        list.add((E) "zero");
+        List<E> elements = new ArrayList<E>();
+        elements.add((E) "one");
+        elements.add((E) "two");
+        elements.add((E) "three");
         list.addAll(1,elements);
-        assertTrue("List should contain legal element", 
-         list.contains("zero"));   
-        assertTrue("List should contain legal element", 
-         list.contains("one"));   
-        assertTrue("List should contain legal element", 
-         list.contains("two"));   
-        assertTrue("List should contain legal element", 
-         list.contains("three"));   
-    }       
+        assertTrue("List should contain legal element",
+         list.contains("zero"));
+        assertTrue("List should contain legal element",
+         list.contains("one"));
+        assertTrue("List should contain legal element",
+         list.contains("two"));
+        assertTrue("List should contain legal element",
+         list.contains("three"));
+    }
 
     public String getCompatibilityVersion() {
         return "3.1";