commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r815006 [1/2] - in /commons/proper/collections/trunk/src: java/org/apache/commons/collections/ test/org/apache/commons/collections/collection/
Date Tue, 15 Sep 2009 05:44:37 GMT
Author: bayard
Date: Tue Sep 15 05:44:36 2009
New Revision: 815006

URL: http://svn.apache.org/viewvc?rev=815006&view=rev
Log:
Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified in r738956, r471214 and/or r471578.


Modified:
    commons/proper/collections/trunk/src/java/org/apache/commons/collections/BidiMap.java
    commons/proper/collections/trunk/src/java/org/apache/commons/collections/Buffer.java
    commons/proper/collections/trunk/src/java/org/apache/commons/collections/KeyValue.java
    commons/proper/collections/trunk/src/java/org/apache/commons/collections/OrderedBidiMap.java
    commons/proper/collections/trunk/src/java/org/apache/commons/collections/OrderedMap.java
    commons/proper/collections/trunk/src/java/org/apache/commons/collections/OrderedMapIterator.java
    commons/proper/collections/trunk/src/java/org/apache/commons/collections/ResettableIterator.java
    commons/proper/collections/trunk/src/java/org/apache/commons/collections/SortedBag.java
    commons/proper/collections/trunk/src/java/org/apache/commons/collections/SortedBidiMap.java
    commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/AbstractTestCollection.java
    commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/TestPredicatedCollection.java
    commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/TestSynchronizedCollection.java
    commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/TestTransformedCollection.java
    commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/TestUnmodifiableCollection.java

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/BidiMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/BidiMap.java?rev=815006&r1=815005&r2=815006&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/BidiMap.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/BidiMap.java Tue Sep 15 05:44:36 2009
@@ -33,34 +33,17 @@
  * This is required so that "inverting" the map results in a map without 
  * duplicate keys. See the {@link #put} method description for more information.
  *
+ * @param <K> the type of the keys in the map
+ * @param <V> the type of the values in the map
+ *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
  *
  * @author Stephen Colebourne
  */
-public interface BidiMap extends IterableMap {
+public interface BidiMap<K, V> extends IterableMap<K, V> {
 
     /**
-     * Obtains a <code>MapIterator</code> over the map.
-     * <p>
-     * A map iterator is an efficient way of iterating over maps.
-     * It does not require that the map is stored using Map Entry objects
-     * which can increase performance.
-     * <pre>
-     * BidiMap map = new DualHashBidiMap();
-     * MapIterator it = map.mapIterator();
-     * while (it.hasNext()) {
-     *   Object key = it.next();
-     *   Object value = it.getValue();
-     *   it.setValue("newValue");
-     * }
-     * </pre>
-     * 
-     * @return a map iterator
-     */
-    MapIterator mapIterator();
-    
-    /**
      * Puts the key-value pair into the map, replacing any previous pair.
      * <p>
      * When adding a key-value pair, the value may already exist in the map
@@ -88,8 +71,8 @@
      * @throws NullPointerException (optional) if the map limits the values to
      *  non-null and null was specified
      */
-    Object put(Object key, Object value);
-    
+    V put(K key, V value);
+
     /**
      * Gets the key that is currently mapped to the specified value.
      * <p>
@@ -106,8 +89,8 @@
      * @throws NullPointerException (optional) if the map limits the values to
      *  non-null and null was specified
      */
-    Object getKey(Object value);
-    
+    K getKey(Object value);
+
     /**
      * Removes the key-value pair that is currently mapped to the specified
      * value (optional operation).
@@ -127,8 +110,8 @@
      * @throws UnsupportedOperationException if this method is not supported
      *  by the implementation
      */
-    Object removeValue(Object value);
-    
+    K removeValue(Object value);
+
     /**
      * Gets a view of this map where the keys and values are reversed.
      * <p>
@@ -141,6 +124,6 @@
      *
      * @return an inverted bidirectional map
      */
-    BidiMap inverseBidiMap();
-    
+    BidiMap<V, K> inverseBidiMap();
+
 }

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/Buffer.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/Buffer.java?rev=815006&r1=815005&r2=815006&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/Buffer.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/Buffer.java Tue Sep 15 05:44:36 2009
@@ -35,6 +35,7 @@
  * also implement {@link java.util.List}, {@link java.util.Set} or 
  * {@link Bag}.
  *
+ * @param <E> the type of the elements in the buffer
  * @since Commons Collections 2.1
  * @version $Revision$ $Date$
  *
@@ -43,7 +44,7 @@
  * @author Paul Jack
  * @author Stephen Colebourne
  */
-public interface Buffer extends Collection {
+public interface Buffer<E> extends Collection<E> {
 
     /**
      * Gets and removes the next object from the buffer.
@@ -51,7 +52,7 @@
      * @return the next object in the buffer, which is also removed
      * @throws BufferUnderflowException if the buffer is already empty
      */
-    Object remove();
+    E remove();
 
     /**
      * Gets the next object from the buffer without removing it.
@@ -59,6 +60,6 @@
      * @return the next object in the buffer, which is not removed
      * @throws BufferUnderflowException if the buffer is empty
      */
-    Object get();
+    E get();
 
 }

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/KeyValue.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/KeyValue.java?rev=815006&r1=815005&r2=815006&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/KeyValue.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/KeyValue.java Tue Sep 15 05:44:36 2009
@@ -23,25 +23,27 @@
  * key-value pair. This interface defines the minimum key value, with just the
  * two get methods.
  *
+ * @param <K> the type of the key
+ * @param <V> the type of the value
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
  *
  * @author Stephen Colebourne
  */
-public interface KeyValue {
+public interface KeyValue<K, V> {
 
     /**
      * Gets the key from the pair.
      *
      * @return the key 
      */
-    Object getKey();
+    K getKey();
 
     /**
      * Gets the value from the pair.
      *
      * @return the value
      */
-    Object getValue();
+    V getValue();
 
 }

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/OrderedBidiMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/OrderedBidiMap.java?rev=815006&r1=815005&r2=815006&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/OrderedBidiMap.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/OrderedBidiMap.java Tue Sep 15 05:44:36 2009
@@ -23,12 +23,15 @@
  * Implementations should allow a value to be looked up from a key and
  * a key to be looked up from a value with equal performance.
  *
+ * @param <K> the type of the keys in the map
+ * @param <V> the type of the values in the map
+ *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
  *
  * @author Stephen Colebourne
  */
-public interface OrderedBidiMap extends BidiMap, OrderedMap {
+public interface OrderedBidiMap<K, V> extends BidiMap<K, V>, OrderedMap<K, V> {
 
     /**
      * Gets a view of this map where the keys and values are reversed.
@@ -45,20 +48,6 @@
      *
      * @return an inverted bidirectional map
      */
-    public BidiMap inverseBidiMap();
-    
-    /**
-     * Gets a view of this map where the keys and values are reversed.
-     * <p>
-     * Changes to one map will be visible in the other and vice versa.
-     * This enables both directions of the map to be accessed equally.
-     * <p>
-     * Implementations should seek to avoid creating a new object every time this
-     * method is called. See <code>AbstractMap.values()</code> etc. Calling this
-     * method on the inverse map should return the original.
-     *
-     * @return an inverted bidirectional map
-     */
-    public OrderedBidiMap inverseOrderedBidiMap();
-    
+    public OrderedBidiMap<V, K> inverseBidiMap();
+
 }

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/OrderedMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/OrderedMap.java?rev=815006&r1=815005&r2=815006&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/OrderedMap.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/OrderedMap.java Tue Sep 15 05:44:36 2009
@@ -20,40 +20,33 @@
  * Defines a map that maintains order and allows both forward and backward
  * iteration through that order.
  *
+ * @param <K> the type of the keys in the map
+ * @param <V> the type of the values in the map
+ *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
  *
  * @author Stephen Colebourne
  */
-public interface OrderedMap extends IterableMap {
-    
+public interface OrderedMap<K, V> extends IterableMap<K, V> {
+
     /**
      * Obtains an <code>OrderedMapIterator</code> over the map.
      * <p>
      * A ordered map iterator is an efficient way of iterating over maps
      * in both directions.
-     * <pre>
-     * BidiMap map = new TreeBidiMap();
-     * MapIterator it = map.mapIterator();
-     * while (it.hasNext()) {
-     *   Object key = it.next();
-     *   Object value = it.getValue();
-     *   it.setValue("newValue");
-     *   Object previousKey = it.previous();
-     * }
-     * </pre>
      * 
      * @return a map iterator
      */
-    OrderedMapIterator orderedMapIterator();
-    
+    OrderedMapIterator<K, V> mapIterator();
+
     /**
      * Gets the first key currently in this map.
      *
      * @return the first key currently in this map
      * @throws java.util.NoSuchElementException if this map is empty
      */
-    public Object firstKey();
+    public K firstKey();
 
     /**
      * Gets the last key currently in this map.
@@ -61,15 +54,15 @@
      * @return the last key currently in this map
      * @throws java.util.NoSuchElementException if this map is empty
      */
-    public Object lastKey();
-    
+    public K lastKey();
+
     /**
      * Gets the next key after the one specified.
      *
      * @param key  the key to search for next from
      * @return the next key, null if no match or at end
      */
-    public Object nextKey(Object key);
+    public K nextKey(K key);
 
     /**
      * Gets the previous key before the one specified.
@@ -77,6 +70,6 @@
      * @param key  the key to search for previous from
      * @return the previous key, null if no match or at start
      */
-    public Object previousKey(Object key);
-    
+    public K previousKey(K key);
+
 }

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/OrderedMapIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/OrderedMapIterator.java?rev=815006&r1=815005&r2=815006&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/OrderedMapIterator.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/OrderedMapIterator.java Tue Sep 15 05:44:36 2009
@@ -16,18 +16,22 @@
  */
 package org.apache.commons.collections;
 
+import java.util.NoSuchElementException;
+
 /**
  * Defines an iterator that operates over an ordered <code>Map</code>.
  * <p>
  * This iterator allows both forward and reverse iteration through the map.
- *  
+ *
+ * @param <K> the type of the keys in the map
+ * @param <V> the type of the values in the map
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
  *
  * @author Stephen Colebourne
  */
-public interface OrderedMapIterator extends MapIterator, OrderedIterator {
-    
+public interface OrderedMapIterator<K, V> extends MapIterator<K, V>, OrderedIterator<K> {
+
     /**
      * Checks to see if there is a previous entry that can be iterated to.
      *
@@ -39,8 +43,8 @@
      * Gets the previous <em>key</em> from the <code>Map</code>.
      *
      * @return the previous key in the iteration
-     * @throws java.util.NoSuchElementException if the iteration is finished
+     * @throws NoSuchElementException if the iteration is finished
      */
-    Object previous();
+    K previous();
 
 }

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/ResettableIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/ResettableIterator.java?rev=815006&r1=815005&r2=815006&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/ResettableIterator.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/ResettableIterator.java Tue Sep 15 05:44:36 2009
@@ -23,12 +23,13 @@
  * <p>
  * This interface allows an iterator to be repeatedly reused.
  *
+ * @param <E> the type to iterate over
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
  *
  * @author Stephen Colebourne
  */
-public interface ResettableIterator extends Iterator {
+public interface ResettableIterator<E> extends Iterator<E> {
 
     /**
      * Resets the iterator back to the position at which the iterator

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/SortedBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/SortedBag.java?rev=815006&r1=815005&r2=815006&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/SortedBag.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/SortedBag.java Tue Sep 15 05:44:36 2009
@@ -22,12 +22,13 @@
  * Defines a type of <code>Bag</code> that maintains a sorted order among
  * its unique representative members.
  *
+ * @param <E> the type to iterate over
  * @since Commons Collections 2.0
  * @version $Revision$ $Date$
  *
  * @author Chuck Burdick
  */
-public interface SortedBag extends Bag {
+public interface SortedBag<E> extends Bag<E> {
 
     /**
      * Returns the comparator associated with this sorted set, or null
@@ -35,20 +36,20 @@
      * 
      * @return the comparator in use, or null if natural ordering
      */
-    public Comparator comparator();
+    public Comparator<? super E> comparator();
 
     /**
      * Returns the first (lowest) member.
      * 
      * @return the first element in the sorted bag
      */
-    public Object first();
+    public E first();
 
     /**
      * Returns the last (highest) member.
      * 
      * @return the last element in the sorted bag
      */
-    public Object last();
-    
+    public E last();
+
 }

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/SortedBidiMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/SortedBidiMap.java?rev=815006&r1=815005&r2=815006&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/SortedBidiMap.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/SortedBidiMap.java Tue Sep 15 05:44:36 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.collections;
 
+import java.util.Comparator;
 import java.util.SortedMap;
 
 /**
@@ -25,12 +26,14 @@
  * Implementations should allow a value to be looked up from a key and
  * a key to be looked up from a value with equal performance.
  *  
+ * @param <K> the type of the keys in the map
+ * @param <V> the type of the values in the map
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
  *
  * @author Stephen Colebourne
  */
-public interface SortedBidiMap extends OrderedBidiMap, SortedMap {
+public interface SortedBidiMap<K, V> extends OrderedBidiMap<K, V>, SortedMap<K, V> {
 
     /**
      * Gets a view of this map where the keys and values are reversed.
@@ -47,23 +50,11 @@
      *
      * @return an inverted bidirectional map
      */
-    public BidiMap inverseBidiMap();
-    
+    public SortedBidiMap<V, K> inverseBidiMap();
+
     /**
-     * Gets a view of this map where the keys and values are reversed.
-     * <p>
-     * Changes to one map will be visible in the other and vice versa.
-     * This enables both directions of the map to be accessed as a <code>SortedMap</code>.
-     * <p>
-     * Implementations should seek to avoid creating a new object every time this
-     * method is called. See <code>AbstractMap.values()</code> etc. Calling this
-     * method on the inverse map should return the original.
-     * <p>
-     * The inverse map returned by <code>inverseBidiMap()</code> should be the
-     * same object as returned by this method.
-     *
-     * @return an inverted bidirectional map
+     * Get the comparator used for the values in the value-to-key map aspect.
+     * @return Comparator<? super V>
      */
-    public SortedBidiMap inverseSortedBidiMap();
-    
+    public Comparator<? super V> valueComparator();
 }

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/AbstractTestCollection.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/AbstractTestCollection.java?rev=815006&r1=815005&r2=815006&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/AbstractTestCollection.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/AbstractTestCollection.java Tue Sep 15 05:44:36 2009
@@ -40,8 +40,8 @@
  * Abstract test class for {@link java.util.Collection} methods and contracts.
  * <p>
  * You should create a concrete subclass of this class to test any custom
- * {@link Collection} implementation.  At minimum, you'll have to 
- * implement the {@link #makeCollection()} method.  You might want to 
+ * {@link Collection} implementation.  At minimum, you'll have to
+ * implement the {@link #makeCollection()} method.  You might want to
  * override some of the additional public methods as well:
  * <p>
  * <b>Element Population Methods</b>
@@ -81,7 +81,7 @@
  * <p>
  * The {@link #collection} field holds an instance of your collection
  * implementation; the {@link #confirmed} field holds an instance of the
- * confirmed collection implementation.  The {@link #resetEmpty()} and 
+ * confirmed collection implementation.  The {@link #resetEmpty()} and
  * {@link #resetFull()} methods set these fields to empty or full collections,
  * so that tests can proceed from a known state.
  * <p>
@@ -92,14 +92,14 @@
  * views of a map, {@link AbstractTestMap} would override {@link #verify()} to make
  * sure the map is changed after the collection view is changed.
  * <p>
- * If you're extending this class directly, you will have to provide 
+ * If you're extending this class directly, you will have to provide
  * implementations for the following:
  * <ul>
  * <li>{@link #makeConfirmedCollection()}
  * <li>{@link #makeConfirmedFullCollection()}
  * </ul>
  * <p>
- * Those methods should provide a confirmed collection implementation 
+ * Those methods should provide a confirmed collection implementation
  * that's compatible with your collection implementation.
  * <p>
  * If you're extending {@link AbstractTestList}, {@link AbstractTestSet},
@@ -121,10 +121,10 @@
  * @author Neil O'Toole
  * @author Stephen Colebourne
  */
-public abstract class AbstractTestCollection extends AbstractTestObject {
+public abstract class AbstractTestCollection<E> extends AbstractTestObject {
 
     //
-    // NOTE: 
+    // NOTE:
     //
     // Collection doesn't define any semantics for equals, and recommends you
     // use reference-based default behavior of Object.equals.  (And a test for
@@ -133,28 +133,27 @@
     // tests on Collection.equals nor any for Collection.hashCode.
     //
 
-
     // These fields are used by reset() and verify(), and any test
     // method that tests a modification.
 
-    /** 
+    /**
      *  A collection instance that will be used for testing.
      */
-    public Collection collection;
+    private Collection<E> collection;
 
-    /** 
+    /**
      *  Confirmed collection.  This is an instance of a collection that is
      *  confirmed to conform exactly to the java.util.Collection contract.
-     *  Modification operations are tested by performing a mod on your 
+     *  Modification operations are tested by performing a mod on your
      *  collection, performing the exact same mod on an equivalent confirmed
      *  collection, and then calling verify() to make sure your collection
      *  still matches the confirmed collection.
      */
-    public Collection confirmed;
+    private Collection<E> confirmed;
 
     /**
      * JUnit constructor.
-     * 
+     *
      * @param testName  the test class name
      */
     public AbstractTestCollection(String testName) {
@@ -167,7 +166,7 @@
      *  distinguishable with information not readily available.  That is, if a
      *  particular value is to be removed from the collection, then there is
      *  one and only one value that can be removed, even if there are other
-     *  elements which are equal to it.  
+     *  elements which are equal to it.
      *
      *  <P>In most collection cases, elements are not distinguishable (equal is
      *  equal), thus this method defaults to return false.  In some cases,
@@ -189,7 +188,7 @@
     }
 
     /**
-     *  Returns true if the collections produced by 
+     *  Returns true if the collections produced by
      *  {@link #makeCollection()} and {@link #makeFullCollection()}
      *  support the <code>add</code> and <code>addAll</code>
      *  operations.<P>
@@ -201,7 +200,7 @@
     }
 
     /**
-     *  Returns true if the collections produced by 
+     *  Returns true if the collections produced by
      *  {@link #makeCollection()} and {@link #makeFullCollection()}
      *  support the <code>remove</code>, <code>removeAll</code>,
      *  <code>retainAll</code>, <code>clear</code> and
@@ -239,16 +238,15 @@
 
     //-----------------------------------------------------------------------
     /**
-     *  Verifies that {@link #collection} and {@link #confirmed} have 
+     *  Verifies that {@link #collection} and {@link #confirmed} have
      *  identical state.
      */
     public void verify() {
-        int confirmedSize = confirmed.size();
-        assertEquals("Collection size should match confirmed collection's",
-                     confirmedSize, collection.size());
-        assertEquals("Collection isEmpty() result should match confirmed " +
-                     " collection's", 
-                     confirmed.isEmpty(), collection.isEmpty());
+        int confirmedSize = getConfirmed().size();
+        assertEquals("Collection size should match confirmed collection's", confirmedSize,
+                getCollection().size());
+        assertEquals("Collection isEmpty() result should match confirmed collection's",
+                getConfirmed().isEmpty(), getCollection().isEmpty());
 
         // verify the collections are the same by attempting to match each
         // object in the collection and confirmed collection.  To account for
@@ -262,31 +260,30 @@
         // copy each collection value into an array
         Object[] confirmedValues = new Object[confirmedSize];
 
-        Iterator iter;
+        Iterator<E> iter;
 
-        iter = confirmed.iterator(); 
+        iter = getConfirmed().iterator();
         int pos = 0;
-        while(iter.hasNext()) {
+        while (iter.hasNext()) {
             confirmedValues[pos++] = iter.next();
         }
 
         // allocate an array of boolean flags for tracking values that have
         // been matched once and only once.
         boolean[] matched = new boolean[confirmedSize];
-        
+
         // now iterate through the values of the collection and try to match
         // the value with one in the confirmed array.
-        iter = collection.iterator();
-        while(iter.hasNext()) {
+        iter = getCollection().iterator();
+        while (iter.hasNext()) {
             Object o = iter.next();
             boolean match = false;
-            for(int i = 0; i < confirmedSize; i++) {
-                if(matched[i]) {
+            for (int i = 0; i < confirmedSize; i++) {
+                if (matched[i]) {
                     // skip values already matched
                     continue;
                 }
-                if(o == confirmedValues[i] ||
-                   (o != null && o.equals(confirmedValues[i]))) {
+                if (o == confirmedValues[i] || (o != null && o.equals(confirmedValues[i]))) {
                     // values matched
                     matched[i] = true;
                     match = true;
@@ -294,23 +291,23 @@
                 }
             }
             // no match found!
-            if(!match) {
-                fail("Collection should not contain a value that the " +
-                     "confirmed collection does not have: " + o +
-                     "\nTest: " + collection + "\nReal: " + confirmed);
+            if (!match) {
+                fail("Collection should not contain a value that the "
+                        + "confirmed collection does not have: " + o + "\nTest: " + getCollection()
+                        + "\nReal: " + getConfirmed());
             }
         }
-        
+
         // make sure there aren't any unmatched values
-        for(int i = 0; i < confirmedSize; i++) {
-            if(!matched[i]) {
+        for (int i = 0; i < confirmedSize; i++) {
+            if (!matched[i]) {
                 // the collection didn't match all the confirmed values
-                fail("Collection should contain all values that are in the confirmed collection" +
-                     "\nTest: " + collection + "\nReal: " + confirmed);
+                fail("Collection should contain all values that are in the confirmed collection"
+                        + "\nTest: " + getCollection() + "\nReal: " + getConfirmed());
             }
         }
     }
-    
+
     //-----------------------------------------------------------------------
     /**
      *  Resets the {@link #collection} and {@link #confirmed} fields to empty
@@ -318,8 +315,8 @@
      *  test.
      */
     public void resetEmpty() {
-        this.collection = makeCollection();
-        this.confirmed = makeConfirmedCollection();
+        this.setCollection(makeObject());
+        this.setConfirmed(makeConfirmedCollection());
     }
 
     /**
@@ -328,8 +325,8 @@
      *  test.
      */
     public void resetFull() {
-        this.collection = makeFullCollection();
-        this.confirmed = makeConfirmedFullCollection();
+        this.setCollection(makeFullCollection());
+        this.setConfirmed(makeConfirmedFullCollection());
     }
 
     //-----------------------------------------------------------------------
@@ -340,7 +337,7 @@
      *
      *  @return a confirmed empty collection
      */
-    public abstract Collection makeConfirmedCollection();
+    public abstract Collection<E> makeConfirmedCollection();
 
     /**
      *  Returns a confirmed full collection.
@@ -350,12 +347,12 @@
      *
      *  @return a confirmed full collection
      */
-    public abstract Collection makeConfirmedFullCollection();
+    public abstract Collection<E> makeConfirmedFullCollection();
 
     /**
      * Return a new, empty {@link Collection} to be used for testing.
      */
-    public abstract Collection makeCollection();
+    public abstract Collection<E> makeObject();
 
     /**
      *  Returns a full collection to be used for testing.  The collection
@@ -365,26 +362,19 @@
      *  the results of {@link #getFullElements()}.  Override this default
      *  if your collection doesn't support addAll.
      */
-    public Collection makeFullCollection() {
-        Collection c = makeCollection();
+    public Collection<E> makeFullCollection() {
+        Collection<E> c = makeObject();
         c.addAll(Arrays.asList(getFullElements()));
         return c;
     }
 
     /**
-     *  Returns an empty collection for Object tests.
-     */
-    public Object makeObject() {
-        return makeCollection();
-    }
-
-    /**
      * Creates a new Map Entry that is independent of the first and the map.
      */
-    public Map.Entry cloneMapEntry(Map.Entry entry) {
-        HashMap map = new HashMap();
+    public Map.Entry<E, E> cloneMapEntry(Map.Entry<E, E> entry) {
+        HashMap<E, E> map = new HashMap<E, E>();
         map.put(entry.getKey(), entry.getValue());
-        return (Map.Entry) map.entrySet().iterator().next();
+        return map.entrySet().iterator().next();
     }
 
     //-----------------------------------------------------------------------
@@ -392,47 +382,48 @@
      *  Returns an array of objects that are contained in a collection
      *  produced by {@link #makeFullCollection()}.  Every element in the
      *  returned array <I>must</I> be an element in a full collection.<P>
-     *  The default implementation returns a heterogenous array of 
+     *  The default implementation returns a heterogenous array of
      *  objects with some duplicates. null is added if allowed.
      *  Override if you require specific testing elements.  Note that if you
      *  override {@link #makeFullCollection()}, you <I>must</I> override
      *  this method to reflect the contents of a full collection.
      */
-    public Object[] getFullElements() {
+    @SuppressWarnings("unchecked")
+    public E[] getFullElements() {
         if (isNullSupported()) {
-            ArrayList list = new ArrayList();
+            ArrayList<E> list = new ArrayList<E>();
             list.addAll(Arrays.asList(getFullNonNullElements()));
             list.add(4, null);
-            return list.toArray();
-        } else {
-            return (Object[]) getFullNonNullElements().clone();
+            return (E[]) list.toArray();
         }
+        return getFullNonNullElements().clone();
     }
 
     /**
      *  Returns an array of elements that are <I>not</I> contained in a
-     *  full collection.  Every element in the returned array must 
+     *  full collection.  Every element in the returned array must
      *  not exist in a collection returned by {@link #makeFullCollection()}.
      *  The default implementation returns a heterogenous array of elements
      *  without null.  Note that some of the tests add these elements
      *  to an empty or full collection, so if your collection restricts
      *  certain kinds of elements, you should override this method.
      */
-    public Object[] getOtherElements() {
+    public E[] getOtherElements() {
         return getOtherNonNullElements();
     }
-    
+
     //-----------------------------------------------------------------------
     /**
      *  Returns a list of elements suitable for return by
      *  {@link #getFullElements()}.  The array returned by this method
-     *  does not include null, but does include a variety of objects 
+     *  does not include null, but does include a variety of objects
      *  of different types.  Override getFullElements to return
      *  the results of this method if your collection does not support
      *  the null element.
      */
-    public Object[] getFullNonNullElements() {
-        return new Object[] {
+    @SuppressWarnings("unchecked")
+    public E[] getFullNonNullElements() {
+        return (E[]) new Object[] {
             new String(""),
             new String("One"),
             new Integer(2),
@@ -455,12 +446,13 @@
     }
 
     /**
-     *  Returns the default list of objects returned by 
+     *  Returns the default list of objects returned by
      *  {@link #getOtherElements()}.  Includes many objects
      *  of different types.
      */
-    public Object[] getOtherNonNullElements() {
-        return new Object[] {
+    @SuppressWarnings("unchecked")
+    public E[] getOtherNonNullElements() {
+        return (E[]) new Object[] {
             new Integer(0),
             new Float(0),
             new Double(0),
@@ -481,8 +473,8 @@
      */
     public Object[] getFullNonNullStringElements() {
         return new Object[] {
-            "If","the","dull","substance","of","my","flesh","were","thought",
-            "Injurious","distance","could","not","stop","my","way",
+            "If", "the", "dull", "substance", "of", "my", "flesh", "were",
+                "thought", "Injurious", "distance", "could", "not", "stop", "my", "way",
         };
     }
 
@@ -494,44 +486,41 @@
      */
     public Object[] getOtherNonNullStringElements() {
         return new Object[] {
-            "For","then","despite",/* of */"space","I","would","be","brought",
-            "From","limits","far","remote","where","thou","dost","stay"
+            "For", "then", "despite",/* of */"space", "I", "would", "be",
+                "brought", "From", "limits", "far", "remote", "where", "thou", "dost", "stay"
         };
     }
 
-    // Tests    
+    // Tests
     //-----------------------------------------------------------------------
     /**
      *  Tests {@link Collection#add(Object)}.
      */
     public void testCollectionAdd() {
         if (!isAddSupported()) return;
-        
-        Object[] elements = getFullElements();
+
+        E[] elements = getFullElements();
         for (int i = 0; i < elements.length; i++) {
             resetEmpty();
-            boolean r = collection.add(elements[i]);
-            confirmed.add(elements[i]);
+            boolean r = getCollection().add(elements[i]);
+            getConfirmed().add(elements[i]);
             verify();
             assertTrue("Empty collection changed after add", r);
-            assertEquals("Collection size is 1 after first add", 1, collection.size());
+            assertEquals("Collection size is 1 after first add", 1, getCollection().size());
         }
-        
+
         resetEmpty();
         int size = 0;
         for (int i = 0; i < elements.length; i++) {
-            boolean r = collection.add(elements[i]);
-            confirmed.add(elements[i]);
+            boolean r = getCollection().add(elements[i]);
+            getConfirmed().add(elements[i]);
             verify();
             if (r) size++;
-            assertEquals("Collection size should grow after add", 
-                         size, collection.size());
-            assertTrue("Collection should contain added element",
-                       collection.contains(elements[i]));
+            assertEquals("Collection size should grow after add", size, getCollection().size());
+            assertTrue("Collection should contain added element", getCollection().contains(elements[i]));
         }
     }
-    
-    
+
     /**
      *  Tests {@link Collection#addAll(Collection)}.
      */
@@ -539,56 +528,51 @@
         if (!isAddSupported()) return;
 
         resetEmpty();
-        Object[] elements = getFullElements();
-        boolean r = collection.addAll(Arrays.asList(elements));
-        confirmed.addAll(Arrays.asList(elements));
+        E[] elements = getFullElements();
+        boolean r = getCollection().addAll(Arrays.asList(elements));
+        getConfirmed().addAll(Arrays.asList(elements));
         verify();
         assertTrue("Empty collection should change after addAll", r);
         for (int i = 0; i < elements.length; i++) {
-            assertTrue("Collection should contain added element",
-                       collection.contains(elements[i]));
+            assertTrue("Collection should contain added element", getCollection().contains(elements[i]));
         }
 
         resetFull();
-        int size = collection.size();
+        int size = getCollection().size();
         elements = getOtherElements();
-        r = collection.addAll(Arrays.asList(elements));
-        confirmed.addAll(Arrays.asList(elements));
+        r = getCollection().addAll(Arrays.asList(elements));
+        getConfirmed().addAll(Arrays.asList(elements));
         verify();
         assertTrue("Full collection should change after addAll", r);
         for (int i = 0; i < elements.length; i++) {
             assertTrue("Full collection should contain added element",
-                       collection.contains(elements[i]));
+                    getCollection().contains(elements[i]));
         }
-        assertEquals("Size should increase after addAll", 
-                     size + elements.length, collection.size());
-        
-        resetFull();
-        size = collection.size();
-        r = collection.addAll(Arrays.asList(getFullElements()));
-        confirmed.addAll(Arrays.asList(getFullElements()));
+        assertEquals("Size should increase after addAll", size + elements.length, getCollection().size());
+
+        resetFull();
+        size = getCollection().size();
+        r = getCollection().addAll(Arrays.asList(getFullElements()));
+        getConfirmed().addAll(Arrays.asList(getFullElements()));
         verify();
         if (r) {
-            assertTrue("Size should increase if addAll returns true", 
-                       size < collection.size());
+            assertTrue("Size should increase if addAll returns true", size < getCollection().size());
         } else {
-            assertEquals("Size should not change if addAll returns false",
-                         size, collection.size());
-        } 
+            assertEquals("Size should not change if addAll returns false", size, getCollection().size());
+        }
     }
 
-
     /**
      *  If {@link #isAddSupported()} returns false, tests that add operations
      *  raise <code>UnsupportedOperationException.
      */
     public void testUnsupportedAdd() {
         if (isAddSupported()) return;
-        
+
         resetEmpty();
         try {
-            collection.add(new Object());
-            fail("Emtpy collection should not support add.");
+            getCollection().add(getFullNonNullElements()[0]);
+            fail("Empty collection should not support add.");
         } catch (UnsupportedOperationException e) {
             // expected
         }
@@ -597,8 +581,8 @@
         verify();
 
         try {
-            collection.addAll(Arrays.asList(getFullElements()));
-            fail("Emtpy collection should not support addAll.");
+            getCollection().addAll(Arrays.asList(getFullElements()));
+            fail("Empty collection should not support addAll.");
         } catch (UnsupportedOperationException e) {
             // expected
         }
@@ -608,7 +592,7 @@
 
         resetFull();
         try {
-            collection.add(new Object());
+            getCollection().add(getFullNonNullElements()[0]);
             fail("Full collection should not support add.");
         } catch (UnsupportedOperationException e) {
             // expected
@@ -616,9 +600,9 @@
         // make sure things didn't change even if the expected exception was
         // thrown.
         verify();
-        
+
         try {
-            collection.addAll(Arrays.asList(getOtherElements()));
+            getCollection().addAll(Arrays.asList(getOtherElements()));
             fail("Full collection should not support addAll.");
         } catch (UnsupportedOperationException e) {
             // expected
@@ -628,7 +612,6 @@
         verify();
     }
 
-
     /**
      *  Test {@link Collection#clear()}.
      */
@@ -636,16 +619,15 @@
         if (!isRemoveSupported()) return;
 
         resetEmpty();
-        collection.clear(); // just to make sure it doesn't raise anything
+        getCollection().clear(); // just to make sure it doesn't raise anything
         verify();
 
         resetFull();
-        collection.clear();
-        confirmed.clear();
+        getCollection().clear();
+        getConfirmed().clear();
         verify();
-    }    
+    }
 
-    
     /**
      *  Tests {@link Collection#contains(Object)}.
      */
@@ -654,80 +636,78 @@
 
         resetEmpty();
         elements = getFullElements();
-        for(int i = 0; i < elements.length; i++) {
+        for (int i = 0; i < elements.length; i++) {
             assertTrue("Empty collection shouldn't contain element[" + i + "]",
-                       !collection.contains(elements[i]));
+                    !getCollection().contains(elements[i]));
         }
         // make sure calls to "contains" don't change anything
         verify();
 
         elements = getOtherElements();
-        for(int i = 0; i < elements.length; i++) {
+        for (int i = 0; i < elements.length; i++) {
             assertTrue("Empty collection shouldn't contain element[" + i + "]",
-                       !collection.contains(elements[i]));
+                    !getCollection().contains(elements[i]));
         }
         // make sure calls to "contains" don't change anything
         verify();
 
         resetFull();
         elements = getFullElements();
-        for(int i = 0; i < elements.length; i++) {
-            assertTrue("Full collection should contain element[" + i + "]", 
-                       collection.contains(elements[i]));
+        for (int i = 0; i < elements.length; i++) {
+            assertTrue("Full collection should contain element[" + i + "]",
+                    getCollection().contains(elements[i]));
         }
         // make sure calls to "contains" don't change anything
         verify();
 
         resetFull();
         elements = getOtherElements();
-        for(int i = 0; i < elements.length; i++) {
-            assertTrue("Full collection shouldn't contain element", 
-                       !collection.contains(elements[i]));
+        for (int i = 0; i < elements.length; i++) {
+            assertTrue("Full collection shouldn't contain element",
+                    !getCollection().contains(elements[i]));
         }
     }
 
-
     /**
      *  Tests {@link Collection#containsAll(Collection)}.
      */
     public void testCollectionContainsAll() {
         resetEmpty();
-        Collection col = new HashSet();
+        Collection<E> col = new HashSet<E>();
         assertTrue("Every Collection should contain all elements of an " +
-                   "empty Collection.", collection.containsAll(col));
+                "empty Collection.", getCollection().containsAll(col));
         col.addAll(Arrays.asList(getOtherElements()));
         assertTrue("Empty Collection shouldn't contain all elements of " +
-                   "a non-empty Collection.", !collection.containsAll(col));
+                "a non-empty Collection.", !getCollection().containsAll(col));
         // make sure calls to "containsAll" don't change anything
         verify();
 
         resetFull();
-        assertTrue("Full collection shouldn't contain other elements", 
-                   !collection.containsAll(col));
-        
+        assertTrue("Full collection shouldn't contain other elements",
+                !getCollection().containsAll(col));
+
         col.clear();
         col.addAll(Arrays.asList(getFullElements()));
         assertTrue("Full collection should containAll full elements",
-                   collection.containsAll(col));
+                getCollection().containsAll(col));
         // make sure calls to "containsAll" don't change anything
         verify();
 
         int min = (getFullElements().length < 2 ? 0 : 2);
-        int max = (getFullElements().length == 1 ? 1 : 
-                    (getFullElements().length <= 5 ? getFullElements().length - 1 : 5));
+        int max = (getFullElements().length == 1 ? 1 :
+                (getFullElements().length <= 5 ? getFullElements().length - 1 : 5));
         col = Arrays.asList(getFullElements()).subList(min, max);
-        assertTrue("Full collection should containAll partial full " +
-                   "elements", collection.containsAll(col));
-        assertTrue("Full collection should containAll itself", 
-                   collection.containsAll(collection));
+        assertTrue("Full collection should containAll partial full elements",
+                getCollection().containsAll(col));
+        assertTrue("Full collection should containAll itself", getCollection().containsAll(getCollection()));
         // make sure calls to "containsAll" don't change anything
         verify();
-        
-        col = new ArrayList();
+
+        col = new ArrayList<E>();
         col.addAll(Arrays.asList(getFullElements()));
         col.addAll(Arrays.asList(getFullElements()));
-        assertTrue("Full collection should containAll duplicate full " +
-                   "elements", collection.containsAll(col));
+        assertTrue("Full collection should containAll duplicate full elements",
+                getCollection().containsAll(col));
 
         // make sure calls to "containsAll" don't change anything
         verify();
@@ -738,58 +718,52 @@
      */
     public void testCollectionIsEmpty() {
         resetEmpty();
-        assertEquals("New Collection should be empty.", 
-                     true, collection.isEmpty());
+        assertEquals("New Collection should be empty.", true, getCollection().isEmpty());
         // make sure calls to "isEmpty() don't change anything
         verify();
 
         resetFull();
-        assertEquals("Full collection shouldn't be empty", 
-                     false, collection.isEmpty());
+        assertEquals("Full collection shouldn't be empty", false, getCollection().isEmpty());
         // make sure calls to "isEmpty() don't change anything
         verify();
     }
 
-
     /**
      *  Tests the read-only functionality of {@link Collection#iterator()}.
      */
     public void testCollectionIterator() {
         resetEmpty();
-        Iterator it1 = collection.iterator();
-        assertEquals("Iterator for empty Collection shouldn't have next.",
-                     false, it1.hasNext());
+        Iterator<E> it1 = getCollection().iterator();
+        assertEquals("Iterator for empty Collection shouldn't have next.", false, it1.hasNext());
         try {
             it1.next();
-            fail("Iterator at end of Collection should throw " +
-                 "NoSuchElementException when next is called.");
-        } catch(NoSuchElementException e) {
+            fail("Iterator at end of Collection should throw "
+                    + "NoSuchElementException when next is called.");
+        } catch (NoSuchElementException e) {
             // expected
-        } 
+        }
         // make sure nothing has changed after non-modification
         verify();
 
         resetFull();
-        it1 = collection.iterator();
-        for (int i = 0; i < collection.size(); i++) {
-            assertTrue("Iterator for full collection should haveNext", 
-                       it1.hasNext());
+        it1 = getCollection().iterator();
+        for (int i = 0; i < getCollection().size(); i++) {
+            assertTrue("Iterator for full collection should haveNext", it1.hasNext());
             it1.next();
         }
         assertTrue("Iterator should be finished", !it1.hasNext());
-        
-        ArrayList list = new ArrayList();
-        it1 = collection.iterator();
-        for (int i = 0; i < collection.size(); i++) {
-            Object next = it1.next();
-            assertTrue("Collection should contain element returned by " +
-                       "its iterator", collection.contains(next));
+
+        ArrayList<E> list = new ArrayList<E>();
+        it1 = getCollection().iterator();
+        for (int i = 0; i < getCollection().size(); i++) {
+            E next = it1.next();
+            assertTrue("Collection should contain element returned by its iterator",
+                    getCollection().contains(next));
             list.add(next);
         }
         try {
             it1.next();
-            fail("iterator.next() should raise NoSuchElementException " +
-                 "after it finishes");
+            fail("iterator.next() should raise NoSuchElementException after it finishes");
         } catch (NoSuchElementException e) {
             // expected
         }
@@ -797,16 +771,16 @@
         verify();
     }
 
-
     /**
      *  Tests removals from {@link Collection#iterator()}.
      */
+    @SuppressWarnings("unchecked")
     public void testCollectionIteratorRemove() {
         if (!isRemoveSupported()) return;
 
         resetEmpty();
         try {
-            collection.iterator().remove();
+            getCollection().iterator().remove();
             fail("New iterator.remove should raise IllegalState");
         } catch (IllegalStateException e) {
             // expected
@@ -814,25 +788,24 @@
         verify();
 
         try {
-            Iterator iter = collection.iterator();
+            Iterator<E> iter = getCollection().iterator();
             iter.hasNext();
             iter.remove();
-            fail("New iterator.remove should raise IllegalState " +
-                 "even after hasNext");
+            fail("New iterator.remove should raise IllegalState even after hasNext");
         } catch (IllegalStateException e) {
             // expected
         }
         verify();
 
         resetFull();
-        int size = collection.size();
-        Iterator iter = collection.iterator();
+        int size = getCollection().size();
+        Iterator<E> iter = getCollection().iterator();
         while (iter.hasNext()) {
             Object o = iter.next();
             // TreeMap reuses the Map Entry, so the verify below fails
             // Clone it here if necessary
             if (o instanceof Map.Entry) {
-                o = cloneMapEntry((Map.Entry) o);
+                o = cloneMapEntry((Map.Entry<E, E>) o);
             }
             iter.remove();
 
@@ -841,23 +814,22 @@
             // contents are still the same.  Otherwise, we don't have the
             // ability to distinguish the elements and determine which to
             // remove from the confirmed collection (in which case, we don't
-            // verify because we don't know how). 
+            // verify because we don't know how).
             //
             // see areEqualElementsDistinguishable()
-            if(!areEqualElementsDistinguishable()) {
-                confirmed.remove(o);
+            if (!areEqualElementsDistinguishable()) {
+                getConfirmed().remove(o);
                 verify();
             }
 
             size--;
-            assertEquals("Collection should shrink by one after " +
-                         "iterator.remove", size, collection.size());
+            assertEquals("Collection should shrink by one after iterator.remove", size,
+                    getCollection().size());
         }
-        assertTrue("Collection should be empty after iterator purge",
-                   collection.isEmpty());
-        
+        assertTrue("Collection should be empty after iterator purge", getCollection().isEmpty());
+
         resetFull();
-        iter = collection.iterator();
+        iter = getCollection().iterator();
         iter.next();
         iter.remove();
         try {
@@ -868,7 +840,6 @@
         }
     }
 
-
     /**
      *  Tests {@link Collection#remove(Object)}.
      */
@@ -876,46 +847,42 @@
         if (!isRemoveSupported()) return;
 
         resetEmpty();
-        Object[] elements = getFullElements();
+        E[] elements = getFullElements();
         for (int i = 0; i < elements.length; i++) {
-            assertTrue("Shouldn't remove nonexistent element", 
-                       !collection.remove(elements[i]));
+            assertTrue("Shouldn't remove nonexistent element", !getCollection().remove(elements[i]));
             verify();
         }
-        
-        Object[] other = getOtherElements();
-        
+
+        E[] other = getOtherElements();
+
         resetFull();
         for (int i = 0; i < other.length; i++) {
-            assertTrue("Shouldn't remove nonexistent other element", 
-                       !collection.remove(other[i]));
+            assertTrue("Shouldn't remove nonexistent other element", !getCollection().remove(other[i]));
             verify();
         }
-        
-        int size = collection.size();
+
+        int size = getCollection().size();
         for (int i = 0; i < elements.length; i++) {
             resetFull();
             assertTrue("Collection should remove extant element: " + elements[i],
-                       collection.remove(elements[i]));
+                    getCollection().remove(elements[i]));
 
             // if the elements aren't distinguishable, we can just remove a
             // matching element from the confirmed collection and verify
             // contents are still the same.  Otherwise, we don't have the
             // ability to distinguish the elements and determine which to
             // remove from the confirmed collection (in which case, we don't
-            // verify because we don't know how). 
+            // verify because we don't know how).
             //
             // see areEqualElementsDistinguishable()
-            if(!areEqualElementsDistinguishable()) {
-                confirmed.remove(elements[i]);
+            if (!areEqualElementsDistinguishable()) {
+                getConfirmed().remove(elements[i]);
                 verify();
             }
 
-            assertEquals("Collection should shrink after remove", 
-                         size - 1, collection.size());
+            assertEquals("Collection should shrink after remove", size - 1, getCollection().size());
         }
     }
-    
 
     /**
      *  Tests {@link Collection#removeAll(Collection)}.
@@ -924,52 +891,46 @@
         if (!isRemoveSupported()) return;
 
         resetEmpty();
-        assertTrue("Emtpy collection removeAll should return false for " +
-                   "empty input", 
-                   !collection.removeAll(Collections.EMPTY_SET));
+        assertTrue("Empty collection removeAll should return false for empty input",
+                !getCollection().removeAll(Collections.EMPTY_SET));
         verify();
-        
-        assertTrue("Emtpy collection removeAll should return false for " +
-                   "nonempty input", 
-                   !collection.removeAll(new ArrayList(collection)));
+
+        assertTrue("Empty collection removeAll should return false for nonempty input",
+                   !getCollection().removeAll(new ArrayList<E>(getCollection())));
         verify();
-        
+
         resetFull();
-        assertTrue("Full collection removeAll should return false for " + 
-                   "empty input", 
-                   !collection.removeAll(Collections.EMPTY_SET));
+        assertTrue("Full collection removeAll should return false for empty input",
+                   !getCollection().removeAll(Collections.EMPTY_SET));
         verify();
-        
-        assertTrue("Full collection removeAll should return false for other elements", 
-                   !collection.removeAll(Arrays.asList(getOtherElements())));
+
+        assertTrue("Full collection removeAll should return false for other elements",
+                   !getCollection().removeAll(Arrays.asList(getOtherElements())));
         verify();
-        
-        assertTrue("Full collection removeAll should return true for full elements", 
-                    collection.removeAll(new HashSet(collection)));
-        confirmed.removeAll(new HashSet(confirmed));
+
+        assertTrue("Full collection removeAll should return true for full elements",
+                getCollection().removeAll(new HashSet<E>(getCollection())));
+        getConfirmed().removeAll(new HashSet<E>(getConfirmed()));
         verify();
-        
+
         resetFull();
-        int size = collection.size();
+        int size = getCollection().size();
         int min = (getFullElements().length < 2 ? 0 : 2);
-        int max = (getFullElements().length == 1 ? 1 : 
-                    (getFullElements().length <= 5 ? getFullElements().length - 1 : 5));
-        Collection all = Arrays.asList(getFullElements()).subList(min, max);
-        assertTrue("Full collection removeAll should work", 
-                   collection.removeAll(all));
-        confirmed.removeAll(all);
-        verify();
-        
-        assertTrue("Collection should shrink after removeAll", 
-                   collection.size() < size);
-        Iterator iter = all.iterator();
+        int max = (getFullElements().length == 1 ? 1 :
+                (getFullElements().length <= 5 ? getFullElements().length - 1 : 5));
+        Collection<E> all = Arrays.asList(getFullElements()).subList(min, max);
+        assertTrue("Full collection removeAll should work", getCollection().removeAll(all));
+        getConfirmed().removeAll(all);
+        verify();
+
+        assertTrue("Collection should shrink after removeAll", getCollection().size() < size);
+        Iterator<E> iter = all.iterator();
         while (iter.hasNext()) {
             assertTrue("Collection shouldn't contain removed element",
-                       !collection.contains(iter.next()));
+                    !getCollection().contains(iter.next()));
         }
     }
 
-
     /**
      *  Tests {@link Collection#retainAll(Collection)}.
      */
@@ -977,138 +938,131 @@
         if (!isRemoveSupported()) return;
 
         resetEmpty();
-        List elements = Arrays.asList(getFullElements());
-        List other = Arrays.asList(getOtherElements());
+        List<E> elements = Arrays.asList(getFullElements());
+        List<E> other = Arrays.asList(getOtherElements());
 
-        assertTrue("Empty retainAll() should return false", 
-                   !collection.retainAll(Collections.EMPTY_SET));
+        assertTrue("Empty retainAll() should return false",
+                !getCollection().retainAll(Collections.EMPTY_SET));
         verify();
-        
-        assertTrue("Empty retainAll() should return false", 
-                   !collection.retainAll(elements));
+
+        assertTrue("Empty retainAll() should return false", !getCollection().retainAll(elements));
         verify();
-        
+
         resetFull();
-        assertTrue("Collection should change from retainAll empty", 
-                   collection.retainAll(Collections.EMPTY_SET));
-        confirmed.retainAll(Collections.EMPTY_SET);
+        assertTrue("Collection should change from retainAll empty",
+                getCollection().retainAll(Collections.EMPTY_SET));
+        getConfirmed().retainAll(Collections.EMPTY_SET);
         verify();
-        
+
         resetFull();
-        assertTrue("Collection changed from retainAll other", 
-                   collection.retainAll(other));
-        confirmed.retainAll(other);
+        assertTrue("Collection changed from retainAll other", getCollection().retainAll(other));
+        getConfirmed().retainAll(other);
         verify();
-        
+
         resetFull();
-        int size = collection.size();
+        int size = getCollection().size();
         assertTrue("Collection shouldn't change from retainAll elements",
-                   !collection.retainAll(elements));
+                   !getCollection().retainAll(elements));
         verify();
-        assertEquals("Collection size shouldn't change", size, 
-                     collection.size());
-        
+        assertEquals("Collection size shouldn't change", size, getCollection().size());
+
         if (getFullElements().length > 1) {
             resetFull();
-            size = collection.size();
+            size = getCollection().size();
             int min = (getFullElements().length < 2 ? 0 : 2);
             int max = (getFullElements().length <= 5 ? getFullElements().length - 1 : 5);
             assertTrue("Collection should changed by partial retainAll",
-                       collection.retainAll(elements.subList(min, max)));
-            confirmed.retainAll(elements.subList(min, max));
+                    getCollection().retainAll(elements.subList(min, max)));
+            getConfirmed().retainAll(elements.subList(min, max));
             verify();
-        
-            Iterator iter = collection.iterator();
+
+            Iterator<E> iter = getCollection().iterator();
             while (iter.hasNext()) {
-                assertTrue("Collection only contains retained element", 
-                           elements.subList(min, max).contains(iter.next()));
+                assertTrue("Collection only contains retained element",
+                        elements.subList(min, max).contains(iter.next()));
             }
         }
-        
+
         resetFull();
-        HashSet set = new HashSet(elements);
-        size = collection.size();
+        HashSet<E> set = new HashSet<E>(elements);
+        size = getCollection().size();
         assertTrue("Collection shouldn't change from retainAll without " +
-                   "duplicate elements", !collection.retainAll(set));
+                   "duplicate elements", !getCollection().retainAll(set));
         verify();
         assertEquals("Collection size didn't change from nonduplicate " +
-                     "retainAll", size, collection.size());
+                     "retainAll", size, getCollection().size());
     }
-    
-    
+
     /**
      *  Tests {@link Collection#size()}.
      */
     public void testCollectionSize() {
         resetEmpty();
-        assertEquals("Size of new Collection is 0.", 0, collection.size());
+        assertEquals("Size of new Collection is 0.", 0, getCollection().size());
 
         resetFull();
-        assertTrue("Size of full collection should be greater than zero", 
-                   collection.size() > 0);
+        assertTrue("Size of full collection should be greater than zero", getCollection().size() > 0);
     }
 
-
     /**
      *  Tests {@link Collection#toArray()}.
      */
     public void testCollectionToArray() {
         resetEmpty();
         assertEquals("Empty Collection should return empty array for toArray",
-                     0, collection.toArray().length);
+                     0, getCollection().toArray().length);
 
         resetFull();
-        Object[] array = collection.toArray();
-        assertEquals("Full collection toArray should be same size as " +
-                     "collection", array.length, collection.size());
-        Object[] confirmedArray = confirmed.toArray();
-        assertEquals("length of array from confirmed collection should " +
-                     "match the length of the collection's array", 
-                     confirmedArray.length, array.length);
+        Object[] array = getCollection().toArray();
+        assertEquals("Full collection toArray should be same size as collection",
+                array.length, getCollection().size());
+        Object[] confirmedArray = getConfirmed().toArray();
+        assertEquals("length of array from confirmed collection should "
+                + "match the length of the collection's array", confirmedArray.length, array.length);
         boolean[] matched = new boolean[array.length];
 
         for (int i = 0; i < array.length; i++) {
             assertTrue("Collection should contain element in toArray",
-                       collection.contains(array[i]));
+                    getCollection().contains(array[i]));
 
             boolean match = false;
             // find a match in the confirmed array
-            for(int j = 0; j < array.length; j++) {
+            for (int j = 0; j < array.length; j++) {
                 // skip already matched
-                if(matched[j]) continue;
-                if(array[i] == confirmedArray[j] ||
-                   (array[i] != null && array[i].equals(confirmedArray[j]))) {
+                if (matched[j])
+                    continue;
+                if (array[i] == confirmedArray[j]
+                        || (array[i] != null && array[i].equals(confirmedArray[j]))) {
                     matched[j] = true;
                     match = true;
                     break;
                 }
             }
-            if(!match) {
-                fail("element " + i + " in returned array should be found " +
-                     "in the confirmed collection's array");
+            if (!match) {
+                fail("element " + i + " in returned array should be found "
+                        + "in the confirmed collection's array");
             }
         }
-        for(int i = 0; i < matched.length; i++) {
-            assertEquals("Collection should return all its elements in " +
-                         "toArray", true, matched[i]);
+        for (int i = 0; i < matched.length; i++) {
+            assertEquals("Collection should return all its elements in " + "toArray", true,
+                    matched[i]);
         }
     }
 
-
     /**
      *  Tests {@link Collection#toArray(Object[])}.
      */
     public void testCollectionToArray2() {
         resetEmpty();
         Object[] a = new Object[] { new Object(), null, null };
-        Object[] array = collection.toArray(a);
+        Object[] array = getCollection().toArray(a);
         assertEquals("Given array shouldn't shrink", array, a);
         assertNull("Last element should be set to null", a[0]);
         verify();
 
         resetFull();
         try {
-            array = collection.toArray(new Void[0]);
+            array = getCollection().toArray(new Void[0]);
             fail("toArray(new Void[0]) should raise ArrayStore");
         } catch (ArrayStoreException e) {
             // expected
@@ -1116,55 +1070,51 @@
         verify();
 
         try {
-            array = collection.toArray(null);
+            array = getCollection().toArray(null);
             fail("toArray(null) should raise NPE");
         } catch (NullPointerException e) {
             // expected
         }
         verify();
-        
-        array = collection.toArray(new Object[0]);
-        a = collection.toArray();
-        assertEquals("toArrays should be equal", 
+
+        array = getCollection().toArray(new Object[0]);
+        a = getCollection().toArray();
+        assertEquals("toArrays should be equal",
                      Arrays.asList(array), Arrays.asList(a));
 
         // Figure out if they're all the same class
         // TODO: It'd be nicer to detect a common superclass
-        HashSet classes = new HashSet();
+        HashSet<Class<?>> classes = new HashSet<Class<?>>();
         for (int i = 0; i < array.length; i++) {
             classes.add((array[i] == null) ? null : array[i].getClass());
         }
         if (classes.size() > 1) return;
-        
-        Class cl = (Class)classes.iterator().next();
+
+        Class<?> cl = classes.iterator().next();
         if (Map.Entry.class.isAssignableFrom(cl)) {  // check needed for protective cases like Predicated/Unmod map entrySet
             cl = Map.Entry.class;
         }
-        a = (Object[])Array.newInstance(cl, 0);
-        array = collection.toArray(a);
+        a = (Object[]) Array.newInstance(cl, 0);
+        array = getCollection().toArray(a);
         assertEquals("toArray(Object[]) should return correct array type",
-                     a.getClass(), array.getClass());
-        assertEquals("type-specific toArrays should be equal", 
-                     Arrays.asList(array), 
-                     Arrays.asList(collection.toArray()));
+                a.getClass(), array.getClass());
+        assertEquals("type-specific toArrays should be equal",
+                Arrays.asList(array),
+                Arrays.asList(getCollection().toArray()));
         verify();
     }
 
-
     /**
      *  Tests <code>toString</code> on a collection.
      */
     public void testCollectionToString() {
         resetEmpty();
-        assertTrue("toString shouldn't return null", 
-                   collection.toString() != null);
+        assertTrue("toString shouldn't return null", getCollection().toString() != null);
 
         resetFull();
-        assertTrue("toString shouldn't return null", 
-                   collection.toString() != null);
+        assertTrue("toString shouldn't return null", getCollection().toString() != null);
     }
 
-
     /**
      *  If isRemoveSupported() returns false, tests to see that remove
      *  operations raise an UnsupportedOperationException.
@@ -1174,7 +1124,7 @@
 
         resetEmpty();
         try {
-            collection.clear();
+            getCollection().clear();
             fail("clear should raise UnsupportedOperationException");
         } catch (UnsupportedOperationException e) {
             // expected
@@ -1182,7 +1132,7 @@
         verify();
 
         try {
-            collection.remove(null);
+            getCollection().remove(null);
             fail("remove should raise UnsupportedOperationException");
         } catch (UnsupportedOperationException e) {
             // expected
@@ -1190,7 +1140,7 @@
         verify();
 
         try {
-            collection.removeAll(null);
+            getCollection().removeAll(null);
             fail("removeAll should raise UnsupportedOperationException");
         } catch (UnsupportedOperationException e) {
             // expected
@@ -1198,7 +1148,7 @@
         verify();
 
         try {
-            collection.retainAll(null);
+            getCollection().retainAll(null);
             fail("removeAll should raise UnsupportedOperationException");
         } catch (UnsupportedOperationException e) {
             // expected
@@ -1207,7 +1157,7 @@
 
         resetFull();
         try {
-            Iterator iterator = collection.iterator();
+            Iterator<E> iterator = getCollection().iterator();
             iterator.next();
             iterator.remove();
             fail("iterator.remove should raise UnsupportedOperationException");
@@ -1218,32 +1168,31 @@
 
     }
 
-
     /**
-     *  Tests that the collection's iterator is fail-fast.  
+     *  Tests that the collection's iterator is fail-fast.
      */
     public void testCollectionIteratorFailFast() {
         if (!isFailFastSupported()) return;
-        
+
         if (isAddSupported()) {
             resetFull();
             try {
-                Iterator iter = collection.iterator();
-                Object o = getOtherElements()[0];
-                collection.add(o);
-                confirmed.add(o);
+                Iterator<E> iter = getCollection().iterator();
+                E o = getOtherElements()[0];
+                getCollection().add(o);
+                getConfirmed().add(o);
                 iter.next();
                 fail("next after add should raise ConcurrentModification");
             } catch (ConcurrentModificationException e) {
                 // expected
             }
             verify();
-            
+
             resetFull();
             try {
-                Iterator iter = collection.iterator();
-                collection.addAll(Arrays.asList(getOtherElements()));
-                confirmed.addAll(Arrays.asList(getOtherElements()));
+                Iterator<E> iter = getCollection().iterator();
+                getCollection().addAll(Arrays.asList(getOtherElements()));
+                getConfirmed().addAll(Arrays.asList(getOtherElements()));
                 iter.next();
                 fail("next after addAll should raise ConcurrentModification");
             } catch (ConcurrentModificationException e) {
@@ -1256,8 +1205,8 @@
 
         resetFull();
         try {
-            Iterator iter = collection.iterator();
-            collection.clear();
+            Iterator<E> iter = getCollection().iterator();
+            getCollection().clear();
             iter.next();
             fail("next after clear should raise ConcurrentModification");
         } catch (ConcurrentModificationException e) {
@@ -1265,11 +1214,11 @@
         } catch (NoSuchElementException e) {
             // (also legal given spec)
         }
-        
+
         resetFull();
         try {
-            Iterator iter = collection.iterator();
-            collection.remove(getFullElements()[0]);
+            Iterator<E> iter = getCollection().iterator();
+            getCollection().remove(getFullElements()[0]);
             iter.next();
             fail("next after remove should raise ConcurrentModification");
         } catch (ConcurrentModificationException e) {
@@ -1278,9 +1227,9 @@
 
         resetFull();
         try {
-            Iterator iter = collection.iterator();
-            List sublist = Arrays.asList(getFullElements()).subList(2,5);
-            collection.removeAll(sublist);
+            Iterator<E> iter = getCollection().iterator();
+            List<E> sublist = Arrays.asList(getFullElements()).subList(2,5);
+            getCollection().removeAll(sublist);
             iter.next();
             fail("next after removeAll should raise ConcurrentModification");
         } catch (ConcurrentModificationException e) {
@@ -1289,9 +1238,9 @@
 
         resetFull();
         try {
-            Iterator iter = collection.iterator();
-            List sublist = Arrays.asList(getFullElements()).subList(2,5);
-            collection.retainAll(sublist);
+            Iterator<E> iter = getCollection().iterator();
+            List<E> sublist = Arrays.asList(getFullElements()).subList(2,5);
+            getCollection().retainAll(sublist);
             iter.next();
             fail("next after retainAll should raise ConcurrentModification");
         } catch (ConcurrentModificationException e) {
@@ -1300,7 +1249,7 @@
     }
 
     public void testSerializeDeserializeThenCompare() throws Exception {
-        Object obj = makeCollection();
+        Object obj = makeObject();
         if (obj instanceof Serializable && isTestSerialization()) {
             ByteArrayOutputStream buffer = new ByteArrayOutputStream();
             ObjectOutputStream out = new ObjectOutputStream(buffer);
@@ -1329,5 +1278,88 @@
             }
         }
     }
-    
+
+    public Collection<E> getCollection() {
+        return collection;
+    }
+
+    /**
+     * Set the collection.
+     * @param collection the Collection<E> to set
+     */
+    public void setCollection(Collection<E> collection) {
+        this.collection = collection;
+    }
+
+    public Collection<E> getConfirmed() {
+        return confirmed;
+    }
+
+    /**
+     * Set the confirmed.
+     * @param confirmed the Collection<E> to set
+     */
+    public void setConfirmed(Collection<E> confirmed) {
+        this.confirmed = confirmed;
+    }
+
+    /**
+     * Handle the optional exceptions declared by {@link Collection#contains(Object)}
+     * @param coll
+     * @param element
+     */
+    protected static void assertNotCollectionContains(Collection<?> coll, Object element) {
+        try {
+            assertFalse(coll.contains(element));
+        } catch (ClassCastException e) {
+            //apparently not
+        } catch (NullPointerException e) {
+            //apparently not
+        }
+    }
+
+    /**
+     * Handle the optional exceptions declared by {@link Collection#containsAll(Collection)}
+     * @param coll
+     * @param sub
+     */
+    protected static void assertNotCollectionContainsAll(Collection<?> coll, Collection<?> sub) {
+        try {
+            assertFalse(coll.containsAll(sub));
+        } catch (ClassCastException cce) {
+            //apparently not
+        } catch (NullPointerException e) {
+            //apparently not
+        }
+    }
+
+    /**
+     * Handle optional exceptions of {@link Collection#remove(Object)}
+     * @param coll
+     * @param element
+     */
+    protected static void assertNotRemoveFromCollection(Collection<?> coll, Object element) {
+        try {
+            assertFalse(coll.remove(element));
+        } catch (ClassCastException cce) {
+            //apparently not
+        } catch (NullPointerException e) {
+            //apparently not
+        }
+    }
+
+    /**
+     * Handle optional exceptions of {@link Collection#removeAll(Collection)}
+     * @param coll
+     * @param sub
+     */
+    protected static void assertNotRemoveAllFromCollection(Collection<?> coll, Collection<?> sub) {
+        try {
+            assertFalse(coll.removeAll(sub));
+        } catch (ClassCastException cce) {
+            //apparently not
+        } catch (NullPointerException e) {
+            //apparently not
+        }
+    }
 }

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/TestPredicatedCollection.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/TestPredicatedCollection.java?rev=815006&r1=815005&r2=815006&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/TestPredicatedCollection.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/TestPredicatedCollection.java Tue Sep 15 05:44:36 2009
@@ -25,7 +25,7 @@
 import junit.framework.TestSuite;
 
 import org.apache.commons.collections.Predicate;
-import org.apache.commons.collections.PredicateUtils;
+import org.apache.commons.collections.functors.TruePredicate;
 
 /**
  * Extension of {@link AbstractTestCollection} for exercising the 
@@ -36,12 +36,12 @@
  *
  * @author Phil Steitz
  */
-public class TestPredicatedCollection extends AbstractTestCollection {
+public class TestPredicatedCollection<E> extends AbstractTestCollection<E> {
 
     public TestPredicatedCollection(String name) {
         super(name);
     }
-    
+
     public static Test suite() {
         return new TestSuite(TestPredicatedCollection.class);
     }
@@ -50,86 +50,84 @@
         String[] testCaseName = { TestPredicatedCollection.class.getName()};
         junit.textui.TestRunner.main(testCaseName);
     }
- 
+
    //------------------------------------------------------------------------
-        
-    protected Predicate truePredicate = PredicateUtils.truePredicate();
-    
-    protected Collection decorateCollection(Collection collection, 
-        Predicate predicate) {
+    protected Predicate<E> truePredicate = TruePredicate.<E>truePredicate();
+
+    protected Collection<E> decorateCollection(
+                Collection<E> collection, Predicate<E> predicate) {
         return PredicatedCollection.decorate(collection, predicate);
     }
-    
-    public Collection makeCollection() {
-        return decorateCollection(new ArrayList(), truePredicate);
-    }
-    
-    public Collection makeConfirmedCollection() {
-        return new ArrayList();
-    }
-    
-    public Object[] getFullElements() {
-        return new Object[] {"1", "3", "5", "7", "2", "4", "6"};
-    }
-    
-    public Collection makeFullCollection() {
-        List list = new ArrayList();
+
+    public Collection<E> makeObject() {
+        return decorateCollection(new ArrayList<E>(), truePredicate);
+    }
+
+    public Collection<E> makeConfirmedCollection() {
+        return new ArrayList<E>();
+    }
+
+    @SuppressWarnings("unchecked")
+    public E[] getFullElements() {
+        return (E[]) new Object[] { "1", "3", "5", "7", "2", "4", "6" };
+    }
+
+    public Collection<E> makeFullCollection() {
+        List<E> list = new ArrayList<E>();
         list.addAll(Arrays.asList(getFullElements()));
         return decorateCollection(list, truePredicate);
     }
-    
-    public Collection makeConfirmedFullCollection() {
-        List list = new ArrayList();
+
+    public Collection<E> makeConfirmedFullCollection() {
+        List<E> list = new ArrayList<E>();
         list.addAll(Arrays.asList(getFullElements()));
         return list;
     }
 
- //-----------------------------------------------------------------
-    protected Predicate testPredicate =  
-        new Predicate() {
-            public boolean evaluate(Object o) {
+    //-----------------------------------------------------------------------
+    protected Predicate<E> testPredicate =
+        new Predicate<E>() {
+            public boolean evaluate(E o) {
                 return o instanceof String;
             }
         };
-    
-    public Collection makeTestCollection() {
-        return decorateCollection(new ArrayList(), testPredicate);
+
+    public Collection<E> makeTestCollection() {
+        return decorateCollection(new ArrayList<E>(), testPredicate);
     }
-     
+
+    @SuppressWarnings("unchecked")
     public void testIllegalAdd() {
-        Collection c = makeTestCollection();
+        Collection<E> c = makeTestCollection();
         Integer i = new Integer(3);
         try {
-            c.add(i);
+            c.add((E) i);
             fail("Integer should fail string predicate.");
         } catch (IllegalArgumentException e) {
             // expected
         }
-        assertTrue("Collection shouldn't contain illegal element", 
-         !c.contains(i));   
+        assertTrue("Collection shouldn't contain illegal element",
+         !c.contains(i));
     }
 
+    @SuppressWarnings("unchecked")
     public void testIllegalAddAll() {
-        Collection c = makeTestCollection();
-        List elements = new ArrayList();
-        elements.add("one");
-        elements.add("two");
-        elements.add(new Integer(3));
-        elements.add("four");
+        Collection<E> c = makeTestCollection();
+        List<E> elements = new ArrayList<E>();
+        elements.add((E) "one");
+        elements.add((E) "two");
+        elements.add((E) new Integer(3));
+        elements.add((E) "four");
         try {
             c.addAll(elements);
             fail("Integer should fail string predicate.");
         } catch (IllegalArgumentException e) {
             // expected
         }
-        assertTrue("Collection shouldn't contain illegal element", 
-         !c.contains("one"));   
-        assertTrue("Collection shouldn't contain illegal element", 
-         !c.contains("two"));   
-        assertTrue("Collection shouldn't contain illegal element", 
-         !c.contains(new Integer(3)));   
-        assertTrue("Collection shouldn't contain illegal element", 
-         !c.contains("four"));   
+        assertTrue("Collection shouldn't contain illegal element", !c.contains("one"));
+        assertTrue("Collection shouldn't contain illegal element", !c.contains("two"));
+        assertTrue("Collection shouldn't contain illegal element", !c.contains(new Integer(3)));
+        assertTrue("Collection shouldn't contain illegal element", !c.contains("four"));
     }
 
     public String getCompatibilityVersion() {

Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/TestSynchronizedCollection.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/TestSynchronizedCollection.java?rev=815006&r1=815005&r2=815006&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/TestSynchronizedCollection.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/TestSynchronizedCollection.java Tue Sep 15 05:44:36 2009
@@ -24,7 +24,7 @@
 import junit.framework.TestSuite;
 
 /**
- * Extension of {@link AbstractTestCollection} for exercising the 
+ * Extension of {@link AbstractTestCollection} for exercising the
  * {@link SynchronizedCollection} implementation.
  *
  * @since Commons Collections 3.1
@@ -33,33 +33,32 @@
  * @author Phil Steitz
  * @author Stephen Colebourne
  */
-public class TestSynchronizedCollection extends AbstractTestCollection {
-    
+public class TestSynchronizedCollection<E> extends AbstractTestCollection<E> {
+
     public TestSynchronizedCollection(String testName) {
         super(testName);
     }
-    
+
     public static Test suite() {
         return new TestSuite(TestSynchronizedCollection.class);
     }
-    
+
     public static void main(String args[]) {
         String[] testCaseName = { TestSynchronizedCollection.class.getName()};
         junit.textui.TestRunner.main(testCaseName);
     }
 
-    //-----------------------------------------------------------------------    
-    public Collection makeCollection() {
-        return SynchronizedCollection.decorate(new ArrayList());
-    }
-    
-    public Collection makeConfirmedCollection() {
-        ArrayList list = new ArrayList();
-        return list;
+    //-----------------------------------------------------------------------
+    public Collection<E> makeObject() {
+        return SynchronizedCollection.decorate(new ArrayList<E>());
+    }
+
+    public Collection<E> makeConfirmedCollection() {
+        return new ArrayList<E>();
     }
 
-    public Collection makeConfirmedFullCollection() {
-        ArrayList list = new ArrayList();
+    public Collection<E> makeConfirmedFullCollection() {
+        ArrayList<E> list = new ArrayList<E>();
         list.addAll(Arrays.asList(getFullElements()));
         return list;
     }



Mime
View raw message