commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r738956 [26/34] - in /commons/proper/collections/branches/collections_jdk5_branch/src: java/org/apache/commons/collections/ java/org/apache/commons/collections/bag/ java/org/apache/commons/collections/bidimap/ java/org/apache/commons/collec...
Date Thu, 29 Jan 2009 18:48:47 GMT
Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestObjectArrayListIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestObjectArrayListIterator.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestObjectArrayListIterator.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestObjectArrayListIterator.java Thu Jan 29 18:48:37 2009
@@ -17,7 +17,6 @@
 package org.apache.commons.collections.iterators;
 
 import java.util.Arrays;
-import java.util.Iterator;
 import java.util.ListIterator;
 import java.util.NoSuchElementException;
 
@@ -31,7 +30,7 @@
  * 
  * @author Neil O'Toole
  */
-public class TestObjectArrayListIterator extends TestObjectArrayIterator {
+public class TestObjectArrayListIterator<E> extends TestObjectArrayIterator<E> {
 
     public TestObjectArrayListIterator(String testName) {
         super(testName);
@@ -41,16 +40,18 @@
         return new TestSuite(TestObjectArrayListIterator.class);
     }
 
-    public Iterator makeEmptyIterator() {
-        return new ObjectArrayListIterator(new Object[0]);
+    @SuppressWarnings("unchecked")
+    public ObjectArrayListIterator<E> makeEmptyIterator() {
+        return new ObjectArrayListIterator<E>((E[]) new Object[0]);
     }
 
-    public Iterator makeFullIterator() {
-        return new ObjectArrayListIterator(testArray);
+    @SuppressWarnings("unchecked")
+    public ObjectArrayListIterator<E> makeObject() {
+        return new ObjectArrayListIterator<E>((E[]) testArray);
     }
 
-    public ListIterator makeArrayListIterator(Object[] array) {
-        return new ObjectArrayListIterator(array);
+    public ObjectArrayListIterator<E> makeArrayListIterator(E[] array) {
+        return new ObjectArrayListIterator<E>(array);
     }
 
     /**
@@ -58,7 +59,7 @@
      * <code>previous()</code>.
      */
     public void testListIterator() {
-        ListIterator iter = (ListIterator) makeFullIterator();
+        ListIterator<E> iter = makeObject();
 
         // TestArrayIterator#testIterator() has already tested the iterator forward,
         //  now we need to test it in reverse
@@ -78,7 +79,7 @@
         assertTrue("Iterator should now be empty", !iter.hasPrevious());
 
         try {
-            Object testValue = iter.previous();
+            iter.previous();
         } catch (Exception e) {
             assertTrue(
                 "NoSuchElementException must be thrown",
@@ -90,27 +91,28 @@
     /**
      * Tests the {@link java.util.ListIterator#set} operation.
      */
+    @SuppressWarnings("unchecked")
     public void testListIteratorSet() {
         String[] testData = new String[] { "a", "b", "c" };
 
         String[] result = new String[] { "0", "1", "2" };
 
-        ListIterator iter = (ListIterator) makeArrayListIterator(testData);
+        ListIterator<E> iter = makeArrayListIterator((E[]) testData);
         int x = 0;
 
         while (iter.hasNext()) {
             iter.next();
-            iter.set(Integer.toString(x));
+            iter.set((E) Integer.toString(x));
             x++;
         }
 
         assertTrue("The two arrays should have the same value, i.e. {0,1,2}", Arrays.equals(testData, result));
 
         // a call to set() before a call to next() or previous() should throw an IllegalStateException
-        iter = makeArrayListIterator(testArray);
+        iter = makeArrayListIterator((E[]) testArray);
 
         try {
-            iter.set("should fail");
+            iter.set((E) "should fail");
             fail("ListIterator#set should fail if next() or previous() have not yet been called.");
         } catch (IllegalStateException e) {
             // expected

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestObjectArrayListIterator2.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestObjectArrayListIterator2.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestObjectArrayListIterator2.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestObjectArrayListIterator2.java Thu Jan 29 18:48:37 2009
@@ -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.
@@ -16,22 +16,20 @@
  */
 package org.apache.commons.collections.iterators;
 
-import java.util.ListIterator;
-
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
 /**
  * Tests the ObjectArrayListIterator class.
- * 
+ *
  * @version $Revision$ $Date$
- * 
+ *
  * @author Stephen Colebourne
  */
-public class TestObjectArrayListIterator2 extends AbstractTestListIterator {
+public class TestObjectArrayListIterator2<E> extends AbstractTestListIterator<E> {
 
     protected String[] testArray = { "One", "Two", "Three" };
-    
+
     public TestObjectArrayListIterator2(String testName) {
         super(testName);
     }
@@ -40,22 +38,24 @@
         return new TestSuite(TestObjectArrayListIterator2.class);
     }
 
-    public ListIterator makeEmptyListIterator() {
-        return new ObjectArrayListIterator(new Object[0]);
+    @SuppressWarnings("unchecked")
+    public ObjectArrayListIterator<E> makeEmptyIterator() {
+        return new ObjectArrayListIterator<E>((E[]) new Object[0]);
     }
 
-    public ListIterator makeFullListIterator() {
-        return new ObjectArrayListIterator(testArray);
+    @SuppressWarnings("unchecked")
+    public ObjectArrayListIterator<E> makeObject() {
+        return new ObjectArrayListIterator<E>((E[]) testArray);
     }
 
-    public ListIterator makeArrayListIterator(Object[] array) {
-        return new ObjectArrayListIterator(array);
+    public ObjectArrayListIterator<E> makeArrayListIterator(E[] array) {
+        return new ObjectArrayListIterator<E>(array);
     }
 
     public boolean supportsAdd() {
         return false;
     }
-    
+
     public boolean supportsRemove() {
         return false;
     }

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestObjectGraphIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestObjectGraphIterator.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestObjectGraphIterator.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestObjectGraphIterator.java Thu Jan 29 18:48:37 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/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestReverseListIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestReverseListIterator.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestReverseListIterator.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestReverseListIterator.java Thu Jan 29 18:48:37 2009
@@ -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.
@@ -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/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestSingletonIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestSingletonIterator.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestSingletonIterator.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestSingletonIterator.java Thu Jan 29 18:48:37 2009
@@ -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.
@@ -29,35 +29,36 @@
  * perform the iteration rather than the hasNext() method.
  *
  * @version $Revision$ $Date$
- * 
+ *
  * @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/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestSingletonIterator2.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestSingletonIterator2.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestSingletonIterator2.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestSingletonIterator2.java Thu Jan 29 18:48:37 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/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestSingletonListIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestSingletonListIterator.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestSingletonListIterator.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestSingletonListIterator.java Thu Jan 29 18:48:37 2009
@@ -31,7 +31,7 @@
  * 
  * @author Stephen Colebourne
  */
-public class TestSingletonListIterator extends AbstractTestListIterator {
+public class TestSingletonListIterator<E> extends AbstractTestListIterator<E> {
 
     private static final Object testValue = "foo";
     
@@ -47,16 +47,17 @@
      * Returns a SingletonListIterator from which 
      * the element has already been removed.
      */
-    public ListIterator makeEmptyListIterator() {
-        SingletonListIterator iter = (SingletonListIterator)makeFullIterator();
+    public SingletonListIterator<E> makeEmptyIterator() {
+        SingletonListIterator<E> iter = makeObject();
         iter.next();
         iter.remove();
         iter.reset();        
         return iter;
     }
 
-    public ListIterator makeFullListIterator() {
-        return new SingletonListIterator( testValue );
+    @SuppressWarnings("unchecked")
+    public SingletonListIterator<E> makeObject() {
+        return new SingletonListIterator<E>((E) testValue);
     }
 
     public boolean supportsAdd() {
@@ -72,7 +73,7 @@
     }
 
     public void testIterator() {
-        ListIterator iter = (ListIterator) makeObject();
+        ListIterator<E> iter = makeObject();
         assertTrue( "Iterator should have next item", iter.hasNext() );
         assertTrue( "Iterator should have no previous item", !iter.hasPrevious() );
         assertEquals( "Iteration next index", 0, iter.nextIndex() );
@@ -118,7 +119,7 @@
     }
     
     public void testReset() {
-        ResettableListIterator it = (ResettableListIterator) makeObject();
+        ResettableListIterator<E> it = makeObject();
         
         assertEquals(true, it.hasNext());
         assertEquals(false, it.hasPrevious());

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestUniqueFilterIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestUniqueFilterIterator.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestUniqueFilterIterator.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestUniqueFilterIterator.java Thu Jan 29 18:48:37 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/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestUnmodifiableIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestUnmodifiableIterator.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestUnmodifiableIterator.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestUnmodifiableIterator.java Thu Jan 29 18:48:37 2009
@@ -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.
@@ -29,15 +29,15 @@
 
 /**
  * Tests the UnmodifiableIterator.
- * 
+ *
  * @version $Revision$ $Date$
- * 
+ *
  * @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/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestUnmodifiableListIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestUnmodifiableListIterator.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestUnmodifiableListIterator.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestUnmodifiableListIterator.java Thu Jan 29 18:48:37 2009
@@ -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.
@@ -29,15 +29,15 @@
 
 /**
  * Tests the UnmodifiableListIterator.
- * 
+ *
  * @version $Revision$ $Date$
- * 
+ *
  * @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/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestUnmodifiableMapIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestUnmodifiableMapIterator.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestUnmodifiableMapIterator.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestUnmodifiableMapIterator.java Thu Jan 29 18:48:37 2009
@@ -22,19 +22,19 @@
 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;
 
 /**
  * Tests the UnmodifiableMapIterator.
- * 
+ *
  * @version $Revision$ $Date$
- * 
+ *
  * @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/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestUnmodifiableOrderedMapIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestUnmodifiableOrderedMapIterator.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestUnmodifiableOrderedMapIterator.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/TestUnmodifiableOrderedMapIterator.java Thu Jan 29 18:48:37 2009
@@ -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.
@@ -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;
@@ -31,12 +30,12 @@
 
 /**
  * Tests the UnmodifiableOrderedMapIterator.
- * 
+ *
  * @version $Revision$ $Date$
- * 
+ *
  * @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/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/keyvalue/AbstractTestMapEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/keyvalue/AbstractTestMapEntry.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/keyvalue/AbstractTestMapEntry.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/keyvalue/AbstractTestMapEntry.java Thu Jan 29 18:48:37 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/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/keyvalue/TestDefaultKeyValue.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/keyvalue/TestDefaultKeyValue.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/keyvalue/TestDefaultKeyValue.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/keyvalue/TestDefaultKeyValue.java Thu Jan 29 18:48:37 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/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/keyvalue/TestDefaultMapEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/keyvalue/TestDefaultMapEntry.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/keyvalue/TestDefaultMapEntry.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/keyvalue/TestDefaultMapEntry.java Thu Jan 29 18:48:37 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/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/keyvalue/TestMultiKey.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/keyvalue/TestMultiKey.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/keyvalue/TestMultiKey.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/keyvalue/TestMultiKey.java Thu Jan 29 18:48:37 2009
@@ -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,9 +25,9 @@
 
 /**
  * Unit tests for {@link org.apache.commons.collections.MultiKey}.
- * 
+ *
  * @version $Revision$ $Date$
- * 
+ *
  * @author Stephen Colebourne
  */
 public class TestMultiKey extends TestCase {
@@ -37,7 +37,7 @@
     Integer THREE = new Integer(3);
     Integer FOUR = new Integer(4);
     Integer FIVE = new Integer(5);
-    
+
     public TestMultiKey(String name) {
         super(name);
     }
@@ -58,87 +58,87 @@
     protected void tearDown() throws Exception {
         super.tearDown();
     }
-    
+
     //-----------------------------------------------------------------------
     public void testConstructors() throws Exception {
-        MultiKey mk = null;
-        mk = new MultiKey(ONE, TWO);
-        Assert.assertTrue(Arrays.equals(new Object[] {ONE, TWO}, mk.getKeys()));
+        MultiKey<Integer> mk = null;
+        mk = new MultiKey<Integer>(ONE, TWO);
+        Assert.assertTrue(Arrays.equals(new Object[] { ONE, TWO }, mk.getKeys()));
 
-        mk = new MultiKey(ONE, TWO, THREE);
-        Assert.assertTrue(Arrays.equals(new Object[] {ONE, TWO, THREE}, mk.getKeys()));
+        mk = new MultiKey<Integer>(ONE, TWO, THREE);
+        Assert.assertTrue(Arrays.equals(new Object[] { ONE, TWO, THREE }, mk.getKeys()));
 
-        mk = new MultiKey(ONE, TWO, THREE, FOUR);
-        Assert.assertTrue(Arrays.equals(new Object[] {ONE, TWO, THREE, FOUR}, mk.getKeys()));
+        mk = new MultiKey<Integer>(ONE, TWO, THREE, FOUR);
+        Assert.assertTrue(Arrays.equals(new Object[] { ONE, TWO, THREE, FOUR }, mk.getKeys()));
 
-        mk = new MultiKey(ONE, TWO, THREE, FOUR, FIVE);
-        Assert.assertTrue(Arrays.equals(new Object[] {ONE, TWO, THREE, FOUR, FIVE}, mk.getKeys()));
+        mk = new MultiKey<Integer>(ONE, TWO, THREE, FOUR, FIVE);
+        Assert.assertTrue(Arrays.equals(new Object[] { ONE, TWO, THREE, FOUR, FIVE }, mk.getKeys()));
 
-        mk = new MultiKey(new Object[] {THREE, FOUR, ONE, TWO}, false);
-        Assert.assertTrue(Arrays.equals(new Object[] {THREE, FOUR, ONE, TWO}, mk.getKeys()));
+        mk = new MultiKey<Integer>(new Integer[] { THREE, FOUR, ONE, TWO }, false);
+        Assert.assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys()));
     }
-    
+
     public void testConstructorsByArray() throws Exception {
-        MultiKey mk = null;
-        Object[] keys = new Object[] {THREE, FOUR, ONE, TWO};
-        mk = new MultiKey(keys);
-        Assert.assertTrue(Arrays.equals(new Object[] {THREE, FOUR, ONE, TWO}, mk.getKeys()));
+        MultiKey<Integer> mk = null;
+        Integer[] keys = new Integer[] { THREE, FOUR, ONE, TWO };
+        mk = new MultiKey<Integer>(keys);
+        Assert.assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys()));
         keys[3] = FIVE;  // no effect
-        Assert.assertTrue(Arrays.equals(new Object[] {THREE, FOUR, ONE, TWO}, mk.getKeys()));
+        Assert.assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys()));
 
-        keys = new Object[] {};
-        mk = new MultiKey(keys);
+        keys = new Integer[] {};
+        mk = new MultiKey<Integer>(keys);
         Assert.assertTrue(Arrays.equals(new Object[] {}, mk.getKeys()));
 
-        keys = new Object[] {THREE, FOUR, ONE, TWO};
-        mk = new MultiKey(keys, true);
-        Assert.assertTrue(Arrays.equals(new Object[] {THREE, FOUR, ONE, TWO}, mk.getKeys()));
+        keys = new Integer[] { THREE, FOUR, ONE, TWO };
+        mk = new MultiKey<Integer>(keys, true);
+        Assert.assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys()));
         keys[3] = FIVE;  // no effect
-        Assert.assertTrue(Arrays.equals(new Object[] {THREE, FOUR, ONE, TWO}, mk.getKeys()));
+        Assert.assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys()));
 
-        keys = new Object[] {THREE, FOUR, ONE, TWO};
-        mk = new MultiKey(keys, false);
-        Assert.assertTrue(Arrays.equals(new Object[] {THREE, FOUR, ONE, TWO}, mk.getKeys()));
+        keys = new Integer[] { THREE, FOUR, ONE, TWO };
+        mk = new MultiKey<Integer>(keys, false);
+        Assert.assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys()));
         // change key - don't do this!
         // the hashcode of the MultiKey is now broken
         keys[3] = FIVE;
-        Assert.assertTrue(Arrays.equals(new Object[] {THREE, FOUR, ONE, FIVE}, mk.getKeys()));
-    }        
-    
+        Assert.assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, FIVE }, mk.getKeys()));
+    }
+
     public void testConstructorsByArrayNull() throws Exception {
-        Object[] keys = null;
+        Integer[] keys = null;
         try {
-            new MultiKey(keys);
+            new MultiKey<Integer>(keys);
             fail();
         } catch (IllegalArgumentException ex) {}
         try {
-            new MultiKey(keys, true);
+            new MultiKey<Integer>(keys, true);
             fail();
         } catch (IllegalArgumentException ex) {}
         try {
-            new MultiKey(keys, false);
+            new MultiKey<Integer>(keys, false);
             fail();
         } catch (IllegalArgumentException ex) {}
     }
-    
+
     public void testSize() {
-        Assert.assertEquals(2, new MultiKey(ONE, TWO).size());
-        Assert.assertEquals(2, new MultiKey(null, null).size());
-        Assert.assertEquals(3, new MultiKey(ONE, TWO, THREE).size());
-        Assert.assertEquals(3, new MultiKey(null, null, null).size());
-        Assert.assertEquals(4, new MultiKey(ONE, TWO, THREE, FOUR).size());
-        Assert.assertEquals(4, new MultiKey(null, null, null, null).size());
-        Assert.assertEquals(5, new MultiKey(ONE, TWO, THREE, FOUR, FIVE).size());
-        Assert.assertEquals(5, new MultiKey(null, null, null, null, null).size());
-        
-        Assert.assertEquals(0, new MultiKey(new Object[] {}).size());
-        Assert.assertEquals(1, new MultiKey(new Object[] {ONE}).size());
-        Assert.assertEquals(2, new MultiKey(new Object[] {ONE, TWO}).size());
-        Assert.assertEquals(7, new MultiKey(new Object[] {ONE, TWO, ONE, TWO, ONE, TWO, ONE}).size());
+        Assert.assertEquals(2, new MultiKey<Integer>(ONE, TWO).size());
+        Assert.assertEquals(2, new MultiKey<Object>(null, null).size());
+        Assert.assertEquals(3, new MultiKey<Integer>(ONE, TWO, THREE).size());
+        Assert.assertEquals(3, new MultiKey<Object>(null, null, null).size());
+        Assert.assertEquals(4, new MultiKey<Integer>(ONE, TWO, THREE, FOUR).size());
+        Assert.assertEquals(4, new MultiKey<Object>(null, null, null, null).size());
+        Assert.assertEquals(5, new MultiKey<Integer>(ONE, TWO, THREE, FOUR, FIVE).size());
+        Assert.assertEquals(5, new MultiKey<Object>(null, null, null, null, null).size());
+
+        Assert.assertEquals(0, new MultiKey<Object>(new Object[] {}).size());
+        Assert.assertEquals(1, new MultiKey<Integer>(new Integer[] { ONE }).size());
+        Assert.assertEquals(2, new MultiKey<Integer>(new Integer[] { ONE, TWO }).size());
+        Assert.assertEquals(7, new MultiKey<Integer>(new Integer[] { ONE, TWO, ONE, TWO, ONE, TWO, ONE }).size());
     }
-    
+
     public void testGetIndexed() {
-        MultiKey mk = new MultiKey(ONE, TWO);
+        MultiKey<Integer> mk = new MultiKey<Integer>(ONE, TWO);
         Assert.assertSame(ONE, mk.getKey(0));
         Assert.assertSame(TWO, mk.getKey(1));
         try {
@@ -150,18 +150,18 @@
             fail();
         } catch (IndexOutOfBoundsException ex) {}
     }
-    
+
     public void testGetKeysSimpleConstructor() {
-        MultiKey mk = new MultiKey(ONE, TWO);
+        MultiKey<Integer> mk = new MultiKey<Integer>(ONE, TWO);
         Object[] array = mk.getKeys();
         Assert.assertSame(ONE, array[0]);
         Assert.assertSame(TWO, array[1]);
         Assert.assertEquals(2, array.length);
     }
-    
+
     public void testGetKeysArrayConstructorCloned() {
-        Object[] keys = new Object[] {ONE, TWO};
-        MultiKey mk = new MultiKey(keys, true);
+        Integer[] keys = new Integer[] { ONE, TWO };
+        MultiKey<Integer> mk = new MultiKey<Integer>(keys, true);
         Object[] array = mk.getKeys();
         Assert.assertTrue(array != keys);
         Assert.assertTrue(Arrays.equals(array, keys));
@@ -169,10 +169,10 @@
         Assert.assertSame(TWO, array[1]);
         Assert.assertEquals(2, array.length);
     }
-    
+
     public void testGetKeysArrayConstructorNonCloned() {
-        Object[] keys = new Object[] {ONE, TWO};
-        MultiKey mk = new MultiKey(keys, false);
+        Integer[] keys = new Integer[] { ONE, TWO };
+        MultiKey<Integer> mk = new MultiKey<Integer>(keys, false);
         Object[] array = mk.getKeys();
         Assert.assertTrue(array != keys);  // still not equal
         Assert.assertTrue(Arrays.equals(array, keys));
@@ -180,30 +180,30 @@
         Assert.assertSame(TWO, array[1]);
         Assert.assertEquals(2, array.length);
     }
-    
+
     public void testHashCode() {
-        MultiKey mk1 = new MultiKey(ONE, TWO);
-        MultiKey mk2 = new MultiKey(ONE, TWO);
-        MultiKey mk3 = new MultiKey(ONE, "TWO");
-        
+        MultiKey<Integer> mk1 = new MultiKey<Integer>(ONE, TWO);
+        MultiKey<Integer> mk2 = new MultiKey<Integer>(ONE, TWO);
+        MultiKey<Object> mk3 = new MultiKey<Object>(ONE, "TWO");
+
         Assert.assertTrue(mk1.hashCode() == mk1.hashCode());
         Assert.assertTrue(mk1.hashCode() == mk2.hashCode());
         Assert.assertTrue(mk1.hashCode() != mk3.hashCode());
-        
+
         int total = (0 ^ ONE.hashCode()) ^ TWO.hashCode();
         Assert.assertEquals(total, mk1.hashCode());
     }
-    
+
     public void testEquals() {
-        MultiKey mk1 = new MultiKey(ONE, TWO);
-        MultiKey mk2 = new MultiKey(ONE, TWO);
-        MultiKey mk3 = new MultiKey(ONE, "TWO");
-        
+        MultiKey<Integer> mk1 = new MultiKey<Integer>(ONE, TWO);
+        MultiKey<Integer> mk2 = new MultiKey<Integer>(ONE, TWO);
+        MultiKey<Object> mk3 = new MultiKey<Object>(ONE, "TWO");
+
         Assert.assertEquals(mk1, mk1);
         Assert.assertEquals(mk1, mk2);
         Assert.assertTrue(mk1.equals(mk3) == false);
         Assert.assertTrue(mk1.equals("") == false);
         Assert.assertTrue(mk1.equals(null) == false);
     }
-    
+
 }

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/keyvalue/TestTiedMapEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/keyvalue/TestTiedMapEntry.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/keyvalue/TestTiedMapEntry.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/keyvalue/TestTiedMapEntry.java Thu Jan 29 18:48:37 2009
@@ -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.
@@ -24,17 +24,16 @@
 
 /**
  * Test the TiedMapEntry class.
- * 
+ *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
- * 
+ *
  * @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/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/keyvalue/TestUnmodifiableMapEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/keyvalue/TestUnmodifiableMapEntry.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/keyvalue/TestUnmodifiableMapEntry.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/keyvalue/TestUnmodifiableMapEntry.java Thu Jan 29 18:48:37 2009
@@ -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.
@@ -26,17 +26,16 @@
 
 /**
  * Test the UnmodifiableMapEntry class.
- * 
+ *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
- * 
+ *
  * @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) {}
     }
 



Mime
View raw message