commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r814997 [18/18] - in /commons/proper/collections/trunk/src: java/org/apache/commons/collections/ java/org/apache/commons/collections/bag/ java/org/apache/commons/collections/bidimap/ java/org/apache/commons/collections/buffer/ java/org/apac...
Date Tue, 15 Sep 2009 05:30:02 GMT
Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestReferenceMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestReferenceMap.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestReferenceMap.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestReferenceMap.java Tue Sep 15 05:29:56 2009
@@ -22,16 +22,17 @@
 import junit.framework.Test;
 
 import org.apache.commons.collections.BulkTest;
+import org.apache.commons.collections.map.AbstractReferenceMap.ReferenceStrength;
 
 /**
- * Tests for ReferenceMap. 
+ * Tests for ReferenceMap.
  *
  * @version $Revision$ $Date$
  *
  * @author Paul Jack
  * @author Guilhem Lavaux
  */
-public class TestReferenceMap extends AbstractTestIterableMap {
+public class TestReferenceMap<K, V> extends AbstractTestIterableMap<K, V> {
 
     public TestReferenceMap(String testName) {
         super(testName);
@@ -46,9 +47,8 @@
         junit.textui.TestRunner.main(testCaseName);
     }
 
-    public Map makeEmptyMap() {
-        ReferenceMap map = new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK);
-        return map;
+    public ReferenceMap<K, V> makeObject() {
+        return new ReferenceMap<K, V>(ReferenceStrength.WEAK, ReferenceStrength.WEAK);
     }
 
     public boolean isAllowNullKey() {
@@ -64,6 +64,7 @@
     }
 
     //-----------------------------------------------------------------------
+    @SuppressWarnings("unchecked")
     public void testNullHandling() {
         resetFull();
         assertEquals(null, map.get(null));
@@ -78,11 +79,11 @@
             fail();
         } catch (NullPointerException ex) {}
         try {
-            map.put(new Object(), null);
+            map.put((K) new Object(), null);
             fail();
         } catch (NullPointerException ex) {}
         try {
-            map.put(null, new Object());
+            map.put(null, (V) new Object());
             fail();
         } catch (NullPointerException ex) {}
     }
@@ -198,19 +199,20 @@
     }
 */
 
-    WeakReference keyReference;
-    WeakReference valueReference;
+    WeakReference<K> keyReference;
+    WeakReference<V> valueReference;
+
+    @SuppressWarnings("unchecked")
+    public Map<K, V> buildRefMap() {
+        K key = (K) new Object();
+        V value = (V) new Object();
+
+        keyReference = new WeakReference<K>(key);
+        valueReference = new WeakReference<V>(value);
 
-    public Map buildRefMap() {
-        Object key = new Object();
-        Object value = new Object();
-        
-        keyReference = new WeakReference(key);
-        valueReference = new WeakReference(value);
-        
-        Map testMap = new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.HARD, true);
+        Map<K, V> testMap = new ReferenceMap<K, V>(ReferenceStrength.WEAK, ReferenceStrength.HARD, true);
         testMap.put(key, value);
- 
+
         assertEquals("In map", value, testMap.get(key));
         assertNotNull("Weak reference released early (1)", keyReference.get());
         assertNotNull("Weak reference released early (2)", valueReference.get());
@@ -220,29 +222,29 @@
     /** Tests whether purge values setting works */
     public void testPurgeValues() throws Exception {
         // many thanks to Juozas Baliuka for suggesting this method
-        Map testMap = buildRefMap();
+        Map<K, V> testMap = buildRefMap();
 
         int iterations = 0;
         int bytz = 2;
-        while(true) {
+        while (true) {
             System.gc();
-            if(iterations++ > 50){
+            if (iterations++ > 50) {
                 fail("Max iterations reached before resource released.");
             }
             testMap.isEmpty();
-            if( 
-                keyReference.get() == null &&
-                valueReference.get() == null) {
+            if (keyReference.get() == null && valueReference.get() == null) {
                 break;
-                
+
             } else {
                 // create garbage:
-                byte[] b =  new byte[bytz];
+                @SuppressWarnings("unused")
+                byte[] b = new byte[bytz];
                 bytz = bytz * 2;
             }
         }
     }
 
+    @SuppressWarnings("unused")
     private static void gc() {
         try {
             // trigger GC

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestSingletonMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestSingletonMap.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestSingletonMap.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestSingletonMap.java Tue Sep 15 05:29:56 2009
@@ -17,7 +17,6 @@
 package org.apache.commons.collections.map;
 
 import java.util.HashMap;
-import java.util.Map;
 
 import junit.framework.Test;
 import junit.textui.TestRunner;
@@ -25,6 +24,7 @@
 import org.apache.commons.collections.BoundedMap;
 import org.apache.commons.collections.BulkTest;
 import org.apache.commons.collections.KeyValue;
+import org.apache.commons.collections.OrderedMap;
 
 /**
  * JUnit tests.
@@ -33,13 +33,12 @@
  *
  * @author Stephen Colebourne
  */
-public class TestSingletonMap extends AbstractTestOrderedMap {
+public class TestSingletonMap<K, V> extends AbstractTestOrderedMap<K, V> {
 
     private static final Integer ONE = new Integer(1);
     private static final Integer TWO = new Integer(2);
     private static final String TEN = "10";
-    private static final String TWENTY = "20";
-        
+
     public TestSingletonMap(String testName) {
         super(testName);
     }
@@ -47,18 +46,18 @@
     public static void main(String[] args) {
         TestRunner.run(suite());
     }
-    
+
     public static Test suite() {
         return BulkTest.makeSuite(TestSingletonMap.class);
     }
 
     //-----------------------------------------------------------------------
-    public Map makeEmptyMap() {
+    public OrderedMap<K, V> makeObject() {
         // need an empty singleton map, but thats not possible
         // use a ridiculous fake instead to make the tests pass
-        return UnmodifiableOrderedMap.decorate(ListOrderedMap.decorate(new HashMap()));
+        return UnmodifiableOrderedMap.decorate(ListOrderedMap.decorate(new HashMap<K, V>()));
     }
-    
+
     public String[] ignoredTests() {
         // the ridiculous map above still doesn't pass these tests
         // but its not relevant, so we ignore them
@@ -68,9 +67,9 @@
         };
     }
 
-
-    public Map makeFullMap() {
-        return new SingletonMap(ONE, TWO);
+    @SuppressWarnings("unchecked")
+    public SingletonMap<K, V> makeFullMap() {
+        return new SingletonMap<K, V>((K) ONE, (V) TWO);
     }
 
     public boolean isPutAddSupported() {
@@ -81,30 +80,33 @@
         return false;
     }
 
-    public Object[] getSampleKeys() {
-        return new Object[] {ONE};
+    @SuppressWarnings("unchecked")
+    public K[] getSampleKeys() {
+        return (K[]) new Object[] { ONE };
     }
 
-    public Object[] getSampleValues() {
-        return new Object[] {TWO};
+    @SuppressWarnings("unchecked")
+    public V[] getSampleValues() {
+        return (V[]) new Object[] { TWO };
     }
 
-    public Object[] getNewSampleValues() {
-        return new Object[] {TEN};
+    @SuppressWarnings("unchecked")
+    public V[] getNewSampleValues() {
+        return (V[]) new Object[] { TEN };
     }
 
     //-----------------------------------------------------------------------
     public void testClone() {
-        SingletonMap map = new SingletonMap(ONE, TWO);
+        SingletonMap<K, V> map = makeFullMap();
         assertEquals(1, map.size());
-        SingletonMap cloned = (SingletonMap) map.clone();
+        SingletonMap<K, V> cloned = map.clone();
         assertEquals(1, cloned.size());
         assertEquals(true, cloned.containsKey(ONE));
         assertEquals(true, cloned.containsValue(TWO));
     }
 
     public void testKeyValue() {
-        SingletonMap map = new SingletonMap(ONE, TWO);
+        SingletonMap<K, V> map = makeFullMap();
         assertEquals(1, map.size());
         assertEquals(ONE, map.getKey());
         assertEquals(TWO, map.getValue());
@@ -112,7 +114,7 @@
     }
 
     public void testBoundedMap() {
-        SingletonMap map = new SingletonMap(ONE, TWO);
+        SingletonMap<K, V> map = makeFullMap();
         assertEquals(1, map.size());
         assertEquals(true, map.isFull());
         assertEquals(1, map.maxSize());
@@ -123,16 +125,16 @@
 //    public BulkTest bulkTestMapIterator() {
 //        return new TestFlatMapIterator();
 //    }
-//    
+//
 //    public class TestFlatMapIterator extends AbstractTestOrderedMapIterator {
 //        public TestFlatMapIterator() {
 //            super("TestFlatMapIterator");
 //        }
-//        
+//
 //        public Object[] addSetValues() {
 //            return TestSingletonMap.this.getNewSampleValues();
 //        }
-//        
+//
 //        public boolean supportsRemove() {
 //            return TestSingletonMap.this.isRemoveSupported();
 //        }
@@ -150,23 +152,23 @@
 //            resetFull();
 //            return ((Flat3Map) TestSingletonMap.this.map).mapIterator();
 //        }
-//        
+//
 //        public Map getMap() {
 //            // assumes makeFullMapIterator() called first
 //            return TestSingletonMap.this.map;
 //        }
-//        
+//
 //        public Map getConfirmedMap() {
 //            // assumes makeFullMapIterator() called first
 //            return TestSingletonMap.this.confirmed;
 //        }
-//        
+//
 //        public void verify() {
 //            super.verify();
 //            TestSingletonMap.this.verify();
 //        }
 //    }
-    
+
     public String getCompatibilityVersion() {
         return "3.1";
     }

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestTransformedSortedMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestTransformedSortedMap.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestTransformedSortedMap.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestTransformedSortedMap.java Tue Sep 15 05:29:56 2009
@@ -24,6 +24,7 @@
 import junit.framework.Test;
 
 import org.apache.commons.collections.BulkTest;
+import org.apache.commons.collections.Transformer;
 import org.apache.commons.collections.TransformerUtils;
 import org.apache.commons.collections.collection.TestTransformedCollection;
 
@@ -36,8 +37,8 @@
  *
  * @author Stephen Colebourne
  */
-public class TestTransformedSortedMap extends AbstractTestSortedMap {
-    
+public class TestTransformedSortedMap<K, V> extends AbstractTestSortedMap<K, V> {
+
     public TestTransformedSortedMap(String testName) {
         super(testName);
     }
@@ -52,8 +53,11 @@
     }
 
     //-----------------------------------------------------------------------
-    public Map makeEmptyMap() {
-        return TransformedSortedMap.decorate(new TreeMap(), TransformerUtils.nopTransformer(), TransformerUtils.nopTransformer());
+    @SuppressWarnings("unchecked")
+    public SortedMap<K, V> makeObject() {
+        return TransformedSortedMap.decorate(new TreeMap<K, V>(),
+                (Transformer<? super K, ? extends K>) TransformerUtils.nopTransformer(),
+                (Transformer<? super V, ? extends V>) TransformerUtils.nopTransformer());
     }
 
     public boolean isSubMapViewsSerializable() {
@@ -61,14 +65,19 @@
         return false;
     }
 
-    //-----------------------------------------------------------------------    
+    //-----------------------------------------------------------------------
+    @SuppressWarnings("unchecked")
     public void testTransformedMap() {
-        Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
+        Object[] els = new Object[] { "1", "3", "5", "7", "2", "4", "6" };
 
-        Map map = TransformedSortedMap.decorate(new TreeMap(), TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER, null);
+        SortedMap<K, V> map = TransformedSortedMap
+                .decorate(
+                        new TreeMap<K, V>(),
+                        (Transformer<? super K, ? extends K>) TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER,
+                        null);
         assertEquals(0, map.size());
         for (int i = 0; i < els.length; i++) {
-            map.put(els[i], els[i]);
+            map.put((K) els[i], (V) els[i]);
             assertEquals(i + 1, map.size());
             assertEquals(true, map.containsKey(new Integer((String) els[i])));
             try {
@@ -78,17 +87,21 @@
             assertEquals(true, map.containsValue(els[i]));
             assertEquals(els[i], map.get(new Integer((String) els[i])));
         }
-        
+
         try {
             map.remove(els[0]);
             fail();
         } catch (ClassCastException ex) {}
         assertEquals(els[0], map.remove(new Integer((String) els[0])));
-        
-        map = TransformedSortedMap.decorate(new TreeMap(), null, TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
+
+        map = TransformedSortedMap
+                .decorate(
+                        new TreeMap<K, V>(),
+                        null,
+                        (Transformer<? super V, ? extends V>) TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
         assertEquals(0, map.size());
         for (int i = 0; i < els.length; i++) {
-            map.put(els[i], els[i]);
+            map.put((K) els[i], (V) els[i]);
             assertEquals(i + 1, map.size());
             assertEquals(true, map.containsValue(new Integer((String) els[i])));
             assertEquals(false, map.containsValue(els[i]));
@@ -97,47 +110,57 @@
         }
 
         assertEquals(new Integer((String) els[0]), map.remove(els[0]));
-        
-        Set entrySet = map.entrySet();
-        Map.Entry[] array = (Map.Entry[]) entrySet.toArray(new Map.Entry[0]);
-        array[0].setValue("66");
+
+        Set<Map.Entry<K, V>> entrySet = map.entrySet();
+        Map.Entry<K, V>[] array = (Map.Entry<K, V>[]) entrySet.toArray(new Map.Entry[0]);
+        array[0].setValue((V) "66");
         assertEquals(new Integer(66), array[0].getValue());
         assertEquals(new Integer(66), map.get(array[0].getKey()));
-        
-        Map.Entry entry = (Map.Entry) entrySet.iterator().next();
-        entry.setValue("88");
+
+        Map.Entry<K, V> entry = entrySet.iterator().next();
+        entry.setValue((V) "88");
         assertEquals(new Integer(88), entry.getValue());
         assertEquals(new Integer(88), map.get(entry.getKey()));
     }
 
     //-----------------------------------------------------------------------
+    @SuppressWarnings("unchecked")
     public void testFactory_Decorate() {
-        SortedMap base = new TreeMap();
-        base.put("A", "1");
-        base.put("B", "2");
-        base.put("C", "3");
-        
-        SortedMap trans = TransformedSortedMap.decorate(base, null, TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
+        SortedMap<K, V> base = new TreeMap<K, V>();
+        base.put((K) "A", (V) "1");
+        base.put((K) "B", (V) "2");
+        base.put((K) "C", (V) "3");
+
+        SortedMap<K, V> trans = TransformedSortedMap
+                .decorate(
+                        base,
+                        null,
+                        (Transformer<? super V, ? extends V>) TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
         assertEquals(3, trans.size());
         assertEquals("1", trans.get("A"));
         assertEquals("2", trans.get("B"));
         assertEquals("3", trans.get("C"));
-        trans.put("D", "4");
+        trans.put((K) "D", (V) "4");
         assertEquals(new Integer(4), trans.get("D"));
     }
 
+    @SuppressWarnings("unchecked")
     public void testFactory_decorateTransform() {
-        SortedMap base = new TreeMap();
-        base.put("A", "1");
-        base.put("B", "2");
-        base.put("C", "3");
-        
-        SortedMap trans = TransformedSortedMap.decorateTransform(base, null, TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
+        SortedMap<K, V> base = new TreeMap<K, V>();
+        base.put((K) "A", (V) "1");
+        base.put((K) "B", (V) "2");
+        base.put((K) "C", (V) "3");
+
+        SortedMap<K, V> trans = TransformedSortedMap
+                .decorateTransform(
+                        base,
+                        null,
+                        (Transformer<? super V, ? extends V>) TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
         assertEquals(3, trans.size());
         assertEquals(new Integer(1), trans.get("A"));
         assertEquals(new Integer(2), trans.get("B"));
         assertEquals(new Integer(3), trans.get("C"));
-        trans.put("D", "4");
+        trans.put((K) "D", (V) "4");
         assertEquals(new Integer(4), trans.get("D"));
     }
 

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestUnmodifiableMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestUnmodifiableMap.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestUnmodifiableMap.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestUnmodifiableMap.java Tue Sep 15 05:29:56 2009
@@ -22,10 +22,11 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
+import org.apache.commons.collections.IterableMap;
 import org.apache.commons.collections.Unmodifiable;
 
 /**
- * Extension of {@link AbstractTestMap} for exercising the 
+ * Extension of {@link AbstractTestMap} for exercising the
  * {@link UnmodifiableMap} implementation.
  *
  * @since Commons Collections 3.0
@@ -33,55 +34,55 @@
  *
  * @author Phil Steitz
  */
-public class TestUnmodifiableMap extends AbstractTestIterableMap{
-    
+public class TestUnmodifiableMap<K, V> extends AbstractTestIterableMap<K, V> {
+
     public TestUnmodifiableMap(String testName) {
         super(testName);
     }
-    
+
     public static Test suite() {
         return new TestSuite(TestUnmodifiableMap.class);
     }
-    
+
     public static void main(String args[]) {
         String[] testCaseName = { TestUnmodifiableMap.class.getName()};
         junit.textui.TestRunner.main(testCaseName);
     }
-    
+
     //-------------------------------------------------------------------
-    
-    public Map makeEmptyMap() {
-        return UnmodifiableMap.decorate(new HashMap());
+
+    public IterableMap<K, V> makeObject() {
+        return (IterableMap<K, V>) UnmodifiableMap.decorate(new HashMap<K, V>());
     }
-    
+
     public boolean isPutChangeSupported() {
         return false;
     }
-    
+
     public boolean isPutAddSupported() {
         return false;
     }
-    
+
     public boolean isRemoveSupported() {
         return false;
     }
-    
-    public Map makeFullMap() {
-        Map m = new HashMap();
+
+    public IterableMap<K, V> makeFullMap() {
+        Map<K, V> m = new HashMap<K, V>();
         addSampleMappings(m);
-        return UnmodifiableMap.decorate(m);
+        return (IterableMap<K, V>) UnmodifiableMap.decorate(m);
     }
-    
+
     //-----------------------------------------------------------------------
     public void testUnmodifiable() {
-        assertTrue(makeEmptyMap() instanceof Unmodifiable);
+        assertTrue(makeObject() instanceof Unmodifiable);
         assertTrue(makeFullMap() instanceof Unmodifiable);
     }
-    
+
     public void testDecorateFactory() {
-        Map map = makeFullMap();
+        Map<K, V> map = makeFullMap();
         assertSame(map, UnmodifiableMap.decorate(map));
-        
+
         try {
             UnmodifiableMap.decorate(null);
             fail();
@@ -102,4 +103,4 @@
 //            (java.io.Serializable) map,
 //            "D:/dev/collections/data/test/UnmodifiableMap.fullCollection.version3.1.obj");
 //    }
-}
\ No newline at end of file
+}

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestUnmodifiableOrderedMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestUnmodifiableOrderedMap.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestUnmodifiableOrderedMap.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestUnmodifiableOrderedMap.java Tue Sep 15 05:29:56 2009
@@ -17,7 +17,6 @@
 package org.apache.commons.collections.map;
 
 import java.util.HashMap;
-import java.util.Map;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -26,7 +25,7 @@
 import org.apache.commons.collections.Unmodifiable;
 
 /**
- * Extension of {@link AbstractTestOrderedMap} for exercising the 
+ * Extension of {@link AbstractTestOrderedMap} for exercising the
  * {@link UnmodifiableOrderedMap} implementation.
  *
  * @since Commons Collections 3.0
@@ -34,55 +33,55 @@
  *
  * @author Stephen Colebourne
  */
-public class TestUnmodifiableOrderedMap extends AbstractTestOrderedMap {
-    
+public class TestUnmodifiableOrderedMap<K, V> extends AbstractTestOrderedMap<K, V> {
+
     public TestUnmodifiableOrderedMap(String testName) {
         super(testName);
     }
-    
+
     public static Test suite() {
         return new TestSuite(TestUnmodifiableOrderedMap.class);
     }
-    
+
     public static void main(String args[]) {
         String[] testCaseName = { TestUnmodifiableOrderedMap.class.getName()};
         junit.textui.TestRunner.main(testCaseName);
     }
-    
+
     //-------------------------------------------------------------------
-    
-    public Map makeEmptyMap() {
-        return UnmodifiableOrderedMap.decorate(ListOrderedMap.decorate(new HashMap()));
+
+    public OrderedMap<K, V> makeObject() {
+        return UnmodifiableOrderedMap.decorate(ListOrderedMap.decorate(new HashMap<K, V>()));
     }
-    
+
     public boolean isPutChangeSupported() {
         return false;
     }
-    
+
     public boolean isPutAddSupported() {
         return false;
     }
-    
+
     public boolean isRemoveSupported() {
         return false;
     }
-    
-    public Map makeFullMap() {
-        OrderedMap m = ListOrderedMap.decorate(new HashMap());
+
+    public OrderedMap<K, V> makeFullMap() {
+        OrderedMap<K, V> m = ListOrderedMap.decorate(new HashMap<K, V>());
         addSampleMappings(m);
         return UnmodifiableOrderedMap.decorate(m);
     }
-    
+
     //-----------------------------------------------------------------------
     public void testUnmodifiable() {
-        assertTrue(makeEmptyMap() instanceof Unmodifiable);
+        assertTrue(makeObject() instanceof Unmodifiable);
         assertTrue(makeFullMap() instanceof Unmodifiable);
     }
-    
+
     public void testDecorateFactory() {
-        Map map = makeFullMap();
-        assertSame(map, UnmodifiableOrderedMap.decorate((OrderedMap) map));
-        
+        OrderedMap<K, V> map = makeFullMap();
+        assertSame(map, UnmodifiableOrderedMap.decorate(map));
+
         try {
             UnmodifiableOrderedMap.decorate(null);
             fail();
@@ -103,4 +102,4 @@
 //            (java.io.Serializable) map,
 //            "D:/dev/collections/data/test/UnmodifiableOrderedMap.fullCollection.version3.1.obj");
 //    }
-}
\ No newline at end of file
+}

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestUnmodifiableSortedMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestUnmodifiableSortedMap.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestUnmodifiableSortedMap.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestUnmodifiableSortedMap.java Tue Sep 15 05:29:56 2009
@@ -16,7 +16,6 @@
  */
 package org.apache.commons.collections.map;
 
-import java.util.Map;
 import java.util.SortedMap;
 import java.util.TreeMap;
 
@@ -26,7 +25,7 @@
 import org.apache.commons.collections.Unmodifiable;
 
 /**
- * Extension of {@link AbstractTestSortedMap} for exercising the 
+ * Extension of {@link AbstractTestSortedMap} for exercising the
  * {@link UnmodifiableSortedMap} implementation.
  *
  * @since Commons Collections 3.0
@@ -34,55 +33,55 @@
  *
  * @author Stephen Colebourne
  */
-public class TestUnmodifiableSortedMap extends AbstractTestSortedMap {
-    
+public class TestUnmodifiableSortedMap<K, V> extends AbstractTestSortedMap<K, V> {
+
     public TestUnmodifiableSortedMap(String testName) {
         super(testName);
     }
-    
+
     public static Test suite() {
         return new TestSuite(TestUnmodifiableSortedMap.class);
     }
-    
+
     public static void main(String args[]) {
         String[] testCaseName = { TestUnmodifiableSortedMap.class.getName()};
         junit.textui.TestRunner.main(testCaseName);
     }
-    
+
     //-------------------------------------------------------------------
-    
-    public Map makeEmptyMap() {
-        return UnmodifiableSortedMap.decorate(new TreeMap());
+
+    public SortedMap<K, V> makeObject() {
+        return UnmodifiableSortedMap.decorate(new TreeMap<K, V>());
     }
-    
+
     public boolean isPutChangeSupported() {
         return false;
     }
-    
+
     public boolean isPutAddSupported() {
         return false;
     }
-    
+
     public boolean isRemoveSupported() {
         return false;
     }
-    
-    public Map makeFullMap() {
-        SortedMap m = new TreeMap();
+
+    public SortedMap<K, V> makeFullMap() {
+        SortedMap<K, V> m = new TreeMap<K, V>();
         addSampleMappings(m);
         return UnmodifiableSortedMap.decorate(m);
     }
-    
+
     //-----------------------------------------------------------------------
     public void testUnmodifiable() {
-        assertTrue(makeEmptyMap() instanceof Unmodifiable);
+        assertTrue(makeObject() instanceof Unmodifiable);
         assertTrue(makeFullMap() instanceof Unmodifiable);
     }
-    
+
     public void testDecorateFactory() {
-        Map map = makeFullMap();
-        assertSame(map, UnmodifiableSortedMap.decorate((SortedMap) map));
-        
+        SortedMap<K, V> map = makeFullMap();
+        assertSame(map, UnmodifiableSortedMap.decorate(map));
+
         try {
             UnmodifiableSortedMap.decorate(null);
             fail();
@@ -103,4 +102,4 @@
 //            (java.io.Serializable) map,
 //            "D:/dev/collections/data/test/UnmodifiableSortedMap.fullCollection.version3.1.obj");
 //    }
-}
\ No newline at end of file
+}

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/AbstractTestSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/AbstractTestSet.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/AbstractTestSet.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/AbstractTestSet.java Tue Sep 15 05:29:56 2009
@@ -43,7 +43,7 @@
  *
  * @author Paul Jack
  */
-public abstract class AbstractTestSet extends AbstractTestCollection {
+public abstract class AbstractTestSet<E> extends AbstractTestCollection<E> {
 
     /**
      * JUnit constructor.
@@ -61,14 +61,13 @@
     public void verify() {
         super.verify();
         
-        assertEquals("Sets should be equal", confirmed, collection);
+        assertEquals("Sets should be equal", getConfirmed(), getCollection());
         assertEquals("Sets should have equal hashCodes", 
-                     confirmed.hashCode(), collection.hashCode());
-        Collection set = makeConfirmedCollection();
-        Iterator iterator = collection.iterator();
+                     getConfirmed().hashCode(), getCollection().hashCode());
+        Collection<E> set = makeConfirmedCollection();
+        Iterator<E> iterator = getCollection().iterator();
         while (iterator.hasNext()) {
-            assertTrue("Set.iterator should only return unique elements", 
-                       set.add(iterator.next()));
+            assertTrue("Set.iterator should only return unique elements", set.add(iterator.next()));
         }
     }
 
@@ -85,8 +84,8 @@
      *
      * @return a confirmed empty collection
      */
-    public Collection makeConfirmedCollection() {
-        return new HashSet();
+    public Collection<E> makeConfirmedCollection() {
+        return new HashSet<E>();
     }
 
     /**
@@ -94,8 +93,8 @@
      *
      * @return a confirmed full collection
      */
-    public Collection makeConfirmedFullCollection() {
-        Collection set = makeConfirmedCollection();
+    public Collection<E> makeConfirmedFullCollection() {
+        Collection<E> set = makeConfirmedCollection();
         set.addAll(Arrays.asList(getFullElements()));
         return set;
     }
@@ -105,7 +104,7 @@
      *
      * @return an empty set
      */
-    public abstract Set makeEmptySet();
+    public abstract Set<E> makeObject();
 
     /**
      * Makes a full set by first creating an empty set and then adding
@@ -115,68 +114,48 @@
      *
      * @return a full set
      */
-    public Set makeFullSet() {
-        Set set = makeEmptySet();
+    public Set<E> makeFullCollection() {
+        Set<E> set = makeObject();
         set.addAll(Arrays.asList(getFullElements()));
         return set;
     }
 
-    /**
-     * Makes an empty collection by invoking {@link #makeEmptySet()}.  
-     *
-     * @return an empty collection
-     */
-    public final Collection makeCollection() {
-        return makeEmptySet();
-    }
-
-    /**
-     * Makes a full collection by invoking {@link #makeFullSet()}.
-     *
-     * @return a full collection
-     */
-    public final Collection makeFullCollection() {
-        return makeFullSet();
-    }
-
     //-----------------------------------------------------------------------
     /**
      * Return the {@link AbstractTestCollection#collection} fixture, but cast as a Set.  
      */
-    public Set getSet() {
-        return (Set)collection;
+    public Set<E> getCollection() {
+        return (Set<E>) super.getCollection();
     }
 
     /**
      * Return the {@link AbstractTestCollection#confirmed} fixture, but cast as a Set.
      */
-    public Set getConfirmedSet() {
-        return (Set)confirmed;
+    public Set<E> getConfirmed() {
+        return (Set<E>) super.getConfirmed();
     }
 
     //-----------------------------------------------------------------------
     /**
      * Tests {@link Set#equals(Object)}.
      */
+    @SuppressWarnings("unchecked")
     public void testSetEquals() {
         resetEmpty();
-        assertEquals("Empty sets should be equal", 
-                     getSet(), getConfirmedSet());
+        assertEquals("Empty sets should be equal", getCollection(), getConfirmed());
         verify();
 
-        Collection set2 = makeConfirmedCollection();
-        set2.add("foo");
-        assertTrue("Empty set shouldn't equal nonempty set", 
-                   !getSet().equals(set2));
+        Collection<E> set2 = makeConfirmedCollection();
+        set2.add((E) "foo");
+        assertTrue("Empty set shouldn't equal nonempty set", !getCollection().equals(set2));
 
         resetFull();
-        assertEquals("Full sets should be equal", getSet(), getConfirmedSet());
+        assertEquals("Full sets should be equal", getCollection(), getConfirmed());
         verify();
 
         set2.clear();
         set2.addAll(Arrays.asList(getOtherElements()));
-        assertTrue("Sets with different contents shouldn't be equal", 
-                   !getSet().equals(set2));
+        assertTrue("Sets with different contents shouldn't be equal", !getCollection().equals(set2));
     }
 
     /**
@@ -185,11 +164,11 @@
     public void testSetHashCode() {
         resetEmpty();
         assertEquals("Empty sets have equal hashCodes", 
-                     getSet().hashCode(), getConfirmedSet().hashCode());
+                getCollection().hashCode(), getConfirmed().hashCode());
 
         resetFull();
         assertEquals("Equal sets have equal hashCodes", 
-                     getSet().hashCode(), getConfirmedSet().hashCode());
+                getCollection().hashCode(), getConfirmed().hashCode());
     }
 
 }

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/AbstractTestSortedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/AbstractTestSortedSet.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/AbstractTestSortedSet.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/AbstractTestSortedSet.java Tue Sep 15 05:29:56 2009
@@ -16,9 +16,7 @@
  */
 package org.apache.commons.collections.set;
 
-import java.util.Collection;
 import java.util.Iterator;
-import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeSet;
 
@@ -38,7 +36,7 @@
  * @author Stephen Colebourne
  * @author Dieter Wimberger
  */
-public abstract class AbstractTestSortedSet extends AbstractTestSet {
+public abstract class AbstractTestSortedSet<E> extends AbstractTestSet<E> {
 
     /**
      * JUnit constructor.
@@ -59,10 +57,10 @@
         
         // Check that iterator returns elements in order and first() and last()
         // are consistent
-        Iterator colliter = collection.iterator();
-        Iterator confiter = confirmed.iterator();
-        Object first = null;
-        Object last = null;
+        Iterator<E> colliter = getCollection().iterator();
+        Iterator<E> confiter = getConfirmed().iterator();
+        E first = null;
+        E last = null;
         while (colliter.hasNext()) {
             if (first == null) {
                 first = colliter.next();
@@ -72,11 +70,11 @@
             }  
             assertEquals("Element appears to be out of order.", last, confiter.next());
         }
-        if (collection.size() > 0) {
+        if (getCollection().size() > 0) {
             assertEquals("Incorrect element returned by first().", first,
-                ((SortedSet) collection).first());
+                getCollection().first());
             assertEquals("Incorrect element returned by last().", last,
-                ((SortedSet) collection).last());
+                getCollection().last());
         }
     }
 
@@ -89,47 +87,56 @@
         return false;
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public abstract SortedSet<E> makeObject();
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public SortedSet<E> makeFullCollection() {
+        return (SortedSet<E>) super.makeFullCollection();
+    }
+
     //-----------------------------------------------------------------------
     /**
      * Returns an empty {@link TreeSet} for use in modification testing.
      *
      * @return a confirmed empty collection
      */
-    public Collection makeConfirmedCollection() {
-        return new TreeSet();
+    public SortedSet<E> makeConfirmedCollection() {
+        return new TreeSet<E>();
     }
 
     //-----------------------------------------------------------------------
-    /**
-     * Return the {@link AbstractTestCollection#confirmed} fixture, but cast as a
-     * SortedSet.
-     */
-    public SortedSet getConfirmedSortedSet() {
-        return (SortedSet) confirmed;
-    }
 
     //-----------------------------------------------------------------------
     /**
      * Override to return comparable objects.
      */
-    public Object[] getFullNonNullElements() {
+    @SuppressWarnings("unchecked")
+    public E[] getFullNonNullElements() {
         Object[] elements = new Object[30];
 
         for (int i = 0; i < 30; i++) {
             elements[i] = new Integer(i + i + 1);
         }
-        return elements;
+        return (E[]) elements;
     }
 
     /**
      * Override to return comparable objects.
      */
-    public Object[] getOtherNonNullElements() {
+    @SuppressWarnings("unchecked")
+    public E[] getOtherNonNullElements() {
         Object[] elements = new Object[30];
         for (int i = 0; i < 30; i++) {
             elements[i] = new Integer(i + i + 2);
         }
-        return elements;
+        return (E[]) elements;
     }
 
     //-----------------------------------------------------------------------
@@ -181,23 +188,24 @@
         return new TestSortedSetSubSet(lobound, false);
     }
 
-    public class TestSortedSetSubSet extends AbstractTestSortedSet {
+    public class TestSortedSetSubSet extends AbstractTestSortedSet<E> {
 
         private int m_Type;
         private int m_LowBound;
         private int m_HighBound;
-        private Object[] m_FullElements;
-        private Object[] m_OtherElements;
+        private E[] m_FullElements;
+        private E[] m_OtherElements;
 
+        @SuppressWarnings("unchecked")
         public TestSortedSetSubSet(int bound, boolean head) {
             super("TestSortedSetSubSet");
             if (head) {
                 //System.out.println("HEADSET");
                 m_Type = TYPE_HEADSET;
                 m_HighBound = bound;
-                m_FullElements = new Object[bound];
+                m_FullElements = (E[]) new Object[bound];
                 System.arraycopy(AbstractTestSortedSet.this.getFullElements(), 0, m_FullElements, 0, bound);
-                m_OtherElements = new Object[bound - 1];
+                m_OtherElements = (E[]) new Object[bound - 1];
                 System.arraycopy(//src src_pos dst dst_pos length
                 AbstractTestSortedSet.this.getOtherElements(), 0, m_OtherElements, 0, bound - 1);
                 //System.out.println(new TreeSet(Arrays.asList(m_FullElements)));
@@ -208,9 +216,9 @@
                 m_LowBound = bound;
                 Object[] allelements = AbstractTestSortedSet.this.getFullElements();
                 //System.out.println("bound = "+bound +"::length="+allelements.length);
-                m_FullElements = new Object[allelements.length - bound];
+                m_FullElements = (E[]) new Object[allelements.length - bound];
                 System.arraycopy(allelements, bound, m_FullElements, 0, allelements.length - bound);
-                m_OtherElements = new Object[allelements.length - bound - 1];
+                m_OtherElements = (E[]) new Object[allelements.length - bound - 1];
                 System.arraycopy(//src src_pos dst dst_pos length
                 AbstractTestSortedSet.this.getOtherElements(), bound, m_OtherElements, 0, allelements.length - bound - 1);
                 //System.out.println(new TreeSet(Arrays.asList(m_FullElements)));
@@ -223,6 +231,7 @@
 
         } //type
 
+        @SuppressWarnings("unchecked")
         public TestSortedSetSubSet(int lobound, int hibound) {
             super("TestSortedSetSubSet");
             //System.out.println("SUBSET");
@@ -231,9 +240,9 @@
             m_HighBound = hibound;
             int length = hibound - lobound;
             //System.out.println("Low=" + lobound + "::High=" + hibound + "::Length=" + length);
-            m_FullElements = new Object[length];
+            m_FullElements = (E[]) new Object[length];
             System.arraycopy(AbstractTestSortedSet.this.getFullElements(), lobound, m_FullElements, 0, length);
-            m_OtherElements = new Object[length - 1];
+            m_OtherElements = (E[]) new Object[length - 1];
             System.arraycopy(//src src_pos dst dst_pos length
             AbstractTestSortedSet.this.getOtherElements(), lobound, m_OtherElements, 0, length - 1);
 
@@ -255,15 +264,15 @@
             return AbstractTestSortedSet.this.isFailFastSupported();
         }
 
-        public Object[] getFullElements() {
+        public E[] getFullElements() {
             return m_FullElements;
         }
-        public Object[] getOtherElements() {
+        public E[] getOtherElements() {
             return m_OtherElements;
         }
 
-        private SortedSet getSubSet(SortedSet set) {
-            Object[] elements = AbstractTestSortedSet.this.getFullElements();
+        private SortedSet<E> getSubSet(SortedSet<E> set) {
+            E[] elements = AbstractTestSortedSet.this.getFullElements();
             switch (m_Type) {
                 case TYPE_SUBSET :
                     return set.subSet(elements[m_LowBound], elements[m_HighBound]);
@@ -276,14 +285,12 @@
             }
         }
 
-        public Set makeEmptySet() {
-            SortedSet s = (SortedSet) AbstractTestSortedSet.this.makeEmptySet();
-            return getSubSet(s);
+        public SortedSet<E> makeObject() {
+            return getSubSet(AbstractTestSortedSet.this.makeObject());
         }
 
-        public Set makeFullSet() {
-            SortedSet s = (SortedSet) AbstractTestSortedSet.this.makeFullCollection();
-            return getSubSet(s);
+        public SortedSet<E> makeFullCollection() {
+            return getSubSet(AbstractTestSortedSet.this.makeFullCollection());
         }
         
         public boolean isTestSerialization() {
@@ -306,4 +313,19 @@
 
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public SortedSet<E> getCollection() {
+        return (SortedSet<E>) super.getCollection();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public SortedSet<E> getConfirmed() {
+        return (SortedSet<E>) super.getConfirmed();
+    }
 }

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestListOrderedSet2.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestListOrderedSet2.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestListOrderedSet2.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestListOrderedSet2.java Tue Sep 15 05:29:56 2009
@@ -19,7 +19,6 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Set;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -34,7 +33,12 @@
  * @author Henning P. Schmiedehausen
  * @author Stephen Colebourne
  */
-public class TestListOrderedSet2 extends AbstractTestSet {
+public class TestListOrderedSet2<E> extends AbstractTestSet<E> {
+
+    private static final Integer ZERO = new Integer(0);
+    private static final Integer ONE = new Integer(1);
+    private static final Integer TWO = new Integer(2);
+    private static final Integer THREE = new Integer(3);
 
     public TestListOrderedSet2(String testName) {
         super(testName);
@@ -49,22 +53,24 @@
         junit.textui.TestRunner.main(testCaseName);
     }
 
-    public Set makeEmptySet() {
-        return new ListOrderedSet();
+    public ListOrderedSet<E> makeObject() {
+        return new ListOrderedSet<E>();
     }
 
-    protected Set setupSet() {
-        Set set = makeEmptySet();
+    @SuppressWarnings("unchecked")
+    protected ListOrderedSet<E> setupSet() {
+        ListOrderedSet<E> set = makeObject();
 
         for (int i = 0; i < 10; i++) {
-            set.add(Integer.toString(i));
+            set.add((E) Integer.toString(i));
         }
         return set;
     }
 
+    @SuppressWarnings("unchecked")
     public void testOrdering() {
-        Set set = setupSet();
-        Iterator it = set.iterator();
+        ListOrderedSet<E> set = setupSet();
+        Iterator<E> it = set.iterator();
 
         for (int i = 0; i < 10; i++) {
             assertEquals("Sequence is wrong", Integer.toString(i), it.next());
@@ -80,7 +86,7 @@
         }
 
         for (int i = 0; i < 10; i++) {
-            set.add(Integer.toString(i));
+            set.add((E) Integer.toString(i));
         }
 
         assertEquals("Size of set is wrong!", 10, set.size());
@@ -93,19 +99,15 @@
             assertEquals("Sequence is wrong", Integer.toString(i), it.next());
         }
     }
-    
-    private static final Integer ZERO = new Integer(0);
-    private static final Integer ONE = new Integer(1);
-    private static final Integer TWO = new Integer(2);
-    private static final Integer THREE = new Integer(3);
-    
+
+    @SuppressWarnings("unchecked")
     public void testListAddRemove() {
-        ListOrderedSet set = (ListOrderedSet) makeEmptySet();
-        List view = set.asList();
-        set.add(ZERO);
-        set.add(ONE);
-        set.add(TWO);
-        
+        ListOrderedSet<E> set = makeObject();
+        List<E> view = set.asList();
+        set.add((E) ZERO);
+        set.add((E) ONE);
+        set.add((E) TWO);
+
         assertEquals(3, set.size());
         assertSame(ZERO, set.get(0));
         assertSame(ONE, set.get(1));
@@ -114,11 +116,11 @@
         assertSame(ZERO, view.get(0));
         assertSame(ONE, view.get(1));
         assertSame(TWO, view.get(2));
-        
+
         assertEquals(0, set.indexOf(ZERO));
         assertEquals(1, set.indexOf(ONE));
         assertEquals(2, set.indexOf(TWO));
-        
+
         set.remove(1);
         assertEquals(2, set.size());
         assertSame(ZERO, set.get(0));
@@ -126,37 +128,37 @@
         assertEquals(2, view.size());
         assertSame(ZERO, view.get(0));
         assertSame(TWO, view.get(1));
-    }        
-    
+    }
+
+    @SuppressWarnings("unchecked")
     public void testListAddIndexed() {
-        ListOrderedSet set = (ListOrderedSet) makeEmptySet();
-        List view = set.asList();
-        set.add(ZERO);
-        set.add(TWO);
-        
-        set.add(1, ONE);
+        ListOrderedSet<E> set = makeObject();
+        set.add((E) ZERO);
+        set.add((E) TWO);
+
+        set.add(1, (E) ONE);
         assertEquals(3, set.size());
         assertSame(ZERO, set.get(0));
         assertSame(ONE, set.get(1));
         assertSame(TWO, set.get(2));
-        
-        set.add(0, ONE);
+
+        set.add(0, (E) ONE);
         assertEquals(3, set.size());
         assertSame(ZERO, set.get(0));
         assertSame(ONE, set.get(1));
         assertSame(TWO, set.get(2));
-        
-        List list = new ArrayList();
-        list.add(ZERO);
-        list.add(TWO);
-        
+
+        List<E> list = new ArrayList<E>();
+        list.add((E) ZERO);
+        list.add((E) TWO);
+
         set.addAll(0, list);
         assertEquals(3, set.size());
         assertSame(ZERO, set.get(0));
         assertSame(ONE, set.get(1));
         assertSame(TWO, set.get(2));
-        
-        list.add(0, THREE); // list = [3,0,2]
+
+        list.add(0, (E) THREE); // list = [3,0,2]
         set.remove(TWO);    //  set = [0,1]
         set.addAll(1, list);
         assertEquals(4, set.size());
@@ -165,7 +167,7 @@
         assertSame(TWO, set.get(2));
         assertSame(ONE, set.get(3));
     }
-    
+
     public String getCompatibilityVersion() {
         return "3.1";
     }

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestMapBackedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestMapBackedSet.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestMapBackedSet.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestMapBackedSet.java Tue Sep 15 05:29:56 2009
@@ -31,7 +31,7 @@
  *
  * @author Stephen Colebourne
  */
-public class TestMapBackedSet extends AbstractTestSet {
+public class TestMapBackedSet<E> extends AbstractTestSet<E> {
 
     public TestMapBackedSet(String testName) {
         super(testName);
@@ -46,8 +46,8 @@
         junit.textui.TestRunner.main(testCaseName);
     }
 
-    public Set makeEmptySet() {
-        return MapBackedSet.decorate(new HashedMap());
+    public Set<E> makeObject() {
+        return MapBackedSet.decorate(new HashedMap<E, Object>());
     }
 
     public String getCompatibilityVersion() {

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestMapBackedSet2.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestMapBackedSet2.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestMapBackedSet2.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestMapBackedSet2.java Tue Sep 15 05:29:56 2009
@@ -32,7 +32,7 @@
  *
  * @author Stephen Colebourne
  */
-public class TestMapBackedSet2 extends AbstractTestSet {
+public class TestMapBackedSet2<E> extends AbstractTestSet<E> {
 
     public TestMapBackedSet2(String testName) {
         super(testName);
@@ -47,22 +47,24 @@
         junit.textui.TestRunner.main(testCaseName);
     }
 
-    public Set makeEmptySet() {
-        return MapBackedSet.decorate(new LinkedMap());
+    public Set<E> makeObject() {
+        return MapBackedSet.decorate(new LinkedMap<E, Object>());
     }
 
-    protected Set setupSet() {
-        Set set = makeEmptySet();
+    @SuppressWarnings("unchecked")
+    protected Set<E> setupSet() {
+        Set<E> set = makeObject();
 
         for (int i = 0; i < 10; i++) {
-            set.add(Integer.toString(i));
+            set.add((E) Integer.toString(i));
         }
         return set;
     }
 
+    @SuppressWarnings("unchecked")
     public void testOrdering() {
-        Set set = setupSet();
-        Iterator it = set.iterator();
+        Set<E> set = setupSet();
+        Iterator<E> it = set.iterator();
 
         for (int i = 0; i < 10; i++) {
             assertEquals("Sequence is wrong", Integer.toString(i), it.next());
@@ -78,7 +80,7 @@
         }
 
         for (int i = 0; i < 10; i++) {
-            set.add(Integer.toString(i));
+            set.add((E) Integer.toString(i));
         }
 
         assertEquals("Size of set is wrong!", 10, set.size());

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestSynchronizedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestSynchronizedSet.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestSynchronizedSet.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestSynchronizedSet.java Tue Sep 15 05:29:56 2009
@@ -24,7 +24,7 @@
 import org.apache.commons.collections.BulkTest;
 
 /**
- * Extension of {@link AbstractTestSet} for exercising the 
+ * Extension of {@link AbstractTestSet} for exercising the
  * {@link SynchronizedSet} implementation.
  *
  * @since Commons Collections 3.1
@@ -32,24 +32,24 @@
  *
  * @author Stephen Colebourne
  */
-public class TestSynchronizedSet extends AbstractTestSet{
-    
+public class TestSynchronizedSet<E> extends AbstractTestSet<E> {
+
     public TestSynchronizedSet(String testName) {
         super(testName);
     }
-    
+
     public static Test suite() {
         return BulkTest.makeSuite(TestSynchronizedSet.class);
     }
-    
+
     public static void main(String args[]) {
         String[] testCaseName = { TestSynchronizedSet.class.getName()};
         junit.textui.TestRunner.main(testCaseName);
     }
-    
-   //-------------------------------------------------------------------      
-    public Set makeEmptySet() {
-        return SynchronizedSet.decorate(new HashSet());
+
+   //-------------------------------------------------------------------
+    public Set<E> makeObject() {
+        return SynchronizedSet.decorate(new HashSet<E>());
     }
 
     public String getCompatibilityVersion() {

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestSynchronizedSortedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestSynchronizedSortedSet.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestSynchronizedSortedSet.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestSynchronizedSortedSet.java Tue Sep 15 05:29:56 2009
@@ -16,7 +16,7 @@
  */
 package org.apache.commons.collections.set;
 
-import java.util.Set;
+import java.util.SortedSet;
 import java.util.TreeSet;
 
 import junit.framework.Test;
@@ -24,7 +24,7 @@
 import org.apache.commons.collections.BulkTest;
 
 /**
- * Extension of {@link AbstractTestSet} for exercising the 
+ * Extension of {@link AbstractTestSet} for exercising the
  * {@link SynchronizedSortedSet} implementation.
  *
  * @since Commons Collections 3.1
@@ -32,24 +32,24 @@
  *
  * @author Stephen Colebourne
  */
-public class TestSynchronizedSortedSet extends AbstractTestSortedSet{
-    
+public class TestSynchronizedSortedSet<E> extends AbstractTestSortedSet<E> {
+
     public TestSynchronizedSortedSet(String testName) {
         super(testName);
     }
-    
+
     public static Test suite() {
         return BulkTest.makeSuite(TestSynchronizedSortedSet.class);
     }
-    
+
     public static void main(String args[]) {
         String[] testCaseName = { TestSynchronizedSortedSet.class.getName()};
         junit.textui.TestRunner.main(testCaseName);
     }
-    
-   //-------------------------------------------------------------------      
-    public Set makeEmptySet() {
-        return SynchronizedSortedSet.decorate(new TreeSet());
+
+   //-------------------------------------------------------------------
+    public SortedSet<E> makeObject() {
+        return SynchronizedSortedSet.decorate(new TreeSet<E>());
     }
 
     public String getCompatibilityVersion() {

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestTransformedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestTransformedSet.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestTransformedSet.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestTransformedSet.java Tue Sep 15 05:29:56 2009
@@ -17,13 +17,13 @@
 package org.apache.commons.collections.set;
 
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
+import org.apache.commons.collections.Transformer;
 import org.apache.commons.collections.collection.TestTransformedCollection;
 
 /**
@@ -35,8 +35,8 @@
  *
  * @author Stephen Colebourne
  */
-public class TestTransformedSet extends AbstractTestSet {
-    
+public class TestTransformedSet<E> extends AbstractTestSet<E> {
+
     public TestTransformedSet(String testName) {
         super(testName);
     }
@@ -50,40 +50,46 @@
         junit.textui.TestRunner.main(testCaseName);
     }
 
-    public Collection makeConfirmedCollection() {
-        return new HashSet();
+    public Set<E> makeConfirmedCollection() {
+        return new HashSet<E>();
     }
 
-    public Collection makeConfirmedFullCollection() {
-        Set set = new HashSet();
+    public Set<E> makeConfirmedFullCollection() {
+        Set<E> set = new HashSet<E>();
         set.addAll(Arrays.asList(getFullElements()));
         return set;
     }
-    
-    public Set makeEmptySet() {
-        return TransformedSet.decorate(new HashSet(), TestTransformedCollection.NOOP_TRANSFORMER);
+
+    @SuppressWarnings("unchecked")
+    public Set<E> makeObject() {
+        return TransformedSet.decorate(new HashSet<E>(),
+                (Transformer<E, E>) TestTransformedCollection.NOOP_TRANSFORMER);
     }
 
-    public Set makeFullSet() {
-        Set list = new HashSet();
+    @SuppressWarnings("unchecked")
+    public Set<E> makeFullCollection() {
+        Set<E> list = new HashSet<E>();
         list.addAll(Arrays.asList(getFullElements()));
-        return TransformedSet.decorate(list, TestTransformedCollection.NOOP_TRANSFORMER);
+        return TransformedSet.decorate(list,
+                (Transformer<E, E>) TestTransformedCollection.NOOP_TRANSFORMER);
     }
-    
+
+    @SuppressWarnings("unchecked")
     public void testTransformedSet() {
-        Set set = TransformedSet.decorate(new HashSet(), TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
+        Set<E> set = TransformedSet.decorate(new HashSet<E>(),
+                (Transformer<E, E>) TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
         assertEquals(0, set.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++) {
             set.add(els[i]);
             assertEquals(i + 1, set.size());
             assertEquals(true, set.contains(new Integer((String) els[i])));
             assertEquals(false, set.contains(els[i]));
         }
-        
+
         assertEquals(false, set.remove(els[0]));
         assertEquals(true, set.remove(new Integer((String) els[0])));
-        
+
     }
 
     public void testTransformedSet_decorateTransform() {

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestTransformedSortedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestTransformedSortedSet.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestTransformedSortedSet.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestTransformedSortedSet.java Tue Sep 15 05:29:56 2009
@@ -24,6 +24,7 @@
 import junit.framework.Test;
 
 import org.apache.commons.collections.BulkTest;
+import org.apache.commons.collections.Transformer;
 import org.apache.commons.collections.collection.TestTransformedCollection;
 
 /**
@@ -35,8 +36,8 @@
  *
  * @author Stephen Colebourne
  */
-public class TestTransformedSortedSet extends AbstractTestSortedSet {
-    
+public class TestTransformedSortedSet<E> extends AbstractTestSortedSet<E> {
+
     public TestTransformedSortedSet(String testName) {
         super(testName);
     }
@@ -51,30 +52,33 @@
     }
 
     //-----------------------------------------------------------------------
-    public Set makeEmptySet() {
-        return TransformedSortedSet.decorate(new TreeSet(), TestTransformedCollection.NOOP_TRANSFORMER);
+    @SuppressWarnings("unchecked")
+    public SortedSet<E> makeObject() {
+        return TransformedSortedSet.decorate(new TreeSet<E>(), (Transformer<E, E>) TestTransformedCollection.NOOP_TRANSFORMER);
     }
 
-    public Set makeFullSet() {
-        SortedSet set = new TreeSet();
+    @SuppressWarnings("unchecked")
+    public SortedSet<E> makeFullCollection() {
+        SortedSet<E> set = new TreeSet<E>();
         set.addAll(Arrays.asList(getFullElements()));
-        return TransformedSortedSet.decorate(set, TestTransformedCollection.NOOP_TRANSFORMER);
+        return TransformedSortedSet.decorate(set, (Transformer<E, E>) TestTransformedCollection.NOOP_TRANSFORMER);
     }
-    
-    //-----------------------------------------------------------------------   
+
+    //-----------------------------------------------------------------------
+    @SuppressWarnings("unchecked")
     public void testTransformedSet() {
-        Set set = TransformedSortedSet.decorate(new TreeSet(), TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
+        SortedSet<E> set = TransformedSortedSet.decorate(new TreeSet<E>(),
+                (Transformer<E, E>) TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
         assertEquals(0, set.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++) {
             set.add(els[i]);
             assertEquals(i + 1, set.size());
             assertEquals(true, set.contains(new Integer((String) els[i])));
         }
-        
+
         assertEquals(true, set.remove(new Integer((String) els[0])));
-        
-    } 
+    }
 
     public void testTransformedSet_decorateTransform() {
         Set originalSet = new TreeSet();

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestUnmodifiableSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestUnmodifiableSet.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestUnmodifiableSet.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestUnmodifiableSet.java Tue Sep 15 05:29:56 2009
@@ -25,7 +25,7 @@
 import org.apache.commons.collections.BulkTest;
 
 /**
- * Extension of {@link AbstractTestSet} for exercising the 
+ * Extension of {@link AbstractTestSet} for exercising the
  * {@link UnmodifiableSet} implementation.
  *
  * @since Commons Collections 3.0
@@ -33,36 +33,36 @@
  *
  * @author Phil Steitz
  */
-public class TestUnmodifiableSet extends AbstractTestSet{
-    
+public class TestUnmodifiableSet<E> extends AbstractTestSet<E> {
+
     public TestUnmodifiableSet(String testName) {
         super(testName);
     }
-    
+
     public static Test suite() {
         return BulkTest.makeSuite(TestUnmodifiableSet.class);
     }
-    
+
     public static void main(String args[]) {
         String[] testCaseName = { TestUnmodifiableSet.class.getName()};
         junit.textui.TestRunner.main(testCaseName);
     }
-    
-    //-------------------------------------------------------------------  
-    public Set makeEmptySet() {
-        return UnmodifiableSet.decorate(new HashSet());
-    }
-    
-    public Set makeFullSet() {
-        HashSet set = new HashSet();
+
+    //-------------------------------------------------------------------
+    public Set<E> makeObject() {
+        return UnmodifiableSet.decorate(new HashSet<E>());
+    }
+
+    public Set<E> makeFullCollection() {
+        HashSet<E> set = new HashSet<E>();
         set.addAll(Arrays.asList(getFullElements()));
         return UnmodifiableSet.decorate(set);
     }
-    
+
     public boolean isAddSupported() {
         return false;
     }
-    
+
     public boolean isRemoveSupported() {
         return false;
     }

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestUnmodifiableSortedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestUnmodifiableSortedSet.java?rev=814997&r1=814996&r2=814997&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestUnmodifiableSortedSet.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestUnmodifiableSortedSet.java Tue Sep 15 05:29:56 2009
@@ -20,6 +20,7 @@
 import java.util.Arrays;
 import java.util.Comparator;
 import java.util.Set;
+import java.util.SortedSet;
 import java.util.TreeSet;
 
 import junit.framework.Test;
@@ -27,7 +28,7 @@
 import org.apache.commons.collections.BulkTest;
 
 /**
- * Extension of {@link AbstractTestSortedSet} for exercising the 
+ * Extension of {@link AbstractTestSortedSet} for exercising the
  * {@link UnmodifiableSortedSet} implementation.
  *
  * @since Commons Collections 3.0
@@ -35,73 +36,75 @@
  *
  * @author Phil Steitz
  */
-public class TestUnmodifiableSortedSet extends AbstractTestSortedSet{
-    
+public class TestUnmodifiableSortedSet<E> extends AbstractTestSortedSet<E> {
+    protected UnmodifiableSortedSet<E> set = null;
+    protected ArrayList<E> array = null;
+
     public TestUnmodifiableSortedSet(String testName) {
         super(testName);
     }
-    
+
     public static Test suite() {
         return BulkTest.makeSuite(TestUnmodifiableSortedSet.class);
     }
-    
+
     public static void main(String args[]) {
         String[] testCaseName = { TestUnmodifiableSortedSet.class.getName()};
         junit.textui.TestRunner.main(testCaseName);
     }
-    
-    //-------------------------------------------------------------------  
-    public Set makeEmptySet() {
-        return UnmodifiableSortedSet.decorate(new TreeSet());
-    }
-    
-    public Set makeFullSet() {
-        TreeSet set = new TreeSet();
+
+    //-------------------------------------------------------------------
+    public SortedSet<E> makeObject() {
+        return UnmodifiableSortedSet.decorate(new TreeSet<E>());
+    }
+
+    public UnmodifiableSortedSet<E> makeFullCollection() {
+        TreeSet<E> set = new TreeSet<E>();
         set.addAll(Arrays.asList(getFullElements()));
-        return UnmodifiableSortedSet.decorate(set);
+        return (UnmodifiableSortedSet<E>) UnmodifiableSortedSet.decorate(set);
     }
-    
+
     public boolean isAddSupported() {
         return false;
     }
-    
+
     public boolean isRemoveSupported() {
         return false;
     }
-           
+
     //--------------------------------------------------------------------
-    protected UnmodifiableSortedSet set = null;
-    protected ArrayList array = null;
-    
+    @SuppressWarnings("unchecked")
     protected void setupSet() {
-        set = (UnmodifiableSortedSet) makeFullSet();
-        array = new ArrayList();
-        array.add(new Integer(1));
+        set = makeFullCollection();
+        array = new ArrayList<E>();
+        array.add((E) new Integer(1));
     }
-    
-    /** 
+
+    /**
      * Verify that base set and subsets are not modifiable
      */
+    @SuppressWarnings("unchecked")
     public void testUnmodifiable() {
         setupSet();
         verifyUnmodifiable(set);
-        verifyUnmodifiable(set.headSet(new Integer(1)));
-        verifyUnmodifiable(set.tailSet(new Integer(1)));
-        verifyUnmodifiable(set.subSet(new Integer(1), new Integer(3)));    
+        verifyUnmodifiable(set.headSet((E) new Integer(1)));
+        verifyUnmodifiable(set.tailSet((E) new Integer(1)));
+        verifyUnmodifiable(set.subSet((E) new Integer(1), (E) new Integer(3)));
     }
-    
+
     /**
      * Verifies that a set is not modifiable
      */
-    public void verifyUnmodifiable(Set set) {
+    @SuppressWarnings("unchecked")
+    public void verifyUnmodifiable(Set<E> set) {
         try {
-            set.add("value");
+            set.add((E) "value");
             fail("Expecting UnsupportedOperationException.");
         } catch (UnsupportedOperationException e) {
-            // expected  
+            // expected
         }
         try {
-            set.addAll(new TreeSet());
+            set.addAll(new TreeSet<E>());
             fail("Expecting UnsupportedOperationException.");
         } catch (UnsupportedOperationException e) {
             // expected
@@ -131,10 +134,10 @@
             // expected
         }
     }
-    
+
     public void testComparator() {
         setupSet();
-        Comparator c = set.comparator();
+        Comparator<? super E> c = set.comparator();
         assertTrue("natural order, so comparator should be null", c == null);
     }
 



Mime
View raw message