commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r738956 [24/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/collection/TestUnmodifiableCollection.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/collection/TestUnmodifiableCollection.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/collection/TestUnmodifiableCollection.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/collection/TestUnmodifiableCollection.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,48 +25,47 @@
 import junit.framework.TestSuite;
 
 /**
- * Extension of {@link AbstractTestCollection} for exercising the 
+ * Extension of {@link AbstractTestCollection} for exercising the
  * {@link UnmodifiableCollection} implementation.
  *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
- * 
+ *
  * @author Phil Steitz
  * @author Stephen Colebourne
  */
-public class TestUnmodifiableCollection extends AbstractTestCollection<Object> {
-    
+public class TestUnmodifiableCollection<E> extends AbstractTestCollection<E> {
+
     public TestUnmodifiableCollection(String testName) {
         super(testName);
     }
-    
+
     public static Test suite() {
         return new TestSuite(TestUnmodifiableCollection.class);
     }
-    
+
     public static void main(String args[]) {
         String[] testCaseName = { TestUnmodifiableCollection.class.getName()};
         junit.textui.TestRunner.main(testCaseName);
     }
 
-    //-----------------------------------------------------------------------    
-    public Collection<Object> makeCollection() {
-        return UnmodifiableCollection.decorate(new ArrayList<Object>());
-    }
-    
-    public Collection<Object> makeFullCollection() {
-        List<Object> list = new ArrayList<Object>();
+    //-----------------------------------------------------------------------
+    public Collection<E> makeObject() {
+        return UnmodifiableCollection.decorate(new ArrayList<E>());
+    }
+
+    public Collection<E> makeFullCollection() {
+        List<E> list = new ArrayList<E>();
         list.addAll(Arrays.asList(getFullElements()));
         return UnmodifiableCollection.decorate(list);
     }
-    
-    public Collection<Object> makeConfirmedCollection() {
-        ArrayList<Object> list = new ArrayList<Object>();
-        return list;
+
+    public Collection<E> makeConfirmedCollection() {
+        return new ArrayList<E>();
     }
 
-    public Collection<Object> makeConfirmedFullCollection() {
-        ArrayList<Object> list = new ArrayList<Object>();
+    public Collection<E> makeConfirmedFullCollection() {
+        ArrayList<E> list = new ArrayList<E>();
         list.addAll(Arrays.asList(getFullElements()));
         return list;
     }
@@ -74,7 +73,7 @@
     public boolean isAddSupported() {
         return false;
     }
-    
+
     public boolean isRemoveSupported() {
         return false;
     }

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/AbstractTestComparator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/AbstractTestComparator.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/AbstractTestComparator.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/AbstractTestComparator.java Thu Jan 29 18:48:37 2009
@@ -34,7 +34,7 @@
  * 
  * @author Stephen Colebourne
  */
-public abstract class AbstractTestComparator extends AbstractTestObject {
+public abstract class AbstractTestComparator<T> extends AbstractTestObject {
 
     /**
      * JUnit constructor.
@@ -46,19 +46,13 @@
     }
 
     //-----------------------------------------------------------------------
-    /**
-     * Implement this method to return the comparator to test.
-     * 
-     * @return the comparator to test
-     */
-    public abstract Comparator makeComparator();
     
     /**
      * Implement this method to return a list of sorted objects.
      * 
      * @return sorted objects
      */
-    public abstract List getComparableObjectsOrdered();
+    public abstract List<T> getComparableObjectsOrdered();
 
     //-----------------------------------------------------------------------
     /**
@@ -66,9 +60,7 @@
      * 
      * @return a full iterator
      */
-    public Object makeObject() {
-        return makeComparator();
-    }
+    public abstract Comparator<T> makeObject();
 
     /**
      * Overrides superclass to block tests.
@@ -96,23 +88,22 @@
     /**
      * Reverse the list.
      */
-    protected void reverseObjects(List list) {
+    protected void reverseObjects(List<?> list) {
         Collections.reverse(list);
     }
 
     /**
      * Randomize the list.
      */
-    protected void randomizeObjects(List list) {
+    protected void randomizeObjects(List<?> list) {
         Collections.shuffle(list);
     }
 
     /**
      * Sort the list.
      */
-    protected void sortObjects(List list, Comparator comparator) {
-        Collections.sort(list,comparator);
-
+    protected void sortObjects(List<T> list, Comparator<? super T> comparator) {
+        Collections.sort(list, comparator);
     }
 
     //-----------------------------------------------------------------------
@@ -120,43 +111,41 @@
      * Test sorting an empty list
      */
     public void testEmptyListSort() {
-        List list = new LinkedList();
-        sortObjects(list, makeComparator());
+        List<T> list = new LinkedList<T>();
+        sortObjects(list, makeObject());
+
+        List<T> list2 = new LinkedList<T>();
 
-        List list2 = new LinkedList();
-        
-        assertTrue("Comparator cannot sort empty lists",
-                   list2.equals(list));
+        assertTrue("Comparator cannot sort empty lists", list2.equals(list));
     }
 
     /**
      * Test sorting a reversed list.
      */
     public void testReverseListSort() {
-        Comparator comparator = makeComparator();
+        Comparator<T> comparator = makeObject();
 
-        List randomList = getComparableObjectsOrdered();
+        List<T> randomList = getComparableObjectsOrdered();
         reverseObjects(randomList);
-        sortObjects(randomList,comparator);
+        sortObjects(randomList, comparator);
 
-        List orderedList = getComparableObjectsOrdered();
+        List<T> orderedList = getComparableObjectsOrdered();
 
         assertTrue("Comparator did not reorder the List correctly",
                    orderedList.equals(randomList));
-
     }
 
     /**
      * Test sorting a random list.
      */
     public void testRandomListSort() {
-        Comparator comparator = makeComparator();
+        Comparator<T> comparator = makeObject();
 
-        List randomList = getComparableObjectsOrdered();
+        List<T> randomList = getComparableObjectsOrdered();
         randomizeObjects(randomList);
         sortObjects(randomList,comparator);
 
-        List orderedList = getComparableObjectsOrdered();
+        List<T> orderedList = getComparableObjectsOrdered();
 
         /* debug 
         Iterator i = randomList.iterator();
@@ -174,7 +163,7 @@
      * Nearly all Comparators should be Serializable.
      */
     public void testComparatorIsSerializable() {
-        Comparator comparator = makeComparator();
+        Comparator<T> comparator = makeObject();
         assertTrue("This comparator should be Serializable.",
                    comparator instanceof Serializable);
     }
@@ -195,37 +184,38 @@
      * Compare the current serialized form of the Comparator
      * against the canonical version in CVS.
      */
+    @SuppressWarnings("unchecked")
     public void testComparatorCompatibility() throws IOException, ClassNotFoundException {
-        if(!skipSerializedCanonicalTests()) {
-            Comparator comparator = null;
+        if (!skipSerializedCanonicalTests()) {
+            Comparator<T> comparator = null;
     
             // test to make sure the canonical form has been preserved
             try {
-                comparator = (Comparator) readExternalFormFromDisk(getCanonicalComparatorName(makeComparator()));
+                comparator = (Comparator<T>) readExternalFormFromDisk(getCanonicalComparatorName(makeObject()));
         	} catch (FileNotFoundException exception) {
     
                 boolean autoCreateSerialized = false;
     
-        	    if(autoCreateSerialized) {
-    	          	comparator = makeComparator();
+        	    if (autoCreateSerialized) {
+    	          	comparator = makeObject();
             		String fileName = getCanonicalComparatorName(comparator);
             		writeExternalFormToDisk((Serializable) comparator, fileName);
-            		fail("Serialized form could not be found.  A serialized version " +
-            		     "has now been written (and should be added to CVS): " + fileName);
+            		fail("Serialized form could not be found.  A serialized version "
+                            + "has now been written (and should be added to CVS): " + fileName);
                 } else {
-                    fail("The Serialized form could be located to test serialization " +
-                        "compatibility: " + exception.getMessage());
+                    fail("The Serialized form could be located to test serialization "
+                            + "compatibility: " + exception.getMessage());
                 }
             }
     
             
             // make sure the canonical form produces the ordering we currently
             // expect
-            List randomList = getComparableObjectsOrdered();
+            List<T> randomList = getComparableObjectsOrdered();
             reverseObjects(randomList);
-            sortObjects(randomList,comparator);
+            sortObjects(randomList, comparator);
     
-            List orderedList = getComparableObjectsOrdered();
+            List<T> orderedList = getComparableObjectsOrdered();
     
             assertTrue("Comparator did not reorder the List correctly",
                        orderedList.equals(randomList));

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/TestBooleanComparator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/TestBooleanComparator.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/TestBooleanComparator.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/TestBooleanComparator.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,12 +25,12 @@
 
 /**
  * Tests for {@link BooleanComparator}.
- * 
+ *
  * @version $Revision$ $Date$
- * 
+ *
  * @author Rodney Waldhoff
  */
-public class TestBooleanComparator extends AbstractTestComparator {
+public class TestBooleanComparator extends AbstractTestComparator<Boolean> {
 
     // conventional
     // ------------------------------------------------------------------------
@@ -46,21 +46,21 @@
     // collections testing framework
     // ------------------------------------------------------------------------
 
-    public Comparator makeComparator() {
+    public Comparator<Boolean> makeObject() {
         return new BooleanComparator();
     }
 
-    public List getComparableObjectsOrdered() {
-        List list = new ArrayList();
+    public List<Boolean> getComparableObjectsOrdered() {
+        List<Boolean> list = new ArrayList<Boolean>();
         list.add(new Boolean(false));
         list.add(Boolean.FALSE);
         list.add(new Boolean(false));
         list.add(Boolean.TRUE);
         list.add(new Boolean(true));
-        list.add(Boolean.TRUE);
+        list.add(true);
         return list;
     }
-    
+
     public String getCompatibilityVersion() {
         return "3";
     }
@@ -71,16 +71,16 @@
     public void testConstructors() {
         allTests(false,new BooleanComparator());
         allTests(false,new BooleanComparator(false));
-        allTests(true,new BooleanComparator(true));        
+        allTests(true,new BooleanComparator(true));
     }
-    
+
     public void testStaticFactoryMethods() {
         allTests(false,BooleanComparator.getFalseFirstComparator());
         allTests(false,BooleanComparator.getBooleanComparator(false));
         allTests(true,BooleanComparator.getTrueFirstComparator());
         allTests(true,BooleanComparator.getBooleanComparator(true));
     }
-    
+
     public void testEqualsCompatibleInstance() {
         assertEquals(new BooleanComparator(),new BooleanComparator(false));
         assertEquals(new BooleanComparator(false),new BooleanComparator(false));
@@ -94,7 +94,7 @@
         assertTrue(!(new BooleanComparator().equals(new BooleanComparator(true))));
         assertTrue(!(new BooleanComparator(true).equals(new BooleanComparator(false))));
     }
-    
+
     // utilities
     // ------------------------------------------------------------------------
 
@@ -109,36 +109,24 @@
 
     protected void trueFirstTests(BooleanComparator comp) {
         assertNotNull(comp);
-        assertEquals(0,comp.compare(Boolean.TRUE,Boolean.TRUE));
-        assertEquals(0,comp.compare(Boolean.FALSE,Boolean.FALSE));
-        assertTrue(comp.compare(Boolean.FALSE,Boolean.TRUE) > 0);
-        assertTrue(comp.compare(Boolean.TRUE,Boolean.FALSE) < 0);
-
-        assertEquals(0,comp.compare((Object)(Boolean.TRUE),(Object)(Boolean.TRUE)));
-        assertEquals(0,comp.compare((Object)(Boolean.FALSE),(Object)(Boolean.FALSE)));
-        assertTrue(comp.compare((Object)(Boolean.FALSE),(Object)(Boolean.TRUE)) > 0);
-        assertTrue(comp.compare((Object)(Boolean.TRUE),(Object)(Boolean.FALSE)) < 0);
+        assertEquals(0,comp.compare(true, true));
+        assertEquals(0,comp.compare(false, false));
+        assertTrue(comp.compare(false, true) > 0);
+        assertTrue(comp.compare(true, false) < 0);
     }
 
     protected void falseFirstTests(BooleanComparator comp) {
         assertNotNull(comp);
-        assertEquals(0,comp.compare(Boolean.TRUE,Boolean.TRUE));
-        assertEquals(0,comp.compare(Boolean.FALSE,Boolean.FALSE));
-        assertTrue(comp.compare(Boolean.FALSE,Boolean.TRUE) < 0);
-        assertTrue(comp.compare(Boolean.TRUE,Boolean.FALSE) > 0);
-
-        assertEquals(0,comp.compare((Object)(Boolean.TRUE),(Object)(Boolean.TRUE)));
-        assertEquals(0,comp.compare((Object)(Boolean.FALSE),(Object)(Boolean.FALSE)));
-        assertTrue(comp.compare((Object)(Boolean.FALSE),(Object)(Boolean.TRUE)) < 0);
-        assertTrue(comp.compare((Object)(Boolean.TRUE),(Object)(Boolean.FALSE)) > 0);
+        assertEquals(0,comp.compare(true, true));
+        assertEquals(0,comp.compare(false, false));
+        assertTrue(comp.compare(false, true) < 0);
+        assertTrue(comp.compare(true, false) > 0);
     }
 
     protected void orderIndependentTests(BooleanComparator comp) {
         nullArgumentTests(comp);
-        nonBooleanArgumentTests(comp);
-        nullAndNonBooleanArgumentsTests(comp);
     }
-    
+
     protected void nullArgumentTests(BooleanComparator comp) {
         assertNotNull(comp);
         try {
@@ -172,59 +160,5 @@
             // expected
         }
     }
-    
-    protected void nonBooleanArgumentTests(BooleanComparator comp) {
-        assertNotNull(comp);
-        try {
-            comp.compare("string","string");
-            fail("Expected ClassCastException");
-        } catch(ClassCastException e) {
-            // expected
-        }
-        try {
-            comp.compare(Boolean.TRUE,"string");
-            fail("Expected ClassCastException");
-        } catch(ClassCastException e) {
-            // expected
-        }
-        try {
-            comp.compare("string",Boolean.TRUE);
-            fail("Expected ClassCastException");
-        } catch(ClassCastException e) {
-            // expected
-        }
-        try {
-            comp.compare("string",new Integer(3));
-            fail("Expected ClassCastException");
-        } catch(ClassCastException e) {
-            // expected
-        }
-        try {
-            comp.compare(new Integer(3),"string");
-            fail("Expected ClassCastException");
-        } catch(ClassCastException e) {
-            // expected
-        }
-    }
-    
-    protected void nullAndNonBooleanArgumentsTests(BooleanComparator comp) {
-        assertNotNull(comp);
-        try {
-            comp.compare(null,"string");
-            fail("Expected ClassCast or NullPointer Exception");
-        } catch(ClassCastException e) {
-            // expected
-        } catch(NullPointerException e) {
-            // expected
-        }
-        try {
-            comp.compare("string",null);
-            fail("Expected ClassCast or NullPointer Exception");
-        } catch(ClassCastException e) {
-            // expected
-        } catch(NullPointerException e) {
-            // expected
-        }
-    }
 
 }

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/TestComparableComparator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/TestComparableComparator.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/TestComparableComparator.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/TestComparableComparator.java Thu Jan 29 18:48:37 2009
@@ -30,7 +30,7 @@
  * 
  * @author Unknown
  */
-public class TestComparableComparator extends AbstractTestComparator {
+public class TestComparableComparator extends AbstractTestComparator<Integer> {
 
     public TestComparableComparator(String testName) {
         super(testName);
@@ -40,17 +40,17 @@
         return new TestSuite(TestComparableComparator.class);
     }
 
-    public Comparator makeComparator() {
-        return new ComparableComparator();
+    public Comparator<Integer> makeObject() {
+        return new ComparableComparator<Integer>();
     }
 
-    public List getComparableObjectsOrdered() {
-        List list = new LinkedList();
-        list.add(new Integer(1));
-        list.add(new Integer(2));
-        list.add(new Integer(3));
-        list.add(new Integer(4));
-        list.add(new Integer(5));
+    public List<Integer> getComparableObjectsOrdered() {
+        List<Integer> list = new LinkedList<Integer>();
+        list.add(1);
+        list.add(2);
+        list.add(3);
+        list.add(4);
+        list.add(5);
         return list;
     }
 

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/TestComparatorChain.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/TestComparatorChain.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/TestComparatorChain.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/TestComparatorChain.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,12 +26,12 @@
 
 /**
  * Tests for ComparatorChain.
- * 
+ *
  * @version $Revision$ $Date$
- * 
+ *
  * @author Unknown
  */
-public class TestComparatorChain extends AbstractTestComparator {
+public class TestComparatorChain extends AbstractTestComparator<TestComparatorChain.PseudoRow> {
 
     public TestComparatorChain(String testName) {
         super(testName);
@@ -41,97 +41,94 @@
         return new TestSuite(TestComparatorChain.class);
     }
 
-    public Comparator makeComparator() {
-        ComparatorChain chain = new ComparatorChain(new ColumnComparator(0));
-        chain.addComparator(new ColumnComparator(1),true); // reverse the second column
-        chain.addComparator(new ColumnComparator(2),false);
+    public Comparator<PseudoRow> makeObject() {
+        ComparatorChain<PseudoRow> chain = new ComparatorChain<PseudoRow>(new ColumnComparator(0));
+        chain.addComparator(new ColumnComparator(1), true); // reverse the second column
+        chain.addComparator(new ColumnComparator(2), false);
         return chain;
     }
 
     public void testNoopComparatorChain() {
-        ComparatorChain chain = new ComparatorChain();
+        ComparatorChain<Integer> chain = new ComparatorChain<Integer>();
         Integer i1 = new Integer(4);
         Integer i2 = new Integer(6);
-        chain.addComparator(new ComparableComparator());
+        chain.addComparator(new ComparableComparator<Integer>());
 
         int correctValue = i1.compareTo(i2);
-        assertTrue("Comparison returns the right order",chain.compare(i1,i2) == correctValue);
+        assertTrue("Comparison returns the right order", chain.compare(i1, i2) == correctValue);
     }
 
     public void testBadNoopComparatorChain() {
-        ComparatorChain chain = new ComparatorChain();
+        ComparatorChain<Integer> chain = new ComparatorChain<Integer>();
         Integer i1 = new Integer(4);
         Integer i2 = new Integer(6);
         try {
             chain.compare(i1,i2);
             fail("An exception should be thrown when a chain contains zero comparators.");
         } catch (UnsupportedOperationException e) {
-
         }
     }
 
     public void testListComparatorChain() {
-        List list = new LinkedList();
-        list.add(new ComparableComparator());
-        ComparatorChain chain = new ComparatorChain(list);
+        List<Comparator<Integer>> list = new LinkedList<Comparator<Integer>>();
+        list.add(new ComparableComparator<Integer>());
+        ComparatorChain<Integer> chain = new ComparatorChain<Integer>(list);
         Integer i1 = new Integer(4);
         Integer i2 = new Integer(6);
 
         int correctValue = i1.compareTo(i2);
-        assertTrue("Comparison returns the right order",chain.compare(i1,i2) == correctValue);
+        assertTrue("Comparison returns the right order", chain.compare(i1, i2) == correctValue);
     }
 
     public void testBadListComparatorChain() {
-        List list = new LinkedList();
-        ComparatorChain chain = new ComparatorChain(list);
+        List<Comparator<Integer>> list = new LinkedList<Comparator<Integer>>();
+        ComparatorChain<Integer> chain = new ComparatorChain<Integer>(list);
         Integer i1 = new Integer(4);
         Integer i2 = new Integer(6);
         try {
-            chain.compare(i1,i2);
+            chain.compare(i1, i2);
             fail("An exception should be thrown when a chain contains zero comparators.");
         } catch (UnsupportedOperationException e) {
-
         }
     }
 
-
     public void testComparatorChainOnMinvaluedCompatator() {
         // -1 * Integer.MIN_VALUE is less than 0,
         // test that ComparatorChain handles this edge case correctly
-        ComparatorChain chain = new ComparatorChain();
-        chain.addComparator(
-            new Comparator() {
-                public int compare(Object a, Object b) {
-                    int result = ((Comparable)a).compareTo(b);
-                    if(result < 0) {
-                        return Integer.MIN_VALUE;
-                    } else if(result > 0) {
-                        return Integer.MAX_VALUE;
-                    } else {
-                        return 0;
-                    }
+        ComparatorChain<Integer> chain = new ComparatorChain<Integer>();
+        chain.addComparator(new Comparator<Integer>() {
+            public int compare(Integer a, Integer b) {
+                int result = a.compareTo(b);
+                if (result < 0) {
+                    return Integer.MIN_VALUE;
                 }
-            }, true);
+                if (result > 0) {
+                    return Integer.MAX_VALUE;
+                }
+                return 0;
+            }
+        }, true);
 
-        assertTrue(chain.compare(new Integer(4), new Integer(5)) > 0);            
-        assertTrue(chain.compare(new Integer(5), new Integer(4)) < 0);            
-        assertTrue(chain.compare(new Integer(4), new Integer(4)) == 0);            
+        assertTrue(chain.compare(new Integer(4), new Integer(5)) > 0);
+        assertTrue(chain.compare(new Integer(5), new Integer(4)) < 0);
+        assertTrue(chain.compare(new Integer(4), new Integer(4)) == 0);
     }
 
-    public List getComparableObjectsOrdered() {
-        List list = new LinkedList();
+    public List<PseudoRow> getComparableObjectsOrdered() {
+        List<PseudoRow> list = new LinkedList<PseudoRow>();
         // this is the correct order assuming a
         // "0th forward, 1st reverse, 2nd forward" sort
-        list.add(new PseudoRow(1,2,3));
-        list.add(new PseudoRow(2,3,5));
-        list.add(new PseudoRow(2,2,4));
-        list.add(new PseudoRow(2,2,8));
-        list.add(new PseudoRow(3,1,0));
-        list.add(new PseudoRow(4,4,4));
-        list.add(new PseudoRow(4,4,7));
+        list.add(new PseudoRow(1, 2, 3));
+        list.add(new PseudoRow(2, 3, 5));
+        list.add(new PseudoRow(2, 2, 4));
+        list.add(new PseudoRow(2, 2, 8));
+        list.add(new PseudoRow(3, 1, 0));
+        list.add(new PseudoRow(4, 4, 4));
+        list.add(new PseudoRow(4, 4, 7));
         return list;
     }
 
+    @SuppressWarnings("serial")
     public static class PseudoRow implements Serializable {
 
         public int cols[] = new int[3];
@@ -170,8 +167,8 @@
 
             if (getColumn(1) != row.getColumn(1)) {
                 return false;
-            }            
-            
+            }
+
             if (getColumn(2) != row.getColumn(2)) {
                 return false;
             }
@@ -181,7 +178,8 @@
 
     }
 
-    public static class ColumnComparator implements Comparator,Serializable {
+    public static class ColumnComparator implements Comparator<PseudoRow>, Serializable {
+        private static final long serialVersionUID = -2284880866328872105L;
 
         protected int colIndex = 0;
 
@@ -189,32 +187,26 @@
             this.colIndex = colIndex;
         }
 
-        public int compare(Object o1, Object o2) {
+        public int compare(PseudoRow o1, PseudoRow o2) {
 
-            int col1 = ( (PseudoRow) o1).getColumn(colIndex);
-            int col2 = ( (PseudoRow) o2).getColumn(colIndex);
+            int col1 = o1.getColumn(colIndex);
+            int col2 = o2.getColumn(colIndex);
 
             if (col1 > col2) {
                 return 1;
-            } else if (col1 < col2) {
+            }
+            if (col1 < col2) {
                 return -1;
             }
-
             return 0;
         }
-        
+
         public int hashCode() {
             return colIndex;
         }
-        
+
         public boolean equals(Object that) {
-            if(that instanceof ColumnComparator) {
-                return colIndex == ((ColumnComparator)that).colIndex;
-            } else {
-                return false;
-            }
+            return that instanceof ColumnComparator && colIndex == ((ColumnComparator) that).colIndex;
         }
-        
-        private static final long serialVersionUID = -2284880866328872105L;
     }
 }

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/TestFixedOrderComparator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/TestFixedOrderComparator.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/TestFixedOrderComparator.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/TestFixedOrderComparator.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.
@@ -28,15 +28,14 @@
 
 /**
  * Test class for FixedOrderComparator.
- * 
+ *
  * @version $Revision$ $Date$
- * 
- * @author David Leppik 
+ *
+ * @author David Leppik
  * @author Stephen Colebourne
  */
 public class TestFixedOrderComparator extends TestCase {
 
-
     /**
      * Top cities of the world, by population including metro areas.
      */
@@ -65,7 +64,7 @@
         return new TestSuite(TestFixedOrderComparator.class);
     }
 
-    public static void main(String args[]) { 
+    public static void main(String args[]) {
         junit.textui.TestRunner.run(suite());
     }
 
@@ -79,11 +78,11 @@
     // The tests
     //
 
-    /** 
-     * Tests that the constructor plus add method compares items properly. 
+    /**
+     * Tests that the constructor plus add method compares items properly.
      */
     public void testConstructorPlusAdd() {
-        FixedOrderComparator comparator = new FixedOrderComparator();
+        FixedOrderComparator<String> comparator = new FixedOrderComparator<String>();
         for (int i = 0; i < topCities.length; i++) {
             comparator.add(topCities[i]);
         }
@@ -91,13 +90,13 @@
         assertComparatorYieldsOrder(keys, comparator);
     }
 
-    /** 
-     * Tests that the array constructor compares items properly. 
+    /**
+     * Tests that the array constructor compares items properly.
      */
     public void testArrayConstructor() {
         String[] keys = (String[]) topCities.clone();
         String[] topCitiesForTest = (String[]) topCities.clone();
-        FixedOrderComparator comparator = new FixedOrderComparator(topCitiesForTest);
+        FixedOrderComparator<String> comparator = new FixedOrderComparator<String>(topCitiesForTest);
         assertComparatorYieldsOrder(keys, comparator);
         // test that changing input after constructor has no effect
         topCitiesForTest[0] = "Brighton";
@@ -105,12 +104,12 @@
     }
 
     /**
-     * Tests the list constructor. 
+     * Tests the list constructor.
      */
     public void testListConstructor() {
         String[] keys = (String[]) topCities.clone();
-        List topCitiesForTest = new LinkedList(Arrays.asList(topCities));
-        FixedOrderComparator comparator = new FixedOrderComparator(topCitiesForTest);
+        List<String> topCitiesForTest = new LinkedList<String>(Arrays.asList(topCities));
+        FixedOrderComparator<String> comparator = new FixedOrderComparator<String>(topCitiesForTest);
         assertComparatorYieldsOrder(keys, comparator);
         // test that changing input after constructor has no effect
         topCitiesForTest.set(0, "Brighton");
@@ -121,18 +120,18 @@
      * Tests addAsEqual method.
      */
     public void testAddAsEqual() {
-        FixedOrderComparator comparator = new FixedOrderComparator(topCities);
+        FixedOrderComparator<String> comparator = new FixedOrderComparator<String>(topCities);
         comparator.addAsEqual("New York", "Minneapolis");
         assertEquals(0, comparator.compare("New York", "Minneapolis"));
         assertEquals(-1, comparator.compare("Tokyo", "Minneapolis"));
         assertEquals(1, comparator.compare("Shanghai", "Minneapolis"));
     }
 
-    /** 
+    /**
      * Tests whether or not updates are disabled after a comparison is made.
      */
     public void testLock() {
-        FixedOrderComparator comparator = new FixedOrderComparator(topCities);
+        FixedOrderComparator<String> comparator = new FixedOrderComparator<String>(topCities);
         assertEquals(false, comparator.isLocked());
         comparator.compare("New York", "Tokyo");
         assertEquals(true, comparator.isLocked());
@@ -152,7 +151,7 @@
     }
 
     public void testUnknownObjectBehavior() {
-        FixedOrderComparator comparator = new FixedOrderComparator(topCities);
+        FixedOrderComparator<String> comparator = new FixedOrderComparator<String>(topCities);
         try {
             comparator.compare("New York", "Minneapolis");
             fail("Should have thrown a IllegalArgumentException");
@@ -165,42 +164,43 @@
         } catch (IllegalArgumentException e) {
             // success-- ignore
         }
-        assertEquals(FixedOrderComparator.UNKNOWN_THROW_EXCEPTION, comparator.getUnknownObjectBehavior());
+        assertEquals(FixedOrderComparator.UnknownObjectBehavior.EXCEPTION, comparator.getUnknownObjectBehavior());
 
-        comparator = new FixedOrderComparator(topCities);
-        comparator.setUnknownObjectBehavior(FixedOrderComparator.UNKNOWN_BEFORE);
-        assertEquals(FixedOrderComparator.UNKNOWN_BEFORE, comparator.getUnknownObjectBehavior());
-        LinkedList keys = new LinkedList(Arrays.asList(topCities));
+        comparator = new FixedOrderComparator<String>(topCities);
+        comparator.setUnknownObjectBehavior(FixedOrderComparator.UnknownObjectBehavior.BEFORE);
+        assertEquals(FixedOrderComparator.UnknownObjectBehavior.BEFORE, comparator.getUnknownObjectBehavior());
+        LinkedList<String> keys = new LinkedList<String>(Arrays.asList(topCities));
         keys.addFirst("Minneapolis");
         assertComparatorYieldsOrder(keys.toArray(new String[0]), comparator);
-        
+
         assertEquals(-1, comparator.compare("Minneapolis", "New York"));
         assertEquals( 1, comparator.compare("New York", "Minneapolis"));
         assertEquals( 0, comparator.compare("Minneapolis", "St Paul"));
 
-        comparator = new FixedOrderComparator(topCities);
-        comparator.setUnknownObjectBehavior(FixedOrderComparator.UNKNOWN_AFTER);
-        keys = new LinkedList(Arrays.asList(topCities));
+        comparator = new FixedOrderComparator<String>(topCities);
+        comparator.setUnknownObjectBehavior(FixedOrderComparator.UnknownObjectBehavior.AFTER);
+        keys = new LinkedList<String>(Arrays.asList(topCities));
         keys.add("Minneapolis");
         assertComparatorYieldsOrder(keys.toArray(new String[0]), comparator);
-        
+
         assertEquals( 1, comparator.compare("Minneapolis", "New York"));
         assertEquals(-1, comparator.compare("New York", "Minneapolis"));
         assertEquals( 0, comparator.compare("Minneapolis", "St Paul"));
-        
+
     }
-    
+
     //
     // Helper methods
     //
-    
+
     /** Shuffles the keys and asserts that the comparator sorts them back to
      * their original order.
      */
-    private void assertComparatorYieldsOrder(Object[] orderedObjects, 
-                                             Comparator comparator) {
-        Object[] keys = (Object[]) orderedObjects.clone();
-        
+    @SuppressWarnings("unused")
+    private void assertComparatorYieldsOrder(String[] orderedObjects,
+                                             Comparator<String> comparator) {
+        String[] keys = orderedObjects.clone();
+
         // shuffle until the order changes.  It's extremely rare that
         // this requires more than one shuffle.
 
@@ -209,13 +209,13 @@
             shuffle: {
                 Random rand = new Random();
                 for (int i = keys.length-1; i > 0; i--) {
-                        Object swap = keys[i];
+                        String swap = keys[i];
                         int j = rand.nextInt(i+1);
                         keys[i] = keys[j];
-                        keys[j] = swap;     
+                        keys[j] = swap;
                     }
             }
-        
+
             testShuffle: {
                 for (int i = 0; i < keys.length && !isInNewOrder; i++) {
                     if( !orderedObjects[i].equals(keys[i])) {
@@ -224,14 +224,14 @@
                 }
             }
         }
-        
+
         // The real test:  sort and make sure they come out right.
-        
+
         Arrays.sort(keys, comparator);
 
         for (int i = 0; i < orderedObjects.length; i++) {
             assertEquals(orderedObjects[i], keys[i]);
         }
     }
-    
+
 }

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/TestNullComparator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/TestNullComparator.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/TestNullComparator.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/TestNullComparator.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,12 +25,12 @@
 
 /**
  * Test the NullComparator.
- * 
+ *
  * @version $Revision$ $Date$
- * 
+ *
  * @author Michael A. Smith
  */
-public abstract class TestNullComparator extends AbstractTestComparator {
+public abstract class TestNullComparator extends AbstractTestComparator<Integer> {
 
     public TestNullComparator(String testName) {
         super(testName);
@@ -48,45 +48,45 @@
      **/
     public static class TestNullComparator1 extends TestNullComparator {
 
-	public TestNullComparator1(String testName) {
-	    super(testName);
-	}
-
-    public Comparator makeComparator() {
-	    return new NullComparator();
-	}
-	
-    public List getComparableObjectsOrdered() {
-        List list = new LinkedList();
-	    list.add(new Integer(1));
-	    list.add(new Integer(2));
-	    list.add(new Integer(3));
-	    list.add(new Integer(4));
-	    list.add(new Integer(5));
-	    list.add(null);
-	    return list;
-	}
-
-	public String getCanonicalComparatorName(Object object) {
-	    return super.getCanonicalComparatorName(object) + "1";
-	}
+    	public TestNullComparator1(String testName) {
+    	    super(testName);
+    	}
+
+        public Comparator<Integer> makeObject() {
+    	    return new NullComparator<Integer>();
+    	}
+
+        public List<Integer> getComparableObjectsOrdered() {
+            List<Integer> list = new LinkedList<Integer>();
+    	    list.add(new Integer(1));
+    	    list.add(new Integer(2));
+    	    list.add(new Integer(3));
+    	    list.add(new Integer(4));
+    	    list.add(new Integer(5));
+    	    list.add(null);
+    	    return list;
+    	}
+
+    	public String getCanonicalComparatorName(Object object) {
+    	    return super.getCanonicalComparatorName(object) + "1";
+    	}
     }
 
     /**
      *  Test the NullComparator with nulls low using the comparable comparator
      **/
     public static class TestNullComparator2 extends TestNullComparator {
-        
+
         public TestNullComparator2(String testName) {
             super(testName);
         }
-        
-        public Comparator makeComparator() {
-            return new NullComparator(false);
+
+        public Comparator<Integer> makeObject() {
+            return new NullComparator<Integer>(false);
         }
-        
-        public List getComparableObjectsOrdered() {
-            List list = new LinkedList();
+
+        public List<Integer> getComparableObjectsOrdered() {
+            List<Integer> list = new LinkedList<Integer>();
             list.add(null);
             list.add(new Integer(1));
             list.add(new Integer(2));
@@ -95,7 +95,7 @@
             list.add(new Integer(5));
             return list;
         }
-        
+
         public String getCanonicalComparatorName(Object object) {
             return super.getCanonicalComparatorName(object) + "2";
         }

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/TestReverseComparator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/TestReverseComparator.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/TestReverseComparator.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/comparators/TestReverseComparator.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.
@@ -30,12 +30,12 @@
 
 /**
  * Tests for ReverseComparator.
- * 
+ *
  * @version $Revision$ $Date$
- * 
+ *
  * @author Unknown
  */
-public class TestReverseComparator extends AbstractTestComparator {
+public class TestReverseComparator extends AbstractTestComparator<Integer> {
 
     public TestReverseComparator(String testName) {
         super(testName);
@@ -46,21 +46,21 @@
     }
 
     /**
-     * For the purposes of this test, return a 
+     * For the purposes of this test, return a
      * ReverseComparator that wraps the java.util.Collections.reverseOrder()
      * Comparator.  The resulting comparator should
      * sort according to natural Order.  (Note: we wrap
      * a Comparator taken from the JDK so that we can
      * save a "canonical" form in CVS.
-     * 
+     *
      * @return Comparator that returns "natural" order
      */
-    public Comparator makeComparator() {
-        return new ReverseComparator(Collections.reverseOrder());
+    public Comparator<Integer> makeObject() {
+        return new ReverseComparator<Integer>(Collections.<Integer>reverseOrder());
     }
 
-    public List getComparableObjectsOrdered() {
-        List list = new LinkedList();
+    public List<Integer> getComparableObjectsOrdered() {
+        List<Integer> list = new LinkedList<Integer>();
         list.add(new Integer(1));
         list.add(new Integer(2));
         list.add(new Integer(3));
@@ -69,11 +69,12 @@
         return list;
     }
 
-    /** 
+    /**
      * Override this inherited test since Collections.reverseOrder
      * doesn't adhere to the "soft" Comparator contract, and we've
      * already "cannonized" the comparator returned by makeComparator.
      */
+    @SuppressWarnings("unchecked")
     public void testSerializeDeserializeThenCompare() throws Exception {
         Comparator comp = new ReverseComparator(new ComparableComparator());
 
@@ -81,7 +82,7 @@
         ObjectOutputStream out = new ObjectOutputStream(buffer);
         out.writeObject(comp);
         out.close();
-            
+
         ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
         Object dest = in.readObject();
         in.close();

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/functors/TestAllPredicate.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/functors/TestAllPredicate.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/functors/TestAllPredicate.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/functors/TestAllPredicate.java Thu Jan 29 18:48:37 2009
@@ -49,7 +49,7 @@
      * {@inheritDoc}
      */    
     @Override
-    protected final Predicate<Integer> getPredicateInstance(final Collection<Predicate<? super Integer>> predicates) {
+    protected final Predicate<Integer> getPredicateInstance(final Collection<Predicate<Integer>> predicates) {
         return AllPredicate.allPredicate(predicates);
     }
 
@@ -58,8 +58,7 @@
      */
     @SuppressWarnings({"unchecked"})
     @Test
-    public void emptyArrayToGetInstance()
-    {
+    public void emptyArrayToGetInstance() {
         assertTrue("empty array not true", getPredicateInstance(new Predicate[] {}).evaluate(null));
     }
 
@@ -67,19 +66,18 @@
      * Verifies that providing an empty predicate collection evaluates to true.
      */
     @Test
-    public void emptyCollectionToGetInstance()
-    {
+    public void emptyCollectionToGetInstance() {
         final Predicate<Integer> allPredicate = getPredicateInstance(
-                Collections.<Predicate<? super Integer>>emptyList());
+                Collections.<Predicate<Integer>>emptyList());
         assertTrue("empty collection not true", allPredicate.evaluate(getTestValue()));
     }
 
     /**
      * Tests whether a single true predicate evaluates to true.
      */
+    @SuppressWarnings("unchecked")
     @Test
-    public void oneTruePredicate()
-    {
+    public void oneTruePredicate() {
         // use the constructor directly, as getInstance() returns the original predicate when passed
         // an array of size one.
         final Predicate<Integer> predicate = createMockPredicate(true);
@@ -91,9 +89,9 @@
     /**
      * Tests whether a single false predicate evaluates to true.
      */
+    @SuppressWarnings("unchecked")
     @Test
-    public void oneFalsePredicate()
-    {
+    public void oneFalsePredicate() {
         // use the constructor directly, as getInstance() returns the original predicate when passed
         // an array of size one.
         final Predicate<Integer> predicate = createMockPredicate(false);
@@ -105,8 +103,7 @@
      * Tests whether multiple true predicates evaluates to true.
      */
     @Test
-    public void allTrue()
-    {
+    public void allTrue() {
         assertTrue("multiple true predicates evaluated to false",
                 getPredicateInstance(true, true).evaluate(getTestValue()));
         assertTrue("multiple true predicates evaluated to false",
@@ -118,8 +115,7 @@
      * false predicate is actually evaluated
      */
     @Test
-    public void trueAndFalseCombined()
-    {
+    public void trueAndFalseCombined() {
         assertFalse("false predicate evaluated to true",
                 getPredicateInstance(false, null).evaluate(getTestValue()));
         assertFalse("false predicate evaluated to true",

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/functors/TestAnyAllOnePredicate.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/functors/TestAnyAllOnePredicate.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/functors/TestAnyAllOnePredicate.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/functors/TestAnyAllOnePredicate.java Thu Jan 29 18:48:37 2009
@@ -1,3 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  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.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 package org.apache.commons.collections.functors;
 
 import org.apache.commons.collections.Predicate;
@@ -27,13 +43,12 @@
         super(testValue);
     }
 
-
     /**
      * Tests whether <code>getInstance</code> with a one element array returns the first element in the array.
      */
+    @SuppressWarnings("unchecked")
     @Test
-    public final void singleElementArrayToGetInstance()
-    {
+    public final void singleElementArrayToGetInstance() {
         final Predicate<T> predicate = createMockPredicate(null);
         final Predicate<T> allPredicate = getPredicateInstance(predicate);
         assertSame("expected argument to be returned by getInstance()", predicate, allPredicate);
@@ -44,11 +59,10 @@
      * collection.
      */
     @Test
-    public final void singletonCollectionToGetInstance()
-    {
+    public final void singletonCollectionToGetInstance() {
         final Predicate<T> predicate = createMockPredicate(null);
         final Predicate<T> allPredicate = getPredicateInstance(
-                Collections.<Predicate<? super T>>singleton(predicate));
+                Collections.<Predicate<T>>singleton(predicate));
         assertSame("expected singleton collection member to be returned by getInstance()",
                 predicate, allPredicate);
     }
@@ -57,8 +71,7 @@
      * Tests creating composite predicate instances with single predicates and verifies that the composite returns
      * the same value as the single predicate does. 
      */
-    public final void singleValues()
-    {
+    public final void singleValues() {
         assertTrue(getPredicateInstance(true).evaluate(null));
         assertFalse(getPredicateInstance(false).evaluate(null));
     }

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/functors/TestCompositePredicate.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/functors/TestCompositePredicate.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/functors/TestCompositePredicate.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/functors/TestCompositePredicate.java Thu Jan 29 18:48:37 2009
@@ -45,7 +45,7 @@
      *
      * @return a predicate to test.
      */
-    protected abstract Predicate<T> getPredicateInstance(final Collection<Predicate<? super T>> predicates);
+    protected abstract Predicate<T> getPredicateInstance(final Collection<Predicate<T>> predicates);
 
     /**
      * Creates an instance of the predicate to test.
@@ -55,20 +55,19 @@
      *
      * @return a predicate to test.
      */
-    protected final Predicate<T> getPredicateInstance(final Boolean ... mockReturnValues)
-    {
-        final List<Predicate<? super T>> predicates = new ArrayList<Predicate<? super T>>();
+    protected final Predicate<T> getPredicateInstance(final Boolean... mockReturnValues) {
+        final List<Predicate<T>> predicates = new ArrayList<Predicate<T>>();
         for (Boolean returnValue : mockReturnValues) {
             predicates.add(createMockPredicate(returnValue));
-        }        
+        }
         return getPredicateInstance(predicates);
     }
 
     /**
      * Tests whether <code>getInstance</code> with a one element array returns the first element in the array.
      */
-    public void singleElementArrayToGetInstance()
-    {
+    @SuppressWarnings("unchecked")
+    public void singleElementArrayToGetInstance() {
         final Predicate<T> predicate = createMockPredicate(null);
         final Predicate<T> allPredicate = getPredicateInstance(predicate);
         Assert.assertSame("expected argument to be returned by getInstance()", predicate, allPredicate);
@@ -78,18 +77,16 @@
      * Tests that passing a singleton collection to <code>getInstance</code> returns the single element in the
      * collection.
      */
-    public void singletonCollectionToGetInstance()
-    {
+    public void singletonCollectionToGetInstance() {
         final Predicate<T> predicate = createMockPredicate(null);
         final Predicate<T> allPredicate = getPredicateInstance(
-                Collections.<Predicate<? super T>>singleton(predicate));
+                Collections.<Predicate<T>>singleton(predicate));
         Assert.assertSame("expected argument to be returned by getInstance()", predicate, allPredicate);
     }
 
     /**
      * Tests <code>getInstance</code> with a null predicate array.
      */
-    @SuppressWarnings({"unchecked"})
     @Test(expected = IllegalArgumentException.class)
     public final void nullArrayToGetInstance() {
         getPredicateInstance((Predicate<T>[]) null);
@@ -119,7 +116,7 @@
      */
     @Test(expected = IllegalArgumentException.class)
     public final void nullCollectionToGetInstance() {
-        getPredicateInstance((Collection<Predicate<? super T>>) null);
+        getPredicateInstance((Collection<Predicate<T>>) null);
     }
 
     /**
@@ -127,7 +124,7 @@
      */
     @Test(expected = IllegalArgumentException.class)
     public final void nullElementsInCollectionToGetInstance() {
-        final Collection<Predicate<? super T>> coll = new ArrayList<Predicate<? super T>>();
+        final Collection<Predicate<T>> coll = new ArrayList<Predicate<T>>();
         coll.add(null);
         coll.add(null);
         getPredicateInstance(coll);

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/AbstractTestIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/AbstractTestIterator.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/AbstractTestIterator.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/AbstractTestIterator.java Thu Jan 29 18:48:37 2009
@@ -35,7 +35,7 @@
  * @author Morgan Delagrange
  * @author Stephen Colebourne
  */
-public abstract class AbstractTestIterator extends AbstractTestObject {
+public abstract class AbstractTestIterator<E> extends AbstractTestObject {
 
     /**
      * JUnit constructor.
@@ -52,23 +52,14 @@
      * 
      * @return an empty iterator
      */
-    public abstract Iterator makeEmptyIterator();
-
-    /**
-     * Implement this method to return an iterator over a collection with elements.
-     * 
-     * @return a full iterator
-     */
-    public abstract Iterator makeFullIterator();
+    public abstract Iterator<E> makeEmptyIterator();
 
     /**
      * Implements the abstract superclass method to return the full iterator.
      * 
      * @return a full iterator
      */
-    public Object makeObject() {
-        return makeFullIterator();
-    }
+    public abstract Iterator<E> makeObject();
 
     /**
      * Whether or not we are testing an iterator that can be empty.
@@ -116,7 +107,7 @@
             return;
         }
 
-        Iterator it = makeEmptyIterator();
+        Iterator<E> it = makeEmptyIterator();
         
         // hasNext() should return false
         assertEquals("hasNext() should return false for empty iterators", false, it.hasNext());
@@ -140,7 +131,7 @@
             return;
         }
 
-        Iterator it = makeFullIterator();
+        Iterator<E> it = makeObject();
 
         // hasNext() must be true (ensure makeFullIterator is correct!)
         assertEquals("hasNext() should return true for at least one element", true, it.hasNext());
@@ -172,7 +163,7 @@
      * Test remove behaviour.
      */
     public void testRemove() {
-        Iterator it = makeFullIterator();
+        Iterator<E> it = makeObject();
         
         if (supportsRemove() == false) {
             // check for UnsupportedOperationException if not supported

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/AbstractTestListIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/AbstractTestListIterator.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/AbstractTestListIterator.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/AbstractTestListIterator.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.
@@ -17,7 +17,6 @@
 package org.apache.commons.collections.iterators;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.ListIterator;
 import java.util.NoSuchElementException;
 
@@ -28,18 +27,18 @@
  * Concrete subclasses must provide the list iterator to be tested.
  * They must also specify certain details of how the list iterator operates by
  * overriding the supportsXxx() methods if necessary.
- * 
+ *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
- * 
+ *
  * @author Rodney Waldhoff
  * @author Stephen Colebourne
  */
-public abstract class AbstractTestListIterator extends AbstractTestIterator {
+public abstract class AbstractTestListIterator<E> extends AbstractTestIterator<E> {
 
     /**
      * JUnit constructor.
-     * 
+     *
      * @param testName  the test class name
      */
     public AbstractTestListIterator(String testName) {
@@ -48,41 +47,23 @@
 
     //-----------------------------------------------------------------------
     /**
-     * Implement this method to return a list iterator over an empty collection.
-     * 
-     * @return an empty iterator
-     */
-    public abstract ListIterator makeEmptyListIterator();
-
-    /**
-     * Implement this method to return a list iterator over a collection with elements.
-     * 
-     * @return a full iterator
-     */
-    public abstract ListIterator makeFullListIterator();
-
-    /**
      * Implements the abstract superclass method to return the list iterator.
-     * 
+     *
      * @return an empty iterator
      */
-    public Iterator makeEmptyIterator() {
-        return makeEmptyListIterator();
-    }
+    public abstract ListIterator<E> makeEmptyIterator();
 
     /**
      * Implements the abstract superclass method to return the list iterator.
-     * 
+     *
      * @return a full iterator
      */
-    public Iterator makeFullIterator() {
-        return makeFullListIterator();
-    }
+    public abstract ListIterator<E> makeObject();
 
     /**
      * Whether or not we are testing an iterator that supports add().
      * Default is true.
-     * 
+     *
      * @return true if Iterator supports add
      */
     public boolean supportsAdd() {
@@ -92,7 +73,7 @@
     /**
      * Whether or not we are testing an iterator that supports set().
      * Default is true.
-     * 
+     *
      * @return true if Iterator supports set
      */
     public boolean supportsSet() {
@@ -103,7 +84,7 @@
      * The value to be used in the add and set tests.
      * Default is null.
      */
-    public Object addSetValue() {
+    public E addSetValue() {
         return null;
     }
 
@@ -116,20 +97,20 @@
             return;
         }
 
-        ListIterator it = makeEmptyListIterator();
-        
+        ListIterator<E> it = makeEmptyIterator();
+
         assertEquals(false, it.hasNext());
         assertEquals(0, it.nextIndex());
         assertEquals(false, it.hasPrevious());
         assertEquals(-1, it.previousIndex());
-        
+
         // 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();
@@ -137,17 +118,17 @@
         } catch (NoSuchElementException e) {
         }
     }
-    
+
     /**
      * Test navigation through the iterator.
      */
     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());
@@ -156,16 +137,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 + 1, it.nextIndex());
             assertEquals(i, it.previousIndex());
-        
+
             Object obj = list.get(i);
             assertEquals(obj, it.previous());
         }
-        
+
         // check state at start
         assertEquals(true, it.hasNext());
         assertEquals(false, it.hasPrevious());
@@ -175,14 +156,14 @@
         } catch (NoSuchElementException e) {
         }
     }
-    
+
     /**
      * Test add behaviour.
      */
     public void testAdd() {
-        ListIterator it = makeFullListIterator();
-        
-        Object addValue = addSetValue();
+        ListIterator<E> it = makeObject();
+
+        E addValue = addSetValue();
         if (supportsAdd() == false) {
             // check for UnsupportedOperationException if not supported
             try {
@@ -190,34 +171,34 @@
             } catch (UnsupportedOperationException ex) {}
             return;
         }
-        
+
         // add at start should be OK, added should be previous
-        it = makeFullListIterator();
+        it = makeObject();
         it.add(addValue);
         assertEquals(addValue, it.previous());
 
         // add at start should be OK, added should not be next
-        it = makeFullListIterator();
+        it = makeObject();
         it.add(addValue);
         assertTrue(addValue != it.next());
 
         // add in middle and at end should be OK
-        it = makeFullListIterator();
+        it = makeObject();
         while (it.hasNext()) {
             it.next();
             it.add(addValue);
             // check add OK
             assertEquals(addValue, it.previous());
             it.next();
-        }        
+        }
     }
-    
+
     /**
      * Test set behaviour.
      */
     public void testSet() {
-        ListIterator it = makeFullListIterator();
-        
+        ListIterator<E> it = makeObject();
+
         if (supportsSet() == false) {
             // check for UnsupportedOperationException if not supported
             try {
@@ -225,24 +206,24 @@
             } catch (UnsupportedOperationException ex) {}
             return;
         }
-        
+
         // should throw IllegalStateException before next() called
         try {
             it.set(addSetValue());
             fail();
         } catch (IllegalStateException ex) {}
-        
+
         // set after next should be fine
         it.next();
         it.set(addSetValue());
-        
+
         // repeated set calls should be fine
         it.set(addSetValue());
 
     }
-    
+
     public void testRemoveThenSet() {
-        ListIterator it = makeFullListIterator();
+        ListIterator<E> it = makeObject();
         if (supportsRemove() && supportsSet()) {
             it.next();
             it.remove();
@@ -255,7 +236,7 @@
     }
 
     public void testAddThenSet() {
-        ListIterator it = makeFullListIterator();        
+        ListIterator<E> it = makeObject();
         // add then set
         if (supportsAdd() && supportsSet()) {
             it.next();
@@ -267,13 +248,13 @@
             }
         }
     }
-    
+
     /**
      * Test remove after add behaviour.
      */
     public void testAddThenRemove() {
-        ListIterator it = makeFullListIterator();
-        
+        ListIterator<E> it = makeObject();
+
         // add then remove
         if (supportsAdd() && supportsRemove()) {
             it.next();
@@ -285,5 +266,5 @@
             }
         }
     }
-    
+
 }

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/AbstractTestMapIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/AbstractTestMapIterator.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/AbstractTestMapIterator.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/AbstractTestMapIterator.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.
@@ -17,7 +17,6 @@
 package org.apache.commons.collections.iterators;
 
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.Set;
@@ -31,17 +30,17 @@
  * Concrete subclasses must provide the list iterator to be tested.
  * They must also specify certain details of how the list iterator operates by
  * overriding the supportsXxx() methods if necessary.
- * 
+ *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
- * 
+ *
  * @author Stephen Colebourne
  */
-public abstract class AbstractTestMapIterator extends AbstractTestIterator {
+public abstract class AbstractTestMapIterator<K, V> extends AbstractTestIterator<K> {
 
     /**
      * JUnit constructor.
-     * 
+     *
      * @param testName  the test class name
      */
     public AbstractTestMapIterator(String testName) {
@@ -51,56 +50,38 @@
     //-----------------------------------------------------------------------
     /**
      * Implement this method to return a map iterator over an empty map.
-     * 
+     *
      * @return an empty iterator
      */
-    public abstract MapIterator makeEmptyMapIterator();
+    public abstract MapIterator<K, V> makeEmptyIterator();
 
     /**
      * Implement this method to return a map iterator over a map with elements.
-     * 
+     *
      * @return a full iterator
      */
-    public abstract MapIterator makeFullMapIterator();
+    public abstract MapIterator<K, V> makeObject();
 
     /**
      * Implement this method to return the map which contains the same data as the
      * iterator.
-     * 
+     *
      * @return a full map which can be updated
      */
-    public abstract Map getMap();
-    
+    public abstract Map<K, V> getMap();
+
     /**
      * Implement this method to return the confirmed map which contains the same
      * data as the iterator.
-     * 
+     *
      * @return a full map which can be updated
      */
-    public abstract Map getConfirmedMap();
-    
-    /**
-     * Implements the abstract superclass method to return the list iterator.
-     * 
-     * @return an empty iterator
-     */
-    public final Iterator makeEmptyIterator() {
-        return makeEmptyMapIterator();
-    }
-
-    /**
-     * Implements the abstract superclass method to return the list iterator.
-     * 
-     * @return a full iterator
-     */
-    public final Iterator makeFullIterator() {
-        return makeFullMapIterator();
-    }
+    public abstract Map<K, V> getConfirmedMap();
 
     /**
      * Whether or not we are testing an iterator that supports setValue().
      * Default is true.
-     * 
+     *
      * @return true if Iterator supports set
      */
     public boolean supportsSetValue() {
@@ -110,19 +91,20 @@
     /**
      * Whether the get operation on the map structurally modifies the map,
      * such as with LRUMap. Default is false.
-     * 
+     *
      * @return true if the get method structurally modifies the map
      */
     public boolean isGetStructuralModify() {
         return false;
     }
-    
+
     /**
      * The values to be used in the add and set tests.
      * Default is two strings.
      */
-    public Object[] addSetValues() {
-        return new Object[] {"A", "B"};
+    @SuppressWarnings("unchecked")
+    public V[] addSetValues() {
+        return (V[]) new Object[] { "A", "B" };
     }
 
     //-----------------------------------------------------------------------
@@ -134,28 +116,27 @@
             return;
         }
 
-        MapIterator it = makeEmptyMapIterator();
-        Map map = getMap();
+        MapIterator<K, V> it = makeEmptyIterator();
         assertEquals(false, it.hasNext());
-        
+
         // next() should throw a NoSuchElementException
         try {
             it.next();
             fail();
         } catch (NoSuchElementException ex) {}
-        
+
         // getKey() should throw an IllegalStateException
         try {
             it.getKey();
             fail();
         } catch (IllegalStateException ex) {}
-        
+
         // getValue() should throw an IllegalStateException
         try {
             it.getValue();
             fail();
         } catch (IllegalStateException ex) {}
-        
+
         if (supportsSetValue() == false) {
             // setValue() should throw an UnsupportedOperationException/IllegalStateException
             try {
@@ -181,21 +162,21 @@
             return;
         }
 
-        MapIterator it = makeFullMapIterator();
-        Map map = getMap();
+        MapIterator<K, V> it = makeObject();
+        Map<K, V> map = getMap();
         assertEquals(true, it.hasNext());
-        
+
         assertEquals(true, it.hasNext());
-        Set set = new HashSet();
+        Set<K> set = new HashSet<K>();
         while (it.hasNext()) {
             // getKey
-            Object key = it.next();
+            K key = it.next();
             assertSame("it.next() should equals getKey()", key, it.getKey());
             assertTrue("Key must be in map",  map.containsKey(key));
             assertTrue("Key must be unique", set.add(key));
-            
+
             // getValue
-            Object value = it.getValue();
+            V value = it.getValue();
             if (isGetStructuralModify() == false) {
                 assertSame("Value must be mapped to key", map.get(key), value);
             }
@@ -204,22 +185,22 @@
             verify();
         }
     }
-    
+
     //-----------------------------------------------------------------------
     public void testMapIteratorSet() {
         if (supportsFullIterator() == false) {
             return;
         }
 
-        Object newValue = addSetValues()[0];
-        Object newValue2 = (addSetValues().length == 1 ? addSetValues()[0] : addSetValues()[1]);
-        MapIterator it = makeFullMapIterator();
-        Map map = getMap();
-        Map confirmed = getConfirmedMap();
+        V newValue = addSetValues()[0];
+        V newValue2 = (addSetValues().length == 1 ? addSetValues()[0] : addSetValues()[1]);
+        MapIterator<K, V> it = makeObject();
+        Map<K, V> map = getMap();
+        Map<K, V> confirmed = getConfirmedMap();
         assertEquals(true, it.hasNext());
-        Object key = it.next();
-        Object value = it.getValue();
-        
+        K key = it.next();
+        V value = it.getValue();
+
         if (supportsSetValue() == false) {
             try {
                 it.setValue(newValue);
@@ -227,24 +208,24 @@
             } catch (UnsupportedOperationException ex) {}
             return;
         }
-        Object old = it.setValue(newValue);
+        V old = it.setValue(newValue);
         confirmed.put(key, newValue);
         assertSame("Key must not change after setValue", key, it.getKey());
         assertSame("Value must be changed after setValue", newValue, it.getValue());
         assertSame("setValue must return old value", value, old);
         assertEquals("Map must contain key", true, map.containsKey(key));
         // test against confirmed, as map may contain value twice
-        assertEquals("Map must not contain old value", 
+        assertEquals("Map must not contain old value",
             confirmed.containsValue(old), map.containsValue(old));
         assertEquals("Map must contain new value", true, map.containsValue(newValue));
         verify();
-        
+
         it.setValue(newValue);  // same value - should be OK
         confirmed.put(key, newValue);
         assertSame("Key must not change after setValue", key, it.getKey());
         assertSame("Value must be changed after setValue", newValue, it.getValue());
         verify();
-        
+
         it.setValue(newValue2);  // new value
         confirmed.put(key, newValue2);
         assertSame("Key must not change after setValue", key, it.getKey());
@@ -254,12 +235,12 @@
 
     //-----------------------------------------------------------------------
     public void testRemove() { // override
-        MapIterator it = makeFullMapIterator();
-        Map map = getMap();
-        Map confirmed = getConfirmedMap();
+        MapIterator<K, V> it = makeObject();
+        Map<K, V> map = getMap();
+        Map<K, V> confirmed = getConfirmedMap();
         assertEquals(true, it.hasNext());
-        Object key = it.next();
-        
+        K key = it.next();
+
         if (supportsRemove() == false) {
             try {
                 it.remove();
@@ -268,12 +249,12 @@
             }
             return;
         }
-        
+
         it.remove();
         confirmed.remove(key);
         assertEquals(false, map.containsKey(key));
         verify();
-        
+
         try {
             it.remove();  // second remove fails
         } catch (IllegalStateException ex) {
@@ -286,19 +267,18 @@
         if (supportsSetValue() == false || supportsRemove() == false) {
             return;
         }
-        Object newValue = addSetValues()[0];
-        MapIterator it = makeFullMapIterator();
-        Map map = getMap();
-        Map confirmed = getConfirmedMap();
-        
+        V newValue = addSetValues()[0];
+        MapIterator<K, V> it = makeObject();
+        Map<K, V> confirmed = getConfirmedMap();
+
         assertEquals(true, it.hasNext());
-        Object key = it.next();
-        
+        K key = it.next();
+
         it.setValue(newValue);
         it.remove();
         confirmed.remove(key);
         verify();
-        
+
         try {
             it.setValue(newValue);
             fail();
@@ -311,17 +291,16 @@
         if (supportsRemove() == false) {
             return;
         }
-        MapIterator it = makeFullMapIterator();
-        Map map = getMap();
-        Map confirmed = getConfirmedMap();
-        
+        MapIterator<K, V> it = makeObject();
+        Map<K, V> confirmed = getConfirmedMap();
+
         assertEquals(true, it.hasNext());
-        Object key = it.next();
-        
+        K key = it.next();
+
         it.remove();
         confirmed.remove(key);
         verify();
-        
+
         try {
             it.getKey();
             fail();
@@ -334,17 +313,16 @@
         if (supportsRemove() == false) {
             return;
         }
-        MapIterator it = makeFullMapIterator();
-        Map map = getMap();
-        Map confirmed = getConfirmedMap();
-        
+        MapIterator<K, V> it = makeObject();
+        Map<K, V> confirmed = getConfirmedMap();
+
         assertEquals(true, it.hasNext());
-        Object key = it.next();
-        
+        K key = it.next();
+
         it.remove();
         confirmed.remove(key);
         verify();
-        
+
         try {
             it.getValue();
             fail();

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/AbstractTestOrderedMapIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/AbstractTestOrderedMapIterator.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/AbstractTestOrderedMapIterator.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/iterators/AbstractTestOrderedMapIterator.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,17 +33,17 @@
  * Concrete subclasses must provide the list iterator to be tested.
  * They must also specify certain details of how the list iterator operates by
  * overriding the supportsXxx() methods if necessary.
- * 
+ *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
- * 
+ *
  * @author Stephen Colebourne
  */
-public abstract class AbstractTestOrderedMapIterator extends AbstractTestMapIterator {
+public abstract class AbstractTestOrderedMapIterator<K, V> extends AbstractTestMapIterator<K, V> {
 
     /**
      * JUnit constructor.
-     * 
+     *
      * @param testName  the test class name
      */
     public AbstractTestOrderedMapIterator(String testName) {
@@ -51,14 +51,10 @@
     }
 
     //-----------------------------------------------------------------------
-    public final OrderedMapIterator makeEmptyOrderedMapIterator() {
-        return (OrderedMapIterator) makeEmptyMapIterator();
-    }
+    public abstract OrderedMapIterator<K, V> makeEmptyIterator();
+
+    public abstract OrderedMapIterator<K, V> makeObject();
 
-    public final OrderedMapIterator makeFullOrderedMapIterator() {
-        return (OrderedMapIterator) makeFullMapIterator();
-    }
-    
     //-----------------------------------------------------------------------
     /**
      * Test that the empty list iterator contract is correct.
@@ -69,9 +65,8 @@
         }
 
         super.testEmptyMapIterator();
-        
-        OrderedMapIterator it = makeEmptyOrderedMapIterator();
-        Map map = getMap();
+
+        OrderedMapIterator<K, V> it = makeEmptyIterator();
         assertEquals(false, it.hasPrevious());
         try {
             it.previous();
@@ -89,29 +84,29 @@
         }
 
         super.testFullMapIterator();
-        
-        OrderedMapIterator it = makeFullOrderedMapIterator();
-        Map map = getMap();
-        
+
+        OrderedMapIterator<K, V> it = makeObject();
+        Map<K, V> map = getMap();
+
         assertEquals(true, it.hasNext());
         assertEquals(false, it.hasPrevious());
-        Set set = new HashSet();
+        Set<K> set = new HashSet<K>();
         while (it.hasNext()) {
             // getKey
-            Object key = it.next();
+            K key = it.next();
             assertSame("it.next() should equals getKey()", key, it.getKey());
             assertTrue("Key must be in map",  map.containsKey(key));
             assertTrue("Key must be unique", set.add(key));
-            
+
             // getValue
-            Object value = it.getValue();
+            V value = it.getValue();
             if (isGetStructuralModify() == false) {
                 assertSame("Value must be mapped to key", map.get(key), value);
             }
             assertTrue("Value must be in map",  map.containsValue(value));
 
             assertEquals(true, it.hasPrevious());
-            
+
             verify();
         }
         while (it.hasPrevious()) {
@@ -120,7 +115,7 @@
             assertSame("it.previous() should equals getKey()", key, it.getKey());
             assertTrue("Key must be in map",  map.containsKey(key));
             assertTrue("Key must be unique", set.remove(key));
-            
+
             // getValue
             Object value = it.getValue();
             if (isGetStructuralModify() == false) {
@@ -129,11 +124,11 @@
             assertTrue("Value must be in map",  map.containsValue(value));
 
             assertEquals(true, it.hasNext());
-            
+
             verify();
         }
     }
-    
+
     //-----------------------------------------------------------------------
     /**
      * Test that the iterator order matches the keySet order.
@@ -143,27 +138,27 @@
             return;
         }
 
-        OrderedMapIterator it = makeFullOrderedMapIterator();
-        Map map = getMap();
-        
-        assertEquals("keySet() not consistent", new ArrayList(map.keySet()), new ArrayList(map.keySet()));
-        
-        Iterator it2 = map.keySet().iterator();
+        OrderedMapIterator<K, V> it = makeObject();
+        Map<K, V> map = getMap();
+
+        assertEquals("keySet() not consistent", new ArrayList<K>(map.keySet()), new ArrayList<K>(map.keySet()));
+
+        Iterator<K> it2 = map.keySet().iterator();
         assertEquals(true, it.hasNext());
         assertEquals(true, it2.hasNext());
-        List list = new ArrayList();
+        List<K> list = new ArrayList<K>();
         while (it.hasNext()) {
-            Object key = it.next();
+            K key = it.next();
             assertEquals(it2.next(), key);
             list.add(key);
         }
         assertEquals(map.size(), list.size());
         while (it.hasPrevious()) {
-            Object key = it.previous();
+            K key = it.previous();
             assertEquals(list.get(list.size() - 1), key);
             list.remove(list.size() - 1);
         }
         assertEquals(0, list.size());
     }
-    
+
 }



Mime
View raw message