commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r814997 [11/18] - in /commons/proper/collections/trunk/src: java/org/apache/commons/collections/ java/org/apache/commons/collections/bag/ java/org/apache/commons/collections/bidimap/ java/org/apache/commons/collections/buffer/ java/org/apac...
Date Tue, 15 Sep 2009 05:30:02 GMT
Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/BulkTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/BulkTest.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/BulkTest.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/BulkTest.java Tue Sep 15 05:29:56 2009
@@ -246,7 +246,7 @@
      *  @return  a {@link TestSuite} containing all the simple and bulk tests
      *    defined by that class
      */
-    public static TestSuite makeSuite(Class c) {
+    public static TestSuite makeSuite(Class<? extends BulkTest> c) {
         if (Modifier.isAbstract(c.getModifiers())) {
             throw new IllegalArgumentException("Class must not be abstract.");
         }
@@ -265,10 +265,10 @@
 class BulkTestSuiteMaker {
 
     /** The class that defines simple and bulk tests methods. */
-    private Class startingClass;
+    private Class<? extends BulkTest> startingClass;
 
     /** List of ignored simple test names. */
-    private List ignored;
+    private List<String> ignored;
    
     /** The TestSuite we're currently populating.  Can change over time. */
     private TestSuite result;
@@ -284,7 +284,7 @@
      *
      *  @param startingClass  the starting class
      */     
-    public BulkTestSuiteMaker(Class startingClass) {
+    public BulkTestSuiteMaker(Class<? extends BulkTest> startingClass) {
         this.startingClass = startingClass;
     }
 
@@ -299,7 +299,7 @@
          result.setName(prefix);
 
          BulkTest bulk = makeFirstTestCase(startingClass);
-         ignored = new ArrayList();
+         ignored = new ArrayList<String>();
          String[] s = bulk.ignoredTests();
          if (s != null) {
              ignored.addAll(Arrays.asList(s));
@@ -316,7 +316,7 @@
      *    tests for us to append
      */
     void make(BulkTest bulk) {
-        Class c = bulk.getClass();
+        Class<? extends BulkTest> c = bulk.getClass();
         Method[] all = c.getMethods();
         for (int i = 0; i < all.length; i++) {
             if (isTest(all[i])) addTest(bulk, all[i]);
@@ -388,7 +388,7 @@
      *  @param c  the class
      *  @return the name of that class, minus any package names
      */
-    private static String getBaseName(Class c) {
+    private static String getBaseName(Class<?> c) {
         String name = c.getName();
         int p = name.lastIndexOf('.');
         if (p > 0) {
@@ -401,7 +401,7 @@
     // These three methods are used to create a valid BulkTest instance
     // from a class.
 
-    private static Constructor getTestCaseConstructor(Class c) {
+    private static <T> Constructor<T> getTestCaseConstructor(Class<T> c) {
         try {
             return c.getConstructor(new Class[] { String.class });
         } catch (NoSuchMethodException e) {
@@ -410,10 +410,10 @@
         }
     }
 
-    private static BulkTest makeTestCase(Class c, Method m) {
-        Constructor con = getTestCaseConstructor(c);
+    private static <T extends BulkTest> BulkTest makeTestCase(Class<T> c, Method m) {
+        Constructor<T> con = getTestCaseConstructor(c);
         try {
-            return (BulkTest)con.newInstance(new Object[] {m.getName()});
+            return (BulkTest) con.newInstance(new Object[] { m.getName() });
         } catch (InvocationTargetException e) {
             e.printStackTrace();
             throw new RuntimeException(); // FIXME;
@@ -424,7 +424,7 @@
         }
     }
 
-    private static BulkTest makeFirstTestCase(Class c) {
+    private static <T extends BulkTest> BulkTest makeFirstTestCase(Class<T> c) {
         Method[] all = c.getMethods();
         for (int i = 0; i < all.length; i++) {
             if (isTest(all[i])) return makeTestCase(c, all[i]);

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/LocalTestNode.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/LocalTestNode.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/LocalTestNode.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/LocalTestNode.java Tue Sep 15 05:29:56 2009
@@ -23,46 +23,50 @@
  *
  * @author Marc Johnson (marcj at users dot sourceforge dot net)
  */
-class LocalTestNode implements Comparable {
+class LocalTestNode<K extends Comparable<K>, V extends Comparable<V>> implements Comparable<LocalTestNode<K, V>> {
 
-    private Comparable key;
-    private Comparable value;
+    private K key;
+    private V value;
+
+    static LocalTestNode<Integer, String> createLocalTestNode(final int key) {
+        return new LocalTestNode<Integer, String>(key, String.valueOf(key));
+    }
 
     /**
      * construct a LocalTestNode
      *
      * @param key value used to create the key and value
      */
-    LocalTestNode(final int key) {
-        this.key   = new Integer(key);
-        this.value = String.valueOf(key);
+    private LocalTestNode(K key, V value) {
+        this.key = key;
+        this.value = value;
     }
 
     /**
      * @param key the unique key associated with the current node.
      */
-    void setKey(Comparable key) {
+    void setKey(K key) {
         this.key = key;
     }
 
     /**
      * @return the unique key associated with the current node
      */
-    Comparable getKey() {
+    K getKey() {
         return key;
     }
 
     /**
      * @param value the unique value associated with the current node.
      */
-    void setValue(Comparable value) {
+    void setValue(V value) {
         this.value = value;
     }
 
     /**
      * @return the unique value associated with the current node
      */
-    Comparable getValue() {
+    V getValue() {
         return value;
     }
 
@@ -74,10 +78,9 @@
      * @return a negative integer, zero, or a positive integer
      *  as this object is less than, equal to, or greater than the specified object.
      */
-    public int compareTo(Object o) {
+    public int compareTo(LocalTestNode<K, V> other) {
 
-        LocalTestNode other = (LocalTestNode) o;
-        int           rval  = getKey().compareTo(other.getKey());
+        int rval = getKey().compareTo(other.getKey());
 
         if (rval == 0) {
             rval = getValue().compareTo(other.getValue());
@@ -93,6 +96,7 @@
      *
      * @return true if equal
      */
+    @SuppressWarnings("unchecked")
     public boolean equals(Object o) {
 
         if (o == null) {

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestArrayList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestArrayList.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestArrayList.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestArrayList.java Tue Sep 15 05:29:56 2009
@@ -30,10 +30,8 @@
  *
  * @author Jason van Zyl
  */
-public abstract class TestArrayList extends AbstractTestList {
-    
-    protected ArrayList list = null;
-    
+public abstract class TestArrayList<E> extends AbstractTestList<E> {
+
     public TestArrayList(String testName) {
         super(testName);
     }
@@ -47,12 +45,15 @@
         junit.textui.TestRunner.main(testCaseName);
     }
 
-    public void setUp() {
-        list = (ArrayList) makeEmptyList();
-    }
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public abstract ArrayList<E> makeObject();
 
     //-----------------------------------------------------------------------
     public void testNewArrayList() {
+        ArrayList<E> list = makeObject();
         assertTrue("New list is empty", list.isEmpty());
         assertEquals("New list has size zero", 0, list.size());
 
@@ -64,9 +65,11 @@
         }
     }
 
+    @SuppressWarnings("unchecked")
     public void testSearch() {
-        list.add("First Item");
-        list.add("Last Item");
+        ArrayList<E> list = makeObject();
+        list.add((E) "First Item");
+        list.add((E) "Last Item");
         assertEquals("First item is 'First Item'", "First Item", list.get(0));
         assertEquals("Last Item is 'Last Item'", "Last Item", list.get(1));
     }

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestArrayStack.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestArrayStack.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestArrayStack.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestArrayStack.java Tue Sep 15 05:29:56 2009
@@ -17,7 +17,6 @@
 package org.apache.commons.collections;
 
 import java.util.EmptyStackException;
-import java.util.List;
 
 import junit.framework.Test;
 
@@ -28,10 +27,8 @@
  *
  * @author Craig McClanahan
  */
-public class TestArrayStack extends TestArrayList {
+public class TestArrayStack<E> extends TestArrayList<E> {
     
-    protected ArrayStack stack = null;
-
     public TestArrayStack(String testName) {
         super(testName);
     }
@@ -45,18 +42,13 @@
         junit.textui.TestRunner.main(testCaseName);
     }
 
-    public List makeEmptyList() {
-        return new ArrayStack();
-    }
-
-    public void setUp() {
-        stack = (ArrayStack) makeEmptyList();
-        list = stack;
+    public ArrayStack<E> makeObject() {
+        return new ArrayStack<E>();
     }
 
     //-----------------------------------------------------------------------
     public void testNewStack() {
-
+        ArrayStack<E> stack = makeObject();
         assertTrue("New stack is empty", stack.empty());
         assertEquals("New stack has size zero", 0, stack.size());
 
@@ -76,16 +68,18 @@
 
     }
 
+    @SuppressWarnings("unchecked")
     public void testPushPeekPop() {
+        ArrayStack<E> stack = makeObject();
 
-        stack.push("First Item");
+        stack.push((E) "First Item");
         assertTrue("Stack is not empty", !stack.empty());
         assertEquals("Stack size is one", 1, stack.size());
         assertEquals("Top item is 'First Item'",
                      "First Item", (String) stack.peek());
         assertEquals("Stack size is one", 1, stack.size());
 
-        stack.push("Second Item");
+        stack.push((E) "Second Item");
         assertEquals("Stack size is two", 2, stack.size());
         assertEquals("Top item is 'Second Item'",
                      "Second Item", (String) stack.peek());
@@ -103,10 +97,12 @@
 
     }
 
+    @SuppressWarnings("unchecked")
     public void testSearch() {
+        ArrayStack<E> stack = makeObject();
 
-        stack.push("First Item");
-        stack.push("Second Item");
+        stack.push((E) "First Item");
+        stack.push((E) "Second Item");
         assertEquals("Top item is 'Second Item'",
                      1, stack.search("Second Item"));
         assertEquals("Next Item is 'First Item'",

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestBufferUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestBufferUtils.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestBufferUtils.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestBufferUtils.java Tue Sep 15 05:29:56 2009
@@ -42,16 +42,16 @@
     }
 
     public void testpredicatedBuffer() {
-        Predicate predicate = new Predicate() {
+        Predicate<Object> predicate = new Predicate<Object>() {
             public boolean evaluate(Object o) {
                 return o instanceof String;
             }
         };
-        Buffer buffer = BufferUtils.predicatedBuffer(new ArrayStack(), predicate);
+        Buffer<Object> buffer = BufferUtils.predicatedBuffer(new ArrayStack<Object>(), predicate);
         assertTrue("returned object should be a PredicatedBuffer",
             buffer instanceof PredicatedBuffer);
         try {
-            buffer = BufferUtils.predicatedBuffer(new ArrayStack(), null);
+            buffer = BufferUtils.predicatedBuffer(new ArrayStack<Object>(), null);
             fail("Expecting IllegalArgumentException for null predicate.");
         } catch (IllegalArgumentException ex) {
             // expected

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestEnumerationUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestEnumerationUtils.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestEnumerationUtils.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestEnumerationUtils.java Tue Sep 15 05:29:56 2009
@@ -39,46 +39,46 @@
     public static final String TO_LIST_FIXTURE = "this is a test";
     
     public void testToListWithStringTokenizer() {
-        List expectedList1 = new ArrayList();
+        List<String> expectedList1 = new ArrayList<String>();
         StringTokenizer st = new StringTokenizer(TO_LIST_FIXTURE);
              while (st.hasMoreTokens()) {
                  expectedList1.add(st.nextToken());
-             }        
-        List expectedList2 = new ArrayList();
+             }
+        List<String> expectedList2 = new ArrayList<String>();
         expectedList2.add("this");
         expectedList2.add("is");
         expectedList2.add("a");
         expectedList2.add("test");
-        List actualList = EnumerationUtils.toList(new StringTokenizer(TO_LIST_FIXTURE));
+        List<String> actualList = EnumerationUtils.toList(new StringTokenizer(TO_LIST_FIXTURE));
         Assert.assertEquals(expectedList1, expectedList2);
         Assert.assertEquals(expectedList1, actualList);
         Assert.assertEquals(expectedList2, actualList);
     }
 
     public void testToListWithHashtable() {
-        Hashtable expected = new Hashtable();
+        Hashtable<String, Integer> expected = new Hashtable<String, Integer>();
         expected.put("one", new Integer(1));
         expected.put("two", new Integer(2));
         expected.put("three", new Integer(3));
         // validate elements.
-        List actualEltList = EnumerationUtils.toList(expected.elements());
+        List<Integer> actualEltList = EnumerationUtils.toList(expected.elements());
         Assert.assertEquals(expected.size(), actualEltList.size());
         Assert.assertTrue(actualEltList.contains(new Integer(1)));
         Assert.assertTrue(actualEltList.contains(new Integer(2)));
         Assert.assertTrue(actualEltList.contains(new Integer(3)));
-        List expectedEltList = new ArrayList();
+        List<Integer> expectedEltList = new ArrayList<Integer>();
         expectedEltList.add(new Integer(1));
         expectedEltList.add(new Integer(2));
         expectedEltList.add(new Integer(3));
         Assert.assertTrue(actualEltList.containsAll(expectedEltList));
 
         // validate keys.
-        List actualKeyList = EnumerationUtils.toList(expected.keys());
+        List<String> actualKeyList = EnumerationUtils.toList(expected.keys());
         Assert.assertEquals(expected.size(), actualEltList.size());
         Assert.assertTrue(actualKeyList.contains("one"));
         Assert.assertTrue(actualKeyList.contains("two"));
         Assert.assertTrue(actualKeyList.contains("three"));
-        List expectedKeyList = new ArrayList();
+        List<String> expectedKeyList = new ArrayList<String>();
         expectedKeyList.add("one");
         expectedKeyList.add("two");
         expectedKeyList.add("three");

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestLinkedList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestLinkedList.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestLinkedList.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestLinkedList.java Tue Sep 15 05:29:56 2009
@@ -38,46 +38,21 @@
  *
  * @author Rich Dougherty
  */
-public abstract class TestLinkedList extends AbstractTestList {
+public abstract class TestLinkedList<T> extends AbstractTestList<T> {
 
     public TestLinkedList(String testName) {
         super(testName);
     }
 
-    public List makeEmptyList() {
-        return makeEmptyLinkedList();
-    }
-
-    public List makeFullList() {
-        return makeFullLinkedList();
-    }
-
-    /**
-     *  Return a new, empty {@link LinkedList} to be used for testing.
-     *
-     *  @return an empty list for testing.
-     */
-    protected abstract LinkedList makeEmptyLinkedList();
-
-    /**
-     *  Return a new, full {@link List} to be used for testing.
-     *
-     *  @return a full list for testing
-     */
-    protected LinkedList makeFullLinkedList() {
-        // only works if list supports optional "addAll(Collection)" 
-        LinkedList list = makeEmptyLinkedList();
-        list.addAll(Arrays.asList(getFullElements()));
-        return list;
-    }
+    public abstract LinkedList<T> makeObject();
 
     /**
      *  Returns the {@link #collection} field cast to a {@link LinkedList}.
      *
      *  @return the collection field as a List
      */
-    protected LinkedList getLinkedList() {
-        return (LinkedList)collection;
+    public LinkedList<T> getCollection() {
+        return (LinkedList<T>) super.getCollection();
     }
 
     /**
@@ -85,24 +60,25 @@
      *
      *  @return the confirmed field as a List
      */
-    protected LinkedList getConfirmedLinkedList() {
-        return (LinkedList)confirmed;
+    protected LinkedList<T> getConfirmedLinkedList() {
+        return (LinkedList<T>) getConfirmed();
     }
 
     /**
      *  Tests {@link LinkedList#addFirst(Object)}.
      */
+    @SuppressWarnings("unchecked")
     public void testLinkedListAddFirst() {
         if (!isAddSupported()) return;
-        Object o = "hello";
+        T o = (T) "hello";
 
         resetEmpty();
-        getLinkedList().addFirst(o);
+        getCollection().addFirst(o);
         getConfirmedLinkedList().addFirst(o);
         verify();
 
         resetFull();
-        getLinkedList().addFirst(o);
+        getCollection().addFirst(o);
         getConfirmedLinkedList().addFirst(o);
         verify();
     }
@@ -110,17 +86,18 @@
     /**
      *  Tests {@link LinkedList#addLast(Object)}.
      */
+    @SuppressWarnings("unchecked")
     public void testLinkedListAddLast() {
         if (!isAddSupported()) return;
-        Object o = "hello";
+        T o = (T) "hello";
 
         resetEmpty();
-        getLinkedList().addLast(o);
+        getCollection().addLast(o);
         getConfirmedLinkedList().addLast(o);
         verify();
 
         resetFull();
-        getLinkedList().addLast(o);
+        getCollection().addLast(o);
         getConfirmedLinkedList().addLast(o);
         verify();
     }
@@ -131,7 +108,7 @@
     public void testLinkedListGetFirst() {
         resetEmpty();
         try {
-            getLinkedList().getFirst();
+            getCollection().getFirst();
             fail("getFirst() should throw a NoSuchElementException for an " +
                     "empty list.");
         } catch (NoSuchElementException e) {
@@ -140,7 +117,7 @@
         verify();
 
         resetFull();
-        Object first = getLinkedList().getFirst();
+        Object first = getCollection().getFirst();
         Object confirmedFirst = getConfirmedLinkedList().getFirst();
         assertEquals("Result returned by getFirst() was wrong.",
                 confirmedFirst, first);
@@ -153,7 +130,7 @@
     public void testLinkedListGetLast() {
         resetEmpty();
         try {
-            getLinkedList().getLast();
+            getCollection().getLast();
             fail("getLast() should throw a NoSuchElementException for an " +
                     "empty list.");
         } catch (NoSuchElementException e) {
@@ -162,7 +139,7 @@
         verify();
         
         resetFull();
-        Object last = getLinkedList().getLast();
+        Object last = getCollection().getLast();
         Object confirmedLast = getConfirmedLinkedList().getLast();
         assertEquals("Result returned by getLast() was wrong.",
                 confirmedLast, last);
@@ -177,7 +154,7 @@
 
         resetEmpty();
         try {
-            getLinkedList().removeFirst();
+            getCollection().removeFirst();
             fail("removeFirst() should throw a NoSuchElementException for " +
                     "an empty list.");
         } catch (NoSuchElementException e) {
@@ -186,7 +163,7 @@
         verify();
         
         resetFull();
-        Object first = getLinkedList().removeFirst();
+        Object first = getCollection().removeFirst();
         Object confirmedFirst = getConfirmedLinkedList().removeFirst();
         assertEquals("Result returned by removeFirst() was wrong.",
                 confirmedFirst, first);
@@ -201,7 +178,7 @@
 
         resetEmpty();
         try {
-            getLinkedList().removeLast();
+            getCollection().removeLast();
             fail("removeLast() should throw a NoSuchElementException for " +
                     "an empty list.");
         } catch (NoSuchElementException e) {
@@ -210,7 +187,7 @@
         verify();
 
         resetFull();
-        Object last = getLinkedList().removeLast();
+        Object last = getCollection().removeLast();
         Object confirmedLast = getConfirmedLinkedList().removeLast();
         assertEquals("Result returned by removeLast() was wrong.",
                 confirmedLast, last);
@@ -220,15 +197,15 @@
     /**
      *  Returns an empty {@link LinkedList}.
      */
-    public Collection makeConfirmedCollection() {
-        return new LinkedList();
+    public Collection<T> makeConfirmedCollection() {
+        return new LinkedList<T>();
     }
 
     /**
      *  Returns a full {@link LinkedList}.
      */
-    public Collection makeConfirmedFullCollection() {
-        List list = new LinkedList();
+    public Collection<T> makeConfirmedFullCollection() {
+        List<T> list = new LinkedList<T>();
         list.addAll(Arrays.asList(getFullElements()));
         return list;
     }

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestSetUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestSetUtils.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestSetUtils.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestSetUtils.java Tue Sep 15 05:29:56 2009
@@ -46,18 +46,17 @@
 
     public void testNothing() {
     }
-    
+
     public void testpredicatedSet() {
-        Predicate predicate = new Predicate() {
+        Predicate<Object> predicate = new Predicate<Object>() {
             public boolean evaluate(Object o) {
                 return o instanceof String;
             }
         };
-        Set set = SetUtils.predicatedSet(new HashSet(), predicate);
-        assertTrue("returned object should be a PredicatedSet",
-            set instanceof PredicatedSet);
+        Set<Object> set = SetUtils.predicatedSet(new HashSet<Object>(), predicate);
+        assertTrue("returned object should be a PredicatedSet", set instanceof PredicatedSet);
         try {
-            set = SetUtils.predicatedSet(new HashSet(), null);
+            set = SetUtils.predicatedSet(new HashSet<Object>(), null);
             fail("Expecting IllegalArgumentException for null predicate.");
         } catch (IllegalArgumentException ex) {
             // expected
@@ -71,11 +70,11 @@
     }
 
     public void testEquals() {
-        Collection data = Arrays.asList( new String[] { "a", "b", "c" });
-        
-        Set a = new HashSet( data );
-        Set b = new HashSet( data );
-        
+        Collection<String> data = Arrays.asList( new String[] { "a", "b", "c" });
+
+        Set<String> a = new HashSet<String>(data);
+        Set<String> b = new HashSet<String>(data);
+
         assertEquals(true, a.equals(b));
         assertEquals(true, SetUtils.isEqualSet(a, b));
         a.clear();
@@ -84,13 +83,13 @@
         assertEquals(false, SetUtils.isEqualSet(null, b));
         assertEquals(true, SetUtils.isEqualSet(null, null));
     }
-    
+
     public void testHashCode() {
-        Collection data = Arrays.asList( new String[] { "a", "b", "c" });
-            
-        Set a = new HashSet( data );
-        Set b = new HashSet( data );
-        
+        Collection<String> data = Arrays.asList( new String[] { "a", "b", "c" });
+
+        Set<String> a = new HashSet<String>(data);
+        Set<String> b = new HashSet<String>(data);
+
         assertEquals(true, a.hashCode() == b.hashCode());
         assertEquals(true, a.hashCode() == SetUtils.hashCodeForSet(a));
         assertEquals(true, b.hashCode() == SetUtils.hashCodeForSet(b));
@@ -98,6 +97,6 @@
         a.clear();
         assertEquals(false, SetUtils.hashCodeForSet(a) == SetUtils.hashCodeForSet(b));
         assertEquals(0, SetUtils.hashCodeForSet(null));
-    }   
+    }
 
 }

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestTreeMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestTreeMap.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestTreeMap.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestTreeMap.java Tue Sep 15 05:29:56 2009
@@ -27,8 +27,8 @@
  *
  * @author Jason van Zyl
  */
-public abstract class TestTreeMap extends AbstractTestMap {
-    
+public abstract class TestTreeMap<K, V> extends AbstractTestMap<K, V> {
+
     public TestTreeMap(String testName) {
         super(testName);
     }
@@ -42,23 +42,27 @@
         return false;
     }
 
-    protected TreeMap map = null;
-
-    public void setUp() {
-        map = (TreeMap) makeEmptyMap();
-    }
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public abstract TreeMap<K, V> makeObject();
 
     public void testNewMap() {
+        TreeMap<K, V> map = makeObject();
         assertTrue("New map is empty", map.isEmpty());
         assertEquals("New map has size zero", 0, map.size());
     }
 
+    @SuppressWarnings("unchecked")
     public void testSearch() {
-        map.put("first", "First Item");
-        map.put("second", "Second Item");
+        TreeMap<K, V> map = makeObject();
+        map.put((K) "first", (V) "First Item");
+        map.put((K) "second", (V) "Second Item");
         assertEquals("Top item is 'Second Item'",
             "First Item", map.get("first"));
         assertEquals("Next Item is 'First Item'",
             "Second Item", map.get("second"));
     }
+
 }

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestTypedCollection.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestTypedCollection.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestTypedCollection.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestTypedCollection.java Tue Sep 15 05:29:56 2009
@@ -27,25 +27,25 @@
  *
  * @author Stephen Colebourne
  */
-public abstract class TestTypedCollection extends BulkTest {
+public abstract class TestTypedCollection<T> extends BulkTest {
 
     public TestTypedCollection(String name) {
         super(name);
     }
 
+    protected abstract Collection<T> typedCollection();
 
-    protected abstract Collection typedCollection();
-
-    protected Class getType() {
-        return String.class;
+    @SuppressWarnings("unchecked")
+    protected Class<T> getType() {
+        return (Class<T>) String.class;
     }
 
-
+    @SuppressWarnings("unchecked")
     public void testIllegalAdd() {
-        Collection c = typedCollection();
+        Collection<T> c = typedCollection();
         Integer i = new Integer(3);
         try {
-            c.add(i);
+            c.add((T) i);
             fail("Integer should fail string predicate.");
         } catch (IllegalArgumentException e) {
             // expected
@@ -55,15 +55,16 @@
     }
 
 
+    @SuppressWarnings("unchecked")
     public void testIllegalAddAll() {
-        Collection c = typedCollection();
-        List elements = new ArrayList();
+        Collection<T> c = typedCollection();
+        List<Object> elements = new ArrayList<Object>();
         elements.add("one");
         elements.add("two");
         elements.add(new Integer(3));
         elements.add("four");
         try {
-            c.addAll(elements);
+            c.addAll((Collection<? extends T>) elements);
             fail("Integer should fail string predicate.");
         } catch (IllegalArgumentException e) {
             // expected

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/AbstractTestSortedBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/AbstractTestSortedBag.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/AbstractTestSortedBag.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/AbstractTestSortedBag.java Tue Sep 15 05:29:56 2009
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.collections.bag;
 
+import org.apache.commons.collections.SortedBag;
+
 /**
  * Abstract test class for
  * {@link org.apache.commons.collections.SortedBag SortedBag}
@@ -26,11 +28,17 @@
  *
  * @author Stephen Colebourne
  */
-public abstract class AbstractTestSortedBag extends AbstractTestBag {
+public abstract class AbstractTestSortedBag<T> extends AbstractTestBag<T> {
 
     public AbstractTestSortedBag(String testName) {
         super(testName);
     }
-    
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public abstract SortedBag<T> makeObject();
+
     // TODO: Add the SortedBag tests!
 }

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestHashBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestHashBag.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestHashBag.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestHashBag.java Tue Sep 15 05:29:56 2009
@@ -29,7 +29,7 @@
  *
  * @author Chuck Burdick
  */
-public class TestHashBag extends AbstractTestBag {
+public class TestHashBag<T> extends AbstractTestBag<T> {
     
     public TestHashBag(String testName) {
         super(testName);
@@ -44,8 +44,8 @@
         junit.textui.TestRunner.main(testCaseName);
     }
 
-    public Bag makeBag() {
-        return new HashBag();
+    public Bag<T> makeObject() {
+        return new HashBag<T>();
     }
     
     public String getCompatibilityVersion() {

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestPredicatedBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestPredicatedBag.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestPredicatedBag.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestPredicatedBag.java Tue Sep 15 05:29:56 2009
@@ -23,7 +23,7 @@
 
 import org.apache.commons.collections.Bag;
 import org.apache.commons.collections.Predicate;
-import org.apache.commons.collections.PredicateUtils;
+import org.apache.commons.collections.functors.TruePredicate;
 
 /**
  * Extension of {@link AbstractTestBag} for exercising the {@link PredicatedBag}
@@ -34,8 +34,8 @@
  *
  * @author Phil Steitz
  */
-public class TestPredicatedBag extends AbstractTestBag {
-    
+public class TestPredicatedBag<T> extends AbstractTestBag<T> {
+
     public TestPredicatedBag(String testName) {
         super(testName);
     }
@@ -48,81 +48,84 @@
         String[] testCaseName = { TestPredicatedBag.class.getName()};
         junit.textui.TestRunner.main(testCaseName);
     }
-    
+
     //--------------------------------------------------------------------------
 
-    protected Predicate stringPredicate() {
-        return new Predicate() {
-            public boolean evaluate(Object o) {
+    protected Predicate<T> stringPredicate() {
+        return new Predicate<T>() {
+            public boolean evaluate(T o) {
                 return o instanceof String;
             }
         };
-    }   
-    
-    protected Predicate truePredicate = PredicateUtils.truePredicate();
-    
-    protected Bag decorateBag(HashBag bag, Predicate predicate) {
+    }
+
+    protected Predicate<T> truePredicate = TruePredicate.<T>truePredicate();
+
+    protected Bag<T> decorateBag(HashBag<T> bag, Predicate<T> predicate) {
         return PredicatedBag.decorate(bag, predicate);
     }
 
-    public Bag makeBag() {
-        return decorateBag(new HashBag(), truePredicate);
+    public Bag<T> makeObject() {
+        return decorateBag(new HashBag<T>(), truePredicate);
     }
-    
-    protected Bag makeTestBag() {
-        return decorateBag(new HashBag(), stringPredicate());
+
+    protected Bag<T> makeTestBag() {
+        return decorateBag(new HashBag<T>(), stringPredicate());
     }
-    
+
     //--------------------------------------------------------------------------
 
+    @SuppressWarnings("unchecked")
     public void testlegalAddRemove() {
-        Bag bag = makeTestBag();
+        Bag<T> bag = makeTestBag();
         assertEquals(0, bag.size());
-        Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "1"};
+        T[] els = (T[]) new Object[] { "1", "3", "5", "7", "2", "4", "1" };
         for (int i = 0; i < els.length; i++) {
             bag.add(els[i]);
             assertEquals(i + 1, bag.size());
             assertEquals(true, bag.contains(els[i]));
         }
-        Set set = ((PredicatedBag) bag).uniqueSet();
+        Set<T> set = ((PredicatedBag<T>) bag).uniqueSet();
         assertTrue("Unique set contains the first element",set.contains(els[0]));
-        assertEquals(true, bag.remove(els[0])); 
-        set = ((PredicatedBag) bag).uniqueSet();
+        assertEquals(true, bag.remove(els[0]));
+        set = ((PredicatedBag<T>) bag).uniqueSet();
         assertTrue("Unique set now does not contain the first element",
-            !set.contains(els[0])); 
+            !set.contains(els[0]));
     }
- 
+
+    @SuppressWarnings("unchecked")
     public void testIllegalAdd() {
-        Bag bag = makeTestBag();
+        Bag<T> bag = makeTestBag();
         Integer i = new Integer(3);
         try {
-            bag.add(i);
+            bag.add((T) i);
             fail("Integer should fail string predicate.");
         } catch (IllegalArgumentException e) {
             // expected
         }
-        assertTrue("Collection shouldn't contain illegal element", 
-         !bag.contains(i));   
+        assertTrue("Collection shouldn't contain illegal element",
+         !bag.contains(i));
     }
 
+    @SuppressWarnings("unchecked")
     public void testIllegalDecorate() {
-        HashBag elements = new HashBag();
+        HashBag<Object> elements = new HashBag<Object>();
         elements.add("one");
         elements.add("two");
         elements.add(new Integer(3));
         elements.add("four");
         try {
-            Bag bag = decorateBag(elements, stringPredicate());
+            decorateBag((HashBag<T>) elements, stringPredicate());
             fail("Bag contains an element that should fail the predicate.");
         } catch (IllegalArgumentException e) {
             // expected
         }
         try {
-            Bag bag = decorateBag(new HashBag(), null);
+            decorateBag(new HashBag<T>(), null);
             fail("Expectiing IllegalArgumentException for null predicate.");
         } catch (IllegalArgumentException e) {
             // expected
-        }              
+        }
     }
 
     public String getCompatibilityVersion() {

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestTransformedBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestTransformedBag.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestTransformedBag.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestTransformedBag.java Tue Sep 15 05:29:56 2009
@@ -20,6 +20,7 @@
 import junit.framework.TestSuite;
 
 import org.apache.commons.collections.Bag;
+import org.apache.commons.collections.Transformer;
 import org.apache.commons.collections.collection.TestTransformedCollection;
 
 /**
@@ -31,8 +32,8 @@
  *
  * @author Stephen Colebourne
  */
-public class TestTransformedBag extends AbstractTestBag {
-    
+public class TestTransformedBag<T> extends AbstractTestBag<T> {
+
     public TestTransformedBag(String testName) {
         super(testName);
     }
@@ -46,25 +47,29 @@
         junit.textui.TestRunner.main(testCaseName);
     }
 
-    public Bag makeBag() {
-        return TransformedBag.decorate(new HashBag(), TestTransformedCollection.NOOP_TRANSFORMER);
+    @SuppressWarnings("unchecked")
+    public Bag<T> makeObject() {
+        return TransformedBag.decorate(new HashBag<T>(), (Transformer<T, T>) TestTransformedCollection.NOOP_TRANSFORMER);
     }
 
+    @SuppressWarnings("unchecked")
     public void testTransformedBag() {
-        Bag bag = TransformedBag.decorate(new HashBag(), TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
+        //T had better be Object!
+        Bag<T> bag = TransformedBag.decorate(new HashBag<T>(), (Transformer<T, T>) TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
         assertEquals(0, bag.size());
         Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
         for (int i = 0; i < els.length; i++) {
-            bag.add(els[i]);
+            bag.add((T) els[i]);
             assertEquals(i + 1, bag.size());
             assertEquals(true, bag.contains(new Integer((String) els[i])));
             assertEquals(false, bag.contains(els[i]));
         }
-        
+
         assertEquals(false, bag.remove(els[0]));
         assertEquals(true, bag.remove(new Integer((String) els[0])));
     }
 
+    // TODO: Generics
     public void testTransformedBag_decorateTransform() {
         Bag originalBag = new HashBag();
         Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestTransformedSortedBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestTransformedSortedBag.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestTransformedSortedBag.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestTransformedSortedBag.java Tue Sep 15 05:29:56 2009
@@ -20,6 +20,8 @@
 import junit.framework.TestSuite;
 
 import org.apache.commons.collections.Bag;
+import org.apache.commons.collections.SortedBag;
+import org.apache.commons.collections.Transformer;
 import org.apache.commons.collections.collection.TestTransformedCollection;
 
 /**
@@ -31,8 +33,8 @@
  *
  * @author Stephen Colebourne
  */
-public class TestTransformedSortedBag extends AbstractTestSortedBag {
-    
+public class TestTransformedSortedBag<T> extends AbstractTestSortedBag<T> {
+
     public TestTransformedSortedBag(String testName) {
         super(testName);
     }
@@ -46,22 +48,24 @@
         junit.textui.TestRunner.main(testCaseName);
     }
 
-    public Bag makeBag() {
-        return TransformedSortedBag.decorate(new TreeBag(), TestTransformedCollection.NOOP_TRANSFORMER);
+    @SuppressWarnings("unchecked")
+    public SortedBag<T> makeObject() {
+        return TransformedSortedBag.decorate(new TreeBag<T>(), (Transformer<T, T>) TestTransformedCollection.NOOP_TRANSFORMER);
     }
 
+    @SuppressWarnings("unchecked")
     public void testTransformedBag() {
-        Bag bag = TransformedSortedBag.decorate(new TreeBag(), TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
+        SortedBag<T> bag = TransformedSortedBag.decorate(new TreeBag<T>(), (Transformer<T, T>) TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
         assertEquals(0, bag.size());
         Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
         for (int i = 0; i < els.length; i++) {
-            bag.add(els[i]);
+            bag.add((T) els[i]);
             assertEquals(i + 1, bag.size());
             assertEquals(true, bag.contains(new Integer((String) els[i])));
         }
-        
+
         assertEquals(true, bag.remove(new Integer((String) els[0])));
-        
+
     }
 
     public void testTransformedBag_decorateTransform() {

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestTreeBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestTreeBag.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestTreeBag.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/TestTreeBag.java Tue Sep 15 05:29:56 2009
@@ -30,48 +30,26 @@
  *
  * @author Chuck Burdick
  */
-public class TestTreeBag extends AbstractTestBag {
-    
-   public TestTreeBag(String testName) {
-      super(testName);
-   }
-
-   public static Test suite() {
-      return new TestSuite(TestTreeBag.class);
-   }
+public class TestTreeBag<T> extends AbstractTestSortedBag<T> {
 
-   public static void main(String args[]) {
-      String[] testCaseName = { TestTreeBag.class.getName() };
-      junit.textui.TestRunner.main(testCaseName);
-   }
-
-   public Bag makeBag() {
-      return new TreeBag();
-   }
-
-   public SortedBag setupBag() {
-      SortedBag bag = (SortedBag)makeBag();
-      bag.add("C");
-      bag.add("A");
-      bag.add("B");
-      bag.add("D");
-      return bag;
-   }
-
-   public void testOrdering() {
-      Bag bag = setupBag();
-      assertEquals("Should get elements in correct order",
-                   "A", bag.toArray()[0]);
-      assertEquals("Should get elements in correct order",
-                   "B", bag.toArray()[1]);
-      assertEquals("Should get elements in correct order",
-                   "C", bag.toArray()[2]);
-      assertEquals("Should get first key",
-                   "A", ((SortedBag)bag).first());
-      assertEquals("Should get last key",
-                   "D", ((SortedBag)bag).last());
-   }
+    public TestTreeBag(String testName) {
+        super(testName);
+    }
+
+    public static Test suite() {
+        return new TestSuite(TestTreeBag.class);
+    }
+
+    public static void main(String args[]) {
+        String[] testCaseName = { TestTreeBag.class.getName() };
+        junit.textui.TestRunner.main(testCaseName);
+    }
+
+    public SortedBag<T> makeObject() {
+        return new TreeBag<T>();
+    }
 
+   // TODO: Generics (for example... is this even needed?)
    public void testCollections265() {
        Bag bag = new TreeBag();
        try {
@@ -82,19 +60,38 @@
        }
    }
    
-   public String getCompatibilityVersion() {
-       return "3";
-   }
-    
-//   public void testCreate() throws Exception {
-//       Bag bag = makeBag();
-//       writeExternalFormToDisk((Serializable) bag, "D:/dev/collections/data/test/TreeBag.emptyCollection.version3.obj");
-//       bag = makeBag();
-//       bag.add("A");
-//       bag.add("A");
-//       bag.add("B");
-//       bag.add("B");
-//       bag.add("C");
-//       writeExternalFormToDisk((Serializable) bag, "D:/dev/collections/data/test/TreeBag.fullCollection.version3.obj");
-//   }
+    @SuppressWarnings("unchecked")
+    public SortedBag<T> setupBag() {
+        SortedBag<T> bag = makeObject();
+        bag.add((T) "C");
+        bag.add((T) "A");
+        bag.add((T) "B");
+        bag.add((T) "D");
+        return bag;
+    }
+
+    public void testOrdering() {
+        Bag<T> bag = setupBag();
+        assertEquals("Should get elements in correct order", "A", bag.toArray()[0]);
+        assertEquals("Should get elements in correct order", "B", bag.toArray()[1]);
+        assertEquals("Should get elements in correct order", "C", bag.toArray()[2]);
+        assertEquals("Should get first key", "A", ((SortedBag<T>) bag).first());
+        assertEquals("Should get last key", "D", ((SortedBag<T>) bag).last());
+    }
+
+    public String getCompatibilityVersion() {
+        return "3";
+    }
+
+    //   public void testCreate() throws Exception {
+    //       Bag bag = makeBag();
+    //       writeExternalFormToDisk((Serializable) bag, "D:/dev/collections/data/test/TreeBag.emptyCollection.version3.obj");
+    //       bag = makeBag();
+    //       bag.add("A");
+    //       bag.add("A");
+    //       bag.add("B");
+    //       bag.add("B");
+    //       bag.add("C");
+    //       writeExternalFormToDisk((Serializable) bag, "D:/dev/collections/data/test/TreeBag.fullCollection.version3.obj");
+    //   }
 }

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/AbstractTestOrderedBidiMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/AbstractTestOrderedBidiMap.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/AbstractTestOrderedBidiMap.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/AbstractTestOrderedBidiMap.java Tue Sep 15 05:29:56 2009
@@ -36,7 +36,7 @@
  * @author Matthew Hawthorne
  * @author Stephen Colebourne
  */
-public abstract class AbstractTestOrderedBidiMap extends AbstractTestBidiMap {
+public abstract class AbstractTestOrderedBidiMap<K, V> extends AbstractTestBidiMap<K, V> {
 
     public AbstractTestOrderedBidiMap(String testName) {
         super(testName);
@@ -49,39 +49,39 @@
     //-----------------------------------------------------------------------
     public void testFirstKey() {
         resetEmpty();
-        OrderedBidiMap bidi = (OrderedBidiMap) map;
+        OrderedBidiMap<K, V> bidi = getMap();
         try {
             bidi.firstKey();
             fail();
         } catch (NoSuchElementException ex) {}
-        
+
         resetFull();
-        bidi = (OrderedBidiMap) map;
-        Object confirmedFirst = confirmed.keySet().iterator().next();
+        bidi = getMap();
+        K confirmedFirst = confirmed.keySet().iterator().next();
         assertEquals(confirmedFirst, bidi.firstKey());
     }
-    
+
     public void testLastKey() {
         resetEmpty();
-        OrderedBidiMap bidi = (OrderedBidiMap) map;
+        OrderedBidiMap<K, V> bidi = getMap();
         try {
             bidi.lastKey();
             fail();
         } catch (NoSuchElementException ex) {}
-        
+
         resetFull();
-        bidi = (OrderedBidiMap) map;
-        Object confirmedLast = null;
-        for (Iterator it = confirmed.keySet().iterator(); it.hasNext();) {
+        bidi = getMap();
+        K confirmedLast = null;
+        for (Iterator<K> it = confirmed.keySet().iterator(); it.hasNext();) {
             confirmedLast = it.next();
         }
         assertEquals(confirmedLast, bidi.lastKey());
     }
 
-    //-----------------------------------------------------------------------    
+    //-----------------------------------------------------------------------
     public void testNextKey() {
         resetEmpty();
-        OrderedBidiMap bidi = (OrderedBidiMap) map;
+        OrderedBidiMap<K, V> bidi = (OrderedBidiMap<K, V>) map;
         assertEquals(null, bidi.nextKey(getOtherKeys()[0]));
         if (isAllowNullKey() == false) {
             try {
@@ -90,18 +90,18 @@
         } else {
             assertEquals(null, bidi.nextKey(null));
         }
-        
+
         resetFull();
-        bidi = (OrderedBidiMap) map;
-        Iterator it = confirmed.keySet().iterator();
-        Object confirmedLast = it.next();
+        bidi = (OrderedBidiMap<K, V>) map;
+        Iterator<K> it = confirmed.keySet().iterator();
+        K confirmedLast = it.next();
         while (it.hasNext()) {
-            Object confirmedObject = it.next();
+            K confirmedObject = it.next();
             assertEquals(confirmedObject, bidi.nextKey(confirmedLast));
             confirmedLast = confirmedObject;
         }
         assertEquals(null, bidi.nextKey(confirmedLast));
-        
+
         if (isAllowNullKey() == false) {
             try {
                 bidi.nextKey(null);
@@ -111,10 +111,10 @@
             assertEquals(null, bidi.nextKey(null));
         }
     }
-    
+
     public void testPreviousKey() {
         resetEmpty();
-        OrderedBidiMap bidi = (OrderedBidiMap) map;
+        OrderedBidiMap<K, V> bidi = getMap();
         assertEquals(null, bidi.previousKey(getOtherKeys()[0]));
         if (isAllowNullKey() == false) {
             try {
@@ -123,20 +123,20 @@
         } else {
             assertEquals(null, bidi.previousKey(null));
         }
-        
+
         resetFull();
-        bidi = (OrderedBidiMap) map;
-        List list = new ArrayList(confirmed.keySet());
+        bidi = getMap();
+        List<K> list = new ArrayList<K>(confirmed.keySet());
         Collections.reverse(list);
-        Iterator it = list.iterator();
-        Object confirmedLast = it.next();
+        Iterator<K> it = list.iterator();
+        K confirmedLast = it.next();
         while (it.hasNext()) {
-            Object confirmedObject = it.next();
+            K confirmedObject = it.next();
             assertEquals(confirmedObject, bidi.previousKey(confirmedLast));
             confirmedLast = confirmedObject;
         }
         assertEquals(null, bidi.previousKey(confirmedLast));
-        
+
         if (isAllowNullKey() == false) {
             try {
                 bidi.previousKey(null);
@@ -146,21 +146,29 @@
             assertEquals(null, bidi.previousKey(null));
         }
     }
-    
+
     //-----------------------------------------------------------------------
     public BulkTest bulkTestOrderedMapIterator() {
         return new TestBidiOrderedMapIterator();
     }
-    
-    public class TestBidiOrderedMapIterator extends AbstractTestMapIterator {
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public OrderedBidiMap<K, V> getMap() {
+        return (OrderedBidiMap<K, V>) super.getMap();
+    }
+
+    public class TestBidiOrderedMapIterator extends AbstractTestMapIterator<K, V> {
         public TestBidiOrderedMapIterator() {
             super("TestBidiOrderedMapIterator");
         }
-        
-        public Object[] addSetValues() {
+
+        public V[] addSetValues() {
             return AbstractTestOrderedBidiMap.this.getNewSampleValues();
         }
-        
+
         public boolean supportsRemove() {
             return AbstractTestOrderedBidiMap.this.isRemoveSupported();
         }
@@ -169,30 +177,30 @@
             return AbstractTestOrderedBidiMap.this.isSetValueSupported();
         }
 
-        public MapIterator makeEmptyMapIterator() {
+        public MapIterator<K, V> makeEmptyIterator() {
             resetEmpty();
-            return ((OrderedBidiMap) AbstractTestOrderedBidiMap.this.map).orderedMapIterator();
+            return AbstractTestOrderedBidiMap.this.getMap().mapIterator();
         }
 
-        public MapIterator makeFullMapIterator() {
+        public MapIterator<K, V> makeObject() {
             resetFull();
-            return ((OrderedBidiMap) AbstractTestOrderedBidiMap.this.map).orderedMapIterator();
+            return AbstractTestOrderedBidiMap.this.getMap().mapIterator();
         }
-        
-        public Map getMap() {
+
+        public Map<K, V> getMap() {
             // assumes makeFullMapIterator() called first
             return AbstractTestOrderedBidiMap.this.map;
         }
-        
-        public Map getConfirmedMap() {
+
+        public Map<K, V> getConfirmedMap() {
             // assumes makeFullMapIterator() called first
             return AbstractTestOrderedBidiMap.this.confirmed;
         }
-        
+
         public void verify() {
             super.verify();
             AbstractTestOrderedBidiMap.this.verify();
         }
     }
-    
+
 }

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/AbstractTestSortedBidiMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/AbstractTestSortedBidiMap.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/AbstractTestSortedBidiMap.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/AbstractTestSortedBidiMap.java Tue Sep 15 05:29:56 2009
@@ -40,68 +40,83 @@
  * @author Matthew Hawthorne
  * @author Stephen Colebourne
  */
-public abstract class AbstractTestSortedBidiMap extends AbstractTestOrderedBidiMap {
+public abstract class AbstractTestSortedBidiMap<K extends Comparable<K>, V extends Comparable<V>> extends AbstractTestOrderedBidiMap<K, V> {
 
-    protected List sortedKeys = new ArrayList();
-    protected List sortedValues = new ArrayList();
-    protected SortedSet sortedNewValues = new TreeSet();
+    protected List<K> sortedKeys = new ArrayList<K>();
+    protected List<V> sortedValues = new ArrayList<V>();
+    protected SortedSet<V> sortedNewValues = new TreeSet<V>();
 
     public AbstractTestSortedBidiMap(String testName) {
         super(testName);
         sortedKeys.addAll(Arrays.asList(getSampleKeys()));
         Collections.sort(sortedKeys);
         sortedKeys = Collections.unmodifiableList(sortedKeys);
-        
-        Map map = new TreeMap();
-        for (int i = 0; i < getSampleKeys().length; i++) {
-            map.put(getSampleKeys()[i], getSampleValues()[i]);
-        }
-        sortedValues.addAll(map.values());
-        sortedValues = Collections.unmodifiableList(sortedValues);
-        
-        sortedNewValues.addAll(Arrays.asList(getNewSampleValues()));
-    }
 
-    public AbstractTestSortedBidiMap() {
-        super();
-        sortedKeys.addAll(Arrays.asList(getSampleValues()));
-        Collections.sort(sortedKeys);
-        sortedKeys = Collections.unmodifiableList(sortedKeys);
-        
-        Map map = new TreeMap();
-        for (int i = 0; i < getSampleKeys().length; i++) {
-            map.put(getSampleValues()[i], getSampleKeys()[i]);
-        }
+        Map<K, V> map = new TreeMap<K, V>();
+        addSampleMappings(map);
+
         sortedValues.addAll(map.values());
         sortedValues = Collections.unmodifiableList(sortedValues);
-        
+
         sortedNewValues.addAll(Arrays.asList(getNewSampleValues()));
     }
 
+//    public AbstractTestSortedBidiMap() {
+//        super();
+//        sortedKeys.addAll(Arrays.asList(getSampleValues()));
+//        Collections.sort(sortedKeys);
+//        sortedKeys = Collections.unmodifiableList(sortedKeys);
+//
+//        Map map = new TreeMap();
+//        for (int i = 0; i < getSampleKeys().length; i++) {
+//            map.put(getSampleValues()[i], getSampleKeys()[i]);
+//        }
+//        sortedValues.addAll(map.values());
+//        sortedValues = Collections.unmodifiableList(sortedValues);
+//
+//        sortedNewValues.addAll(Arrays.asList(getNewSampleValues()));
+//    }
+
     //-----------------------------------------------------------------------
     public boolean isAllowNullKey() {
         return false;
     }
+
     public boolean isAllowNullValue() {
         return false;
     }
-    public Map makeConfirmedMap() {
-        return new TreeMap();
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public abstract SortedBidiMap<K, V> makeObject();
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public SortedBidiMap<K, V> makeFullMap() {
+        return (SortedBidiMap<K, V>) super.makeFullMap();
+    }
+
+    public SortedMap<K, V> makeConfirmedMap() {
+        return new TreeMap<K, V>();
     }
 
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
     public void testBidiHeadMapContains() {
         // extra test as other tests get complex
-        SortedBidiMap sm = (SortedBidiMap) makeFullMap();
-        Iterator it = sm.keySet().iterator();
-        Object first = it.next();
-        Object toKey = it.next();
-        Object second = it.next();
-        Object firstValue = sm.get(first);
-        Object secondValue = sm.get(second);
-        
-        SortedMap head = sm.headMap(toKey);
+        SortedBidiMap<K, V> sm = makeFullMap();
+        Iterator<K> it = sm.keySet().iterator();
+        K first = it.next();
+        K toKey = it.next();
+        K second = it.next();
+        V firstValue = sm.get(first);
+        V secondValue = sm.get(second);
+
+        SortedMap<K, V> head = sm.headMap(toKey);
         assertEquals(1, head.size());
         assertEquals(true, sm.containsKey(first));
         assertEquals(true, head.containsKey(first));
@@ -112,44 +127,44 @@
         assertEquals(true, sm.containsValue(secondValue));
         assertEquals(false, head.containsValue(secondValue));
     }
-                
+
     //-----------------------------------------------------------------------
     public void testBidiClearByHeadMap() {
         if (isRemoveSupported() == false) return;
-        
+
         // extra test as other tests get complex
-        SortedBidiMap sm = (SortedBidiMap) makeFullMap();
-        Iterator it = sm.keySet().iterator();
-        Object first = it.next();
-        Object second = it.next();
-        Object toKey = it.next();
-        
-        Object firstValue = sm.get(first);
-        Object secondValue = sm.get(second);
-        Object toKeyValue = sm.get(toKey);
-        
-        SortedMap sub = sm.headMap(toKey);
+        SortedBidiMap<K, V> sm = makeFullMap();
+        Iterator<K> it = sm.keySet().iterator();
+        K first = it.next();
+        K second = it.next();
+        K toKey = it.next();
+
+        V firstValue = sm.get(first);
+        V secondValue = sm.get(second);
+        V toKeyValue = sm.get(toKey);
+
+        SortedMap<K, V> sub = sm.headMap(toKey);
         int size = sm.size();
         assertEquals(2, sub.size());
         sub.clear();
         assertEquals(0, sub.size());
         assertEquals(size - 2, sm.size());
         assertEquals(size - 2, sm.inverseBidiMap().size());
-        
+
         assertEquals(false, sm.containsKey(first));
         assertEquals(false, sm.containsValue(firstValue));
         assertEquals(false, sm.inverseBidiMap().containsKey(firstValue));
         assertEquals(false, sm.inverseBidiMap().containsValue(first));
         assertEquals(false, sub.containsKey(first));
         assertEquals(false, sub.containsValue(firstValue));
-        
+
         assertEquals(false, sm.containsKey(second));
         assertEquals(false, sm.containsValue(secondValue));
         assertEquals(false, sm.inverseBidiMap().containsKey(secondValue));
         assertEquals(false, sm.inverseBidiMap().containsValue(second));
         assertEquals(false, sub.containsKey(second));
         assertEquals(false, sub.containsValue(secondValue));
-        
+
         assertEquals(true, sm.containsKey(toKey));
         assertEquals(true, sm.containsValue(toKeyValue));
         assertEquals(true, sm.inverseBidiMap().containsKey(toKeyValue));
@@ -161,23 +176,23 @@
     //-----------------------------------------------------------------------
     public void testBidiRemoveByHeadMap() {
         if (isRemoveSupported() == false) return;
-        
+
         // extra test as other tests get complex
-        SortedBidiMap sm = (SortedBidiMap) makeFullMap();
-        Iterator it = sm.keySet().iterator();
-        Object first = it.next();
-        Object second = it.next();
-        Object toKey = it.next();
-        
+        SortedBidiMap<K, V> sm = makeFullMap();
+        Iterator<K> it = sm.keySet().iterator();
+        K first = it.next();
+        K second = it.next();
+        K toKey = it.next();
+
         int size = sm.size();
-        SortedMap sub = sm.headMap(toKey);
+        SortedMap<K, V> sub = sm.headMap(toKey);
         assertEquals(2, sub.size());
         assertEquals(true, sm.containsKey(first));
         assertEquals(true, sub.containsKey(first));
         assertEquals(true, sm.containsKey(second));
         assertEquals(true, sub.containsKey(second));
-        
-        Object firstValue = sub.remove(first);
+
+        V firstValue = sub.remove(first);
         assertEquals(1, sub.size());
         assertEquals(size - 1, sm.size());
         assertEquals(size - 1, sm.inverseBidiMap().size());
@@ -187,8 +202,8 @@
         assertEquals(false, sm.inverseBidiMap().containsValue(first));
         assertEquals(false, sub.containsKey(first));
         assertEquals(false, sub.containsValue(firstValue));
-        
-        Object secondValue = sub.remove(second);
+
+        V secondValue = sub.remove(second);
         assertEquals(0, sub.size());
         assertEquals(size - 2, sm.size());
         assertEquals(size - 2, sm.inverseBidiMap().size());
@@ -203,30 +218,30 @@
     //-----------------------------------------------------------------------
     public void testBidiRemoveByHeadMapEntrySet() {
         if (isRemoveSupported() == false) return;
-        
+
         // extra test as other tests get complex
-        SortedBidiMap sm = (SortedBidiMap) makeFullMap();
-        Iterator it = sm.keySet().iterator();
-        Object first = it.next();
-        Object second = it.next();
-        Object toKey = it.next();
-        
+        SortedBidiMap<K, V> sm = makeFullMap();
+        Iterator<K> it = sm.keySet().iterator();
+        K first = it.next();
+        K second = it.next();
+        K toKey = it.next();
+
         int size = sm.size();
-        SortedMap sub = sm.headMap(toKey);
-        Set set = sub.entrySet();
+        SortedMap<K, V> sub = sm.headMap(toKey);
+        Set<Map.Entry<K, V>> set = sub.entrySet();
         assertEquals(2, sub.size());
         assertEquals(2, set.size());
-        
-        Iterator it2 = set.iterator();
-        Map.Entry firstEntry = cloneMapEntry((Map.Entry) it2.next());
-        Map.Entry secondEntry = cloneMapEntry((Map.Entry) it2.next());
+
+        Iterator<Map.Entry<K, V>> it2 = set.iterator();
+        Map.Entry<K, V> firstEntry = cloneMapEntry(it2.next());
+        Map.Entry<K, V> secondEntry = cloneMapEntry(it2.next());
         assertEquals(true, sm.containsKey(first));
         assertEquals(true, sub.containsKey(first));
         assertEquals(true, set.contains(firstEntry));
         assertEquals(true, sm.containsKey(second));
         assertEquals(true, sub.containsKey(second));
         assertEquals(true, set.contains(secondEntry));
-        
+
         set.remove(firstEntry);
         assertEquals(1, sub.size());
         assertEquals(size - 1, sm.size());
@@ -238,7 +253,7 @@
         assertEquals(false, sub.containsKey(firstEntry.getKey()));
         assertEquals(false, sub.containsValue(firstEntry.getValue()));
         assertEquals(false, set.contains(firstEntry));
-        
+
         set.remove(secondEntry);
         assertEquals(0, sub.size());
         assertEquals(size - 2, sm.size());
@@ -256,16 +271,16 @@
     //-----------------------------------------------------------------------
     public void testBidiTailMapContains() {
         // extra test as other tests get complex
-        SortedBidiMap sm = (SortedBidiMap) makeFullMap();
-        Iterator it = sm.keySet().iterator();
-        Object first = it.next();
-        Object fromKey = it.next();
-        Object second = it.next();
-        Object firstValue = sm.get(first);
-        Object fromKeyValue = sm.get(fromKey);
-        Object secondValue = sm.get(second);
-        
-        SortedMap sub = sm.tailMap(fromKey);
+        SortedBidiMap<K, V> sm = makeFullMap();
+        Iterator<K> it = sm.keySet().iterator();
+        K first = it.next();
+        K fromKey = it.next();
+        K second = it.next();
+        V firstValue = sm.get(first);
+        V fromKeyValue = sm.get(fromKey);
+        V secondValue = sm.get(second);
+
+        SortedMap<K, V> sub = sm.tailMap(fromKey);
         assertEquals(sm.size() - 1, sub.size());
         assertEquals(true, sm.containsKey(first));
         assertEquals(false, sub.containsKey(first));
@@ -284,42 +299,42 @@
     //-----------------------------------------------------------------------
     public void testBidiClearByTailMap() {
         if (isRemoveSupported() == false) return;
-        
+
         // extra test as other tests get complex
-        SortedBidiMap sm = (SortedBidiMap) makeFullMap();
-        Iterator it = sm.keySet().iterator();
+        SortedBidiMap<K, V> sm = makeFullMap();
+        Iterator<K> it = sm.keySet().iterator();
         it.next();
         it.next();
-        Object first = it.next();
-        Object fromKey = it.next();
-        Object second = it.next();
-        
-        Object firstValue = sm.get(first);
-        Object fromKeyValue = sm.get(fromKey);
-        Object secondValue = sm.get(second);
-        
-        SortedMap sub = sm.tailMap(fromKey);
+        K first = it.next();
+        K fromKey = it.next();
+        K second = it.next();
+
+        V firstValue = sm.get(first);
+        V fromKeyValue = sm.get(fromKey);
+        V secondValue = sm.get(second);
+
+        SortedMap<K, V> sub = sm.tailMap(fromKey);
         int size = sm.size();
         assertEquals(size - 3, sub.size());
         sub.clear();
         assertEquals(0, sub.size());
         assertEquals(3, sm.size());
         assertEquals(3, sm.inverseBidiMap().size());
-        
+
         assertEquals(true, sm.containsKey(first));
         assertEquals(true, sm.containsValue(firstValue));
         assertEquals(true, sm.inverseBidiMap().containsKey(firstValue));
         assertEquals(true, sm.inverseBidiMap().containsValue(first));
         assertEquals(false, sub.containsKey(first));
         assertEquals(false, sub.containsValue(firstValue));
-        
+
         assertEquals(false, sm.containsKey(fromKey));
         assertEquals(false, sm.containsValue(fromKeyValue));
         assertEquals(false, sm.inverseBidiMap().containsKey(fromKeyValue));
         assertEquals(false, sm.inverseBidiMap().containsValue(fromKey));
         assertEquals(false, sub.containsKey(fromKey));
         assertEquals(false, sub.containsValue(fromKeyValue));
-        
+
         assertEquals(false, sm.containsKey(second));
         assertEquals(false, sm.containsValue(secondValue));
         assertEquals(false, sm.inverseBidiMap().containsKey(secondValue));
@@ -328,26 +343,26 @@
         assertEquals(false, sub.containsValue(secondValue));
     }
 
-    //-----------------------------------------------------------------------                
+    //-----------------------------------------------------------------------
     public void testBidiRemoveByTailMap() {
         if (isRemoveSupported() == false) return;
-        
+
         // extra test as other tests get complex
-        SortedBidiMap sm = (SortedBidiMap) makeFullMap();
-        Iterator it = sm.keySet().iterator();
+        SortedBidiMap<K, V> sm = makeFullMap();
+        Iterator<K> it = sm.keySet().iterator();
         it.next();
         it.next();
-        Object fromKey = it.next();
-        Object first = it.next();
-        Object second = it.next();
-        
+        K fromKey = it.next();
+        K first = it.next();
+        K second = it.next();
+
         int size = sm.size();
-        SortedMap sub = sm.tailMap(fromKey);
+        SortedMap<K, V> sub = sm.tailMap(fromKey);
         assertEquals(true, sm.containsKey(first));
         assertEquals(true, sub.containsKey(first));
         assertEquals(true, sm.containsKey(second));
         assertEquals(true, sub.containsKey(second));
-        
+
         Object firstValue = sub.remove(first);
         assertEquals(size - 3, sub.size());
         assertEquals(size - 1, sm.size());
@@ -358,7 +373,7 @@
         assertEquals(false, sm.inverseBidiMap().containsValue(first));
         assertEquals(false, sub.containsKey(first));
         assertEquals(false, sub.containsValue(firstValue));
-        
+
         Object secondValue = sub.remove(second);
         assertEquals(size - 4, sub.size());
         assertEquals(size - 2, sm.size());
@@ -374,30 +389,30 @@
     //-----------------------------------------------------------------------
     public void testBidiRemoveByTailMapEntrySet() {
         if (isRemoveSupported() == false) return;
-        
+
         // extra test as other tests get complex
-        SortedBidiMap sm = (SortedBidiMap) makeFullMap();
-        Iterator it = sm.keySet().iterator();
+        SortedBidiMap<K, V> sm = makeFullMap();
+        Iterator<K> it = sm.keySet().iterator();
         it.next();
         it.next();
-        Object fromKey = it.next();
-        Object first = it.next();
-        Object second = it.next();
-        
+        K fromKey = it.next();
+        K first = it.next();
+        K second = it.next();
+
         int size = sm.size();
-        SortedMap sub = sm.tailMap(fromKey);
-        Set set = sub.entrySet();
-        Iterator it2 = set.iterator();
-        Object fromEntry = it2.next();
-        Map.Entry firstEntry = cloneMapEntry((Map.Entry) it2.next());
-        Map.Entry secondEntry = cloneMapEntry((Map.Entry) it2.next());
+        SortedMap<K, V> sub = sm.tailMap(fromKey);
+        Set<Map.Entry<K, V>> set = sub.entrySet();
+        Iterator<Map.Entry<K, V>> it2 = set.iterator();
+        it2.next();
+        Map.Entry<K, V> firstEntry = cloneMapEntry(it2.next());
+        Map.Entry<K, V> secondEntry = cloneMapEntry(it2.next());
         assertEquals(true, sm.containsKey(first));
         assertEquals(true, sub.containsKey(first));
         assertEquals(true, set.contains(firstEntry));
         assertEquals(true, sm.containsKey(second));
         assertEquals(true, sub.containsKey(second));
         assertEquals(true, set.contains(secondEntry));
-        
+
         set.remove(firstEntry);
         assertEquals(size - 3, sub.size());
         assertEquals(size - 1, sm.size());
@@ -409,7 +424,7 @@
         assertEquals(false, sub.containsKey(firstEntry.getKey()));
         assertEquals(false, sub.containsValue(firstEntry.getValue()));
         assertEquals(false, set.contains(firstEntry));
-        
+
         set.remove(secondEntry);
         assertEquals(size - 4, sub.size());
         assertEquals(size - 2, sm.size());
@@ -427,19 +442,19 @@
     //-----------------------------------------------------------------------
     public void testBidiSubMapContains() {
         // extra test as other tests get complex
-        SortedBidiMap sm = (SortedBidiMap) makeFullMap();
-        Iterator it = sm.keySet().iterator();
-        Object first = it.next();
-        Object fromKey = it.next();
-        Object second = it.next();
-        Object toKey = it.next();
-        Object third = it.next();
-        Object firstValue = sm.get(first);
-        Object fromKeyValue = sm.get(fromKey);
-        Object secondValue = sm.get(second);
-        Object thirdValue = sm.get(third);
-        
-        SortedMap sub = sm.subMap(fromKey, toKey);
+        SortedBidiMap<K, V> sm = makeFullMap();
+        Iterator<K> it = sm.keySet().iterator();
+        K first = it.next();
+        K fromKey = it.next();
+        K second = it.next();
+        K toKey = it.next();
+        K third = it.next();
+        V firstValue = sm.get(first);
+        V fromKeyValue = sm.get(fromKey);
+        V secondValue = sm.get(second);
+        V thirdValue = sm.get(third);
+
+        SortedMap<K, V> sub = sm.subMap(fromKey, toKey);
         assertEquals(2, sub.size());
         assertEquals(true, sm.containsKey(first));
         assertEquals(false, sub.containsKey(first));
@@ -462,50 +477,50 @@
     //-----------------------------------------------------------------------
     public void testBidiClearBySubMap() {
         if (isRemoveSupported() == false) return;
-        
+
         // extra test as other tests get complex
-        SortedBidiMap sm = (SortedBidiMap) makeFullMap();
-        Iterator it = sm.keySet().iterator();
+        SortedBidiMap<K, V> sm = makeFullMap();
+        Iterator<K> it = sm.keySet().iterator();
         it.next();
-        Object fromKey = it.next();
-        Object first = it.next();
-        Object second = it.next();
-        Object toKey = it.next();
-        
-        Object fromKeyValue = sm.get(fromKey);
-        Object firstValue = sm.get(first);
-        Object secondValue = sm.get(second);
-        Object toKeyValue = sm.get(toKey);
-        
-        SortedMap sub = sm.subMap(fromKey, toKey);
+        K fromKey = it.next();
+        K first = it.next();
+        K second = it.next();
+        K toKey = it.next();
+
+        V fromKeyValue = sm.get(fromKey);
+        V firstValue = sm.get(first);
+        V secondValue = sm.get(second);
+        V toKeyValue = sm.get(toKey);
+
+        SortedMap<K, V> sub = sm.subMap(fromKey, toKey);
         int size = sm.size();
         assertEquals(3, sub.size());
         sub.clear();
         assertEquals(0, sub.size());
         assertEquals(size - 3, sm.size());
         assertEquals(size - 3, sm.inverseBidiMap().size());
-        
+
         assertEquals(false, sm.containsKey(fromKey));
         assertEquals(false, sm.containsValue(fromKeyValue));
         assertEquals(false, sm.inverseBidiMap().containsKey(fromKeyValue));
         assertEquals(false, sm.inverseBidiMap().containsValue(fromKey));
         assertEquals(false, sub.containsKey(fromKey));
         assertEquals(false, sub.containsValue(fromKeyValue));
-        
+
         assertEquals(false, sm.containsKey(first));
         assertEquals(false, sm.containsValue(firstValue));
         assertEquals(false, sm.inverseBidiMap().containsKey(firstValue));
         assertEquals(false, sm.inverseBidiMap().containsValue(first));
         assertEquals(false, sub.containsKey(first));
         assertEquals(false, sub.containsValue(firstValue));
-        
+
         assertEquals(false, sm.containsKey(second));
         assertEquals(false, sm.containsValue(secondValue));
         assertEquals(false, sm.inverseBidiMap().containsKey(secondValue));
         assertEquals(false, sm.inverseBidiMap().containsValue(second));
         assertEquals(false, sub.containsKey(second));
         assertEquals(false, sub.containsValue(secondValue));
-        
+
         assertEquals(true, sm.containsKey(toKey));
         assertEquals(true, sm.containsValue(toKeyValue));
         assertEquals(true, sm.inverseBidiMap().containsKey(toKeyValue));
@@ -517,25 +532,25 @@
     //-----------------------------------------------------------------------
     public void testBidiRemoveBySubMap() {
         if (isRemoveSupported() == false) return;
-        
+
         // extra test as other tests get complex
-        SortedBidiMap sm = (SortedBidiMap) makeFullMap();
-        Iterator it = sm.keySet().iterator();
+        SortedBidiMap<K, V> sm = makeFullMap();
+        Iterator<K> it = sm.keySet().iterator();
         it.next();
         it.next();
-        Object fromKey = it.next();
-        Object first = it.next();
-        Object second = it.next();
-        Object toKey = it.next();
-        
+        K fromKey = it.next();
+        K first = it.next();
+        K second = it.next();
+        K toKey = it.next();
+
         int size = sm.size();
-        SortedMap sub = sm.subMap(fromKey, toKey);
+        SortedMap<K, V> sub = sm.subMap(fromKey, toKey);
         assertEquals(true, sm.containsKey(first));
         assertEquals(true, sub.containsKey(first));
         assertEquals(true, sm.containsKey(second));
         assertEquals(true, sub.containsKey(second));
-        
-        Object firstValue = sub.remove(first);
+
+        V firstValue = sub.remove(first);
         assertEquals(2, sub.size());
         assertEquals(size - 1, sm.size());
         assertEquals(size - 1, sm.inverseBidiMap().size());
@@ -545,8 +560,8 @@
         assertEquals(false, sm.inverseBidiMap().containsValue(first));
         assertEquals(false, sub.containsKey(first));
         assertEquals(false, sub.containsValue(firstValue));
-        
-        Object secondValue = sub.remove(second);
+
+        V secondValue = sub.remove(second);
         assertEquals(1, sub.size());
         assertEquals(size - 2, sm.size());
         assertEquals(size - 2, sm.inverseBidiMap().size());
@@ -561,32 +576,32 @@
     //-----------------------------------------------------------------------
     public void testBidiRemoveBySubMapEntrySet() {
         if (isRemoveSupported() == false) return;
-        
+
         // extra test as other tests get complex
-        SortedBidiMap sm = (SortedBidiMap) makeFullMap();
-        Iterator it = sm.keySet().iterator();
+        SortedBidiMap<K, V> sm = makeFullMap();
+        Iterator<K> it = sm.keySet().iterator();
         it.next();
         it.next();
-        Object fromKey = it.next();
-        Object first = it.next();
-        Object second = it.next();
-        Object toKey = it.next();
-        
+        K fromKey = it.next();
+        K first = it.next();
+        K second = it.next();
+        K toKey = it.next();
+
         int size = sm.size();
-        SortedMap sub = sm.subMap(fromKey, toKey);
-        Set set = sub.entrySet();
+        SortedMap<K, V> sub = sm.subMap(fromKey, toKey);
+        Set<Map.Entry<K, V>> set = sub.entrySet();
         assertEquals(3, set.size());
-        Iterator it2 = set.iterator();
-        Object fromEntry = it2.next();
-        Map.Entry firstEntry = cloneMapEntry((Map.Entry) it2.next());
-        Map.Entry secondEntry = cloneMapEntry((Map.Entry) it2.next());
+        Iterator<Map.Entry<K, V>> it2 = set.iterator();
+        it2.next();
+        Map.Entry<K, V> firstEntry = cloneMapEntry(it2.next());
+        Map.Entry<K, V> secondEntry = cloneMapEntry(it2.next());
         assertEquals(true, sm.containsKey(first));
         assertEquals(true, sub.containsKey(first));
         assertEquals(true, set.contains(firstEntry));
         assertEquals(true, sm.containsKey(second));
         assertEquals(true, sub.containsKey(second));
         assertEquals(true, set.contains(secondEntry));
-        
+
         set.remove(firstEntry);
         assertEquals(2, sub.size());
         assertEquals(size - 1, sm.size());
@@ -598,7 +613,7 @@
         assertEquals(false, sub.containsKey(firstEntry.getKey()));
         assertEquals(false, sub.containsValue(firstEntry.getValue()));
         assertEquals(false, set.contains(firstEntry));
-        
+
         set.remove(secondEntry);
         assertEquals(1, sub.size());
         assertEquals(size - 2, sm.size());
@@ -612,17 +627,17 @@
         assertEquals(false, set.contains(secondEntry));
     }
 
-    //-----------------------------------------------------------------------    
+    //-----------------------------------------------------------------------
     public BulkTest bulkTestHeadMap() {
-        return new AbstractTestSortedMap.TestHeadMap(this);
+        return new AbstractTestSortedMap.TestHeadMap<K, V>(this);
     }
 
     public BulkTest bulkTestTailMap() {
-        return new AbstractTestSortedMap.TestTailMap(this);
+        return new AbstractTestSortedMap.TestTailMap<K, V>(this);
     }
 
     public BulkTest bulkTestSubMap() {
-        return new AbstractTestSortedMap.TestSubMap(this);
+        return new AbstractTestSortedMap.TestSubMap<K, V>(this);
     }
 
 }

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/TestAbstractOrderedBidiMapDecorator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/TestAbstractOrderedBidiMapDecorator.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/TestAbstractOrderedBidiMapDecorator.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/TestAbstractOrderedBidiMapDecorator.java Tue Sep 15 05:29:56 2009
@@ -16,13 +16,12 @@
  */
 package org.apache.commons.collections.bidimap;
 
-import java.util.Map;
+import java.util.SortedMap;
 import java.util.TreeMap;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
-import org.apache.commons.collections.BidiMap;
 import org.apache.commons.collections.OrderedBidiMap;
 
 /**
@@ -30,8 +29,8 @@
  *
  * @version $Revision$ $Date$
  */
-public class TestAbstractOrderedBidiMapDecorator
-        extends AbstractTestOrderedBidiMap {
+public class TestAbstractOrderedBidiMapDecorator<K, V>
+        extends AbstractTestOrderedBidiMap<K, V> {
 
     public TestAbstractOrderedBidiMapDecorator(String testName) {
         super(testName);
@@ -41,12 +40,16 @@
         return new TestSuite(TestAbstractOrderedBidiMapDecorator.class);
     }
 
-    public BidiMap makeEmptyBidiMap() {
-        return new TestOrderedBidiMap();
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public OrderedBidiMap<K, V> makeObject() {
+        return new TestOrderedBidiMap<K, V>();
     }
 
-    public Map makeConfirmedMap() {
-        return new TreeMap();
+    public SortedMap<K, V> makeConfirmedMap() {
+        return new TreeMap<K, V>();
     }
 
     public boolean isAllowNullKey() {
@@ -64,21 +67,21 @@
     /**
      * Simple class to actually test.
      */
-    private static final class TestOrderedBidiMap extends AbstractOrderedBidiMapDecorator {
-            
-        private TestOrderedBidiMap inverse = null;
+    private static final class TestOrderedBidiMap<K, V> extends AbstractOrderedBidiMapDecorator<K, V> {
+
+        private TestOrderedBidiMap<V, K> inverse = null;
 
         public TestOrderedBidiMap() {
-            super(new DualTreeBidiMap());
+            super(new DualTreeBidiMap<K, V>());
         }
-        
-        public TestOrderedBidiMap(OrderedBidiMap map) {
+
+        public TestOrderedBidiMap(OrderedBidiMap<K, V> map) {
             super(map);
         }
-        
-        public BidiMap inverseBidiMap() {
+
+        public OrderedBidiMap<V, K> inverseBidiMap() {
             if (inverse == null) {
-                inverse = new TestOrderedBidiMap((OrderedBidiMap) getBidiMap().inverseBidiMap());
+                inverse = new TestOrderedBidiMap<V, K>(decorated().inverseBidiMap());
                 inverse.inverse = this;
             }
             return inverse;

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/TestDualHashBidiMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/TestDualHashBidiMap.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/TestDualHashBidiMap.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/TestDualHashBidiMap.java Tue Sep 15 05:29:56 2009
@@ -19,7 +19,6 @@
 import junit.framework.Test;
 import junit.textui.TestRunner;
 
-import org.apache.commons.collections.BidiMap;
 import org.apache.commons.collections.BulkTest;
 
 /**
@@ -30,7 +29,7 @@
  * @author Matthew Hawthorne
  * @author Stephen Colebourne
  */
-public class TestDualHashBidiMap extends AbstractTestBidiMap {
+public class TestDualHashBidiMap<K, V> extends AbstractTestBidiMap<K, V> {
 
     public static void main(String[] args) {
         TestRunner.run(suite());
@@ -44,15 +43,19 @@
         super(testName);
     }
 
-    public BidiMap makeEmptyBidiMap() {
-        return new DualHashBidiMap();
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public DualHashBidiMap<K, V> makeObject() {
+        return new DualHashBidiMap<K, V>();
     }
 
     /**
      * Override to prevent infinite recursion of tests.
      */
     public String[] ignoredTests() {
-        return new String[] {"TestDualHashBidiMap.bulkTestInverseMap.bulkTestInverseMap"};
+        return new String[] { "TestDualHashBidiMap.bulkTestInverseMap.bulkTestInverseMap" };
     }
     
 //    public void testCreate() throws Exception {

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/TestDualTreeBidiMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/TestDualTreeBidiMap.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/TestDualTreeBidiMap.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/bidimap/TestDualTreeBidiMap.java Tue Sep 15 05:29:56 2009
@@ -19,7 +19,6 @@
 import junit.framework.Test;
 import junit.textui.TestRunner;
 
-import org.apache.commons.collections.BidiMap;
 import org.apache.commons.collections.BulkTest;
 
 /**
@@ -30,7 +29,7 @@
  * @author Matthew Hawthorne
  * @author Stephen Colebourne
  */
-public class TestDualTreeBidiMap extends AbstractTestSortedBidiMap {
+public class TestDualTreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> extends AbstractTestSortedBidiMap<K, V> {
 
     public static void main(String[] args) {
         TestRunner.run(suite());
@@ -44,8 +43,12 @@
         super(testName);
     }
 
-    public BidiMap makeEmptyBidiMap() {
-        return new DualTreeBidiMap();
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public DualTreeBidiMap<K, V> makeObject() {
+        return new DualTreeBidiMap<K, V>();
     }
 
     /**



Mime
View raw message