commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chtom...@apache.org
Subject [15/77] [abbrv] commons-collections git commit: finish generics (minus one class)
Date Tue, 11 Jul 2017 17:55:00 GMT
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/test/org/apache/commons/collections/bag/AbstractTestBag.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/commons/collections/bag/AbstractTestBag.java b/src/test/org/apache/commons/collections/bag/AbstractTestBag.java
index ee6db91..2ec00a0 100644
--- a/src/test/org/apache/commons/collections/bag/AbstractTestBag.java
+++ b/src/test/org/apache/commons/collections/bag/AbstractTestBag.java
@@ -42,7 +42,7 @@ import org.apache.commons.collections.Bag;
  * @author Chuck Burdick
  * @author Stephen Colebourne
  */
-public abstract class AbstractTestBag extends AbstractTestObject {
+public abstract class AbstractTestBag<T> extends AbstractTestObject {
 //  TODO: this class should really extend from TestCollection, but the bag
 //  implementations currently do not conform to the Collection interface.  Once
 //  those are fixed or at least a strategy is made for resolving the issue, this
@@ -63,52 +63,46 @@ public abstract class AbstractTestBag extends AbstractTestObject {
      * 
      * @return the bag to be tested
      */
-    public abstract Bag makeBag();
-
-    /**
-     * Implements the superclass method to return the Bag.
-     * 
-     * @return the bag to be tested
-     */
-    public Object makeObject() {
-        return makeBag();
-    }
+    public abstract Bag<T> makeObject();
 
     //-----------------------------------------------------------------------
+    @SuppressWarnings("unchecked")
     public void testBagAdd() {
-        Bag bag = makeBag();
-        bag.add("A");
+        Bag<T> bag = makeObject();
+        bag.add((T) "A");
         assertTrue("Should contain 'A'", bag.contains("A"));
         assertEquals("Should have count of 1", 1, bag.getCount("A"));
-        bag.add("A");
+        bag.add((T) "A");
         assertTrue("Should contain 'A'", bag.contains("A"));
         assertEquals("Should have count of 2", 2, bag.getCount("A"));
-        bag.add("B");
+        bag.add((T) "B");
         assertTrue(bag.contains("A"));
         assertTrue(bag.contains("B"));
     }
 
+    @SuppressWarnings("unchecked")
     public void testBagEqualsSelf() {
-        Bag bag = makeBag();
+        Bag<T> bag = makeObject();
         assertTrue(bag.equals(bag));
-        bag.add("elt");
+        bag.add((T) "elt");
         assertTrue(bag.equals(bag));
-        bag.add("elt"); // again
+        bag.add((T) "elt"); // again
         assertTrue(bag.equals(bag));
-        bag.add("elt2");
+        bag.add((T) "elt2");
         assertTrue(bag.equals(bag));
     }
 
+    @SuppressWarnings("unchecked")
     public void testRemove() {
-        Bag bag = makeBag();
-        bag.add("A");
+        Bag<T> bag = makeObject();
+        bag.add((T) "A");
         assertEquals("Should have count of 1", 1, bag.getCount("A"));
         bag.remove("A");
         assertEquals("Should have count of 0", 0, bag.getCount("A"));
-        bag.add("A");
-        bag.add("A");
-        bag.add("A");
-        bag.add("A");
+        bag.add((T) "A");
+        bag.add((T) "A");
+        bag.add((T) "A");
+        bag.add((T) "A");
         assertEquals("Should have count of 4", 4, bag.getCount("A"));
         bag.remove("A", 0);
         assertEquals("Should have count of 4", 4, bag.getCount("A"));
@@ -118,14 +112,15 @@ public abstract class AbstractTestBag extends AbstractTestObject {
         assertEquals("Should have count of 0", 0, bag.getCount("A"));
     }
 
+    @SuppressWarnings("unchecked")
     public void testRemoveAll() {
-        Bag bag = makeBag();
-        bag.add("A", 2);
+        Bag<T> bag = makeObject();
+        bag.add((T) "A", 2);
         assertEquals("Should have count of 2", 2, bag.getCount("A"));
-        bag.add("B");
-        bag.add("C");
+        bag.add((T) "B");
+        bag.add((T) "C");
         assertEquals("Should have count of 4", 4, bag.size());
-        List delete = new ArrayList();
+        List<String> delete = new ArrayList<String>();
         delete.add("A");
         delete.add("B");
         bag.removeAll(delete);
@@ -135,36 +130,38 @@ public abstract class AbstractTestBag extends AbstractTestObject {
         assertEquals("Should have count of 2", 2, bag.size());
     }
     
+    @SuppressWarnings("unchecked")
     public void testContains() {
-        Bag bag = makeBag();
+        Bag<T> bag = makeObject();
         
         assertEquals("Bag does not have at least 1 'A'", false, bag.contains("A"));
         assertEquals("Bag does not have at least 1 'B'", false, bag.contains("B"));
         
-        bag.add("A");  // bag 1A
+        bag.add((T) "A");  // bag 1A
         assertEquals("Bag has at least 1 'A'", true, bag.contains("A"));
         assertEquals("Bag does not have at least 1 'B'", false, bag.contains("B"));
         
-        bag.add("A");  // bag 2A
+        bag.add((T) "A");  // bag 2A
         assertEquals("Bag has at least 1 'A'", true, bag.contains("A"));
         assertEquals("Bag does not have at least 1 'B'", false, bag.contains("B"));
         
-        bag.add("B");  // bag 2A,1B
+        bag.add((T) "B");  // bag 2A,1B
         assertEquals("Bag has at least 1 'A'", true, bag.contains("A"));
         assertEquals("Bag has at least 1 'B'", true, bag.contains("B"));
     }
 
+    @SuppressWarnings("unchecked")
     public void testContainsAll() {
-        Bag bag = makeBag();
-        List known = new ArrayList();
-        List known1A = new ArrayList();
+        Bag<T> bag = makeObject();
+        List<String> known = new ArrayList<String>();
+        List<String> known1A = new ArrayList<String>();
         known1A.add("A");
-        List known2A = new ArrayList();
+        List<String> known2A = new ArrayList<String>();
         known2A.add("A");
         known2A.add("A");
-        List known1B = new ArrayList();
+        List<String> known1B = new ArrayList<String>();
         known1B.add("B");
-        List known1A1B = new ArrayList();
+        List<String> known1A1B = new ArrayList<String>();
         known1A1B.add("A");
         known1A1B.add("B");
         
@@ -174,28 +171,28 @@ public abstract class AbstractTestBag extends AbstractTestObject {
         assertEquals("Bag does not containsAll of 1 'B'", false, bag.containsAll(known1B));
         assertEquals("Bag does not containsAll of 1 'A' 1 'B'", false, bag.containsAll(known1A1B));
         
-        bag.add("A");  // bag 1A
+        bag.add((T) "A");  // bag 1A
         assertEquals("Bag containsAll of empty", true, bag.containsAll(known));
         assertEquals("Bag containsAll of 1 'A'", true, bag.containsAll(known1A));
         assertEquals("Bag does not containsAll of 2 'A'", false, bag.containsAll(known2A));
         assertEquals("Bag does not containsAll of 1 'B'", false, bag.containsAll(known1B));
         assertEquals("Bag does not containsAll of 1 'A' 1 'B'", false, bag.containsAll(known1A1B));
         
-        bag.add("A");  // bag 2A
+        bag.add((T) "A");  // bag 2A
         assertEquals("Bag containsAll of empty", true, bag.containsAll(known));
         assertEquals("Bag containsAll of 1 'A'", true, bag.containsAll(known1A));
         assertEquals("Bag containsAll of 2 'A'", true, bag.containsAll(known2A));
         assertEquals("Bag does not containsAll of 1 'B'", false, bag.containsAll(known1B));
         assertEquals("Bag does not containsAll of 1 'A' 1 'B'", false, bag.containsAll(known1A1B));
         
-        bag.add("A");  // bag 3A
+        bag.add((T) "A");  // bag 3A
         assertEquals("Bag containsAll of empty", true, bag.containsAll(known));
         assertEquals("Bag containsAll of 1 'A'", true, bag.containsAll(known1A));
         assertEquals("Bag containsAll of 2 'A'", true, bag.containsAll(known2A));
         assertEquals("Bag does not containsAll of 1 'B'", false, bag.containsAll(known1B));
         assertEquals("Bag does not containsAll of 1 'A' 1 'B'", false, bag.containsAll(known1A1B));
         
-        bag.add("B");  // bag 3A1B
+        bag.add((T) "B");  // bag 3A1B
         assertEquals("Bag containsAll of empty", true, bag.containsAll(known));
         assertEquals("Bag containsAll of 1 'A'", true, bag.containsAll(known1A));
         assertEquals("Bag containsAll of 2 'A'", true, bag.containsAll(known2A));
@@ -203,18 +200,19 @@ public abstract class AbstractTestBag extends AbstractTestObject {
         assertEquals("Bag containsAll of 1 'A' 1 'B'", true, bag.containsAll(known1A1B));
     }
 
+    @SuppressWarnings("unchecked")
     public void testSize() {
-        Bag bag = makeBag();
+        Bag<T> bag = makeObject();
         assertEquals("Should have 0 total items", 0, bag.size());
-        bag.add("A");
+        bag.add((T) "A");
         assertEquals("Should have 1 total items", 1, bag.size());
-        bag.add("A");
+        bag.add((T) "A");
         assertEquals("Should have 2 total items", 2, bag.size());
-        bag.add("A");
+        bag.add((T) "A");
         assertEquals("Should have 3 total items", 3, bag.size());
-        bag.add("B");
+        bag.add((T) "B");
         assertEquals("Should have 4 total items", 4, bag.size());
-        bag.add("B");
+        bag.add((T) "B");
         assertEquals("Should have 5 total items", 5, bag.size());
         bag.remove("A", 2);
         assertEquals("Should have 1 'A'", 1, bag.getCount("A"));
@@ -223,28 +221,30 @@ public abstract class AbstractTestBag extends AbstractTestObject {
         assertEquals("Should have 1 total item", 1, bag.size());
     }
     
+    @SuppressWarnings("unchecked")
     public void testRetainAll() {
-        Bag bag = makeBag();
-        bag.add("A");
-        bag.add("A");
-        bag.add("A");
-        bag.add("B");
-        bag.add("B");
-        bag.add("C");
-        List retains = new ArrayList();
+        Bag<T> bag = makeObject();
+        bag.add((T) "A");
+        bag.add((T) "A");
+        bag.add((T) "A");
+        bag.add((T) "B");
+        bag.add((T) "B");
+        bag.add((T) "C");
+        List<String> retains = new ArrayList<String>();
         retains.add("B");
         retains.add("C");
         bag.retainAll(retains);
         assertEquals("Should have 2 total items", 2, bag.size());
     }
 
+    @SuppressWarnings("unchecked")
     public void testIterator() {
-        Bag bag = makeBag();
-        bag.add("A");
-        bag.add("A");
-        bag.add("B");
+        Bag<T> bag = makeObject();
+        bag.add((T) "A");
+        bag.add((T) "A");
+        bag.add((T) "B");
         assertEquals("Bag should have 3 items", 3, bag.size());
-        Iterator i = bag.iterator();
+        Iterator<T> i = bag.iterator();
     
         boolean foundA = false;
         while (i.hasNext()) {
@@ -264,12 +264,13 @@ public abstract class AbstractTestBag extends AbstractTestObject {
         assertEquals("Bag should have 1 'A'", 1, bag.getCount("A"));
     }
 
+    @SuppressWarnings("unchecked")
     public void testIteratorFail() {
-        Bag bag = makeBag();
-        bag.add("A");
-        bag.add("A");
-        bag.add("B");
-        Iterator it = bag.iterator();
+        Bag<T> bag = makeObject();
+        bag.add((T) "A");
+        bag.add((T) "A");
+        bag.add((T) "B");
+        Iterator<T> it = bag.iterator();
         it.next();
         bag.remove("A");
         try {
@@ -280,12 +281,13 @@ public abstract class AbstractTestBag extends AbstractTestObject {
         }
     }
     
+    @SuppressWarnings("unchecked")
     public void testIteratorFailNoMore() {
-        Bag bag = makeBag();
-        bag.add("A");
-        bag.add("A");
-        bag.add("B");
-        Iterator it = bag.iterator();
+        Bag<T> bag = makeObject();
+        bag.add((T) "A");
+        bag.add((T) "A");
+        bag.add((T) "B");
+        Iterator<T> it = bag.iterator();
         it.next();
         it.next();
         it.next();
@@ -297,12 +299,13 @@ public abstract class AbstractTestBag extends AbstractTestObject {
         }
     }
     
+    @SuppressWarnings("unchecked")
     public void testIteratorFailDoubleRemove() {
-        Bag bag = makeBag();
-        bag.add("A");
-        bag.add("A");
-        bag.add("B");
-        Iterator it = bag.iterator();
+        Bag<T> bag = makeObject();
+        bag.add((T) "A");
+        bag.add((T) "A");
+        bag.add((T) "B");
+        Iterator<T> it = bag.iterator();
         it.next();
         it.next();
         assertEquals(3, bag.size());
@@ -320,12 +323,13 @@ public abstract class AbstractTestBag extends AbstractTestObject {
         assertEquals(1, bag.size());
     }
     
+    @SuppressWarnings("unchecked")
     public void testIteratorRemoveProtectsInvariants() {
-        Bag bag = makeBag();
-        bag.add("A");
-        bag.add("A");
+        Bag<T> bag = makeObject();
+        bag.add((T) "A");
+        bag.add((T) "A");
         assertEquals(2, bag.size());
-        Iterator it = bag.iterator();
+        Iterator<T> it = bag.iterator();
         assertEquals("A", it.next());
         assertEquals(true, it.hasNext());
         it.remove();
@@ -337,17 +341,18 @@ public abstract class AbstractTestBag extends AbstractTestObject {
         assertEquals(0, bag.size());
         assertEquals(false, it.hasNext());
         
-        Iterator it2 = bag.iterator();
+        Iterator<T> it2 = bag.iterator();
         assertEquals(false, it2.hasNext());
     }
     
+    @SuppressWarnings("unchecked")
     public void testToArray() {
-        Bag bag = makeBag();
-        bag.add("A");
-        bag.add("A");
-        bag.add("B");
-        bag.add("B");
-        bag.add("C");
+        Bag<T> bag = makeObject();
+        bag.add((T) "A");
+        bag.add((T) "A");
+        bag.add((T) "B");
+        bag.add((T) "B");
+        bag.add((T) "C");
         Object[] array = bag.toArray();
         int a = 0, b = 0, c = 0;
         for (int i = 0; i < array.length; i++) {
@@ -360,13 +365,14 @@ public abstract class AbstractTestBag extends AbstractTestObject {
         assertEquals(1, c);
     }
 
+    @SuppressWarnings("unchecked")
     public void testToArrayPopulate() {
-        Bag bag = makeBag();
-        bag.add("A");
-        bag.add("A");
-        bag.add("B");
-        bag.add("B");
-        bag.add("C");
+        Bag<T> bag = makeObject();
+        bag.add((T) "A");
+        bag.add((T) "A");
+        bag.add((T) "B");
+        bag.add((T) "B");
+        bag.add((T) "C");
         String[] array = (String[]) bag.toArray(new String[0]);
         int a = 0, b = 0, c = 0;
         for (int i = 0; i < array.length; i++) {
@@ -380,60 +386,63 @@ public abstract class AbstractTestBag extends AbstractTestObject {
     }
 
     //-----------------------------------------------------------------------
+    @SuppressWarnings("unchecked")
     public void testEquals() {
-        Bag bag = makeBag();
-        Bag bag2 = makeBag();
+        Bag<T> bag = makeObject();
+        Bag<T> bag2 = makeObject();
         assertEquals(true, bag.equals(bag2));
-        bag.add("A");
+        bag.add((T) "A");
         assertEquals(false, bag.equals(bag2));
-        bag2.add("A");
+        bag2.add((T) "A");
         assertEquals(true, bag.equals(bag2));
-        bag.add("A");
-        bag.add("B");
-        bag.add("B");
-        bag.add("C");
-        bag2.add("A");
-        bag2.add("B");
-        bag2.add("B");
-        bag2.add("C");
+        bag.add((T) "A");
+        bag.add((T) "B");
+        bag.add((T) "B");
+        bag.add((T) "C");
+        bag2.add((T) "A");
+        bag2.add((T) "B");
+        bag2.add((T) "B");
+        bag2.add((T) "C");
         assertEquals(true, bag.equals(bag2));
     }
 
+    @SuppressWarnings("unchecked")
     public void testEqualsHashBag() {
-        Bag bag = makeBag();
-        Bag bag2 = new HashBag();
+        Bag<T> bag = makeObject();
+        Bag<T> bag2 = new HashBag<T>();
         assertEquals(true, bag.equals(bag2));
-        bag.add("A");
+        bag.add((T) "A");
         assertEquals(false, bag.equals(bag2));
-        bag2.add("A");
+        bag2.add((T) "A");
         assertEquals(true, bag.equals(bag2));
-        bag.add("A");
-        bag.add("B");
-        bag.add("B");
-        bag.add("C");
-        bag2.add("A");
-        bag2.add("B");
-        bag2.add("B");
-        bag2.add("C");
+        bag.add((T) "A");
+        bag.add((T) "B");
+        bag.add((T) "B");
+        bag.add((T) "C");
+        bag2.add((T) "A");
+        bag2.add((T) "B");
+        bag2.add((T) "B");
+        bag2.add((T) "C");
         assertEquals(true, bag.equals(bag2));
     }
 
+    @SuppressWarnings("unchecked")
     public void testHashCode() {
-        Bag bag = makeBag();
-        Bag bag2 = makeBag();
+        Bag<T> bag = makeObject();
+        Bag<T> bag2 = makeObject();
         assertEquals(0, bag.hashCode());
         assertEquals(0, bag2.hashCode());
         assertEquals(bag.hashCode(), bag2.hashCode());
-        bag.add("A");
-        bag.add("A");
-        bag.add("B");
-        bag.add("B");
-        bag.add("C");
-        bag2.add("A");
-        bag2.add("A");
-        bag2.add("B");
-        bag2.add("B");
-        bag2.add("C");
+        bag.add((T) "A");
+        bag.add((T) "A");
+        bag.add((T) "B");
+        bag.add((T) "B");
+        bag.add((T) "C");
+        bag2.add((T) "A");
+        bag2.add((T) "A");
+        bag2.add((T) "B");
+        bag2.add((T) "B");
+        bag2.add((T) "C");
         assertEquals(bag.hashCode(), bag2.hashCode());
         
         int total = 0;
@@ -445,8 +454,9 @@ public abstract class AbstractTestBag extends AbstractTestObject {
     }
 
     //-----------------------------------------------------------------------
+    @SuppressWarnings("unchecked")
     public void testEmptyBagSerialization() throws IOException, ClassNotFoundException {
-        Bag bag = makeBag();
+        Bag<T> bag = makeObject();
         if (!(bag instanceof Serializable && isTestSerialization())) return;
         
         byte[] objekt = writeExternalFormToBytes((Serializable) bag);
@@ -456,13 +466,14 @@ public abstract class AbstractTestBag extends AbstractTestObject {
         assertEquals("Bag should be empty",0, bag2.size());
     }
 
+    @SuppressWarnings("unchecked")
     public void testFullBagSerialization() throws IOException, ClassNotFoundException {
-        Bag bag = makeBag();
-        bag.add("A");
-        bag.add("A");
-        bag.add("B");
-        bag.add("B");
-        bag.add("C");
+        Bag<T> bag = makeObject();
+        bag.add((T) "A");
+        bag.add((T) "A");
+        bag.add((T) "B");
+        bag.add((T) "B");
+        bag.add((T) "C");
         int size = bag.size();
         if (!(bag instanceof Serializable && isTestSerialization())) return;
         
@@ -488,10 +499,11 @@ public abstract class AbstractTestBag extends AbstractTestObject {
      * Compare the current serialized form of the Bag
      * against the canonical version in CVS.
      */
+    @SuppressWarnings("unchecked")
     public void testEmptyBagCompatibility() throws IOException, ClassNotFoundException {
         // test to make sure the canonical form has been preserved
-        Bag bag = makeBag();
-        if(bag instanceof Serializable && !skipSerializedCanonicalTests() && isTestSerialization()) {
+        Bag<T> bag = makeObject();
+        if (bag instanceof Serializable && !skipSerializedCanonicalTests() && isTestSerialization()) {
             Bag bag2 = (Bag) readExternalFormFromDisk(getCanonicalEmptyCollectionName(bag));
             assertTrue("Bag is empty",bag2.size()  == 0);
             assertEquals(bag, bag2);
@@ -502,15 +514,16 @@ public abstract class AbstractTestBag extends AbstractTestObject {
      * Compare the current serialized form of the Bag
      * against the canonical version in CVS.
      */
+    @SuppressWarnings("unchecked")
     public void testFullBagCompatibility() throws IOException, ClassNotFoundException {
         // test to make sure the canonical form has been preserved
-        Bag bag = makeBag();
-        bag.add("A");
-        bag.add("A");
-        bag.add("B");
-        bag.add("B");
-        bag.add("C");
-        if(bag instanceof Serializable && !skipSerializedCanonicalTests() && isTestSerialization()) {
+        Bag<T> bag = makeObject();
+        bag.add((T) "A");
+        bag.add((T) "A");
+        bag.add((T) "B");
+        bag.add((T) "B");
+        bag.add((T) "C");
+        if (bag instanceof Serializable && !skipSerializedCanonicalTests() && isTestSerialization()) {
             Bag bag2 = (Bag) readExternalFormFromDisk(getCanonicalFullCollectionName(bag));
             assertEquals("Bag is the right size",bag.size(), bag2.size());
             assertEquals(bag, bag2);

http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/test/org/apache/commons/collections/bag/AbstractTestSortedBag.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/commons/collections/bag/AbstractTestSortedBag.java b/src/test/org/apache/commons/collections/bag/AbstractTestSortedBag.java
index 0327eba..739d701 100644
--- a/src/test/org/apache/commons/collections/bag/AbstractTestSortedBag.java
+++ b/src/test/org/apache/commons/collections/bag/AbstractTestSortedBag.java
@@ -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 @@ package org.apache.commons.collections.bag;
  * 
  * @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!
 }

http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/test/org/apache/commons/collections/bag/TestHashBag.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/commons/collections/bag/TestHashBag.java b/src/test/org/apache/commons/collections/bag/TestHashBag.java
index 39d4ede..1e2b500 100644
--- a/src/test/org/apache/commons/collections/bag/TestHashBag.java
+++ b/src/test/org/apache/commons/collections/bag/TestHashBag.java
@@ -29,7 +29,7 @@ import org.apache.commons.collections.Bag;
  *
  * @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 @@ public class TestHashBag extends AbstractTestBag {
         junit.textui.TestRunner.main(testCaseName);
     }
 
-    public Bag makeBag() {
-        return new HashBag();
+    public Bag<T> makeObject() {
+        return new HashBag<T>();
     }
     
     public String getCompatibilityVersion() {

http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/test/org/apache/commons/collections/bag/TestPredicatedBag.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/commons/collections/bag/TestPredicatedBag.java b/src/test/org/apache/commons/collections/bag/TestPredicatedBag.java
index db25fd2..3799dad 100644
--- a/src/test/org/apache/commons/collections/bag/TestPredicatedBag.java
+++ b/src/test/org/apache/commons/collections/bag/TestPredicatedBag.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,7 +23,7 @@ import junit.framework.TestSuite;
 
 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 TestBag} for exercising the {@link PredicatedBag}
@@ -31,11 +31,11 @@ import org.apache.commons.collections.PredicateUtils;
  *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
- * 
+ *
  * @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 @@ public class TestPredicatedBag extends AbstractTestBag {
         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() {

http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/test/org/apache/commons/collections/bag/TestPredicatedSortedBag.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/commons/collections/bag/TestPredicatedSortedBag.java b/src/test/org/apache/commons/collections/bag/TestPredicatedSortedBag.java
index 98a2d26..89d5e15 100644
--- a/src/test/org/apache/commons/collections/bag/TestPredicatedSortedBag.java
+++ b/src/test/org/apache/commons/collections/bag/TestPredicatedSortedBag.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,10 +21,9 @@ import java.util.Comparator;
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
-import org.apache.commons.collections.Bag;
 import org.apache.commons.collections.Predicate;
-import org.apache.commons.collections.PredicateUtils;
 import org.apache.commons.collections.SortedBag;
+import org.apache.commons.collections.functors.TruePredicate;
 
 /**
  * Extension of {@link TestBag} for exercising the {@link PredicatedSortedBag}
@@ -32,76 +31,77 @@ import org.apache.commons.collections.SortedBag;
  *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
- * 
+ *
  * @author Phil Steitz
  */
-public class TestPredicatedSortedBag extends AbstractTestSortedBag {
-    
-    private SortedBag nullBag = null;
-    
+public class TestPredicatedSortedBag<T> extends AbstractTestSortedBag<T> {
+
+    private SortedBag<T> nullBag = null;
+
     public TestPredicatedSortedBag(String testName) {
         super(testName);
     }
-    
+
     public static Test suite() {
         return new TestSuite(TestPredicatedSortedBag.class);
     }
-    
+
     public static void main(String args[]) {
         String[] testCaseName = { TestPredicatedSortedBag.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 SortedBag decorateBag(SortedBag bag, Predicate predicate) {
+    }
+
+    protected Predicate<T> truePredicate = TruePredicate.<T>truePredicate();
+
+    protected SortedBag<T> decorateBag(SortedBag<T> bag, Predicate<T> predicate) {
         return PredicatedSortedBag.decorate(bag, predicate);
     }
-    
-    public Bag makeBag() {
-        return decorateBag(new TreeBag(), truePredicate);
+
+    public SortedBag<T> makeObject() {
+        return decorateBag(new TreeBag<T>(), truePredicate);
     }
-    
-    protected Bag makeTestBag() {
-        return decorateBag(new TreeBag(), stringPredicate());
+
+    protected SortedBag<T> makeTestBag() {
+        return decorateBag(new TreeBag<T>(), stringPredicate());
     }
-    
+
     //--------------------------------------------------------------------------
-    
+
     public void testDecorate() {
-        SortedBag bag = decorateBag(new TreeBag(), stringPredicate());
-        SortedBag bag2 = ((PredicatedSortedBag) bag).decorated();
+        SortedBag<T> bag = decorateBag(new TreeBag<T>(), stringPredicate());
+        ((PredicatedSortedBag<T>) bag).decorated();
         try {
-            SortedBag bag3 = decorateBag(new TreeBag(), null);
+            decorateBag(new TreeBag<T>(), null);
             fail("Expecting IllegalArgumentException for null predicate");
         } catch (IllegalArgumentException e) {}
         try {
-            SortedBag bag4 = decorateBag(nullBag, stringPredicate());
+            decorateBag(nullBag, stringPredicate());
             fail("Expecting IllegalArgumentException for null bag");
         } catch (IllegalArgumentException e) {}
     }
-    
+
+    @SuppressWarnings("unchecked")
     public void testSortOrder() {
-        SortedBag bag = decorateBag(new TreeBag(), stringPredicate());
+        SortedBag<T> bag = decorateBag(new TreeBag<T>(), stringPredicate());
         String one = "one";
         String two = "two";
         String three = "three";
-        bag.add(one);
-        bag.add(two);
-        bag.add(three);
+        bag.add((T) one);
+        bag.add((T) two);
+        bag.add((T) three);
         assertEquals("first element", bag.first(), one);
-        assertEquals("last element", bag.last(), two); 
-        Comparator c = bag.comparator();
+        assertEquals("last element", bag.last(), two);
+        Comparator<? super T> c = bag.comparator();
         assertTrue("natural order, so comparator should be null", c == null);
     }
 

http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/test/org/apache/commons/collections/bag/TestTransformedBag.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/commons/collections/bag/TestTransformedBag.java b/src/test/org/apache/commons/collections/bag/TestTransformedBag.java
index b7c1f68..78e73a5 100644
--- a/src/test/org/apache/commons/collections/bag/TestTransformedBag.java
+++ b/src/test/org/apache/commons/collections/bag/TestTransformedBag.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +20,7 @@ import junit.framework.Test;
 import junit.framework.TestSuite;
 
 import org.apache.commons.collections.Bag;
+import org.apache.commons.collections.Transformer;
 import org.apache.commons.collections.collection.TestTransformedCollection;
 
 /**
@@ -28,11 +29,11 @@ import org.apache.commons.collections.collection.TestTransformedCollection;
  *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
- * 
+ *
  * @author Stephen Colebourne
  */
-public class TestTransformedBag extends AbstractTestBag {
-    
+public class TestTransformedBag<T> extends AbstractTestBag<T> {
+
     public TestTransformedBag(String testName) {
         super(testName);
     }
@@ -46,24 +47,26 @@ public class TestTransformedBag extends AbstractTestBag {
         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])));
-        
     }
 
     public String getCompatibilityVersion() {

http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/test/org/apache/commons/collections/bag/TestTransformedSortedBag.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/commons/collections/bag/TestTransformedSortedBag.java b/src/test/org/apache/commons/collections/bag/TestTransformedSortedBag.java
index 8ed906a..f840aa4 100644
--- a/src/test/org/apache/commons/collections/bag/TestTransformedSortedBag.java
+++ b/src/test/org/apache/commons/collections/bag/TestTransformedSortedBag.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,7 +19,8 @@ package org.apache.commons.collections.bag;
 import junit.framework.Test;
 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;
 
 /**
@@ -28,11 +29,11 @@ import org.apache.commons.collections.collection.TestTransformedCollection;
  *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
- * 
+ *
  * @author Stephen Colebourne
  */
-public class TestTransformedSortedBag extends AbstractTestSortedBag {
-    
+public class TestTransformedSortedBag<T> extends AbstractTestSortedBag<T> {
+
     public TestTransformedSortedBag(String testName) {
         super(testName);
     }
@@ -46,22 +47,24 @@ public class TestTransformedSortedBag extends AbstractTestSortedBag {
         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 String getCompatibilityVersion() {

http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/test/org/apache/commons/collections/bag/TestTreeBag.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/commons/collections/bag/TestTreeBag.java b/src/test/org/apache/commons/collections/bag/TestTreeBag.java
index df0f2cd..ce4f250 100644
--- a/src/test/org/apache/commons/collections/bag/TestTreeBag.java
+++ b/src/test/org/apache/commons/collections/bag/TestTreeBag.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,65 +26,62 @@ import org.apache.commons.collections.SortedBag;
  * Extension of {@link TestBag} for exercising the {@link TreeBag}
  * implementation.
  * 
- * @version $Revision$ $Date$
- *
+ * @version $Revision$ $Date: 2006-10-27 19:52:37 -0500 (Fri, 27 Oct
+ * 2006) $
+ * 
  * @author Chuck Burdick
  */
-public class TestTreeBag extends AbstractTestBag {
-    
-   public TestTreeBag(String testName) {
-      super(testName);
-   }
+public class TestTreeBag<T> extends AbstractTestSortedBag<T> {
+
+    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 static Test suite() {
-      return new TestSuite(TestTreeBag.class);
-   }
+    public SortedBag<T> makeObject() {
+        return new TreeBag<T>();
+    }
 
-   public static void main(String args[]) {
-      String[] testCaseName = { TestTreeBag.class.getName() };
-      junit.textui.TestRunner.main(testCaseName);
-   }
+    @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 Bag makeBag() {
-      return new TreeBag();
-   }
+    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 SortedBag setupBag() {
-      SortedBag bag = (SortedBag)makeBag();
-      bag.add("C");
-      bag.add("A");
-      bag.add("B");
-      bag.add("D");
-      return bag;
-   }
+    public String getCompatibilityVersion() {
+        return "3";
+    }
 
-   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 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");
-//   }
+    //   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");
+    //   }
 }

http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/test/org/apache/commons/collections/bidimap/AbstractTestBidiMap.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/commons/collections/bidimap/AbstractTestBidiMap.java b/src/test/org/apache/commons/collections/bidimap/AbstractTestBidiMap.java
index d84ca70..7f026db 100644
--- a/src/test/org/apache/commons/collections/bidimap/AbstractTestBidiMap.java
+++ b/src/test/org/apache/commons/collections/bidimap/AbstractTestBidiMap.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -30,66 +30,37 @@ import org.apache.commons.collections.map.AbstractTestMap;
 
 /**
  * Abstract test class for {@link BidiMap} methods and contracts.
- * 
+ *
  * @version $Revision$ $Date$
- * 
+ *
  * @author Matthew Hawthorne
  * @author Stephen Colebourne
  */
-public abstract class AbstractTestBidiMap extends AbstractTestMap {
-
-    // Test data.
-    private static final Object[][] entriesKV =
-        new Object[][] {
-            new Object[] { "key1", "value1" },
-            new Object[] { "key2", "value2" },
-            new Object[] { "key3", "value3" }
-    };
-    private static final Object[][] entriesVK =
-        new Object[][] {
-            new Object[] { "value1", "key1" },
-            new Object[] { "value2", "key2" },
-            new Object[] { "value3", "key3" }
-    };
-    protected final Object[][] entries;
+public abstract class AbstractTestBidiMap<K, V> extends AbstractTestMap<K, V> {
 
     public AbstractTestBidiMap(String testName) {
         super(testName);
-        entries = entriesKV;
     }
 
     public AbstractTestBidiMap() {
         super("Inverse");
-        entries = entriesVK;
     }
 
     //-----------------------------------------------------------------------
     /**
-     * Implement to create an empty <code>BidiMap</code>.
-     * 
-     * @return an empty <code>BidiMap</code> implementation.
-     */
-    public abstract BidiMap makeEmptyBidiMap();
-
-    /**
      * Override to create a full <code>BidiMap</code> other than the default.
-     * 
+     *
      * @return a full <code>BidiMap</code> implementation.
      */
-    public BidiMap makeFullBidiMap() {
-        final BidiMap map = makeEmptyBidiMap();
-        for (int i = 0; i < entries.length; i++) {
-            map.put(entries[i][0], entries[i][1]);
-        }
-        return map;
+    @Override
+    public BidiMap<K, V> makeFullMap() {
+        return (BidiMap<K, V>) super.makeFullMap();
     }
 
     /**
      * Override to return the empty BidiMap.
      */
-    public final  Map makeEmptyMap() {
-        return makeEmptyBidiMap();
-    }
+    public abstract BidiMap<K, V> makeObject();
 
     /**
      * Override to indicate to AbstractTestMap this is a BidiMap.
@@ -97,7 +68,7 @@ public abstract class AbstractTestBidiMap extends AbstractTestMap {
     public boolean isAllowDuplicateValues() {
         return false;
     }
-    
+
     /**
      * Override as DualHashBidiMap didn't exist until version 3.
      */
@@ -107,33 +78,34 @@ public abstract class AbstractTestBidiMap extends AbstractTestMap {
 
     // BidiPut
     //-----------------------------------------------------------------------
+    @SuppressWarnings("unchecked")
     public void testBidiPut() {
         if (isPutAddSupported() == false || isPutChangeSupported() == false) return;
 
-        BidiMap map = makeEmptyBidiMap();
-        BidiMap inverse = map.inverseBidiMap();
+        BidiMap<K, V> map = makeObject();
+        BidiMap<V, K> inverse = map.inverseBidiMap();
         assertEquals(0, map.size());
         assertEquals(map.size(), inverse.size());
-        
-        map.put("A", "B");
+
+        map.put((K) "A", (V) "B");
         assertEquals(1, map.size());
         assertEquals(map.size(), inverse.size());
         assertEquals("B", map.get("A"));
         assertEquals("A", inverse.get("B"));
-        
-        map.put("A", "C");
+
+        map.put((K) "A", (V) "C");
         assertEquals(1, map.size());
         assertEquals(map.size(), inverse.size());
         assertEquals("C", map.get("A"));
         assertEquals("A", inverse.get("C"));
-        
-        map.put("B", "C");
+
+        map.put((K) "B", (V) "C");
         assertEquals(1, map.size());
         assertEquals(map.size(), inverse.size());
         assertEquals("C", map.get("B"));
         assertEquals("B", inverse.get("C"));
-        
-        map.put("E", "F");
+
+        map.put((K) "E", (V) "F");
         assertEquals(2, map.size());
         assertEquals(map.size(), inverse.size());
         assertEquals("F", map.get("E"));
@@ -151,33 +123,33 @@ public abstract class AbstractTestBidiMap extends AbstractTestMap {
     }
 
     public void verifyInverse() {
-        assertEquals(map.size(), ((BidiMap) map).inverseBidiMap().size());
-        Map map1 = new HashMap(map);
-        Map map2 = new HashMap(((BidiMap) map).inverseBidiMap());
-        Set keys1 = map1.keySet();
-        Set keys2 = map2.keySet();
-        Collection values1 = map1.values();
-        Collection values2 = map2.values();
+        assertEquals(map.size(), ((BidiMap<K, V>) map).inverseBidiMap().size());
+        Map<K, V> map1 = new HashMap<K, V>(map);
+        Map<V, K> map2 = new HashMap<V, K>(((BidiMap<K, V>) map).inverseBidiMap());
+        Set<K> keys1 = map1.keySet();
+        Set<V> keys2 = map2.keySet();
+        Collection<V> values1 = map1.values();
+        Collection<K> values2 = map2.values();
         assertEquals(true, keys1.containsAll(values2));
         assertEquals(true, values2.containsAll(keys1));
         assertEquals(true, values1.containsAll(keys2));
         assertEquals(true, keys2.containsAll(values1));
     }
-    
+
     // testGetKey
     //-----------------------------------------------------------------------
     public void testBidiGetKey() {
-        doTestGetKey(makeFullBidiMap(), entries[0][0], entries[0][1]);
+        doTestGetKey(makeFullMap(), getSampleKeys()[0], getSampleValues()[0]);
     }
 
     public void testBidiGetKeyInverse() {
         doTestGetKey(
-            makeFullBidiMap().inverseBidiMap(),
-            entries[0][1],
-            entries[0][0]);
+            makeFullMap().inverseBidiMap(),
+            getSampleValues()[0],
+            getSampleKeys()[0]);
     }
 
-    private final void doTestGetKey(BidiMap map, Object key, Object value) {
+    private final void doTestGetKey(BidiMap<?, ?> map, Object key, Object value) {
         assertEquals("Value not found for key.", value, map.get(key));
         assertEquals("Key not found for value.", key, map.getKey(value));
     }
@@ -185,8 +157,8 @@ public abstract class AbstractTestBidiMap extends AbstractTestMap {
     // testInverse
     //-----------------------------------------------------------------------
     public void testBidiInverse() {
-        final BidiMap map = makeFullBidiMap();
-        final BidiMap inverseMap = map.inverseBidiMap();
+        final BidiMap<K, V> map = makeFullMap();
+        final BidiMap<V, K> inverseMap = map.inverseBidiMap();
 
         assertSame(
             "Inverse of inverse is not equal to original.",
@@ -195,26 +167,27 @@ public abstract class AbstractTestBidiMap extends AbstractTestMap {
 
         assertEquals(
             "Value not found for key.",
-            entries[0][0],
-            inverseMap.get(entries[0][1]));
+            getSampleKeys()[0],
+            inverseMap.get(getSampleValues()[0]));
 
         assertEquals(
             "Key not found for value.",
-            entries[0][1],
-            inverseMap.getKey(entries[0][0]));
+            getSampleValues()[0],
+            inverseMap.getKey(getSampleKeys()[0]));
     }
 
     //-----------------------------------------------------------------------
     public void testBidiModifyEntrySet() {
         if (isSetValueSupported() == false) return;
-        
-        modifyEntrySet(makeFullBidiMap());
-        modifyEntrySet(makeFullBidiMap().inverseBidiMap());
+
+        modifyEntrySet(makeFullMap());
+        modifyEntrySet(makeFullMap().inverseBidiMap());
     }
 
-    private final void modifyEntrySet(BidiMap map) {
+    @SuppressWarnings("unchecked")
+    private final <T> void modifyEntrySet(BidiMap<?, T> map) {
         // Gets first entry
-        final Map.Entry entry = (Map.Entry)map.entrySet().iterator().next();
+        final Map.Entry<?, T> entry = map.entrySet().iterator().next();
 
         // Gets key and value
         final Object key = entry.getKey();
@@ -222,7 +195,7 @@ public abstract class AbstractTestBidiMap extends AbstractTestMap {
 
         // Sets new value
         final Object newValue = "newValue";
-        entry.setValue(newValue);
+        entry.setValue((T) newValue);
 
         assertEquals(
             "Modifying entrySet did not affect underlying Map.",
@@ -238,19 +211,19 @@ public abstract class AbstractTestBidiMap extends AbstractTestMap {
     public void testBidiClear() {
         if (isRemoveSupported() == false) {
             try {
-                makeFullBidiMap().clear();
+                makeFullMap().clear();
                 fail();
             } catch(UnsupportedOperationException ex) {}
             return;
         }
 
-        BidiMap map = makeFullBidiMap();
+        BidiMap<?, ?> map = makeFullMap();
         map.clear();
         assertTrue("Map was not cleared.", map.isEmpty());
         assertTrue("Inverse map was not cleared.", map.inverseBidiMap().isEmpty());
 
         // Tests clear on inverse
-        map = makeFullBidiMap().inverseBidiMap();
+        map = makeFullMap().inverseBidiMap();
         map.clear();
         assertTrue("Map was not cleared.", map.isEmpty());
         assertTrue("Inverse map was not cleared.", map.inverseBidiMap().isEmpty());
@@ -261,32 +234,32 @@ public abstract class AbstractTestBidiMap extends AbstractTestMap {
     public void testBidiRemove() {
         if (isRemoveSupported() == false) {
             try {
-                makeFullBidiMap().remove(entries[0][0]);
+                makeFullMap().remove(getSampleKeys()[0]);
                 fail();
             } catch(UnsupportedOperationException ex) {}
             try {
-                makeFullBidiMap().removeValue(entries[0][1]);
+                makeFullMap().removeValue(getSampleValues()[0]);
                 fail();
             } catch(UnsupportedOperationException ex) {}
             return;
         }
-        
-        remove(makeFullBidiMap(), entries[0][0]);
-        remove(makeFullBidiMap().inverseBidiMap(), entries[0][1]);
-
-        removeValue(makeFullBidiMap(), entries[0][1]);
-        removeValue(makeFullBidiMap().inverseBidiMap(), entries[0][0]);
-        
-        assertEquals(null, makeFullBidiMap().removeValue("NotPresent"));
+
+        remove(makeFullMap(), getSampleKeys()[0]);
+        remove(makeFullMap().inverseBidiMap(), getSampleValues()[0]);
+
+        removeValue(makeFullMap(), getSampleValues()[0]);
+        removeValue(makeFullMap().inverseBidiMap(), getSampleKeys()[0]);
+
+        assertEquals(null, makeFullMap().removeValue("NotPresent"));
     }
 
-    private final void remove(BidiMap map, Object key) {
+    private final void remove(BidiMap<?, ?> map, Object key) {
         final Object value = map.remove(key);
         assertTrue("Key was not removed.", !map.containsKey(key));
         assertNull("Value was not removed.", map.getKey(value));
     }
 
-    private final void removeValue(BidiMap map, Object value) {
+    private final void removeValue(BidiMap<?, ?> map, Object value) {
         final Object key = map.removeValue(value);
         assertTrue("Key was not removed.", !map.containsKey(key));
         assertNull("Value was not removed.", map.getKey(value));
@@ -295,11 +268,11 @@ public abstract class AbstractTestBidiMap extends AbstractTestMap {
     //-----------------------------------------------------------------------
     public void testBidiKeySetValuesOrder() {
         resetFull();
-        Iterator keys = map.keySet().iterator();
-        Iterator values = map.values().iterator();
+        Iterator<K> keys = map.keySet().iterator();
+        Iterator<V> values = map.values().iterator();
         for (; keys.hasNext() && values.hasNext();) {
-            Object key = keys.next();
-            Object value = values.next();
+            K key = keys.next();
+            V value = values.next();
             assertSame(map.get(key), value);
         }
         assertEquals(false, keys.hasNext());
@@ -309,12 +282,12 @@ public abstract class AbstractTestBidiMap extends AbstractTestMap {
     //-----------------------------------------------------------------------
     public void testBidiRemoveByKeySet() {
         if (isRemoveSupported() == false) return;
-        
-        removeByKeySet(makeFullBidiMap(), entries[0][0], entries[0][1]);
-        removeByKeySet(makeFullBidiMap().inverseBidiMap(), entries[0][1], entries[0][0]);
+
+        removeByKeySet(makeFullMap(), getSampleKeys()[0], getSampleValues()[0]);
+        removeByKeySet(makeFullMap().inverseBidiMap(), getSampleValues()[0], getSampleKeys()[0]);
     }
 
-    private final void removeByKeySet(BidiMap map, Object key, Object value) {
+    private final void removeByKeySet(BidiMap<?, ?> map, Object key, Object value) {
         map.keySet().remove(key);
 
         assertTrue("Key was not removed.", !map.containsKey(key));
@@ -331,13 +304,13 @@ public abstract class AbstractTestBidiMap extends AbstractTestMap {
     //-----------------------------------------------------------------------
     public void testBidiRemoveByEntrySet() {
         if (isRemoveSupported() == false) return;
-        
-        removeByEntrySet(makeFullBidiMap(), entries[0][0], entries[0][1]);
-        removeByEntrySet(makeFullBidiMap().inverseBidiMap(), entries[0][1], entries[0][0]);
+
+        removeByEntrySet(makeFullMap(), getSampleKeys()[0], getSampleValues()[0]);
+        removeByEntrySet(makeFullMap().inverseBidiMap(), getSampleValues()[0], getSampleKeys()[0]);
     }
 
-    private final void removeByEntrySet(BidiMap map, Object key, Object value) {
-        Map temp = new HashMap();
+    private final void removeByEntrySet(BidiMap<?, ?> map, Object key, Object value) {
+        Map<Object, Object> temp = new HashMap<Object, Object>();
         temp.put(key, value);
         map.entrySet().remove(temp.entrySet().iterator().next());
 
@@ -352,6 +325,14 @@ public abstract class AbstractTestBidiMap extends AbstractTestMap {
             !map.inverseBidiMap().containsKey(value));
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public BidiMap<K, V> getMap() {
+        return (BidiMap<K, V>) super.getMap();
+    }
+
     //-----------------------------------------------------------------------
     public BulkTest bulkTestMapEntrySet() {
         return new TestBidiMapEntrySet();
@@ -362,24 +343,24 @@ public abstract class AbstractTestBidiMap extends AbstractTestMap {
             super();
         }
         public void testMapEntrySetIteratorEntrySetValueCrossCheck() {
-            Object key1 = getSampleKeys()[0];
-            Object key2 = getSampleKeys()[1];
-            Object newValue1 = getNewSampleValues()[0];
-            Object newValue2 = getNewSampleValues()[1];
-                
+            K key1 = getSampleKeys()[0];
+            K key2 = getSampleKeys()[1];
+            V newValue1 = getNewSampleValues()[0];
+            V newValue2 = getNewSampleValues()[1];
+
             resetFull();
             // explicitly get entries as sample values/keys are connected for some maps
             // such as BeanMap
-            Iterator it = TestBidiMapEntrySet.this.collection.iterator();
-            Map.Entry entry1 = getEntry(it, key1);
-            it = TestBidiMapEntrySet.this.collection.iterator();
-            Map.Entry entry2 = getEntry(it, key2);
-            Iterator itConfirmed = TestBidiMapEntrySet.this.confirmed.iterator();
-            Map.Entry entryConfirmed1 = getEntry(itConfirmed, key1);
-            itConfirmed = TestBidiMapEntrySet.this.confirmed.iterator();
-            Map.Entry entryConfirmed2 = getEntry(itConfirmed, key2);
+            Iterator<Map.Entry<K, V>> it = TestBidiMapEntrySet.this.getCollection().iterator();
+            Map.Entry<K, V> entry1 = getEntry(it, key1);
+            it = TestBidiMapEntrySet.this.getCollection().iterator();
+            Map.Entry<K, V> entry2 = getEntry(it, key2);
+            Iterator<Map.Entry<K, V>> itConfirmed = TestBidiMapEntrySet.this.getConfirmed().iterator();
+            Map.Entry<K, V> entryConfirmed1 = getEntry(itConfirmed, key1);
+            itConfirmed = TestBidiMapEntrySet.this.getConfirmed().iterator();
+            Map.Entry<K, V> entryConfirmed2 = getEntry(itConfirmed, key2);
             TestBidiMapEntrySet.this.verify();
-                
+
             if (isSetValueSupported() == false) {
                 try {
                     entry1.setValue(newValue1);
@@ -388,12 +369,12 @@ public abstract class AbstractTestBidiMap extends AbstractTestMap {
                 return;
             }
 
-            // these checked in superclass                
+            // these checked in superclass
             entry1.setValue(newValue1);
             entryConfirmed1.setValue(newValue1);
             entry2.setValue(newValue2);
             entryConfirmed2.setValue(newValue2);
-            
+
             // at this point
             // key1=newValue1, key2=newValue2
             try {
@@ -402,15 +383,15 @@ public abstract class AbstractTestBidiMap extends AbstractTestMap {
                 return;  // simplest way of dealing with tricky situation
             }
             entryConfirmed2.setValue(newValue1);
-            AbstractTestBidiMap.this.confirmed.remove(key1);
+            AbstractTestBidiMap.this.getConfirmed().remove(key1);
             assertEquals(newValue1, entry2.getValue());
-            assertEquals(true, AbstractTestBidiMap.this.map.containsKey(entry2.getKey()));
-            assertEquals(true, AbstractTestBidiMap.this.map.containsValue(newValue1));
-            assertEquals(newValue1, AbstractTestBidiMap.this.map.get(entry2.getKey()));
-            assertEquals(false, AbstractTestBidiMap.this.map.containsKey(key1));
-            assertEquals(false, AbstractTestBidiMap.this.map.containsValue(newValue2));
+            assertEquals(true, AbstractTestBidiMap.this.getMap().containsKey(entry2.getKey()));
+            assertEquals(true, AbstractTestBidiMap.this.getMap().containsValue(newValue1));
+            assertEquals(newValue1, AbstractTestBidiMap.this.getMap().get(entry2.getKey()));
+            assertEquals(false, AbstractTestBidiMap.this.getMap().containsKey(key1));
+            assertEquals(false, AbstractTestBidiMap.this.getMap().containsValue(newValue2));
             TestBidiMapEntrySet.this.verify();
-            
+
             // check for ConcurrentModification
             it.next();  // if you fail here, maybe you should be throwing an IAE, see above
             if (isRemoveSupported()) {
@@ -418,72 +399,78 @@ public abstract class AbstractTestBidiMap extends AbstractTestMap {
             }
         }
     }
-        
+
     public BulkTest bulkTestInverseMap() {
         return new TestInverseBidiMap(this);
     }
 
-    public class TestInverseBidiMap extends AbstractTestBidiMap {
-        final AbstractTestBidiMap main;
-        
-        public TestInverseBidiMap(AbstractTestBidiMap main) {
+    public class TestInverseBidiMap extends AbstractTestBidiMap<V, K> {
+        final AbstractTestBidiMap<K, V> main;
+
+        public TestInverseBidiMap(AbstractTestBidiMap<K, V> main) {
             super();
             this.main = main;
         }
-        public BidiMap makeEmptyBidiMap() {
-            return main.makeEmptyBidiMap().inverseBidiMap();
-        }
-        public BidiMap makeFullBidiMap() {
-            return main.makeFullBidiMap().inverseBidiMap();
+
+        public BidiMap<V, K> makeObject() {
+            return main.makeObject().inverseBidiMap();
         }
-        public Map makeFullMap() {
-            return ((BidiMap) main.makeFullMap()).inverseBidiMap();
+
+        public BidiMap<V, K> makeFullMap() {
+            return main.makeFullMap().inverseBidiMap();
         }
-        public Object[] getSampleKeys() {
+
+        public V[] getSampleKeys() {
             return main.getSampleValues();
         }
-        public Object[] getSampleValues() {
+        public K[] getSampleValues() {
             return main.getSampleKeys();
         }
-        
+
         public String getCompatibilityVersion() {
             return main.getCompatibilityVersion();
         }
+
         public boolean isAllowNullKey() {
             return main.isAllowNullKey();
         }
+
         public boolean isAllowNullValue() {
             return main.isAllowNullValue();
         }
+
         public boolean isPutAddSupported() {
             return main.isPutAddSupported();
         }
+
         public boolean isPutChangeSupported() {
             return main.isPutChangeSupported();
         }
+
         public boolean isSetValueSupported() {
             return main.isSetValueSupported();
         }
+
         public boolean isRemoveSupported() {
             return main.isRemoveSupported();
         }
 
     }
-    
+
     //-----------------------------------------------------------------------
     public BulkTest bulkTestBidiMapIterator() {
         return new TestBidiMapIterator();
     }
-    
-    public class TestBidiMapIterator extends AbstractTestMapIterator {
+
+    public class TestBidiMapIterator extends AbstractTestMapIterator<K, V> {
         public TestBidiMapIterator() {
             super("TestBidiMapIterator");
         }
-        
-        public Object[] addSetValues() {
+
+        public V[] addSetValues() {
             return AbstractTestBidiMap.this.getNewSampleValues();
         }
-        
+
         public boolean supportsRemove() {
             return AbstractTestBidiMap.this.isRemoveSupported();
         }
@@ -492,43 +479,43 @@ public abstract class AbstractTestBidiMap extends AbstractTestMap {
             return AbstractTestBidiMap.this.isSetValueSupported();
         }
 
-        public MapIterator makeEmptyMapIterator() {
+        public MapIterator<K, V> makeEmptyIterator() {
             resetEmpty();
-            return ((BidiMap) AbstractTestBidiMap.this.map).mapIterator();
+            return AbstractTestBidiMap.this.getMap().mapIterator();
         }
 
-        public MapIterator makeFullMapIterator() {
+        public MapIterator<K, V> makeObject() {
             resetFull();
-            return ((BidiMap) AbstractTestBidiMap.this.map).mapIterator();
+            return AbstractTestBidiMap.this.getMap().mapIterator();
         }
-        
-        public Map getMap() {
+
+        public BidiMap<K, V> getMap() {
             // assumes makeFullMapIterator() called first
-            return AbstractTestBidiMap.this.map;
+            return AbstractTestBidiMap.this.getMap();
         }
-        
-        public Map getConfirmedMap() {
+
+        public Map<K, V> getConfirmedMap() {
             // assumes makeFullMapIterator() called first
-            return AbstractTestBidiMap.this.confirmed;
+            return AbstractTestBidiMap.this.getConfirmed();
         }
-        
+
         public void verify() {
             super.verify();
             AbstractTestBidiMap.this.verify();
         }
     }
-    
+
     //-----------------------------------------------------------------------
     public void testBidiMapIteratorSet() {
-        Object newValue1 = getOtherValues()[0];
-        Object newValue2 = getOtherValues()[1];
-        
+        V newValue1 = getOtherValues()[0];
+        V newValue2 = getOtherValues()[1];
+
         resetFull();
-        BidiMap bidi = (BidiMap) map;
-        MapIterator it = bidi.mapIterator();
+        BidiMap<K, V> bidi = getMap();
+        MapIterator<K, V> it = bidi.mapIterator();
         assertEquals(true, it.hasNext());
-        Object key1 = it.next();
-        
+        K key1 = it.next();
+
         if (isSetValueSupported() == false) {
             try {
                 it.setValue(newValue1);
@@ -537,7 +524,7 @@ public abstract class AbstractTestBidiMap extends AbstractTestMap {
             }
             return;
         }
-        
+
         it.setValue(newValue1);
         confirmed.put(key1, newValue1);
         assertSame(key1, it.getKey());
@@ -546,7 +533,7 @@ public abstract class AbstractTestBidiMap extends AbstractTestMap {
         assertEquals(true, bidi.containsValue(newValue1));
         assertEquals(newValue1, bidi.get(key1));
         verify();
-        
+
         it.setValue(newValue1);  // same value - should be OK
         confirmed.put(key1, newValue1);
         assertSame(key1, it.getKey());
@@ -555,8 +542,8 @@ public abstract class AbstractTestBidiMap extends AbstractTestMap {
         assertEquals(true, bidi.containsValue(newValue1));
         assertEquals(newValue1, bidi.get(key1));
         verify();
-        
-        Object key2 = it.next();
+
+        K key2 = it.next();
         it.setValue(newValue2);
         confirmed.put(key2, newValue2);
         assertSame(key2, it.getKey());
@@ -565,7 +552,7 @@ public abstract class AbstractTestBidiMap extends AbstractTestMap {
         assertEquals(true, bidi.containsValue(newValue2));
         assertEquals(newValue2, bidi.get(key2));
         verify();
-        
+
         // at this point
         // key1=newValue1, key2=newValue2
         try {
@@ -575,7 +562,7 @@ public abstract class AbstractTestBidiMap extends AbstractTestMap {
             return;  // simplest way of dealing with tricky situation
         }
         confirmed.put(key2, newValue1);
-        AbstractTestBidiMap.this.confirmed.remove(key1);
+        AbstractTestBidiMap.this.getConfirmed().remove(key1);
         assertEquals(newValue1, it.getValue());
         assertEquals(true, bidi.containsKey(it.getKey()));
         assertEquals(true, bidi.containsValue(newValue1));
@@ -583,7 +570,7 @@ public abstract class AbstractTestBidiMap extends AbstractTestMap {
         assertEquals(false, bidi.containsKey(key1));
         assertEquals(false, bidi.containsValue(newValue2));
         verify();
-            
+
         // check for ConcurrentModification
         it.next();  // if you fail here, maybe you should be throwing an IAE, see above
         if (isRemoveSupported()) {

http://git-wip-us.apache.org/repos/asf/commons-collections/blob/884baf0d/src/test/org/apache/commons/collections/bidimap/AbstractTestOrderedBidiMap.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/commons/collections/bidimap/AbstractTestOrderedBidiMap.java b/src/test/org/apache/commons/collections/bidimap/AbstractTestOrderedBidiMap.java
index 802810f..dcf7e29 100644
--- a/src/test/org/apache/commons/collections/bidimap/AbstractTestOrderedBidiMap.java
+++ b/src/test/org/apache/commons/collections/bidimap/AbstractTestOrderedBidiMap.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -30,13 +30,13 @@ import org.apache.commons.collections.iterators.AbstractTestMapIterator;
 
 /**
  * Abstract test class for {@link OrderedBidiMap} methods and contracts.
- * 
+ *
  * @version $Revision$ $Date$
- * 
+ *
  * @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 abstract class AbstractTestOrderedBidiMap extends AbstractTestBidiMap {
     //-----------------------------------------------------------------------
     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 @@ public abstract class AbstractTestOrderedBidiMap extends AbstractTestBidiMap {
         } 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 @@ public abstract class AbstractTestOrderedBidiMap extends AbstractTestBidiMap {
             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 @@ public abstract class AbstractTestOrderedBidiMap extends AbstractTestBidiMap {
         } 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 @@ public abstract class AbstractTestOrderedBidiMap extends AbstractTestBidiMap {
             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 @@ public abstract class AbstractTestOrderedBidiMap extends AbstractTestBidiMap {
             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();
         }
     }
-    
+
 }


Mime
View raw message