commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r738956 [29/34] - in /commons/proper/collections/branches/collections_jdk5_branch/src: java/org/apache/commons/collections/ java/org/apache/commons/collections/bag/ java/org/apache/commons/collections/bidimap/ java/org/apache/commons/collec...
Date Thu, 29 Jan 2009 18:48:47 GMT
Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/list/TestPredicatedList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/list/TestPredicatedList.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/list/TestPredicatedList.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/list/TestPredicatedList.java Thu Jan 29 18:48:37 2009
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,124 +23,129 @@
 import junit.framework.TestSuite;
 
 import org.apache.commons.collections.Predicate;
-import org.apache.commons.collections.PredicateUtils;
+import org.apache.commons.collections.functors.TruePredicate;
 
 /**
- * Extension of {@link TestList} for exercising the 
+ * Extension of {@link TestList} for exercising the
  * {@link PredicatedList} implementation.
  *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
- * 
+ *
  * @author Phil Steitz
  */
-public class TestPredicatedList extends AbstractTestList {
-    
+public class TestPredicatedList<E> extends AbstractTestList<E> {
+
     public TestPredicatedList(String testName) {
         super(testName);
     }
-    
+
     public static Test suite() {
         return new TestSuite(TestPredicatedList.class);
     }
-    
+
     public static void main(String args[]) {
         String[] testCaseName = { TestPredicatedList.class.getName()};
         junit.textui.TestRunner.main(testCaseName);
     }
-    
+
  //-------------------------------------------------------------------
-    
-    protected Predicate truePredicate = PredicateUtils.truePredicate();
-    
-    protected List decorateList(List list, Predicate predicate) {
+
+    protected Predicate<E> truePredicate = TruePredicate.<E>truePredicate();
+
+    protected List<E> decorateList(List<E> list, Predicate<E> predicate) {
         return PredicatedList.decorate(list, predicate);
     }
-    
-    public List makeEmptyList() {
-        return decorateList(new ArrayList(), truePredicate);
-    }
-    
-    public Object[] getFullElements() {
-        return new Object[] {"1", "3", "5", "7", "2", "4", "6"};
-    }
-    
-//--------------------------------------------------------------------   
-    
-     protected Predicate testPredicate =  
-        new Predicate() {
-            public boolean evaluate(Object o) {
+
+    public List<E> makeObject() {
+        return decorateList(new ArrayList<E>(), truePredicate);
+    }
+
+    @SuppressWarnings("unchecked")
+    public E[] getFullElements() {
+        return (E[]) new Object[] { "1", "3", "5", "7", "2", "4", "6" };
+    }
+
+//--------------------------------------------------------------------
+
+    protected Predicate<E> testPredicate =
+        new Predicate<E>() {
+            public boolean evaluate(E o) {
                 return o instanceof String;
             }
-        };      
-    
-    public List makeTestList() {
-        return decorateList(new ArrayList(), testPredicate);
+        };
+
+    public List<E> makeTestList() {
+        return decorateList(new ArrayList<E>(), testPredicate);
     }
-    
+
+    @SuppressWarnings("unchecked")
     public void testIllegalAdd() {
-        List list = makeTestList();
+        List<E> list = makeTestList();
         Integer i = new Integer(3);
         try {
-            list.add(i);
+            list.add((E) i);
             fail("Integer should fail string predicate.");
         } catch (IllegalArgumentException e) {
             // expected
         }
-        assertTrue("Collection shouldn't contain illegal element", 
-         !list.contains(i));   
+        assertTrue("Collection shouldn't contain illegal element",
+         !list.contains(i));
     }
 
+    @SuppressWarnings("unchecked")
     public void testIllegalAddAll() {
-        List list = makeTestList();
-        List elements = new ArrayList();
-        elements.add("one");
-        elements.add("two");
-        elements.add(new Integer(3));
-        elements.add("four");
+        List<E> list = makeTestList();
+        List<E> elements = new ArrayList<E>();
+        elements.add((E) "one");
+        elements.add((E) "two");
+        elements.add((E) new Integer(3));
+        elements.add((E) "four");
         try {
-            list.addAll(0,elements);
+            list.addAll(0, elements);
             fail("Integer should fail string predicate.");
         } catch (IllegalArgumentException e) {
             // expected
         }
-        assertTrue("List shouldn't contain illegal element", 
-         !list.contains("one"));   
-        assertTrue("List shouldn't contain illegal element", 
-         !list.contains("two"));   
-        assertTrue("List shouldn't contain illegal element", 
-         !list.contains(new Integer(3)));   
-        assertTrue("List shouldn't contain illegal element", 
-         !list.contains("four"));   
+        assertTrue("List shouldn't contain illegal element",
+         !list.contains("one"));
+        assertTrue("List shouldn't contain illegal element",
+         !list.contains("two"));
+        assertTrue("List shouldn't contain illegal element",
+         !list.contains(new Integer(3)));
+        assertTrue("List shouldn't contain illegal element",
+         !list.contains("four"));
     }
-    
+
+    @SuppressWarnings("unchecked")
     public void testIllegalSet() {
-        List list = makeTestList();
+        List<E> list = makeTestList();
         try {
-            list.set(0,new Integer(3));
+            list.set(0, (E) new Integer(3));
             fail("Integer should fail string predicate.");
         } catch (IllegalArgumentException e) {
             // expected
         }
     }
-    
+
+    @SuppressWarnings("unchecked")
     public void testLegalAddAll() {
-        List list = makeTestList();
-        list.add("zero");
-        List elements = new ArrayList();
-        elements.add("one");
-        elements.add("two");
-        elements.add("three");
+        List<E> list = makeTestList();
+        list.add((E) "zero");
+        List<E> elements = new ArrayList<E>();
+        elements.add((E) "one");
+        elements.add((E) "two");
+        elements.add((E) "three");
         list.addAll(1,elements);
-        assertTrue("List should contain legal element", 
-         list.contains("zero"));   
-        assertTrue("List should contain legal element", 
-         list.contains("one"));   
-        assertTrue("List should contain legal element", 
-         list.contains("two"));   
-        assertTrue("List should contain legal element", 
-         list.contains("three"));   
-    }       
+        assertTrue("List should contain legal element",
+         list.contains("zero"));
+        assertTrue("List should contain legal element",
+         list.contains("one"));
+        assertTrue("List should contain legal element",
+         list.contains("two"));
+        assertTrue("List should contain legal element",
+         list.contains("three"));
+    }
 
     public String getCompatibilityVersion() {
         return "3.1";

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/list/TestSetUniqueList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/list/TestSetUniqueList.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/list/TestSetUniqueList.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/list/TestSetUniqueList.java Thu Jan 29 18:48:37 2009
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,6 +22,7 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.ListIterator;
+import java.util.Set;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -32,11 +33,11 @@
  *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
- * 
+ *
  * @author Matthew Hawthorne
  * @author Tom Dunham
  */
-public class TestSetUniqueList extends AbstractTestList {
+public class TestSetUniqueList<E> extends AbstractTestList<E> {
 
     public static void main(String[] args) {
         TestRunner.run(suite());
@@ -51,53 +52,54 @@
     }
 
     //-----------------------------------------------------------------------
-    public List makeEmptyList() {
-        return new SetUniqueList(new ArrayList(), new HashSet());
+    public List<E> makeObject() {
+        return new SetUniqueList<E>(new ArrayList<E>(), new HashSet<E>());
     }
 
     public void testListIteratorSet() {
         // override to block
         resetFull();
-        ListIterator it = getList().listIterator();
+        ListIterator<E> it = getCollection().listIterator();
         it.next();
         try {
             it.set(null);
             fail();
         } catch (UnsupportedOperationException ex) {}
     }
-    
-    public Object[] getFullNonNullElements() {
+
+    @SuppressWarnings("unchecked")
+    public E[] getFullNonNullElements() {
         // override to avoid duplicate "One"
-        return new Object[] {
-            new String(""),
-            new String("One"),
-            new Integer(2),
-            "Three",
-            new Integer(4),
-            new Double(5),
-            new Float(6),
-            "Seven",
-            "Eight",
-            new String("Nine"),
-            new Integer(10),
-            new Short((short)11),
-            new Long(12),
-            "Thirteen",
-            "14",
-            "15",
-            new Byte((byte)16)
+        return (E[]) new Object[] {
+                new String(""),
+                new String("One"),
+                new Integer(2),
+                "Three",
+                new Integer(4),
+                new Double(5),
+                new Float(6),
+                "Seven",
+                "Eight",
+                new String("Nine"),
+                new Integer(10),
+                new Short((short)11),
+                new Long(12),
+                "Thirteen",
+                "14",
+                "15",
+                new Byte((byte)16)
         };
     }
-    
+
     public void testListIteratorAdd() {
         // override to cope with Set behaviour
         resetEmpty();
-        List list1 = getList();
-        List list2 = getConfirmedList();
+        List<E> list1 = getCollection();
+        List<E> list2 = getConfirmed();
 
-        Object[] elements = getOtherElements();  // changed here
-        ListIterator iter1 = list1.listIterator();
-        ListIterator iter2 = list2.listIterator();
+        E[] elements = getOtherElements();  // changed here
+        ListIterator<E> iter1 = list1.listIterator();
+        ListIterator<E> iter2 = list2.listIterator();
 
         for (int i = 0; i < elements.length; i++) {
             iter1.add(elements[i]);
@@ -106,8 +108,8 @@
         }
 
         resetFull();
-        iter1 = getList().listIterator();
-        iter2 = getConfirmedList().listIterator();
+        iter1 = getCollection().listIterator();
+        iter2 = getConfirmed().listIterator();
         for (int i = 0; i < elements.length; i++) {
             iter1.next();
             iter2.next();
@@ -116,47 +118,48 @@
             super.verify();  // changed here
         }
     }
-    
+
     public void testCollectionAddAll() {
         // override for set behaviour
         resetEmpty();
-        Object[] elements = getFullElements();
-        boolean r = collection.addAll(Arrays.asList(elements));
-        confirmed.addAll(Arrays.asList(elements));
+        E[] elements = getFullElements();
+        boolean r = getCollection().addAll(Arrays.asList(elements));
+        getConfirmed().addAll(Arrays.asList(elements));
         verify();
         assertTrue("Empty collection should change after addAll", r);
         for (int i = 0; i < elements.length; i++) {
             assertTrue("Collection should contain added element",
-                       collection.contains(elements[i]));
+                    getCollection().contains(elements[i]));
         }
 
         resetFull();
-        int size = collection.size();
+        int size = getCollection().size();
         elements = getOtherElements();
-        r = collection.addAll(Arrays.asList(elements));
-        confirmed.addAll(Arrays.asList(elements));
+        r = getCollection().addAll(Arrays.asList(elements));
+        getConfirmed().addAll(Arrays.asList(elements));
         verify();
         assertTrue("Full collection should change after addAll", r);
         for (int i = 0; i < elements.length; i++) {
             assertTrue("Full collection should contain added element " + i,
-                       collection.contains(elements[i]));
+                    getCollection().contains(elements[i]));
         }
-        assertEquals("Size should increase after addAll", 
-                     size + elements.length, collection.size());
+        assertEquals("Size should increase after addAll",
+                size + elements.length, getCollection().size());
     }
-    
+
+    @SuppressWarnings("unchecked")
     public void testListSetByIndex() {
         // override for set behaviour
         resetFull();
-        int size = collection.size();
-        getList().set(0, new Long(1000));
-        assertEquals(size, collection.size());
-
-        getList().set(2, new Long(1000));
-        assertEquals(size - 1, collection.size());
-        assertEquals(new Long(1000), getList().get(1));  // set into 2, but shifted down to 1
+        int size = getCollection().size();
+        getCollection().set(0, (E) new Long(1000));
+        assertEquals(size, getCollection().size());
+
+        getCollection().set(2, (E) new Long(1000));
+        assertEquals(size - 1, getCollection().size());
+        assertEquals(new Long(1000), getCollection().get(1));  // set into 2, but shifted down to 1
     }
-    
+
     boolean extraVerify = true;
     public void testCollectionIteratorRemove() {
         try {
@@ -166,28 +169,29 @@
             extraVerify = true;
         }
     }
-    
+
+    @SuppressWarnings("unchecked")
     public void verify() {
         super.verify();
-        
+
         if (extraVerify) {
-            int size = collection.size();
-            getList().add(new Long(1000));
-            assertEquals(size + 1, collection.size());
-
-            getList().add(new Long(1000));
-            assertEquals(size + 1, collection.size());
-            assertEquals(new Long(1000), getList().get(size));
-        
-            getList().remove(size);
+            int size = getCollection().size();
+            getCollection().add((E) new Long(1000));
+            assertEquals(size + 1, getCollection().size());
+
+            getCollection().add((E) new Long(1000));
+            assertEquals(size + 1, getCollection().size());
+            assertEquals(new Long(1000), getCollection().get(size));
+
+            getCollection().remove(size);
         }
     }
-    
+
     //-----------------------------------------------------------------------
     public void testFactory() {
-        Integer[] array = new Integer[] {new Integer(1), new Integer(2), new Integer(1)};
-        ArrayList list = new ArrayList(Arrays.asList(array));
-        final SetUniqueList lset = SetUniqueList.decorate(list);
+        Integer[] array = new Integer[] { new Integer(1), new Integer(2), new Integer(1) };
+        ArrayList<Integer> list = new ArrayList<Integer>(Arrays.asList(array));
+        final SetUniqueList<Integer> lset = SetUniqueList.decorate(list);
 
         assertEquals("Duplicate element was added.", 2, lset.size());
         assertEquals(new Integer(1), lset.get(0));
@@ -196,36 +200,39 @@
         assertEquals(new Integer(2), list.get(1));
     }
 
+    @SuppressWarnings("unchecked")
     public void testAdd() {
-        final SetUniqueList lset = new SetUniqueList(new ArrayList(), new HashSet());
+        final SetUniqueList<E> lset = new SetUniqueList<E>(new ArrayList<E>(), new HashSet<E>());
 
         // Duplicate element
-        final Object obj = new Integer(1);
+        final E obj = (E) new Integer(1);
         lset.add(obj);
         lset.add(obj);
         assertEquals("Duplicate element was added.", 1, lset.size());
 
         // Unique element
-        lset.add(new Integer(2));
+        lset.add((E) new Integer(2));
         assertEquals("Unique element was not added.", 2, lset.size());
     }
 
+    @SuppressWarnings("unchecked")
     public void testAddAll() {
-        final SetUniqueList lset = new SetUniqueList(new ArrayList(), new HashSet());
+        final SetUniqueList<E> lset = new SetUniqueList<E>(new ArrayList<E>(), new HashSet<E>());
 
         lset.addAll(
-            Arrays.asList(new Integer[] { new Integer(1), new Integer(1)}));
+            Arrays.asList((E[]) new Integer[] { new Integer(1), new Integer(1)}));
 
         assertEquals("Duplicate element was added.", 1, lset.size());
     }
 
+    @SuppressWarnings("unchecked")
     public void testSet() {
-        final SetUniqueList lset = new SetUniqueList(new ArrayList(), new HashSet());
+        final SetUniqueList<E> lset = new SetUniqueList<E>(new ArrayList<E>(), new HashSet<E>());
 
         // Duplicate element
-        final Object obj1 = new Integer(1);
-        final Object obj2 = new Integer(2);
-        final Object obj3 = new Integer(3);
+        final E obj1 = (E) new Integer(1);
+        final E obj2 = (E) new Integer(2);
+        final E obj3 = (E) new Integer(3);
 
         lset.add(obj1);
         lset.add(obj2);
@@ -257,16 +264,17 @@
         assertSame(obj1, lset.get(0));
     }
 
+    @SuppressWarnings("unchecked")
     public void testListIterator() {
-        final SetUniqueList lset = new SetUniqueList(new ArrayList(), new HashSet());
+        final SetUniqueList<E> lset = new SetUniqueList<E>(new ArrayList<E>(), new HashSet<E>());
 
-        final Object obj1 = new Integer(1);
-        final Object obj2 = new Integer(2);
+        final E obj1 = (E) new Integer(1);
+        final E obj2 = (E) new Integer(2);
         lset.add(obj1);
         lset.add(obj2);
 
         // Attempts to add a duplicate object
-        for (final ListIterator it = lset.listIterator(); it.hasNext();) {
+        for (final ListIterator<E> it = lset.listIterator(); it.hasNext();) {
             it.next();
 
             if (!it.hasNext()) {
@@ -278,36 +286,39 @@
         assertEquals("Duplicate element was added", 2, lset.size());
     }
 
+    @SuppressWarnings("unchecked")
     public void testUniqueListReInsert() {
-        List l = SetUniqueList.decorate(new LinkedList());
-        l.add(new Object());
-        l.add(new Object());
-        
-        Object a = l.get(0);
-        
+        List<E> l = SetUniqueList.decorate(new LinkedList<E>());
+        l.add((E) new Object());
+        l.add((E) new Object());
+
+        E a = l.get(0);
+
         // duplicate is removed
-        l.set(0, l.get(1)); 
+        l.set(0, l.get(1));
         assertEquals(1, l.size());
-        
-        // old object is added back in 
-        l.add(1, a); 
+
+        // old object is added back in
+        l.add(1, a);
         assertEquals(2, l.size());
     }
-    
+
+    @SuppressWarnings("unchecked")
     public void testUniqueListDoubleInsert() {
-        List l = SetUniqueList.decorate(new LinkedList());
-        l.add(new Object());
-        l.add(new Object());
-        
+        List<E> l = SetUniqueList.decorate(new LinkedList<E>());
+        l.add((E) new Object());
+        l.add((E) new Object());
+
         // duplicate is removed
-        l.set(0, l.get(1)); 
+        l.set(0, l.get(1));
         assertEquals(1, l.size());
-        
+
         // duplicate should be removed again
         l.add(1, l.get(0));
         assertEquals(1, l.size());
     }
 
+    @SuppressWarnings("unchecked")
     public void testSetDownwardsInList() {
         /*
          * Checks the following semantics
@@ -315,19 +326,19 @@
          * set(0,b): [b]->a
          * So UniqList contains [b] and a is returned
          */
-        ArrayList l = new ArrayList();
-        HashSet s = new HashSet();
-        final SetUniqueList ul = new SetUniqueList(l, s);
+        ArrayList<E> l = new ArrayList<E>();
+        HashSet<E> s = new HashSet<E>();
+        final SetUniqueList<E> ul = new SetUniqueList<E>(l, s);
 
-        Object a = new Object();
-        Object b = new Object();
+        E a = (E) new Object();
+        E b = (E) new Object();
         ul.add(a);
         ul.add(b);
         assertEquals(a, l.get(0));
         assertEquals(b, l.get(1));
-        assertTrue(s.contains(a)); 
+        assertTrue(s.contains(a));
         assertTrue(s.contains(b));
-        
+
         assertEquals(a, ul.set(0, b));
         assertEquals(1, s.size());
         assertEquals(1, l.size());
@@ -336,6 +347,7 @@
         assertFalse(s.contains(a));
     }
 
+    @SuppressWarnings("unchecked")
     public void testSetInBiggerList() {
         /*
          * Checks the following semantics
@@ -343,13 +355,13 @@
          * set(0,b): [b,c]->a
          * So UniqList contains [b,c] and a is returned
          */
-        ArrayList l = new ArrayList();
-        HashSet s = new HashSet();
-        final SetUniqueList ul = new SetUniqueList(l, s);
-
-        Object a = new Object();
-        Object b = new Object();
-        Object c = new Object();
+        ArrayList<E> l = new ArrayList<E>();
+        HashSet<E> s = new HashSet<E>();
+        final SetUniqueList<E> ul = new SetUniqueList<E>(l, s);
+
+        E a = (E) new Object();
+        E b = (E) new Object();
+        E c = (E) new Object();
 
         ul.add(a);
         ul.add(b);
@@ -357,10 +369,10 @@
         assertEquals(a, l.get(0));
         assertEquals(b, l.get(1));
         assertEquals(c, l.get(2));
-        assertTrue(s.contains(a)); 
+        assertTrue(s.contains(a));
         assertTrue(s.contains(b));
         assertTrue(s.contains(c));
-        
+
         assertEquals(a, ul.set(0, b));
         assertEquals(2, s.size());
         assertEquals(2, l.size());
@@ -369,8 +381,9 @@
         assertFalse(s.contains(a));
         assertTrue(s.contains(b));
         assertTrue(s.contains(c));
-    }    
+    }
 
+    @SuppressWarnings("unchecked")
     public void testSetUpwardsInList() {
         /*
          * Checks the following semantics
@@ -378,13 +391,13 @@
          * set(1,a): [a,c]->b
          * So UniqList contains [a,c] and b is returned
          */
-        ArrayList l = new ArrayList();
-        HashSet s = new HashSet();
-        final SetUniqueList ul = new SetUniqueList(l, s);
-
-        Object a = new String("A");
-        Object b = new String("B");
-        Object c = new String("C");
+        ArrayList<E> l = new ArrayList<E>();
+        HashSet<E> s = new HashSet<E>();
+        final SetUniqueList<E> ul = new SetUniqueList<E>(l, s);
+
+        E a = (E) new String("A");
+        E b = (E) new String("B");
+        E c = (E) new String("C");
 
         ul.add(a);
         ul.add(b);
@@ -392,10 +405,10 @@
         assertEquals(a, l.get(0));
         assertEquals(b, l.get(1));
         assertEquals(c, l.get(2));
-        assertTrue(s.contains(a)); 
+        assertTrue(s.contains(a));
         assertTrue(s.contains(b));
         assertTrue(s.contains(c));
-        
+
         assertEquals(b, ul.set(1, a));
         assertEquals(2, s.size());
         assertEquals(2, l.size());
@@ -418,4 +431,52 @@
 //        writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/SetUniqueList.fullCollection.version3.1.obj");
 //    }
 
+    @SuppressWarnings("unchecked")
+    public void testCollections307() {
+        List<E> list = new ArrayList<E>();
+        List<E> uniqueList = SetUniqueList.decorate(list);
+
+        String hello = "Hello";
+        String world = "World";
+        uniqueList.add((E) hello);
+        uniqueList.add((E) world);
+
+        List<E> subList = list.subList(0, 0);
+        List<E> subUniqueList = uniqueList.subList(0, 0);
+
+        assertFalse(subList.contains(world)); // passes
+        assertFalse(subUniqueList.contains(world)); // fails
+
+        List<E> worldList = new ArrayList<E>();
+        worldList.add((E) world);
+        assertFalse(subList.contains("World")); // passes
+        assertFalse(subUniqueList.contains("World")); // fails
+
+        // repeat the test with a different class than HashSet;
+        // which means subclassing SetUniqueList below
+        list = new ArrayList<E>();
+        uniqueList = new SetUniqueList307(list, new java.util.TreeSet<E>());
+
+        uniqueList.add((E) hello);
+        uniqueList.add((E) world);
+
+        subList = list.subList(0, 0);
+        subUniqueList = uniqueList.subList(0, 0);
+
+        assertFalse(subList.contains(world)); // passes
+        assertFalse(subUniqueList.contains(world)); // fails
+
+        worldList = new ArrayList<E>();
+        worldList.add((E) world);
+        assertFalse(subList.contains("World")); // passes
+        assertFalse(subUniqueList.contains("World")); // fails
+    }
+
+    @SuppressWarnings("serial")
+    class SetUniqueList307 extends SetUniqueList<E> {
+        public SetUniqueList307(List<E> list, Set<E> set) {
+            super(list, set);
+        }
+    }
+
 }

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/list/TestSynchronizedList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/list/TestSynchronizedList.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/list/TestSynchronizedList.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/list/TestSynchronizedList.java Thu Jan 29 18:48:37 2009
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,6 @@
 package org.apache.commons.collections.list;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 
 import junit.framework.Test;
@@ -29,11 +28,11 @@
  *
  * @since Commons Collections 3.1
  * @version $Revision$ $Date$
- * 
+ *
  * @author Stephen Colebourne
  */
-public class TestSynchronizedList extends AbstractTestList {
-    
+public class TestSynchronizedList<E> extends AbstractTestList<E> {
+
     public TestSynchronizedList(String testName) {
         super(testName);
     }
@@ -47,12 +46,12 @@
         junit.textui.TestRunner.main(testCaseName);
     }
 
-    public Collection makeConfirmedCollection() {
-        return new ArrayList();
+    public List<E> makeConfirmedCollection() {
+        return new ArrayList<E>();
     }
 
-    public List makeEmptyList() {
-        return SynchronizedList.decorate(new ArrayList());
+    public List<E> makeObject() {
+        return SynchronizedList.decorate(new ArrayList<E>());
     }
 
     public String getCompatibilityVersion() {

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/list/TestTransformedList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/list/TestTransformedList.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/list/TestTransformedList.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/list/TestTransformedList.java Thu Jan 29 18:48:37 2009
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,13 +18,13 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.List;
 import java.util.ListIterator;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
+import org.apache.commons.collections.Transformer;
 import org.apache.commons.collections.collection.TestTransformedCollection;
 
 /**
@@ -33,11 +33,11 @@
  *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
- * 
+ *
  * @author Stephen Colebourne
  */
-public class TestTransformedList extends AbstractTestList {
-    
+public class TestTransformedList<E> extends AbstractTestList<E> {
+
     public TestTransformedList(String testName) {
         super(testName);
     }
@@ -51,67 +51,70 @@
         junit.textui.TestRunner.main(testCaseName);
     }
 
-    public Collection makeConfirmedCollection() {
-        return new ArrayList();
+    public List<E> makeConfirmedCollection() {
+        return new ArrayList<E>();
     }
 
-    public Collection makeConfirmedFullCollection() {
-        List list = new ArrayList();
+    public List<E> makeConfirmedFullCollection() {
+        List<E> list = new ArrayList<E>();
         list.addAll(Arrays.asList(getFullElements()));
         return list;
     }
-    
-    public List makeEmptyList() {
-        return TransformedList.decorate(new ArrayList(), TestTransformedCollection.NOOP_TRANSFORMER);
+
+    @SuppressWarnings("unchecked")
+    public List<E> makeObject() {
+        return TransformedList.decorate(new ArrayList<E>(), (Transformer<E, E>) TestTransformedCollection.NOOP_TRANSFORMER);
     }
 
-    public List makeFullList() {
-        List list = new ArrayList();
+    @SuppressWarnings("unchecked")
+    public List<E> makeFullCollection() {
+        List<E> list = new ArrayList<E>();
         list.addAll(Arrays.asList(getFullElements()));
-        return TransformedList.decorate(list, TestTransformedCollection.NOOP_TRANSFORMER);
+        return TransformedList.decorate(list, (Transformer<E, E>) TestTransformedCollection.NOOP_TRANSFORMER);
     }
-    
+
+    @SuppressWarnings("unchecked")
     public void testTransformedList() {
-        List list = TransformedList.decorate(new ArrayList(), TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
+        List<E> list = TransformedList.decorate(new ArrayList<E>(), (Transformer<E, E>) TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
         assertEquals(0, list.size());
-        Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
+        E[] els = (E[]) new Object[] {"1", "3", "5", "7", "2", "4", "6"};
         for (int i = 0; i < els.length; i++) {
             list.add(els[i]);
             assertEquals(i + 1, list.size());
             assertEquals(true, list.contains(new Integer((String) els[i])));
             assertEquals(false, list.contains(els[i]));
         }
-        
+
         assertEquals(false, list.remove(els[0]));
         assertEquals(true, list.remove(new Integer((String) els[0])));
-        
+
         list.clear();
         for (int i = 0; i < els.length; i++) {
             list.add(0, els[i]);
             assertEquals(i + 1, list.size());
             assertEquals(new Integer((String) els[i]), list.get(0));
         }
-        
-        list.set(0, "22");
+
+        list.set(0, (E) "22");
         assertEquals(new Integer(22), list.get(0));
-        
-        ListIterator it = list.listIterator();
+
+        ListIterator<E> it = list.listIterator();
         it.next();
-        it.set("33");
+        it.set((E) "33");
         assertEquals(new Integer(33), list.get(0));
-        it.add("44");
+        it.add((E) "44");
         assertEquals(new Integer(44), list.get(1));
-        
-        List adds = new ArrayList();
-        adds.add("1");
-        adds.add("2");
+
+        List<E> adds = new ArrayList<E>();
+        adds.add((E) "1");
+        adds.add((E) "2");
         list.clear();
         list.addAll(adds);
         assertEquals(new Integer(1), list.get(0));
         assertEquals(new Integer(2), list.get(1));
-        
+
         adds.clear();
-        adds.add("3");
+        adds.add((E) "3");
         list.addAll(1, adds);
         assertEquals(new Integer(1), list.get(0));
         assertEquals(new Integer(3), list.get(1));

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/list/TestTreeList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/list/TestTreeList.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/list/TestTreeList.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/list/TestTreeList.java Thu Jan 29 18:48:37 2009
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,14 +25,14 @@
 
 /**
  * JUnit tests
- * 
+ *
  * @since Commons Collections 3.1
  * @version $Revision$ $Date$
  *
  * @author Joerg Schmuecker
  */
-public class TestTreeList extends AbstractTestList {
-    
+public class TestTreeList<E> extends AbstractTestList<E> {
+
 	public TestTreeList(String name) {
 		super(name);
 	}
@@ -53,49 +53,49 @@
         return BulkTest.makeSuite(TestTreeList.class);
     }
 
-    public static void benchmark(List l) {
+    public static void benchmark(List<? super Integer> l) {
         long start = System.currentTimeMillis();
         for (int i = 0; i < 100000; i++) {
             l.add(new Integer(i));
         }
         System.out.print(System.currentTimeMillis() - start + ";");
-        
+
         start = System.currentTimeMillis();
         for (int i = 0; i < 200; i++) {
             l.toArray();
         }
         System.out.print(System.currentTimeMillis() - start + ";");
-        
+
         start = System.currentTimeMillis();
         for (int i = 0; i < 100; i++) {
-            java.util.Iterator it = l.iterator();
+            java.util.Iterator<? super Integer> it = l.iterator();
             while (it.hasNext()) {
                 it.next();
             }
         }
         System.out.print(System.currentTimeMillis() - start + ";");
-        
+
         start = System.currentTimeMillis();
         for (int i = 0; i < 10000; i++) {
             int j = (int) (Math.random() * 100000);
             l.add(j, new Integer(-j));
         }
         System.out.print(System.currentTimeMillis() - start + ";");
-        
+
         start = System.currentTimeMillis();
         for (int i = 0; i < 50000; i++) {
             int j = (int) (Math.random() * 110000);
             l.get(j);
         }
         System.out.print(System.currentTimeMillis() - start + ";");
-        
+
         start = System.currentTimeMillis();
         for (int i = 0; i < 200; i++) {
             int j = (int) (Math.random() * 100000);
             l.indexOf(new Integer(j));
         }
         System.out.print(System.currentTimeMillis() - start + ";");
-        
+
         start = System.currentTimeMillis();
         for (int i = 0; i < 10000; i++) {
             int j = (int) (Math.random() * 100000);
@@ -105,18 +105,19 @@
     }
 
     //-----------------------------------------------------------------------
-	public List makeEmptyList() {
-		return new TreeList();
+	public TreeList<E> makeObject() {
+		return new TreeList<E>();
 	}
 
     //-----------------------------------------------------------------------
-	public void testAddMultiple() {
-		List l = makeEmptyList();
-		l.add("hugo");
-		l.add("erna");
-		l.add("daniel");
-		l.add("andres");
-		l.add("harald");
+	@SuppressWarnings("unchecked")
+    public void testAddMultiple() {
+		List<E> l = makeObject();
+		l.add((E) "hugo");
+		l.add((E) "erna");
+		l.add((E) "daniel");
+		l.add((E) "andres");
+		l.add((E) "harald");
 		l.add(0, null);
 		assertEquals(null, l.get(0));
 		assertEquals("hugo", l.get(1));
@@ -126,14 +127,15 @@
 		assertEquals("harald", l.get(5));
 	}
 
-	public void testRemove() {
-		List l = makeEmptyList();
-		l.add("hugo");
-		l.add("erna");
-		l.add("daniel");
-		l.add("andres");
-		l.add("harald");
-		l.add(0, null);
+	@SuppressWarnings("unchecked")
+    public void testRemove() {
+        List<E> l = makeObject();
+        l.add((E) "hugo");
+        l.add((E) "erna");
+        l.add((E) "daniel");
+        l.add((E) "andres");
+        l.add((E) "harald");
+        l.add(0, null);
 		int i = 0;
 		assertEquals(null, l.get(i++));
 		assertEquals("hugo", l.get(i++));
@@ -164,23 +166,25 @@
 		assertEquals("harald", l.get(i++));
 	}
 
-	public void testInsertBefore() {
-		List l = makeEmptyList();
-		l.add("erna");
-		l.add(0, "hugo");
+	@SuppressWarnings("unchecked")
+    public void testInsertBefore() {
+        List<E> l = makeObject();
+        l.add((E) "erna");
+        l.add(0, (E) "hugo");
 		assertEquals("hugo", l.get(0));
 		assertEquals("erna", l.get(1));
 	}
 
+    @SuppressWarnings("unchecked")
     public void testIndexOf() {
-        List l = makeEmptyList();
-        l.add("0");
-        l.add("1");
-        l.add("2");
-        l.add("3");
-        l.add("4");
-        l.add("5");
-        l.add("6");
+        List<E> l = makeObject();
+        l.add((E) "0");
+        l.add((E) "1");
+        l.add((E) "2");
+        l.add((E) "3");
+        l.add((E) "4");
+        l.add((E) "5");
+        l.add((E) "6");
         assertEquals(0, l.indexOf("0"));
         assertEquals(1, l.indexOf("1"));
         assertEquals(2, l.indexOf("2"));
@@ -188,17 +192,17 @@
         assertEquals(4, l.indexOf("4"));
         assertEquals(5, l.indexOf("5"));
         assertEquals(6, l.indexOf("6"));
-        
-        l.set(1, "0");
+
+        l.set(1, (E) "0");
         assertEquals(0, l.indexOf("0"));
-        
-        l.set(3, "3");
+
+        l.set(3, (E) "3");
         assertEquals(3, l.indexOf("3"));
-        l.set(2, "3");
+        l.set(2, (E) "3");
         assertEquals(2, l.indexOf("3"));
-        l.set(1, "3");
+        l.set(1, (E) "3");
         assertEquals(1, l.indexOf("3"));
-        l.set(0, "3");
+        l.set(0, (E) "3");
         assertEquals(0, l.indexOf("3"));
     }
 
@@ -214,18 +218,18 @@
 
     public void testBug35258() {
         Object objectToRemove = new Integer(3);
-        
-        List treelist = new TreeList();
+
+        List<Integer> treelist = new TreeList<Integer>();
         treelist.add(new Integer(0));
         treelist.add(new Integer(1));
         treelist.add(new Integer(2));
         treelist.add(new Integer(3));
         treelist.add(new Integer(4));
-        
+
         // this cause inconsistence of ListIterator()
         treelist.remove(objectToRemove);
-        
-        ListIterator li = treelist.listIterator();
+
+        ListIterator<Integer> li = treelist.listIterator();
         assertEquals(new Integer(0), li.next());
         assertEquals(new Integer(0), li.previous());
         assertEquals(new Integer(0), li.next());

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/list/TestUnmodifiableList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/list/TestUnmodifiableList.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/list/TestUnmodifiableList.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/list/TestUnmodifiableList.java Thu Jan 29 18:48:37 2009
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,80 +25,82 @@
 import junit.framework.TestSuite;
 
 /**
- * Extension of {@link AbstractTestList} for exercising the 
+ * Extension of {@link AbstractTestList} for exercising the
  * {@link UnmodifiableList} implementation.
  *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
- * 
+ *
  * @author Phil Steitz
  */
-public class TestUnmodifiableList extends AbstractTestList {
-    
+public class TestUnmodifiableList<E> extends AbstractTestList<E> {
+
     public TestUnmodifiableList(String testName) {
         super(testName);
     }
-    
+
     public static Test suite() {
         return new TestSuite(TestUnmodifiableList.class);
     }
-    
+
     public static void main(String args[]) {
         String[] testCaseName = { TestUnmodifiableList.class.getName()};
         junit.textui.TestRunner.main(testCaseName);
     }
 
-    //-----------------------------------------------------------------------    
-    public List makeEmptyList() {
-        return UnmodifiableList.decorate(new ArrayList());
-    }
-    
-    public List makeFullList() {
-        ArrayList list = new ArrayList();
+    //-----------------------------------------------------------------------
+    public UnmodifiableList<E> makeObject() {
+        return new UnmodifiableList<E>(new ArrayList<E>());
+    }
+
+    public UnmodifiableList<E> makeFullCollection() {
+        ArrayList<E> list = new ArrayList<E>();
         list.addAll(Arrays.asList(getFullElements()));
-        return UnmodifiableList.decorate(list);
+        return new UnmodifiableList<E>(list);
     }
-    
+
     public boolean isSetSupported() {
         return false;
     }
-    
+
     public boolean isAddSupported() {
         return false;
     }
-    
+
     public boolean isRemoveSupported() {
         return false;
     }
-    
-    //-----------------------------------------------------------------------    
-    protected UnmodifiableList list = null;
-    protected ArrayList array = null;
-    
+
+    //-----------------------------------------------------------------------
+    protected UnmodifiableList<E> list;
+    protected ArrayList<E> array;
+
+    @SuppressWarnings("unchecked")
     protected void setupList() {
-        list = (UnmodifiableList) makeFullList();
-        array = new ArrayList();
-        array.add(new Integer(1));
+        list = makeFullCollection();
+        array = new ArrayList<E>();
+        array.add((E) new Integer(1));
     }
-    
-    /** 
+
+    /**
      * Verify that base list and sublists are not modifiable
      */
     public void testUnmodifiable() {
         setupList();
-        verifyUnmodifiable(list); 
+        verifyUnmodifiable(list);
         verifyUnmodifiable(list.subList(0, 2));
-    } 
-        
-    protected void verifyUnmodifiable(List list) {
+    }
+
+    @SuppressWarnings("unchecked")
+    protected void verifyUnmodifiable(List<E> list) {
         try {
-            list.add(0, new Integer(0));
+            list.add(0, (E) new Integer(0));
             fail("Expecting UnsupportedOperationException.");
         } catch (UnsupportedOperationException e) {
             // expected
-        } 
+        }
         try {
-            list.add(new Integer(0));
+            list.add((E) new Integer(0));
              fail("Expecting UnsupportedOperationException.");
         } catch (UnsupportedOperationException e) {
             // expected
@@ -146,21 +148,21 @@
             // expected
         }
         try {
-            list.set(0, new Integer(0));
+            list.set(0, (E) new Integer(0));
              fail("Expecting UnsupportedOperationException.");
         } catch (UnsupportedOperationException e) {
             // expected
         }
     }
-    
+
     /**
      * Verify that iterator is not modifiable
      */
     public void testUnmodifiableIterator() {
         setupList();
-        Iterator iterator = list.iterator();
+        Iterator<E> iterator = list.iterator();
         try {
-            Object obj = iterator.next();
+            iterator.next();
             iterator.remove();
             fail("Expecting UnsupportedOperationException.");
         } catch (UnsupportedOperationException e) {

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/map/AbstractTestIterableMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/map/AbstractTestIterableMap.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/map/AbstractTestIterableMap.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/map/AbstractTestIterableMap.java Thu Jan 29 18:48:37 2009
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,102 +29,116 @@
  * Abstract test class for {@link IterableMap} methods and contracts.
  *
  * @version $Revision$ $Date$
- * 
+ *
  * @author Stephen Colebourne
  */
-public abstract class AbstractTestIterableMap extends AbstractTestMap {
+public abstract class AbstractTestIterableMap<K, V> extends AbstractTestMap<K, V> {
 
     /**
      * JUnit constructor.
-     * 
+     *
      * @param testName  the test name
      */
     public AbstractTestIterableMap(String testName) {
         super(testName);
     }
-    
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public abstract IterableMap<K, V> makeObject();
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public IterableMap<K, V> makeFullMap() {
+        return (IterableMap<K, V>) super.makeFullMap();
+    }
+
     //-----------------------------------------------------------------------
     public void testFailFastEntrySet() {
         if (isRemoveSupported() == false) return;
         resetFull();
-        Iterator it = map.entrySet().iterator();
-        Map.Entry val = (Map.Entry) it.next();
-        map.remove(val.getKey());
+        Iterator<Map.Entry<K, V>> it = getMap().entrySet().iterator();
+        Map.Entry<K, V> val = it.next();
+        getMap().remove(val.getKey());
         try {
             it.next();
             fail();
         } catch (ConcurrentModificationException ex) {}
-        
+
         resetFull();
-        it = map.entrySet().iterator();
+        it = getMap().entrySet().iterator();
         it.next();
-        map.clear();
+        getMap().clear();
         try {
             it.next();
             fail();
         } catch (ConcurrentModificationException ex) {}
     }
-    
+
     public void testFailFastKeySet() {
         if (isRemoveSupported() == false) return;
         resetFull();
-        Iterator it = map.keySet().iterator();
-        Object val = it.next();
-        map.remove(val);
+        Iterator<K> it = getMap().keySet().iterator();
+        K val = it.next();
+        getMap().remove(val);
         try {
             it.next();
             fail();
         } catch (ConcurrentModificationException ex) {}
-        
+
         resetFull();
-        it = map.keySet().iterator();
+        it = getMap().keySet().iterator();
         it.next();
-        map.clear();
+        getMap().clear();
         try {
             it.next();
             fail();
         } catch (ConcurrentModificationException ex) {}
     }
-    
+
     public void testFailFastValues() {
         if (isRemoveSupported() == false) return;
         resetFull();
-        Iterator it = map.values().iterator();
+        Iterator<V> it = getMap().values().iterator();
         it.next();
-        map.remove(map.keySet().iterator().next());
+        getMap().remove(getMap().keySet().iterator().next());
         try {
             it.next();
             fail();
         } catch (ConcurrentModificationException ex) {}
-        
+
         resetFull();
-        it = map.values().iterator();
+        it = getMap().values().iterator();
         it.next();
-        map.clear();
+        getMap().clear();
         try {
             it.next();
             fail();
         } catch (ConcurrentModificationException ex) {}
     }
-    
+
     //-----------------------------------------------------------------------
     public BulkTest bulkTestMapIterator() {
         return new InnerTestMapIterator();
     }
-    
-    public class InnerTestMapIterator extends AbstractTestMapIterator {
+
+    public class InnerTestMapIterator extends AbstractTestMapIterator<K, V> {
         public InnerTestMapIterator() {
             super("InnerTestMapIterator");
         }
-        
-        public Object[] addSetValues() {
+
+        public V[] addSetValues() {
             return AbstractTestIterableMap.this.getNewSampleValues();
         }
-        
+
         public boolean supportsRemove() {
             return AbstractTestIterableMap.this.isRemoveSupported();
         }
-        
+
         public boolean isGetStructuralModify() {
             return AbstractTestIterableMap.this.isGetStructuralModify();
         }
@@ -133,36 +147,44 @@
             return AbstractTestIterableMap.this.isSetValueSupported();
         }
 
-        public MapIterator makeEmptyMapIterator() {
+        public MapIterator<K, V> makeEmptyIterator() {
             resetEmpty();
-            return ((IterableMap) AbstractTestIterableMap.this.map).mapIterator();
+            return AbstractTestIterableMap.this.getMap().mapIterator();
         }
 
-        public MapIterator makeFullMapIterator() {
+        public MapIterator<K, V> makeObject() {
             resetFull();
-            return ((IterableMap) AbstractTestIterableMap.this.map).mapIterator();
+            return AbstractTestIterableMap.this.getMap().mapIterator();
         }
-        
-        public Map getMap() {
+
+        public Map<K, V> getMap() {
             // assumes makeFullMapIterator() called first
-            return AbstractTestIterableMap.this.map;
+            return AbstractTestIterableMap.this.getMap();
         }
-        
-        public Map getConfirmedMap() {
+
+        public Map<K, V> getConfirmedMap() {
             // assumes makeFullMapIterator() called first
-            return AbstractTestIterableMap.this.confirmed;
+            return AbstractTestIterableMap.this.getConfirmed();
         }
-        
+
         public void verify() {
             super.verify();
             AbstractTestIterableMap.this.verify();
         }
     }
-    
+
 //  public void testCreate() throws Exception {
 //      resetEmpty();
 //      writeExternalFormToDisk((Serializable) map, "D:/dev/collections/data/test/HashedMap.emptyCollection.version3.obj");
 //      resetFull();
 //      writeExternalFormToDisk((Serializable) map, "D:/dev/collections/data/test/HashedMap.fullCollection.version3.obj");
 //  }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public IterableMap<K, V> getMap() {
+        return (IterableMap<K, V>) super.getMap();
+    }
 }



Mime
View raw message