commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r738956 [18/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/TestBagUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestBagUtils.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestBagUtils.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestBagUtils.java Thu Jan 29 18:48:37 2009
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,10 +28,11 @@
 import org.apache.commons.collections.bag.TreeBag;
 import org.apache.commons.collections.bag.UnmodifiableBag;
 import org.apache.commons.collections.bag.UnmodifiableSortedBag;
+import org.apache.commons.collections.functors.TruePredicate;
 
 /**
  * Tests for BagUtils factory methods.
- * 
+ *
  * @version $Revision$ $Date$
  *
  * @author Phil Steitz
@@ -46,17 +47,17 @@
     public static Test suite() {
         return BulkTest.makeSuite(TestBagUtils.class);
     }
-    
+
     //----------------------------------------------------------------------
 
-    protected Class stringClass = this.getName().getClass();
-    protected Predicate truePredicate = PredicateUtils.truePredicate();
-    protected Transformer nopTransformer = TransformerUtils.nopTransformer();
-    
+    protected Class<?> stringClass = this.getName().getClass();
+    protected Predicate<Object> truePredicate = TruePredicate.truePredicate();
+    protected Transformer<Object, Object> nopTransformer = TransformerUtils.nopTransformer();
+
     //----------------------------------------------------------------------
-    
+
     public void testSynchronizedBag() {
-        Bag bag = BagUtils.synchronizedBag(new HashBag());
+        Bag<Object> bag = BagUtils.synchronizedBag(new HashBag<Object>());
         assertTrue("Returned object should be a SynchronizedBag.",
             bag instanceof SynchronizedBag);
         try {
@@ -64,11 +65,11 @@
             fail("Expecting IllegalArgumentException for null bag.");
         } catch (IllegalArgumentException ex) {
             // expected
-        }  
+        }
     }
-    
+
     public void testUnmodifiableBag() {
-        Bag bag = BagUtils.unmodifiableBag(new HashBag());
+        Bag<Object> bag = BagUtils.unmodifiableBag(new HashBag<Object>());
         assertTrue("Returned object should be an UnmodifiableBag.",
             bag instanceof UnmodifiableBag);
         try {
@@ -76,11 +77,11 @@
             fail("Expecting IllegalArgumentException for null bag.");
         } catch (IllegalArgumentException ex) {
             // expected
-        }  
+        }
     }
-    
+
     public void testPredicatedBag() {
-        Bag bag = BagUtils.predicatedBag(new HashBag(), truePredicate);
+        Bag<Object> bag = BagUtils.predicatedBag(new HashBag<Object>(), truePredicate);
         assertTrue("Returned object should be a PredicatedBag.",
             bag instanceof PredicatedBag);
         try {
@@ -88,35 +89,35 @@
             fail("Expecting IllegalArgumentException for null bag.");
         } catch (IllegalArgumentException ex) {
             // expected
-        } 
+        }
         try {
-            bag = BagUtils.predicatedBag(new HashBag(), null);
+            bag = BagUtils.predicatedBag(new HashBag<Object>(), null);
             fail("Expecting IllegalArgumentException for null predicate.");
         } catch (IllegalArgumentException ex) {
             // expected
-        }  
+        }
     }
-    
+
      public void testTransformedBag() {
-        Bag bag = BagUtils.transformedBag(new HashBag(), nopTransformer);      
+        Bag<Object> bag = BagUtils.transformedBag(new HashBag<Object>(), nopTransformer);
         assertTrue("Returned object should be an TransformedBag.",
             bag instanceof TransformedBag);
         try {
-            bag = BagUtils.transformedBag(null, nopTransformer);      
+            bag = BagUtils.transformedBag(null, nopTransformer);
             fail("Expecting IllegalArgumentException for null bag.");
         } catch (IllegalArgumentException ex) {
             // expected
-        } 
+        }
         try {
-            bag = BagUtils.transformedBag(new HashBag(), null);  
+            bag = BagUtils.transformedBag(new HashBag<Object>(), null);
             fail("Expecting IllegalArgumentException for null transformer.");
         } catch (IllegalArgumentException ex) {
             // expected
-        }  
+        }
     }
-     
+
     public void testSynchronizedSortedBag() {
-        Bag bag = BagUtils.synchronizedSortedBag(new TreeBag());
+        Bag<Object> bag = BagUtils.synchronizedSortedBag(new TreeBag<Object>());
         assertTrue("Returned object should be a SynchronizedSortedBag.",
             bag instanceof SynchronizedSortedBag);
         try {
@@ -124,11 +125,11 @@
             fail("Expecting IllegalArgumentException for null bag.");
         } catch (IllegalArgumentException ex) {
             // expected
-        }  
+        }
     }
-    
+
     public void testUnmodifiableSortedBag() {
-        Bag bag = BagUtils.unmodifiableSortedBag(new TreeBag());
+        Bag<Object> bag = BagUtils.unmodifiableSortedBag(new TreeBag<Object>());
         assertTrue("Returned object should be an UnmodifiableSortedBag.",
             bag instanceof UnmodifiableSortedBag);
         try {
@@ -136,11 +137,11 @@
             fail("Expecting IllegalArgumentException for null bag.");
         } catch (IllegalArgumentException ex) {
             // expected
-        }  
+        }
     }
-    
+
     public void testPredicatedSortedBag() {
-        Bag bag = BagUtils.predicatedSortedBag(new TreeBag(), truePredicate);
+        Bag<Object> bag = BagUtils.predicatedSortedBag(new TreeBag<Object>(), truePredicate);
         assertTrue("Returned object should be a PredicatedSortedBag.",
             bag instanceof PredicatedSortedBag);
         try {
@@ -148,31 +149,31 @@
             fail("Expecting IllegalArgumentException for null bag.");
         } catch (IllegalArgumentException ex) {
             // expected
-        } 
+        }
         try {
-            bag = BagUtils.predicatedSortedBag(new TreeBag(), null);
+            bag = BagUtils.predicatedSortedBag(new TreeBag<Object>(), null);
             fail("Expecting IllegalArgumentException for null predicate.");
         } catch (IllegalArgumentException ex) {
             // expected
-        }  
+        }
     }
-    
+
     public void testTransformedSortedBag() {
-        Bag bag = BagUtils.transformedSortedBag(new TreeBag(), nopTransformer);      
+        Bag<Object> bag = BagUtils.transformedSortedBag(new TreeBag<Object>(), nopTransformer);
         assertTrue("Returned object should be an TransformedSortedBag",
             bag instanceof TransformedSortedBag);
         try {
-            bag = BagUtils.transformedSortedBag(null, nopTransformer);      
+            bag = BagUtils.transformedSortedBag(null, nopTransformer);
             fail("Expecting IllegalArgumentException for null bag.");
         } catch (IllegalArgumentException ex) {
             // expected
-        } 
+        }
         try {
-            bag = BagUtils.transformedSortedBag(new TreeBag(), null);  
+            bag = BagUtils.transformedSortedBag(new TreeBag<Object>(), null);
             fail("Expecting IllegalArgumentException for null transformer.");
         } catch (IllegalArgumentException ex) {
             // expected
-        }  
+        }
     }
 }
 

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

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestClosureUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestClosureUtils.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestClosureUtils.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestClosureUtils.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.
@@ -27,11 +27,13 @@
 import junit.textui.TestRunner;
 
 import org.apache.commons.collections.functors.EqualPredicate;
+import org.apache.commons.collections.functors.FalsePredicate;
 import org.apache.commons.collections.functors.NOPClosure;
+import org.apache.commons.collections.functors.TruePredicate;
 
 /**
  * Tests the org.apache.commons.collections.ClosureUtils class.
- * 
+ *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
  *
@@ -51,7 +53,7 @@
     /**
      * Main.
      * @param args
-     */    
+     */
     public static void main(String[] args) {
         TestRunner.run(suite());
     }
@@ -74,18 +76,23 @@
      */
     public void tearDown() {
     }
-    
-    static class MockClosure implements Closure {
+
+    static class MockClosure<T> implements Closure<T> {
         int count = 0;
-        
-        public void execute(Object object) {
+
+        public void execute(T object) {
             count++;
         }
+
+        public void reset() {
+            count = 0;
+        }
     }
-    static class MockTransformer implements Transformer {
+
+    static class MockTransformer<T> implements Transformer<T, T> {
         int count = 0;
-        
-        public Object transform(Object object) {
+
+        public T transform(T object) {
             count++;
             return object;
         }
@@ -108,7 +115,7 @@
         }
         fail();
     }
-    
+
     // nopClosure
     //------------------------------------------------------------------
 
@@ -136,11 +143,11 @@
     //------------------------------------------------------------------
 
     public void testForClosure() {
-        MockClosure cmd = new MockClosure();
+        MockClosure<Object> cmd = new MockClosure<Object>();
         ClosureUtils.forClosure(5, cmd).execute(null);
         assertEquals(5, cmd.count);
-        assertSame(NOPClosure.INSTANCE, ClosureUtils.forClosure(0, new MockClosure()));
-        assertSame(NOPClosure.INSTANCE, ClosureUtils.forClosure(-1, new MockClosure()));
+        assertSame(NOPClosure.INSTANCE, ClosureUtils.forClosure(0, new MockClosure<Object>()));
+        assertSame(NOPClosure.INSTANCE, ClosureUtils.forClosure(-1, new MockClosure<Object>()));
         assertSame(NOPClosure.INSTANCE, ClosureUtils.forClosure(1, null));
         assertSame(NOPClosure.INSTANCE, ClosureUtils.forClosure(3, null));
         assertSame(cmd, ClosureUtils.forClosure(1, cmd));
@@ -150,20 +157,20 @@
     //------------------------------------------------------------------
 
     public void testWhileClosure() {
-        MockClosure cmd = new MockClosure();
-        ClosureUtils.whileClosure(PredicateUtils.falsePredicate(), cmd).execute(null);
+        MockClosure<Object> cmd = new MockClosure<Object>();
+        ClosureUtils.whileClosure(FalsePredicate.falsePredicate(), cmd).execute(null);
         assertEquals(0, cmd.count);
-        
-        cmd = new MockClosure();
+
+        cmd = new MockClosure<Object>();
         ClosureUtils.whileClosure(PredicateUtils.uniquePredicate(), cmd).execute(null);
         assertEquals(1, cmd.count);
-        
+
         try {
             ClosureUtils.whileClosure(null, ClosureUtils.nopClosure());
             fail();
         } catch (IllegalArgumentException ex) {}
         try {
-            ClosureUtils.whileClosure(PredicateUtils.falsePredicate(), null);
+            ClosureUtils.whileClosure(FalsePredicate.falsePredicate(), null);
             fail();
         } catch (IllegalArgumentException ex) {}
         try {
@@ -176,14 +183,14 @@
     //------------------------------------------------------------------
 
     public void testDoWhileClosure() {
-        MockClosure cmd = new MockClosure();
-        ClosureUtils.doWhileClosure(cmd, PredicateUtils.falsePredicate()).execute(null);
+        MockClosure<Object> cmd = new MockClosure<Object>();
+        ClosureUtils.doWhileClosure(cmd, FalsePredicate.falsePredicate()).execute(null);
         assertEquals(1, cmd.count);
-        
-        cmd = new MockClosure();
+
+        cmd = new MockClosure<Object>();
         ClosureUtils.doWhileClosure(cmd, PredicateUtils.uniquePredicate()).execute(null);
         assertEquals(2, cmd.count);
-        
+
         try {
             ClosureUtils.doWhileClosure(null, null);
             fail();
@@ -193,135 +200,137 @@
     // chainedClosure
     //------------------------------------------------------------------
 
+    @SuppressWarnings("unchecked")
     public void testChainedClosure() {
-        MockClosure a = new MockClosure();
-        MockClosure b = new MockClosure();
+        MockClosure<Object> a = new MockClosure<Object>();
+        MockClosure<Object> b = new MockClosure<Object>();
         ClosureUtils.chainedClosure(a, b).execute(null);
         assertEquals(1, a.count);
         assertEquals(1, b.count);
-        
-        a = new MockClosure();
-        b = new MockClosure();
-        ClosureUtils.chainedClosure(new Closure[] {a, b, a}).execute(null);
+
+        a = new MockClosure<Object>();
+        b = new MockClosure<Object>();
+        ClosureUtils.<Object>chainedClosure(new Closure[] {a, b, a}).execute(null);
         assertEquals(2, a.count);
         assertEquals(1, b.count);
-        
-        a = new MockClosure();
-        b = new MockClosure();
-        Collection coll = new ArrayList();
+
+        a = new MockClosure<Object>();
+        b = new MockClosure<Object>();
+        Collection<Closure<Object>> coll = new ArrayList<Closure<Object>>();
         coll.add(b);
         coll.add(a);
         coll.add(b);
-        ClosureUtils.chainedClosure(coll).execute(null);
+        ClosureUtils.<Object>chainedClosure(coll).execute(null);
         assertEquals(1, a.count);
         assertEquals(2, b.count);
-        
-        assertSame(NOPClosure.INSTANCE, ClosureUtils.chainedClosure(new Closure[0]));
-        assertSame(NOPClosure.INSTANCE, ClosureUtils.chainedClosure(Collections.EMPTY_LIST));
-        
+
+        assertSame(NOPClosure.INSTANCE, ClosureUtils.<Object>chainedClosure(new Closure[0]));
+        assertSame(NOPClosure.INSTANCE, ClosureUtils.<Object>chainedClosure(Collections.<Closure<Object>>emptyList()));
+
         try {
             ClosureUtils.chainedClosure(null, null);
             fail();
         } catch (IllegalArgumentException ex) {}
         try {
-            ClosureUtils.chainedClosure((Closure[]) null);
+            ClosureUtils.<Object>chainedClosure((Closure[]) null);
             fail();
         } catch (IllegalArgumentException ex) {}
         try {
-            ClosureUtils.chainedClosure((Collection) null);
+            ClosureUtils.<Object>chainedClosure((Collection<Closure<Object>>) null);
             fail();
         } catch (IllegalArgumentException ex) {}
         try {
-            ClosureUtils.chainedClosure(new Closure[] {null, null});
+            ClosureUtils.<Object>chainedClosure(new Closure[] {null, null});
             fail();
         } catch (IllegalArgumentException ex) {}
         try {
-            coll = new ArrayList();
+            coll = new ArrayList<Closure<Object>>();
             coll.add(null);
             coll.add(null);
             ClosureUtils.chainedClosure(coll);
             fail();
         } catch (IllegalArgumentException ex) {}
     }
-    
+
     // ifClosure
     //------------------------------------------------------------------
 
     public void testIfClosure() {
-        MockClosure a = new MockClosure();
-        MockClosure b = null;
-        ClosureUtils.ifClosure(PredicateUtils.truePredicate(), a).execute(null);
+        MockClosure<Object> a = new MockClosure<Object>();
+        MockClosure<Object> b = null;
+        ClosureUtils.ifClosure(TruePredicate.truePredicate(), a).execute(null);
         assertEquals(1, a.count);
 
-        a = new MockClosure();
-        ClosureUtils.ifClosure(PredicateUtils.falsePredicate(), a).execute(null);
+        a = new MockClosure<Object>();
+        ClosureUtils.ifClosure(FalsePredicate.<Object>falsePredicate(), a).execute(null);
         assertEquals(0, a.count);
 
-        a = new MockClosure();
-        b = new MockClosure();
-        ClosureUtils.ifClosure(PredicateUtils.truePredicate(), a, b).execute(null);
+        a = new MockClosure<Object>();
+        b = new MockClosure<Object>();
+        ClosureUtils.ifClosure(TruePredicate.<Object>truePredicate(), a, b).execute(null);
         assertEquals(1, a.count);
         assertEquals(0, b.count);
-        
-        a = new MockClosure();
-        b = new MockClosure();
-        ClosureUtils.ifClosure(PredicateUtils.falsePredicate(), a, b).execute(null);
+
+        a = new MockClosure<Object>();
+        b = new MockClosure<Object>();
+        ClosureUtils.ifClosure(FalsePredicate.<Object>falsePredicate(), a, b).execute(null);
         assertEquals(0, a.count);
         assertEquals(1, b.count);
-    }        
+    }
 
     // switchClosure
     //------------------------------------------------------------------
 
+    @SuppressWarnings("unchecked")
     public void testSwitchClosure() {
-        MockClosure a = new MockClosure();
-        MockClosure b = new MockClosure();
-        ClosureUtils.switchClosure(
-            new Predicate[] {EqualPredicate.equalPredicate("HELLO"), EqualPredicate.equalPredicate("THERE")}, 
-            new Closure[] {a, b}).execute("WELL");
+        MockClosure<String> a = new MockClosure<String>();
+        MockClosure<String> b = new MockClosure<String>();
+        ClosureUtils.<String>switchClosure(
+            new Predicate[] { EqualPredicate.equalPredicate("HELLO"), EqualPredicate.equalPredicate("THERE") },
+            new Closure[] { a, b }).execute("WELL");
         assertEquals(0, a.count);
         assertEquals(0, b.count);
-        
-        a = new MockClosure();
-        b = new MockClosure();
-        ClosureUtils.switchClosure(
-            new Predicate[] {EqualPredicate.equalPredicate("HELLO"), EqualPredicate.equalPredicate("THERE")}, 
-            new Closure[] {a, b}).execute("HELLO");
+
+        a.reset();
+        b.reset();
+        ClosureUtils.<String>switchClosure(
+            new Predicate[] { EqualPredicate.equalPredicate("HELLO"), EqualPredicate.equalPredicate("THERE") },
+            new Closure[] { a, b }).execute("HELLO");
         assertEquals(1, a.count);
         assertEquals(0, b.count);
-        
-        a = new MockClosure();
-        b = new MockClosure();
-        MockClosure c = new MockClosure();
-        ClosureUtils.switchClosure(
-            new Predicate[] {EqualPredicate.equalPredicate("HELLO"), EqualPredicate.equalPredicate("THERE")}, 
-            new Closure[] {a, b}, c).execute("WELL");
+
+        a.reset();
+        b.reset();
+        MockClosure<String> c = new MockClosure<String>();
+        ClosureUtils.<String>switchClosure(
+            new Predicate[] { EqualPredicate.equalPredicate("HELLO"), EqualPredicate.equalPredicate("THERE") },
+            new Closure[] { a, b }, c).execute("WELL");
         assertEquals(0, a.count);
         assertEquals(0, b.count);
         assertEquals(1, c.count);
-        
-        a = new MockClosure();
-        b = new MockClosure();
-        Map map = new HashMap();
+
+        a.reset();
+        b.reset();
+        Map<Predicate<String>, Closure<String>> map = new HashMap<Predicate<String>, Closure<String>>();
         map.put(EqualPredicate.equalPredicate("HELLO"), a);
         map.put(EqualPredicate.equalPredicate("THERE"), b);
-        ClosureUtils.switchClosure(map).execute(null);
+        ClosureUtils.<String>switchClosure(map).execute(null);
         assertEquals(0, a.count);
         assertEquals(0, b.count);
 
-        a = new MockClosure();
-        b = new MockClosure();
-        map = new HashMap();
+        a.reset();
+        b.reset();
+        map.clear();
         map.put(EqualPredicate.equalPredicate("HELLO"), a);
         map.put(EqualPredicate.equalPredicate("THERE"), b);
         ClosureUtils.switchClosure(map).execute("THERE");
         assertEquals(0, a.count);
         assertEquals(1, b.count);
 
-        a = new MockClosure();
-        b = new MockClosure();
-        c = new MockClosure();
-        map = new HashMap();
+        a.reset();
+        b.reset();
+        c.reset();
+        map.clear();
         map.put(EqualPredicate.equalPredicate("HELLO"), a);
         map.put(EqualPredicate.equalPredicate("THERE"), b);
         map.put(null, c);
@@ -329,63 +338,63 @@
         assertEquals(0, a.count);
         assertEquals(0, b.count);
         assertEquals(1, c.count);
-        
-        assertSame(NOPClosure.INSTANCE, ClosureUtils.switchClosure(new Predicate[0], new Closure[0]));
-        assertSame(NOPClosure.INSTANCE, ClosureUtils.switchClosure(new HashMap()));
-        map = new HashMap();
+
+        assertEquals(NOPClosure.INSTANCE, ClosureUtils.<String>switchClosure(new Predicate[0], new Closure[0]));
+        assertEquals(NOPClosure.INSTANCE, ClosureUtils.<String>switchClosure(new HashMap<Predicate<String>, Closure<String>>()));
+        map.clear();
         map.put(null, null);
-        assertSame(NOPClosure.INSTANCE, ClosureUtils.switchClosure(map));
+        assertEquals(NOPClosure.INSTANCE, ClosureUtils.switchClosure(map));
 
         try {
             ClosureUtils.switchClosure(null, null);
             fail();
         } catch (IllegalArgumentException ex) {}
         try {
-            ClosureUtils.switchClosure((Predicate[]) null, (Closure[]) null);
+            ClosureUtils.<String>switchClosure((Predicate<String>[]) null, (Closure<String>[]) null);
             fail();
         } catch (IllegalArgumentException ex) {}
         try {
-            ClosureUtils.switchClosure((Map) null);
+            ClosureUtils.<String>switchClosure((Map<Predicate<String>, Closure<String>>) null);
             fail();
         } catch (IllegalArgumentException ex) {}
         try {
-            ClosureUtils.switchClosure(new Predicate[2], new Closure[2]);
+            ClosureUtils.<String>switchClosure(new Predicate[2], new Closure[2]);
             fail();
         } catch (IllegalArgumentException ex) {}
         try {
-            ClosureUtils.switchClosure(
-                    new Predicate[] {PredicateUtils.truePredicate()},
-                    new Closure[] {a,b});
+            ClosureUtils.<String>switchClosure(
+                    new Predicate[] { TruePredicate.<String>truePredicate() },
+                    new Closure[] { a, b });
             fail();
         } catch (IllegalArgumentException ex) {}
     }
-    
+
     // switchMapClosure
     //------------------------------------------------------------------
 
     public void testSwitchMapClosure() {
-        MockClosure a = new MockClosure();
-        MockClosure b = new MockClosure();
-        Map map = new HashMap();
+        MockClosure<String> a = new MockClosure<String>();
+        MockClosure<String> b = new MockClosure<String>();
+        Map<String, Closure<String>> map = new HashMap<String, Closure<String>>();
         map.put("HELLO", a);
         map.put("THERE", b);
         ClosureUtils.switchMapClosure(map).execute(null);
         assertEquals(0, a.count);
         assertEquals(0, b.count);
 
-        a = new MockClosure();
-        b = new MockClosure();
-        map = new HashMap();
+        a.reset();
+        b.reset();
+        map.clear();
         map.put("HELLO", a);
         map.put("THERE", b);
         ClosureUtils.switchMapClosure(map).execute("THERE");
         assertEquals(0, a.count);
         assertEquals(1, b.count);
 
-        a = new MockClosure();
-        b = new MockClosure();
-        MockClosure c = new MockClosure();
-        map = new HashMap();
+        a.reset();
+        b.reset();
+        map.clear();
+        MockClosure<String> c = new MockClosure<String>();
         map.put("HELLO", a);
         map.put("THERE", b);
         map.put(null, c);
@@ -394,26 +403,26 @@
         assertEquals(0, b.count);
         assertEquals(1, c.count);
 
-        assertSame(NOPClosure.INSTANCE, ClosureUtils.switchMapClosure(new HashMap()));
-        
+        assertEquals(NOPClosure.INSTANCE, ClosureUtils.switchMapClosure(new HashMap<String, Closure<String>>()));
+
         try {
             ClosureUtils.switchMapClosure(null);
             fail();
         } catch (IllegalArgumentException ex) {}
     }
-    
+
     // asClosure
     //------------------------------------------------------------------
 
     public void testTransformerClosure() {
-        MockTransformer mock = new MockTransformer();
-        Closure closure = ClosureUtils.asClosure(mock);
+        MockTransformer<Object> mock = new MockTransformer<Object>();
+        Closure<Object> closure = ClosureUtils.asClosure(mock);
         closure.execute(null);
         assertEquals(1, mock.count);
         closure.execute(null);
         assertEquals(2, mock.count);
-        
-        assertSame(ClosureUtils.nopClosure(), ClosureUtils.asClosure(null));
+
+        assertEquals(ClosureUtils.nopClosure(), ClosureUtils.asClosure(null));
     }
-    
+
 }

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestCollectionUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestCollectionUtils.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestCollectionUtils.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestCollectionUtils.java Thu Jan 29 18:48:37 2009
@@ -31,7 +31,6 @@
 import org.apache.commons.collections.collection.SynchronizedCollection;
 import org.apache.commons.collections.collection.TransformedCollection;
 import org.apache.commons.collections.collection.UnmodifiableCollection;
-import org.apache.commons.collections.functors.EqualPredicate;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -139,7 +138,7 @@
 
     @Test
     public void getCardinalityMap() {
-        Map<Number, Integer> freqA = CollectionUtils.<Number, Integer>getCardinalityMap(iterableA);
+        Map<Number, Integer> freqA = CollectionUtils.<Number>getCardinalityMap(iterableA);
         assertEquals(1, (int) freqA.get(1));
         assertEquals(2, (int) freqA.get(2));
         assertEquals(3, (int) freqA.get(3));
@@ -185,7 +184,7 @@
         assertEquals(0, CollectionUtils.cardinality("D", set));
         assertEquals(1, CollectionUtils.cardinality("E", set));
 
-        Bag<String> bag = new HashBag();
+        Bag<String> bag = new HashBag<String>();
         bag.add("A", 3);
         bag.add("C");
         bag.add("E");
@@ -202,43 +201,43 @@
         List<String> list = new ArrayList<String>();
         assertEquals(0, CollectionUtils.cardinality(null, list));
         {
-            Map freq = CollectionUtils.getCardinalityMap(list);
+            Map<String, Integer> freq = CollectionUtils.getCardinalityMap(list);
             assertNull(freq.get(null));
         }
         list.add("A");
         assertEquals(0, CollectionUtils.cardinality(null, list));
         {
-            Map freq = CollectionUtils.getCardinalityMap(list);
+            Map<String, Integer> freq = CollectionUtils.getCardinalityMap(list);
             assertNull(freq.get(null));
         }
         list.add(null);
         assertEquals(1, CollectionUtils.cardinality(null, list));
         {
-            Map freq = CollectionUtils.getCardinalityMap(list);
+            Map<String, Integer> freq = CollectionUtils.getCardinalityMap(list);
             assertEquals(1, freq.get(null));
         }
         list.add("B");
         assertEquals(1, CollectionUtils.cardinality(null, list));
         {
-            Map freq = CollectionUtils.getCardinalityMap(list);
+            Map<String, Integer> freq = CollectionUtils.getCardinalityMap(list);
             assertEquals(1, freq.get(null));
         }
         list.add(null);
         assertEquals(2, CollectionUtils.cardinality(null, list));
         {
-            Map freq = CollectionUtils.getCardinalityMap(list);
+            Map<String, Integer> freq = CollectionUtils.getCardinalityMap(list);
             assertEquals(2, freq.get(null));
         }
         list.add("B");
         assertEquals(2, CollectionUtils.cardinality(null, list));
         {
-            Map freq = CollectionUtils.getCardinalityMap(list);
+            Map<String, Integer> freq = CollectionUtils.getCardinalityMap(list);
             assertEquals(2, freq.get(null));
         }
         list.add(null);
         assertEquals(3, CollectionUtils.cardinality(null, list));
         {
-            Map freq = CollectionUtils.getCardinalityMap(list);
+            Map<String, Integer> freq = CollectionUtils.getCardinalityMap(list);
             assertEquals(3, freq.get(null));
         }
     }
@@ -275,7 +274,7 @@
     @Test
     public void union() {
         Collection<Integer> col = CollectionUtils.union(iterableA, iterableC);
-        Map freq = CollectionUtils.getCardinalityMap(col);
+        Map<Integer, Integer> freq = CollectionUtils.getCardinalityMap(col);
         assertEquals(1, freq.get(1));
         assertEquals(4, freq.get(2));
         assertEquals(3, freq.get(3));
@@ -283,7 +282,7 @@
         assertEquals(1, freq.get(5));
 
         Collection<Number> col2 = CollectionUtils.union(collectionC2, iterableA);
-        Map freq2 = CollectionUtils.getCardinalityMap(col2);
+        Map<Number, Integer> freq2 = CollectionUtils.getCardinalityMap(col2);
         assertEquals(1, freq2.get(1));
         assertEquals(4, freq2.get(2));
         assertEquals(3, freq2.get(3));
@@ -294,7 +293,7 @@
     @Test
     public void intersection() {
         Collection<Integer> col = CollectionUtils.intersection(iterableA, iterableC);
-        Map freq = CollectionUtils.getCardinalityMap(col);
+        Map<Integer, Integer> freq = CollectionUtils.getCardinalityMap(col);
         assertNull(freq.get(1));
         assertEquals(2, freq.get(2));
         assertEquals(3, freq.get(3));
@@ -302,7 +301,7 @@
         assertNull(freq.get(5));
 
         Collection<Number> col2 = CollectionUtils.intersection(collectionC2, collectionA);
-        Map freq2 = CollectionUtils.getCardinalityMap(col2);
+        Map<Number, Integer> freq2 = CollectionUtils.getCardinalityMap(col2);
         assertNull(freq2.get(1));
         assertEquals(2, freq2.get(2));
         assertEquals(3, freq2.get(3));
@@ -313,7 +312,7 @@
     @Test
     public void disjunction() {
         Collection<Integer> col = CollectionUtils.disjunction(iterableA, iterableC);
-        Map freq = CollectionUtils.getCardinalityMap(col);
+        Map<Integer, Integer> freq = CollectionUtils.getCardinalityMap(col);
         assertEquals(1, freq.get(1));
         assertEquals(2, freq.get(2));
         assertNull(freq.get(3));
@@ -321,7 +320,7 @@
         assertEquals(1, freq.get(5));
 
         Collection<Number> col2 = CollectionUtils.disjunction(collectionC2, collectionA);
-        Map freq2 = CollectionUtils.getCardinalityMap(col2);
+        Map<Number, Integer> freq2 = CollectionUtils.getCardinalityMap(col2);
         assertEquals(1, freq2.get(1));
         assertEquals(2, freq2.get(2));
         assertNull(freq2.get(3));
@@ -348,7 +347,7 @@
     @Test
     public void testSubtract() {
         Collection<Integer> col = CollectionUtils.subtract(iterableA, iterableC);
-        Map freq = CollectionUtils.getCardinalityMap(col);
+        Map<Integer, Integer> freq = CollectionUtils.getCardinalityMap(col);
         assertEquals(1, freq.get(1));
         assertNull(freq.get(2));
         assertNull(freq.get(3));
@@ -356,7 +355,7 @@
         assertNull(freq.get(5));
 
         Collection<Number> col2 = CollectionUtils.subtract(collectionC2, collectionA);
-        Map freq2 = CollectionUtils.getCardinalityMap(col2);
+        Map<Number, Integer> freq2 = CollectionUtils.getCardinalityMap(col2);
         assertEquals(1, freq2.get(5));
         assertNull(freq2.get(4));
         assertNull(freq2.get(3));
@@ -500,8 +499,8 @@
 
     @Test
     public void forAllDo() {
-        Closure<Collection> testClosure = ClosureUtils.invokerClosure("clear");
-        Collection<List> col = new ArrayList<List>();
+        Closure<List<? extends Number>> testClosure = ClosureUtils.invokerClosure("clear");
+        Collection<List<? extends Number>> col = new ArrayList<List<? extends Number>>();
         col.add(collectionA);
         col.add(collectionB);
         CollectionUtils.forAllDo(col, testClosure);
@@ -601,10 +600,10 @@
     @Test
     public void getFromEnumeration() throws Exception {
         // Enumeration, entry exists
-        Vector vector = new Vector();
+        Vector<String> vector = new Vector<String>();
         vector.addElement("zero");
         vector.addElement("one");
-        Enumeration en = vector.elements();
+        Enumeration<String> en = vector.elements();
         assertEquals("zero", CollectionUtils.get(en, 0));
         en = vector.elements();
         assertEquals("one", CollectionUtils.get(en, 1));
@@ -622,7 +621,7 @@
     @Test(expected = IndexOutOfBoundsException.class)
     public void getFromIterable() throws Exception {
         // Collection, entry exists
-        Bag bag = new HashBag();
+        Bag<String> bag = new HashBag<String>();
         bag.add("element", 1);
         assertEquals("element", CollectionUtils.get(bag, 0));
 
@@ -714,7 +713,7 @@
 
     @Test
     public void testSize_Enumeration() {
-        Vector list = new Vector();
+        Vector<String> list = new Vector<String>();
         assertEquals(0, CollectionUtils.size(list.elements()));
         list.add("a");
         assertEquals(1, CollectionUtils.size(list.elements()));
@@ -724,7 +723,7 @@
 
     @Test
     public void testSize_Iterator() {
-        List list = new ArrayList();
+        List<String> list = new ArrayList<String>();
         assertEquals(0, CollectionUtils.size(list.iterator()));
         list.add("a");
         assertEquals(1, CollectionUtils.size(list.iterator()));
@@ -795,7 +794,7 @@
         assertEquals(true, CollectionUtils.sizeIsEmpty(list.elements()));
         list.add("a");
         assertEquals(false, CollectionUtils.sizeIsEmpty(list.elements()));
-        Enumeration en = list.elements();
+        Enumeration<String> en = list.elements();
         en.nextElement();
         assertEquals(true, CollectionUtils.sizeIsEmpty(en));
     }
@@ -806,7 +805,7 @@
         assertEquals(true, CollectionUtils.sizeIsEmpty(list.iterator()));
         list.add("a");
         assertEquals(false, CollectionUtils.sizeIsEmpty(list.iterator()));
-        Iterator it = list.iterator();
+        Iterator<String> it = list.iterator();
         it.next();
         assertEquals(true, CollectionUtils.sizeIsEmpty(it));
     }
@@ -828,7 +827,7 @@
     // -----------------------------------------------------------------------
     @Test
     public void testIsEmptyWithEmptyCollection() {
-        Collection coll = new ArrayList();
+        Collection<Object> coll = new ArrayList<Object>();
         assertEquals(true, CollectionUtils.isEmpty(coll));
     }
 
@@ -841,13 +840,13 @@
 
     @Test
     public void testIsEmptyWithNull() {
-        Collection coll = null;
+        Collection<?> coll = null;
         assertEquals(true, CollectionUtils.isEmpty(coll));
     }
 
     @Test
     public void testIsNotEmptyWithEmptyCollection() {
-        Collection coll = new ArrayList();
+        Collection<Object> coll = new ArrayList<Object>();
         assertEquals(false, CollectionUtils.isNotEmpty(coll));
     }
 
@@ -860,7 +859,7 @@
 
     @Test
     public void testIsNotEmptyWithNull() {
-        Collection coll = null;
+        Collection<?> coll = null;
         assertEquals(false, CollectionUtils.isNotEmpty(coll));
     }
 
@@ -930,7 +929,7 @@
         list.add(4);
         // Ensure that the collection is the input type or a super type
         Collection<Integer> output1 = CollectionUtils.select(list, EQUALS_TWO);
-        Collection<Number> output2 = CollectionUtils.<Number, Integer>select(list, EQUALS_TWO);
+        Collection<Number> output2 = CollectionUtils.<Number>select(list, EQUALS_TWO);
         HashSet<Number> output3 = CollectionUtils.select(list, EQUALS_TWO, new HashSet<Number>());
         assertTrue(CollectionUtils.isEqualCollection(output1, output3));
         assertEquals(4, list.size());
@@ -946,7 +945,7 @@
         list.add(3L);
         list.add(4L);
         Collection<Long> output1 = CollectionUtils.selectRejected(list, EQUALS_TWO);
-        Collection<Number> output2 = CollectionUtils.<Number, Long>selectRejected(list, EQUALS_TWO);
+        Collection<? extends Number> output2 = CollectionUtils.selectRejected(list, EQUALS_TWO);
         HashSet<Number> output3 = CollectionUtils.selectRejected(list, EQUALS_TWO, new HashSet<Number>());
         assertTrue(CollectionUtils.isEqualCollection(output1, output2));
         assertTrue(CollectionUtils.isEqualCollection(output1, output3));
@@ -1091,7 +1090,7 @@
         }
         assertFalse(CollectionUtils.isFull(set));
 
-        BoundedFifoBuffer buf = new BoundedFifoBuffer(set);
+        BoundedFifoBuffer<String> buf = new BoundedFifoBuffer<String>(set);
         assertEquals(true, CollectionUtils.isFull(buf));
         buf.remove("2");
         assertFalse(CollectionUtils.isFull(buf));
@@ -1125,7 +1124,7 @@
         }
         assertEquals(-1, CollectionUtils.maxSize(set));
 
-        Buffer<String> buf = new BoundedFifoBuffer(set);
+        Buffer<String> buf = new BoundedFifoBuffer<String>(set);
         assertEquals(3, CollectionUtils.maxSize(buf));
         buf.remove("2");
         assertEquals(3, CollectionUtils.maxSize(buf));
@@ -1217,16 +1216,16 @@
 
     @Test
     public void testRemoveAll() {
-        List base = new ArrayList();
+        List<String> base = new ArrayList<String>();
         base.add("A");
         base.add("B");
         base.add("C");
-        List sub = new ArrayList();
+        List<String> sub = new ArrayList<String>();
         sub.add("A");
         sub.add("C");
         sub.add("X");
 
-        Collection result = CollectionUtils.removeAll(base, sub);
+        Collection<String> result = CollectionUtils.removeAll(base, sub);
         assertEquals(1, result.size());
         assertFalse(result.contains("A"));
         assertEquals(true, result.contains("B"));
@@ -1250,11 +1249,11 @@
     // -----------------------------------------------------------------------
     @Test
     public void testTransformedCollection() {
-        Transformer transformer = TransformerUtils.nopTransformer();
-        Collection collection = CollectionUtils.transformedCollection(new ArrayList(), transformer);
+        Transformer<Object, Object> transformer = TransformerUtils.nopTransformer();
+        Collection<Object> collection = CollectionUtils.transformedCollection(new ArrayList<Object>(), transformer);
         assertTrue("returned object should be a TransformedCollection", collection instanceof TransformedCollection);
         try {
-            collection = CollectionUtils.transformedCollection(new ArrayList(), null);
+            collection = CollectionUtils.transformedCollection(new ArrayList<Object>(), null);
             fail("Expecting IllegalArgumentException for null transformer.");
         } catch (IllegalArgumentException ex) {
             // expected
@@ -1269,11 +1268,11 @@
 
     @Test
     public void testTransformedCollection_2() {
-        List list = new ArrayList();
+        List<Object> list = new ArrayList<Object>();
         list.add("1");
         list.add("2");
         list.add("3");
-        Collection result = CollectionUtils.transformedCollection(list, TRANSFORM_TO_INTEGER);
+        Collection<Object> result = CollectionUtils.transformedCollection(list, TRANSFORM_TO_INTEGER);
         assertEquals(true, result.contains("1")); // untransformed
         assertEquals(true, result.contains("2")); // untransformed
         assertEquals(true, result.contains("3")); // untransformed
@@ -1281,7 +1280,7 @@
 
     @Test
     public void testSynchronizedCollection() {
-        Collection col = CollectionUtils.synchronizedCollection(new ArrayList());
+        Collection<Object> col = CollectionUtils.synchronizedCollection(new ArrayList<Object>());
         assertTrue("Returned object should be a SynchronizedCollection.", col instanceof SynchronizedCollection);
         try {
             col = CollectionUtils.synchronizedCollection(null);
@@ -1293,7 +1292,7 @@
 
     @Test
     public void testUnmodifiableCollection() {
-        Collection col = CollectionUtils.unmodifiableCollection(new ArrayList());
+        Collection<Object> col = CollectionUtils.unmodifiableCollection(new ArrayList<Object>());
         assertTrue("Returned object should be a UnmodifiableCollection.", col instanceof UnmodifiableCollection);
         try {
             col = CollectionUtils.unmodifiableCollection(null);
@@ -1353,7 +1352,7 @@
 
     @Test
     public void addAllForEnumeration() {
-        Hashtable<Integer, Integer> h = new Hashtable();
+        Hashtable<Integer, Integer> h = new Hashtable<Integer, Integer>();
         h.put(5, 5);
         Enumeration<? extends Integer> enumeration = h.keys();
         CollectionUtils.addAll(collectionA, enumeration);

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

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestFactoryUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestFactoryUtils.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestFactoryUtils.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestFactoryUtils.java Thu Jan 29 18:48:37 2009
@@ -80,7 +80,7 @@
     //------------------------------------------------------------------
     
     public void testNullFactory() {
-        Factory factory = FactoryUtils.nullFactory();
+        Factory<Object> factory = FactoryUtils.nullFactory();
         assertNotNull(factory);
         Object created = factory.create();
         assertNull(created);
@@ -90,7 +90,7 @@
     //------------------------------------------------------------------
     
     public void testConstantFactoryNull() {
-        Factory factory = FactoryUtils.constantFactory(null);
+        Factory<Object> factory = FactoryUtils.constantFactory(null);
         assertNotNull(factory);
         Object created = factory.create();
         assertNull(created);
@@ -98,9 +98,9 @@
 
     public void testConstantFactoryConstant() {
         Integer constant = new Integer(9);
-        Factory factory = FactoryUtils.constantFactory(constant);
+        Factory<Integer> factory = FactoryUtils.constantFactory(constant);
         assertNotNull(factory);
-        Object created = factory.create();
+        Integer created = factory.create();
         assertSame(constant, created);
     }
 
@@ -113,9 +113,9 @@
 
     public void testPrototypeFactoryPublicCloneMethod() throws Exception {
         Date proto = new Date();
-        Factory factory = FactoryUtils.prototypeFactory(proto);
+        Factory<Date> factory = FactoryUtils.prototypeFactory(proto);
         assertNotNull(factory);
-        Object created = factory.create();
+        Date created = factory.create();
         assertTrue(proto != created);
         assertEquals(proto, created);
         
@@ -125,13 +125,13 @@
         out.writeObject(factory);
         out.close();
         ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
-        Object dest = in.readObject();
+        in.readObject();
         in.close();
     }
 
     public void testPrototypeFactoryPublicCopyConstructor() throws Exception {
         Mock1 proto = new Mock1(6);
-        Factory factory = FactoryUtils.prototypeFactory(proto);
+        Factory<Object> factory = FactoryUtils.<Object>prototypeFactory(proto);
         assertNotNull(factory);
         Object created = factory.create();
         assertTrue(proto != created);
@@ -145,21 +145,21 @@
         } catch (NotSerializableException ex) {
             out.close();
         }
-        factory = FactoryUtils.prototypeFactory(new Mock2("S"));
+        factory = FactoryUtils.<Object>prototypeFactory(new Mock2("S"));
         buffer = new ByteArrayOutputStream();
         out = new ObjectOutputStream(buffer);
         out.writeObject(factory);
         out.close();
         ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
-        Object dest = in.readObject();
+        in.readObject();
         in.close();
     }
 
     public void testPrototypeFactoryPublicSerialization() throws Exception {
         Integer proto = new Integer(9);
-        Factory factory = FactoryUtils.prototypeFactory(proto);
+        Factory<Integer> factory = FactoryUtils.prototypeFactory(proto);
         assertNotNull(factory);
-        Object created = factory.create();
+        Integer created = factory.create();
         assertTrue(proto != created);
         assertEquals(proto, created);
         
@@ -169,17 +169,16 @@
         out.writeObject(factory);
         out.close();
         ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
-        Object dest = in.readObject();
+        in.readObject();
         in.close();
     }
 
     public void testPrototypeFactoryPublicSerializationError() {
         Mock2 proto = new Mock2(new Object());
-        Factory factory = FactoryUtils.prototypeFactory(proto);
+        Factory<Object> factory = FactoryUtils.<Object>prototypeFactory(proto);
         assertNotNull(factory);
         try {
-            Object created = factory.create();
-            
+            factory.create();
         } catch (FunctorException ex) {
             assertTrue(ex.getCause() instanceof IOException);
             return;
@@ -190,8 +189,7 @@
     public void testPrototypeFactoryPublicBad() {
         Object proto = new Object();
         try {
-            Factory factory = FactoryUtils.prototypeFactory(proto);
-            
+            FactoryUtils.prototypeFactory(proto);
         } catch (IllegalArgumentException ex) {
             return;
         }
@@ -216,6 +214,7 @@
         }
     }
     
+    @SuppressWarnings("serial")
     public static class Mock2 implements Serializable {
         private final Object iVal;
         public Mock2(Object val) {

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestIteratorUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestIteratorUtils.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestIteratorUtils.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestIteratorUtils.java Thu Jan 29 18:48:37 2009
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -33,9 +33,9 @@
 
 /**
  * Tests for IteratorUtils.
- * 
+ *
  * @version $Revision$ $Date$
- * 
+ *
  * @author Unknown
  */
 public class TestIteratorUtils extends BulkTest {
@@ -53,16 +53,16 @@
     }
 
     public void testToList() {
-        List list = new ArrayList();
+        List<Object> list = new ArrayList<Object>();
         list.add(new Integer(1));
         list.add("Two");
         list.add(null);
-        List result = IteratorUtils.toList(list.iterator());
+        List<Object> result = IteratorUtils.toList(list.iterator());
         assertEquals(list, result);
     }
 
     public void testToArray() {
-        List list = new ArrayList();
+        List<Object> list = new ArrayList<Object>();
         list.add(new Integer(1));
         list.add("Two");
         list.add(null);
@@ -71,137 +71,137 @@
     }
 
     public void testToArray2() {
-        List list = new ArrayList();
+        List<String> list = new ArrayList<String>();
         list.add("One");
         list.add("Two");
         list.add(null);
         String[] result = (String[]) IteratorUtils.toArray(list.iterator(), String.class);
         assertEquals(list, Arrays.asList(result));
     }
-    
+
     public void testArrayIterator() {
         Object[] objArray = {"a", "b", "c"};
-        ResettableIterator iterator = IteratorUtils.arrayIterator(objArray);
+        ResettableIterator<Object> iterator = IteratorUtils.arrayIterator(objArray);
         assertTrue(iterator.next().equals("a"));
         assertTrue(iterator.next().equals("b"));
         iterator.reset();
         assertTrue(iterator.next().equals("a"));
-        
+
         try {
             iterator = IteratorUtils.arrayIterator(new Integer(0));
             fail("Expecting IllegalArgumentException");
         } catch (IllegalArgumentException ex) {
                 // expected
         }
-        
+
         try {
             iterator = IteratorUtils.arrayIterator(null);
             fail("Expecting NullPointerException");
         } catch (NullPointerException ex) {
                 // expected
         }
-        
+
         iterator = IteratorUtils.arrayIterator(objArray, 1);
         assertTrue(iterator.next().equals("b"));
-        
+
         try {
             iterator = IteratorUtils.arrayIterator(objArray, -1);
             fail("Expecting IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
-        
+
         iterator = IteratorUtils.arrayIterator(objArray, 3);
         assertTrue(!iterator.hasNext());
         iterator.reset();
-        
+
         try {
             iterator = IteratorUtils.arrayIterator(objArray, 4);
             fail("Expecting IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
-        
+
         iterator = IteratorUtils.arrayIterator(objArray, 2, 3);
         assertTrue(iterator.next().equals("c"));
-        
+
         try {
             iterator = IteratorUtils.arrayIterator(objArray, 2, 4);
             fail("Expecting IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
-        
+
         try {
             iterator = IteratorUtils.arrayIterator(objArray, -1, 1);
             fail("Expecting IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
-        
+
         try {
             iterator = IteratorUtils.arrayIterator(objArray, 2, 1);
             fail("Expecting IllegalArgumentException");
         } catch (IllegalArgumentException ex) {
             // expected
         }
-        
+
         int[] intArray = {0, 1, 2};
         iterator = IteratorUtils.arrayIterator(intArray);
         assertTrue(iterator.next().equals(new Integer(0)));
         assertTrue(iterator.next().equals(new Integer(1)));
         iterator.reset();
         assertTrue(iterator.next().equals(new Integer(0)));
-        
+
         iterator = IteratorUtils.arrayIterator(intArray, 1);
         assertTrue(iterator.next().equals(new Integer(1)));
-        
+
         try {
             iterator = IteratorUtils.arrayIterator(intArray, -1);
             fail("Expecting IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
-        
+
         iterator = IteratorUtils.arrayIterator(intArray, 3);
         assertTrue(!iterator.hasNext());
         iterator.reset();
-        
+
         try {
             iterator = IteratorUtils.arrayIterator(intArray, 4);
             fail("Expecting IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
-        
+
         iterator = IteratorUtils.arrayIterator(intArray, 2, 3);
         assertTrue(iterator.next().equals(new Integer(2)));
-        
+
         try {
             iterator = IteratorUtils.arrayIterator(intArray, 2, 4);
             fail("Expecting IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
-        
+
         try {
             iterator = IteratorUtils.arrayIterator(intArray, -1, 1);
             fail("Expecting IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
-        
+
         try {
             iterator = IteratorUtils.arrayIterator(intArray, 2, 1);
             fail("Expecting IllegalArgumentException");
         } catch (IllegalArgumentException ex) {
             // expected
-        }          
+        }
     }
-    
+
     public void testArrayListIterator() {
         Object[] objArray = {"a", "b", "c", "d"};
-        ResettableListIterator iterator = IteratorUtils.arrayListIterator(objArray);
+        ResettableListIterator<Object> iterator = IteratorUtils.arrayListIterator(objArray);
         assertTrue(!iterator.hasPrevious());
         assertTrue(iterator.previousIndex() == -1);
         assertTrue(iterator.nextIndex() == 0);
@@ -215,158 +215,158 @@
         assertTrue(iterator.next().equals("d"));
         assertTrue(iterator.nextIndex() == 4); // size of list
         assertTrue(iterator.previousIndex() == 3);
-        
+
         try {
             iterator = IteratorUtils.arrayListIterator(new Integer(0));
             fail("Expecting IllegalArgumentException");
         } catch (IllegalArgumentException ex) {
                 // expected
         }
-        
+
         try {
             iterator = IteratorUtils.arrayListIterator(null);
             fail("Expecting NullPointerException");
         } catch (NullPointerException ex) {
                 // expected
         }
-        
+
         iterator = IteratorUtils.arrayListIterator(objArray, 1);
-        assertTrue(iterator.previousIndex() == -1); 
+        assertTrue(iterator.previousIndex() == -1);
         assertTrue(!iterator.hasPrevious());
-        assertTrue(iterator.nextIndex() == 0); 
+        assertTrue(iterator.nextIndex() == 0);
         assertTrue(iterator.next().equals("b"));
-        assertTrue(iterator.previousIndex() == 0);        
-        
+        assertTrue(iterator.previousIndex() == 0);
+
         try {
             iterator = IteratorUtils.arrayListIterator(objArray, -1);
             fail("Expecting IndexOutOfBoundsException.");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
-        
+
         iterator = IteratorUtils.arrayListIterator(objArray, 3);
         assertTrue(iterator.hasNext());
         try {
-            Object x = iterator.previous();
+            iterator.previous();
             fail("Expecting NoSuchElementException.");
         } catch (NoSuchElementException ex) {
             // expected
         }
-        
+
         try {
             iterator = IteratorUtils.arrayListIterator(objArray, 5);
             fail("Expecting IndexOutOfBoundsException.");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
-        
+
         iterator = IteratorUtils.arrayListIterator(objArray, 2, 3);
         assertTrue(iterator.next().equals("c"));
-        
+
         try {
             iterator = IteratorUtils.arrayListIterator(objArray, 2, 5);
             fail("Expecting IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
-        
+
         try {
             iterator = IteratorUtils.arrayListIterator(objArray, -1, 1);
             fail("Expecting IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
-        
+
         try {
             iterator = IteratorUtils.arrayListIterator(objArray, 2, 1);
             fail("Expecting IllegalArgumentException");
         } catch (IllegalArgumentException ex) {
             // expected
         }
-        
+
         int[] intArray = {0, 1, 2};
         iterator = IteratorUtils.arrayListIterator(intArray);
-        assertTrue(iterator.previousIndex() == -1); 
+        assertTrue(iterator.previousIndex() == -1);
         assertTrue(!iterator.hasPrevious());
-        assertTrue(iterator.nextIndex() == 0); 
+        assertTrue(iterator.nextIndex() == 0);
         assertTrue(iterator.next().equals(new Integer(0)));
-        assertTrue(iterator.previousIndex() == 0); 
-        assertTrue(iterator.nextIndex() == 1); 
+        assertTrue(iterator.previousIndex() == 0);
+        assertTrue(iterator.nextIndex() == 1);
         assertTrue(iterator.next().equals(new Integer(1)));
-        assertTrue(iterator.previousIndex() == 1); 
-        assertTrue(iterator.nextIndex() == 2); 
+        assertTrue(iterator.previousIndex() == 1);
+        assertTrue(iterator.nextIndex() == 2);
         assertTrue(iterator.previous().equals(new Integer(1)));
         assertTrue(iterator.next().equals(new Integer(1)));
-        
+
         iterator = IteratorUtils.arrayListIterator(intArray, 1);
-        assertTrue(iterator.previousIndex() == -1); 
+        assertTrue(iterator.previousIndex() == -1);
         assertTrue(!iterator.hasPrevious());
-        assertTrue(iterator.nextIndex() == 0); 
+        assertTrue(iterator.nextIndex() == 0);
         assertTrue(iterator.next().equals(new Integer(1)));
         assertTrue(iterator.previous().equals(new Integer(1)));
         assertTrue(iterator.next().equals(new Integer(1)));
-        assertTrue(iterator.previousIndex() == 0); 
-        assertTrue(iterator.nextIndex() == 1); 
+        assertTrue(iterator.previousIndex() == 0);
+        assertTrue(iterator.nextIndex() == 1);
         assertTrue(iterator.next().equals(new Integer(2)));
-        assertTrue(iterator.previousIndex() == 1); 
-        assertTrue(iterator.nextIndex() == 2); 
+        assertTrue(iterator.previousIndex() == 1);
+        assertTrue(iterator.nextIndex() == 2);
         assertTrue(iterator.previous().equals(new Integer(2)));
-        assertTrue(iterator.previousIndex() == 0); 
-        assertTrue(iterator.nextIndex() == 1); 
-        
+        assertTrue(iterator.previousIndex() == 0);
+        assertTrue(iterator.nextIndex() == 1);
+
         try {
             iterator = IteratorUtils.arrayListIterator(intArray, -1);
             fail("Expecting IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
-        
+
         iterator = IteratorUtils.arrayListIterator(intArray, 3);
         assertTrue(!iterator.hasNext());
-     
+
         try {
             iterator = IteratorUtils.arrayListIterator(intArray, 4);
             fail("Expecting IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
-        
+
         iterator = IteratorUtils.arrayListIterator(intArray, 2, 3);
         assertTrue(!iterator.hasPrevious());
         assertTrue(iterator.previousIndex() == -1);
         assertTrue(iterator.next().equals(new Integer(2)));
         assertTrue(iterator.hasPrevious());
         assertTrue(!iterator.hasNext());
-        
-        
+
+
         try {
             iterator = IteratorUtils.arrayListIterator(intArray, 2, 4);
             fail("Expecting IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
-        
+
         try {
             iterator = IteratorUtils.arrayListIterator(intArray, -1, 1);
             fail("Expecting IndexOutOfBoundsException");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
-        
+
         try {
             iterator = IteratorUtils.arrayListIterator(intArray, 2, 1);
             fail("Expecting IllegalArgumentException");
         } catch (IllegalArgumentException ex) {
             // expected
-        }          
+        }
     }
-        
+
 
     /**
      * Gets an immutable Iterator operating on the elements ["a", "b", "c", "d"].
      */
-    private Iterator getImmutableIterator() {
-        List list = new ArrayList();
+    private Iterator<String> getImmutableIterator() {
+        List<String> list = new ArrayList<String>();
         list.add("a");
         list.add("b");
         list.add("c");
@@ -377,8 +377,8 @@
     /**
      * Gets an immutable ListIterator operating on the elements ["a", "b", "c", "d"].
      */
-    private ListIterator getImmutableListIterator() {
-        List list = new ArrayList();
+    private ListIterator<String> getImmutableListIterator() {
+        List<String> list = new ArrayList<String>();
         list.add("a");
         list.add("b");
         list.add("c");
@@ -411,7 +411,7 @@
             fail();
         } catch (IllegalStateException ex) {}
     }
-    
+
     //-----------------------------------------------------------------------
     /**
      * Test empty list iterator
@@ -451,11 +451,12 @@
             fail();
         } catch (UnsupportedOperationException ex) {}
     }
-    
+
     //-----------------------------------------------------------------------
     /**
      * Test empty map iterator
      */
+    @SuppressWarnings("unchecked")
     public void testEmptyMapIterator() {
         assertSame(EmptyMapIterator.INSTANCE, IteratorUtils.EMPTY_MAP_ITERATOR);
         assertEquals(true, IteratorUtils.EMPTY_MAP_ITERATOR instanceof Iterator);
@@ -465,7 +466,7 @@
         assertEquals(false, IteratorUtils.EMPTY_MAP_ITERATOR instanceof OrderedIterator);
         assertEquals(false, IteratorUtils.EMPTY_MAP_ITERATOR instanceof OrderedMapIterator);
         assertEquals(false, IteratorUtils.EMPTY_MAP_ITERATOR.hasNext());
-        ((ResettableIterator) IteratorUtils.EMPTY_MAP_ITERATOR).reset();
+        ((ResettableIterator<Object>) IteratorUtils.EMPTY_MAP_ITERATOR).reset();
         assertSame(IteratorUtils.EMPTY_MAP_ITERATOR, IteratorUtils.EMPTY_MAP_ITERATOR);
         assertSame(IteratorUtils.EMPTY_MAP_ITERATOR, IteratorUtils.emptyMapIterator());
         try {
@@ -489,11 +490,12 @@
             fail();
         } catch (IllegalStateException ex) {}
     }
-    
+
     //-----------------------------------------------------------------------
     /**
      * Test empty map iterator
      */
+    @SuppressWarnings("unchecked")
     public void testEmptyOrderedIterator() {
         assertSame(EmptyOrderedIterator.INSTANCE, IteratorUtils.EMPTY_ORDERED_ITERATOR);
         assertEquals(true, IteratorUtils.EMPTY_ORDERED_ITERATOR instanceof Iterator);
@@ -503,7 +505,7 @@
         assertEquals(false, IteratorUtils.EMPTY_ORDERED_ITERATOR instanceof MapIterator);
         assertEquals(false, IteratorUtils.EMPTY_ORDERED_ITERATOR.hasNext());
         assertEquals(false, IteratorUtils.EMPTY_ORDERED_ITERATOR.hasPrevious());
-        ((ResettableIterator) IteratorUtils.EMPTY_ORDERED_ITERATOR).reset();
+        ((ResettableIterator<Object>) IteratorUtils.EMPTY_ORDERED_ITERATOR).reset();
         assertSame(IteratorUtils.EMPTY_ORDERED_ITERATOR, IteratorUtils.EMPTY_ORDERED_ITERATOR);
         assertSame(IteratorUtils.EMPTY_ORDERED_ITERATOR, IteratorUtils.emptyOrderedIterator());
         try {
@@ -519,11 +521,12 @@
             fail();
         } catch (IllegalStateException ex) {}
     }
-    
+
     //-----------------------------------------------------------------------
     /**
      * Test empty map iterator
      */
+    @SuppressWarnings("unchecked")
     public void testEmptyOrderedMapIterator() {
         assertSame(EmptyOrderedMapIterator.INSTANCE, IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR);
         assertEquals(true, IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR instanceof Iterator);
@@ -533,7 +536,7 @@
         assertEquals(false, IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR instanceof ListIterator);
         assertEquals(false, IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR.hasNext());
         assertEquals(false, IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR.hasPrevious());
-        ((ResettableIterator) IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR).reset();
+        ((ResettableIterator<Object>) IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR).reset();
         assertSame(IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR, IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR);
         assertSame(IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR, IteratorUtils.emptyOrderedMapIterator());
         try {
@@ -561,13 +564,13 @@
             fail();
         } catch (IllegalStateException ex) {}
     }
-    
+
     //-----------------------------------------------------------------------
 	/**
 	 * Test next() and hasNext() for an immutable Iterator.
 	 */
     public void testUnmodifiableIteratorIteration() {
-        Iterator iterator = getImmutableIterator();
+        Iterator<String> iterator = getImmutableIterator();
 
         assertTrue(iterator.hasNext());
 
@@ -593,7 +596,7 @@
      * ListIterator.
      */
     public void testUnmodifiableListIteratorIteration() {
-        ListIterator listIterator = getImmutableListIterator();
+        ListIterator<String> listIterator = getImmutableListIterator();
 
         assertTrue(!listIterator.hasPrevious());
         assertTrue(listIterator.hasNext());
@@ -643,7 +646,7 @@
      * Test remove() for an immutable Iterator.
      */
     public void testUnmodifiableIteratorImmutability() {
-        Iterator iterator = getImmutableIterator();
+        Iterator<String> iterator = getImmutableIterator();
 
         try {
             iterator.remove();
@@ -669,7 +672,7 @@
      * Test remove() for an immutable ListIterator.
      */
     public void testUnmodifiableListIteratorImmutability() {
-    	ListIterator listIterator = getImmutableListIterator();
+    	ListIterator<String> listIterator = getImmutableListIterator();
 
         try {
             listIterator.remove();

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

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestListUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestListUtils.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestListUtils.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestListUtils.java Thu Jan 29 18:48:37 2009
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,9 +28,9 @@
 
 /**
  * Tests for ListUtils.
- * 
+ *
  * @version $Revision$ $Date$
- * 
+ *
  * @author Stephen Colebourne
  * @author Neil O'Toole
  * @author Matthew Hawthorne
@@ -46,7 +46,7 @@
 
     private String[] fullArray;
     private List<String> fullList;
-    
+
     public TestListUtils(String name) {
         super(name);
     }
@@ -57,10 +57,9 @@
 
     public void setUp() {
         fullArray = new String[]{a, b, c, d, e};
-        fullList = new ArrayList(Arrays.asList(fullArray));
+        fullList = new ArrayList<String>(Arrays.asList(fullArray));
     }
-    
-    
+
     public void testNothing() {
     }
 
@@ -68,7 +67,7 @@
      * Tests intersecting a non-empty list with an empty list.
      */
     public void testIntersectNonEmptyWithEmptyList() {
-        final List<?> empty = Collections.EMPTY_LIST;
+        final List<String> empty = Collections.<String>emptyList();
         assertTrue("result not empty", ListUtils.intersection(empty, fullList).isEmpty());
     }
 
@@ -85,7 +84,7 @@
      */
     public void testIntersectNonEmptySubset() {
         // create a copy
-        final List<String> other = new ArrayList(fullList);
+        final List<String> other = new ArrayList<String>(fullList);
 
         // remove a few items
         assertNotNull(other.remove(0));
@@ -111,25 +110,21 @@
     }
 
     public void testPredicatedList() {
-        Predicate predicate = new Predicate() {
+        Predicate<Object> predicate = new Predicate<Object>() {
             public boolean evaluate(Object o) {
                 return o instanceof String;
             }
         };
-        List list =
-        ListUtils.predicatedList(new ArrayStack(), predicate);
-        assertTrue("returned object should be a PredicatedList",
-            list instanceof PredicatedList);
+        List<Object> list = ListUtils.predicatedList(new ArrayStack<Object>(), predicate);
+        assertTrue("returned object should be a PredicatedList", list instanceof PredicatedList);
         try {
-            list =
-            ListUtils.predicatedList(new ArrayStack(), null);
+            list = ListUtils.predicatedList(new ArrayStack<Object>(), null);
             fail("Expecting IllegalArgumentException for null predicate.");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
-            list =
-            ListUtils.predicatedList(null, predicate);
+            list = ListUtils.predicatedList(null, predicate);
             fail("Expecting IllegalArgumentException for null list.");
         } catch (IllegalArgumentException ex) {
             // expected
@@ -137,29 +132,29 @@
     }
 
     public void testLazyList() {
-        List list = ListUtils.lazyList(new ArrayList(), new Factory() {
+        List<Integer> list = ListUtils.lazyList(new ArrayList<Integer>(), new Factory<Integer>() {
 
             private int index;
 
-            public Object create() {
+            public Integer create() {
                 index++;
                 return new Integer(index);
             }
         });
 
-        assertNotNull((Integer)list.get(5));
+        assertNotNull(list.get(5));
         assertEquals(6, list.size());
 
-        assertNotNull((Integer)list.get(5));
+        assertNotNull(list.get(5));
         assertEquals(6, list.size());
     }
 
     public void testEquals() {
-        Collection data = Arrays.asList( new String[] { "a", "b", "c" });
-        
-        List a = new ArrayList( data );
-        List b = new ArrayList( data );
-        
+        Collection<String> data = Arrays.asList( new String[] { "a", "b", "c" });
+
+        List<String> a = new ArrayList<String>( data );
+        List<String> b = new ArrayList<String>( data );
+
         assertEquals(true, a.equals(b));
         assertEquals(true, ListUtils.isEqualList(a, b));
         a.clear();
@@ -168,13 +163,13 @@
         assertEquals(false, ListUtils.isEqualList(null, b));
         assertEquals(true, ListUtils.isEqualList(null, null));
     }
-    
+
     public void testHashCode() {
-        Collection data = Arrays.asList( new String[] { "a", "b", "c" });
-            
-        List a = new ArrayList( data );
-        List b = new ArrayList( data );
-        
+        Collection<String> data = Arrays.asList( new String[] { "a", "b", "c" });
+
+        List<String> a = new ArrayList<String>(data);
+        List<String> b = new ArrayList<String>(data);
+
         assertEquals(true, a.hashCode() == b.hashCode());
         assertEquals(true, a.hashCode() == ListUtils.hashCodeForList(a));
         assertEquals(true, b.hashCode() == ListUtils.hashCodeForList(b));
@@ -183,20 +178,20 @@
         assertEquals(false, ListUtils.hashCodeForList(a) == ListUtils.hashCodeForList(b));
         assertEquals(0, ListUtils.hashCodeForList(null));
     }
-    
+
     public void testRetainAll() {
-        List sub = new ArrayList();
+        List<String> sub = new ArrayList<String>();
         sub.add(a);
         sub.add(b);
         sub.add(x);
 
-        List retained = ListUtils.retainAll(fullList, sub);
+        List<String> retained = ListUtils.retainAll(fullList, sub);
         assertTrue(retained.size() == 2);
         sub.remove(x);
         assertTrue(retained.equals(sub));
         fullList.retainAll(sub);
         assertTrue(retained.equals(fullList));
-        
+
         try {
             ListUtils.retainAll(null, null);
             fail("expecting NullPointerException");
@@ -204,20 +199,20 @@
     }
 
     public void testRemoveAll() {
-        List sub = new ArrayList();
+        List<String> sub = new ArrayList<String>();
         sub.add(a);
         sub.add(b);
         sub.add(x);
 
-        List remainder = ListUtils.removeAll(fullList, sub);
+        List<String> remainder = ListUtils.removeAll(fullList, sub);
         assertTrue(remainder.size() == 3);
         fullList.removeAll(sub);
         assertTrue(remainder.equals(fullList));
-        
+
         try {
             ListUtils.removeAll(null, null);
             fail("expecting NullPointerException");
         } catch(NullPointerException npe) {} // this is what we want
     }
-    
+
 }



Mime
View raw message