You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sc...@apache.org on 2003/10/03 01:01:10 UTC

cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections AbstractTestMap.java AbstractTestSortedMap.java TestSequencedHashMap.java TestMapUtils.java TestDoubleOrderedMap.java TestMultiHashMap.java TestFastHashMap.java TestBeanMap.java TestReferenceMap.java TestStaticBucketMap.java TestTreeMap.java TestSortedMap.java TestMap.java

scolebourne    2003/10/02 16:01:10

  Modified:    collections/src/test/org/apache/commons/collections/decorators
                        TestTransformedMap.java TestFixedSizeSortedMap.java
                        TestLazyMap.java TestTransformedSortedMap.java
                        TestFixedSizeMap.java TestPredicatedMap.java
               collections/src/test/org/apache/commons/collections
                        TestSequencedHashMap.java TestMapUtils.java
                        TestDoubleOrderedMap.java TestMultiHashMap.java
                        TestFastHashMap.java TestBeanMap.java
                        TestReferenceMap.java TestStaticBucketMap.java
                        TestTreeMap.java
  Added:       collections/src/test/org/apache/commons/collections
                        AbstractTestMap.java AbstractTestSortedMap.java
  Removed:     collections/src/test/org/apache/commons/collections
                        TestSortedMap.java TestMap.java
  Log:
  Rename TestMap to AbstractTestMap
  Rename TestSortedMap to AbstractTestSortedMap
  Javadoc and tidy
  
  Revision  Changes    Path
  1.3       +5 -5      jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestTransformedMap.java
  
  Index: TestTransformedMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestTransformedMap.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestTransformedMap.java	31 Aug 2003 17:28:42 -0000	1.2
  +++ TestTransformedMap.java	2 Oct 2003 23:01:09 -0000	1.3
  @@ -64,7 +64,7 @@
   import junit.framework.Test;
   import junit.framework.TestSuite;
   
  -import org.apache.commons.collections.TestMap;
  +import org.apache.commons.collections.AbstractTestMap;
   
   /**
    * Extension of {@link TestMap} for exercising the {@link TransformedMap}
  @@ -75,7 +75,7 @@
    * 
    * @author Stephen Colebourne
    */
  -public class TestTransformedMap extends TestMap {
  +public class TestTransformedMap extends AbstractTestMap {
       
       public TestTransformedMap(String testName) {
           super(testName);
  @@ -90,7 +90,7 @@
           junit.textui.TestRunner.main(testCaseName);
       }
   
  -    public Map makeEmptyMap() {
  +    protected Map makeEmptyMap() {
           return TransformedMap.decorate(new HashMap(), TestTransformedCollection.NOOP_TRANSFORMER, TestTransformedCollection.NOOP_TRANSFORMER);
       }
   
  
  
  
  1.4       +4 -4      jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestFixedSizeSortedMap.java
  
  Index: TestFixedSizeSortedMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestFixedSizeSortedMap.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestFixedSizeSortedMap.java	31 Aug 2003 17:28:42 -0000	1.3
  +++ TestFixedSizeSortedMap.java	2 Oct 2003 23:01:09 -0000	1.4
  @@ -64,7 +64,7 @@
   import junit.framework.Test;
   import junit.framework.TestSuite;
   
  -import org.apache.commons.collections.TestSortedMap;
  +import org.apache.commons.collections.AbstractTestSortedMap;
   
   /**
    * Extension of {@link TestSortedMap} for exercising the {@link FixedSizeSortedMap}
  @@ -75,7 +75,7 @@
    * 
    * @author Stephen Colebourne
    */
  -public class TestFixedSizeSortedMap extends TestSortedMap {
  +public class TestFixedSizeSortedMap extends AbstractTestSortedMap {
   
       public TestFixedSizeSortedMap(String testName) {
           super(testName);
  
  
  
  1.3       +5 -5      jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestLazyMap.java
  
  Index: TestLazyMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestLazyMap.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestLazyMap.java	20 Sep 2003 17:05:36 -0000	1.2
  +++ TestLazyMap.java	2 Oct 2003 23:01:09 -0000	1.3
  @@ -65,7 +65,7 @@
   
   import org.apache.commons.collections.Factory;
   import org.apache.commons.collections.FactoryUtils;
  -import org.apache.commons.collections.TestMap;
  +import org.apache.commons.collections.AbstractTestMap;
   
   /**
    * Extension of {@link TestMap} for exercising the 
  @@ -76,7 +76,7 @@
    * 
    * @author Phil Steitz
    */
  -public class TestLazyMap extends TestMap {
  +public class TestLazyMap extends AbstractTestMap {
       
       public TestLazyMap(String testName) {
           super(testName);
  @@ -100,7 +100,7 @@
           return LazyMap.decorate(map, factory);
       }
       
  -    public Map makeEmptyMap() {
  +    protected Map makeEmptyMap() {
           return decorateMap(new HashMap(), nullFactory);
       }
       
  
  
  
  1.3       +4 -4      jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestTransformedSortedMap.java
  
  Index: TestTransformedSortedMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestTransformedSortedMap.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestTransformedSortedMap.java	31 Aug 2003 17:28:42 -0000	1.2
  +++ TestTransformedSortedMap.java	2 Oct 2003 23:01:09 -0000	1.3
  @@ -64,7 +64,7 @@
   import junit.framework.Test;
   import junit.framework.TestSuite;
   
  -import org.apache.commons.collections.TestSortedMap;
  +import org.apache.commons.collections.AbstractTestSortedMap;
   
   /**
    * Extension of {@link TestSortedMap} for exercising the {@link TransformedSortedMap}
  @@ -75,7 +75,7 @@
    * 
    * @author Stephen Colebourne
    */
  -public class TestTransformedSortedMap extends TestSortedMap {
  +public class TestTransformedSortedMap extends AbstractTestSortedMap {
       
       public TestTransformedSortedMap(String testName) {
           super(testName);
  
  
  
  1.4       +6 -6      jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestFixedSizeMap.java
  
  Index: TestFixedSizeMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestFixedSizeMap.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestFixedSizeMap.java	31 Aug 2003 17:28:42 -0000	1.3
  +++ TestFixedSizeMap.java	2 Oct 2003 23:01:09 -0000	1.4
  @@ -63,10 +63,10 @@
   import junit.framework.Test;
   import junit.framework.TestSuite;
   
  -import org.apache.commons.collections.TestMap;
  +import org.apache.commons.collections.AbstractTestMap;
   
   /**
  - * Extension of {@link TestMap} for exercising the {@link FixedSizeMap}
  + * Extension of {@link AbstractTestMap} for exercising the {@link FixedSizeMap}
    * implementation.
    *
    * @since Commons Collections 3.0
  @@ -74,7 +74,7 @@
    * 
    * @author Stephen Colebourne
    */
  -public class TestFixedSizeMap extends TestMap {
  +public class TestFixedSizeMap extends AbstractTestMap {
   
       public TestFixedSizeMap(String testName) {
           super(testName);
  @@ -89,7 +89,7 @@
           junit.textui.TestRunner.main(testCaseName);
       }
   
  -    public Map makeEmptyMap() {
  +    protected Map makeEmptyMap() {
           return FixedSizeMap.decorate(new HashMap());
       }
   
  
  
  
  1.3       +5 -5      jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestPredicatedMap.java
  
  Index: TestPredicatedMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestPredicatedMap.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestPredicatedMap.java	20 Sep 2003 17:05:36 -0000	1.2
  +++ TestPredicatedMap.java	2 Oct 2003 23:01:09 -0000	1.3
  @@ -66,7 +66,7 @@
   
   import org.apache.commons.collections.Predicate;
   import org.apache.commons.collections.PredicateUtils;
  -import org.apache.commons.collections.TestMap;
  +import org.apache.commons.collections.AbstractTestMap;
   
   /**
    * Extension of {@link TestMap} for exercising the 
  @@ -77,7 +77,7 @@
    * 
    * @author Phil Steitz
    */
  -public class TestPredicatedMap extends TestMap{
  +public class TestPredicatedMap extends AbstractTestMap{
       
       public TestPredicatedMap(String testName) {
           super(testName);
  @@ -101,7 +101,7 @@
           return PredicatedMap.decorate(map, keyPredicate, valuePredicate);
       }
       
  -    public Map makeEmptyMap() {
  +    protected Map makeEmptyMap() {
           return decorateMap(new HashMap(), truePredicate, truePredicate);
       }
       
  
  
  
  1.21      +2 -2      jakarta-commons/collections/src/test/org/apache/commons/collections/TestSequencedHashMap.java
  
  Index: TestSequencedHashMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestSequencedHashMap.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- TestSequencedHashMap.java	31 Aug 2003 17:28:43 -0000	1.20
  +++ TestSequencedHashMap.java	2 Oct 2003 23:01:09 -0000	1.21
  @@ -73,7 +73,7 @@
    * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    */
  -public class TestSequencedHashMap extends TestMap {
  +public class TestSequencedHashMap extends AbstractTestMap {
       /**
        * The instance to experiment on.
        */
  @@ -105,7 +105,7 @@
           labRat = (SequencedHashMap) makeEmptyMap();
       }
   
  -    public Map makeEmptyMap() {
  +    protected Map makeEmptyMap() {
           return new SequencedHashMap();
       }
   
  
  
  
  1.16      +3 -3      jakarta-commons/collections/src/test/org/apache/commons/collections/TestMapUtils.java
  
  Index: TestMapUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestMapUtils.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- TestMapUtils.java	20 Sep 2003 17:02:03 -0000	1.15
  +++ TestMapUtils.java	2 Oct 2003 23:01:09 -0000	1.16
  @@ -162,7 +162,7 @@
       }
       
       public BulkTest bulkTestTypedMap() {
  -        return new TestMap("") {
  +        return new AbstractTestMap("") {
               public boolean useNullKey() {
                   return false;
               }
  
  
  
  1.8       +6 -6      jakarta-commons/collections/src/test/org/apache/commons/collections/TestDoubleOrderedMap.java
  
  Index: TestDoubleOrderedMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestDoubleOrderedMap.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TestDoubleOrderedMap.java	31 Aug 2003 17:28:43 -0000	1.7
  +++ TestDoubleOrderedMap.java	2 Oct 2003 23:01:09 -0000	1.8
  @@ -86,7 +86,7 @@
    * 
    * @author Marc Johnson (marcj at users dot sourceforge dot net)
    */
  -public class TestDoubleOrderedMap extends TestMap  {
  +public class TestDoubleOrderedMap extends AbstractTestMap  {
   
       /**
        * constructor
  @@ -128,11 +128,11 @@
           return false;
       }
   
  -    public Map makeEmptyMap() {
  +    protected Map makeEmptyMap() {
           return new DoubleOrderedMap();
       }
   
  -    public Map makeMap() {
  +    protected Map makeMap() {
           return new DoubleOrderedMap();
       }
   
  
  
  
  1.12      +5 -5      jakarta-commons/collections/src/test/org/apache/commons/collections/TestMultiHashMap.java
  
  Index: TestMultiHashMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestMultiHashMap.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- TestMultiHashMap.java	31 Aug 2003 17:28:43 -0000	1.11
  +++ TestMultiHashMap.java	2 Oct 2003 23:01:10 -0000	1.12
  @@ -73,7 +73,7 @@
    * Unit Tests for <code>MultiHashMap</code>.
    *
    */
  -public class TestMultiHashMap extends TestMap
  +public class TestMultiHashMap extends AbstractTestMap
   {
       public TestMultiHashMap(String testName)
       {
  @@ -96,7 +96,7 @@
           return "2";
       }
   
  -    public Map makeEmptyMap() {
  +    protected Map makeEmptyMap() {
           return new MultiHashMap();
       }
       
  
  
  
  1.10      +5 -5      jakarta-commons/collections/src/test/org/apache/commons/collections/TestFastHashMap.java
  
  Index: TestFastHashMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestFastHashMap.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TestFastHashMap.java	31 Aug 2003 17:28:43 -0000	1.9
  +++ TestFastHashMap.java	2 Oct 2003 23:01:10 -0000	1.10
  @@ -69,7 +69,7 @@
    * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
    * @version $Id$
    */
  -public class TestFastHashMap extends TestMap
  +public class TestFastHashMap extends AbstractTestMap
   {
       public TestFastHashMap(String testName)
       {
  
  
  
  1.11      +7 -7      jakarta-commons/collections/src/test/org/apache/commons/collections/TestBeanMap.java
  
  Index: TestBeanMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestBeanMap.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- TestBeanMap.java	31 Aug 2003 17:28:43 -0000	1.10
  +++ TestBeanMap.java	2 Oct 2003 23:01:10 -0000	1.11
  @@ -71,7 +71,7 @@
    * 
    * @author <a href="mailto:morgand@apache.org">Morgan Delagrange</a>
    */
  -public class TestBeanMap extends TestMap {
  +public class TestBeanMap extends AbstractTestMap {
   
       public TestBeanMap(String testName) {
           super(testName);
  @@ -264,11 +264,11 @@
        *  bean has.  Adding and removing mappings is not possible, thus this
        *  method is overridden to return false.
        **/
  -    public boolean isAddRemoveModifiable() {
  +    protected boolean isAddRemoveModifiable() {
           return false;
       }
     
  -    public Map makeFullMap() {
  +    protected Map makeFullMap() {
           // note: These values must match (i.e. .equals() must return true)
           // those returned from getSampleValues().
           BeanWithProperties bean = new BeanWithProperties();
  @@ -285,7 +285,7 @@
           return new BeanMap(bean);
       }
   
  -    public Map makeEmptyMap() {
  +    protected Map makeEmptyMap() {
           return new BeanMap();
       }
   
  
  
  
  1.11      +6 -6      jakarta-commons/collections/src/test/org/apache/commons/collections/TestReferenceMap.java
  
  Index: TestReferenceMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestReferenceMap.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- TestReferenceMap.java	20 Sep 2003 17:02:03 -0000	1.10
  +++ TestReferenceMap.java	2 Oct 2003 23:01:10 -0000	1.11
  @@ -71,7 +71,7 @@
    * @author Paul Jack
    * @version $Id$
    */
  -public class TestReferenceMap extends TestMap {
  +public class TestReferenceMap extends AbstractTestMap {
   
       public TestReferenceMap(String testName) {
           super(testName);
  @@ -86,7 +86,7 @@
           junit.textui.TestRunner.main(testCaseName);
       }
   
  -    public Map makeEmptyMap() {
  +    protected Map makeEmptyMap() {
           ReferenceMap map = new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK);
           return map;
       }
  
  
  
  1.5       +2 -2      jakarta-commons/collections/src/test/org/apache/commons/collections/TestStaticBucketMap.java
  
  Index: TestStaticBucketMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestStaticBucketMap.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestStaticBucketMap.java	31 Aug 2003 17:28:43 -0000	1.4
  +++ TestStaticBucketMap.java	2 Oct 2003 23:01:10 -0000	1.5
  @@ -64,7 +64,7 @@
    * 
    * @author <a href="mailto:mas@apache.org">Michael A. Smith</a>
    */
  -public class TestStaticBucketMap extends TestMap {
  +public class TestStaticBucketMap extends AbstractTestMap {
   
       public TestStaticBucketMap(String name) {
           super(name);
  @@ -79,7 +79,7 @@
           junit.textui.TestRunner.main(testCaseName);
       }
   
  -    public Map makeEmptyMap() {
  +    protected Map makeEmptyMap() {
           return new StaticBucketMap(30);
       }
   
  
  
  
  1.8       +5 -5      jakarta-commons/collections/src/test/org/apache/commons/collections/TestTreeMap.java
  
  Index: TestTreeMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestTreeMap.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TestTreeMap.java	31 Aug 2003 17:28:43 -0000	1.7
  +++ TestTreeMap.java	2 Oct 2003 23:01:10 -0000	1.8
  @@ -67,7 +67,7 @@
    * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
    * @version $Id$
    */
  -public abstract class TestTreeMap extends TestMap
  +public abstract class TestTreeMap extends AbstractTestMap
   {
       public TestTreeMap(String testName)
       {
  
  
  
  1.1                  jakarta-commons/collections/src/test/org/apache/commons/collections/AbstractTestMap.java
  
  Index: AbstractTestMap.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/AbstractTestMap.java,v 1.1 2003/10/02 23:01:09 scolebourne Exp $
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.collections;
  
  import java.io.IOException;
  import java.io.Serializable;
  import java.util.Collection;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
  import java.util.Set;
  
  /**
   * Abstract test class for {@link java.util.Map} methods and contracts.
   * <p>
   * The forces at work here are similar to those in {@link AbstractTestCollection}.
   * If your class implements the full Map interface, including optional
   * operations, simply extend this class, and implement the {@link
   * #makeEmptyMap()} method.
   * <p>
   * On the other hand, if your map implementation is weird, you may have to
   * override one or more of the other protected methods.  They're described
   * below.
   * <p>
   * <B>Entry Population Methods</B><P>
   *
   * Override these methods if your map requires special entries:
   *
   * <UL>
   * <LI>{@link #getSampleKeys()}
   * <LI>{@link #getSampleValues()}
   * <LI>{@link #getNewSampleValues()}
   * <LI>{@link #getOtherKeys()}
   * <LI>{@link #getOtherValues()}
   * </UL>
   *
   * <B>Supported Operation Methods</B><P>
   *
   * Override these methods if your map doesn't support certain operations:
   *
   * <UL>
   * <LI> {@link #useDuplicateValues()}
   * <LI> {@link #useNullKey()}
   * <LI> {@link #useNullValue()}
   * <LI> {@link #isAddRemoveModifiable()}
   * <LI> {@link #isChangeable()}
   * </UL>
   *
   * <B>Fixture Methods</B><P>
   *
   * For tests on modification operations (puts and removes), fixtures are used
   * to verify that that operation results in correct state for the map and its
   * collection views.  Basically, the modification is performed against your
   * map implementation, and an identical modification is performed against
   * a <I>confirmed</I> map implementation.  A confirmed map implementation is
   * something like <Code>java.util.HashMap</Code>, which is known to conform
   * exactly to the {@link Map} contract.  After the modification takes place
   * on both your map implementation and the confirmed map implementation, the
   * two maps are compared to see if their state is identical.  The comparison
   * also compares the collection views to make sure they're still the same.<P>
   *
   * The upshot of all that is that <I>any</I> test that modifies the map in
   * <I>any</I> way will verify that <I>all</I> of the map's state is still
   * correct, including the state of its collection views.  So for instance
   * if a key is removed by the map's key set's iterator, then the entry set 
   * is checked to make sure the key/value pair no longer appears.<P>
   *
   * The {@link #map} field holds an instance of your collection implementation.
   * The {@link #entrySet}, {@link #keySet} and {@link #values} fields hold
   * that map's collection views.  And the {@link #confirmed} field holds
   * an instance of the confirmed collection implementation.  The 
   * {@link #resetEmpty()} and {@link #resetFull()} methods set these fields to 
   * empty or full maps, so that tests can proceed from a known state.<P>
   *
   * After a modification operation to both {@link #map} and {@link #confirmed},
   * the {@link #verify()} method is invoked to compare the results.  The {@link
   * verify()} method calls separate methods to verify the map and its three
   * collection views ({@link verifyMap(), {@link verifyEntrySet()}, {@link
   * verifyKeySet()}, and {@link verifyValues()}).  You may want to override one
   * of the verification methodsto perform additional verifications.  For
   * instance, {@link TestDoubleOrderedMap} would want override its
   * {@link #verifyValues()} method to verify that the values are unique and in
   * ascending order.<P>
   *  
   * <B>Other Notes</B><P>
   *
   * If your {@link Map} fails one of these tests by design, you may still use
   * this base set of cases.  Simply override the test case (method) your {@link
   * Map} fails and/or the methods that define the assumptions used by the test
   * cases.  For example, if your map does not allow duplicate values, override
   * {@link #useDuplicateValues()} and have it return <code>false</code>
   *
   * @author Michael Smith
   * @author Rodney Waldhoff
   * @author Paul Jack
   * @version $Revision: 1.1 $ $Date: 2003/10/02 23:01:09 $
   */
  public abstract class AbstractTestMap extends AbstractTestObject {
  
      // These instance variables are initialized with the reset method.
      // Tests for map methods that alter the map (put, putAll, remove) 
      // first call reset() to create the map and its views; then perform
      // the modification on the map; perform the same modification on the
      // confirmed; and then call verify() to ensure that the map is equal
      // to the confirmed, that the already-constructed collection views
      // are still equal to the confirmed's collection views.
  
  
      /** Map created by reset(). */
      protected Map map;
  
      /** Entry set of map created by reset(). */
      protected Set entrySet;
  
      /** Key set of map created by reset(). */
      protected Set keySet;
  
      /** Values collection of map created by reset(). */
      protected Collection values;
  
      /** HashMap created by reset(). */
      protected Map confirmed;
  
  
      /**
       * JUnit constructor.
       * 
       * @param testName  the test name
       */
      public AbstractTestMap(String testName) {
          super(testName);
      }
  
  
      /**
       *  Override if your map does not allow a <code>null</code> key.  The
       *  default implementation returns <code>true</code>
       */
      protected boolean useNullKey() {
          return true;
      }
  
      /**
       *  Override if your map does not allow <code>null</code> values.  The
       *  default implementation returns <code>true</code>.
       */
      protected boolean useNullValue() {
          return true;
      }
  
      /**
       *  Override if your map does not allow duplicate values.  The default
       *  implementation returns <code>true</code>.
       */
      protected boolean useDuplicateValues() {
          return true;
      }
  
      /**
       *  Override if your map allows its mappings to be changed to new values.
       *  The default implementation returns <code>true</code>.
       */
      protected boolean isChangeable() {
          return true;
      }
  
      /**
       *  Override if your map does not allow add/remove modifications.  The
       *  default implementation returns <code>true</code>.
       */
      protected boolean isAddRemoveModifiable() {
          return true;
      }
  
      /**
       *  Returns the set of keys in the mappings used to test the map.  This
       *  method must return an array with the same length as {@link
       *  #getSampleValues()} and all array elements must be different. The
       *  default implementation constructs a set of String keys, and includes a
       *  single null key if {@link #useNullKey()} returns <code>true</code>.
       */
      protected Object[] getSampleKeys() {
          Object[] result = new Object[] {
              "blah", "foo", "bar", "baz", "tmp", "gosh", "golly", "gee", 
              "hello", "goodbye", "we'll", "see", "you", "all", "again",
              "key",
              "key2",
              (useNullKey()) ? null : "nonnullkey"
          };
          return result;
      }
  
  
      protected Object[] getOtherKeys() {
          return getOtherNonNullStringElements();
      }
  
      protected Object[] getOtherValues() {
          return getOtherNonNullStringElements();
      }
  
      /**
       *  Returns a list of string elements suitable for return by
       *  {@link getOtherElements()}.  Override getOtherElements to return
       *  the results of this method if your collection does not support
       *  heterogenous elements or the null element.
       */
      protected Object[] getOtherNonNullStringElements() {
          return new Object[] {
              "For","then","despite",/* of */"space","I","would","be","brought",
              "From","limits","far","remote","where","thou","dost","stay"
          };
      }
  
      /**
       *  Returns the set of values in the mappings used to test the map.  This
       *  method must return an array with the same length as {@link
       *  #getSampleKeys()}.  The default implementation constructs a set of
       *  String values and includes a single null value if {@link
       *  #useNullValue()} returns <code>true</code>, and includes two values
       *  that are the same if {@link #useDuplicateValues()} returns
       *  <code>true</code>.
       */
      protected Object[] getSampleValues() {
          Object[] result = new Object[] {
              "blahv", "foov", "barv", "bazv", "tmpv", "goshv", "gollyv", "geev",
              "hellov", "goodbyev", "we'llv", "seev", "youv", "allv", "againv",
              (useNullValue()) ? null : "nonnullvalue",
              "value",
              (useDuplicateValues()) ? "value" : "value2",
          };
          return result;
      }
  
      /**
       *  Returns a the set of values that can be used to replace the values
       *  returned from {@link #getSampleValues()}.  This method must return an
       *  array with the same length as {@link #getSampleValues()}.  The values
       *  returned from this method should not be the same as those returned from
       *  {@link #getSampleValues()}.  The default implementation constructs a
       *  set of String values and includes a single null value if {@link
       *  #useNullValue()} returns <code>true</code>, and includes two values
       *  that are the same if {@link #useDuplicateValues()} returns
       *  <code>true</code>.  
       */
      protected Object[] getNewSampleValues() {
          Object[] result = new Object[] {
              (useNullValue()) ? null : "newnonnullvalue",
              "newvalue",
              (useDuplicateValues()) ? "newvalue" : "newvalue2",
              "newblahv", "newfoov", "newbarv", "newbazv", "newtmpv", "newgoshv", 
              "newgollyv", "newgeev", "newhellov", "newgoodbyev", "newwe'llv", 
              "newseev", "newyouv", "newallv", "newagainv",
          };
          return result;
      }
  
      /**
       *  Helper method to add all the mappings described by {@link
       *  #getSampleKeys()} and {@link #getSampleValues()}.
       */
      protected void addSampleMappings(Map m) {
  
          Object[] keys = getSampleKeys();
          Object[] values = getSampleValues();
          
          for(int i = 0; i < keys.length; i++) {
              try {
                  m.put(keys[i], values[i]);
              } catch (NullPointerException exception) {
                  assertTrue("NullPointerException only allowed to be thrown " +
                             "if either the key or value is null.", 
                             keys[i] == null || values[i] == null);
                  
                  assertTrue("NullPointerException on null key, but " +
                             "useNullKey is not overridden to return false.", 
                             keys[i] == null || !useNullKey());
                  
                  assertTrue("NullPointerException on null value, but " +
                             "useNullValue is not overridden to return false.",
                             values[i] == null || !useNullValue());
                  
                  assertTrue("Unknown reason for NullPointer.", false);
              }
          }
          assertEquals("size must reflect number of mappings added.",
                       keys.length, m.size());
      }
  
      //-----------------------------------------------------------------------
      /**
       * Return a new, empty {@link Map} to be used for testing. 
       * 
       * @return the map to be tested
       */
      protected abstract Map makeEmptyMap();
  
      /**
       * Return a new, populated map.  The mappings in the map should match the
       * keys and values returned from {@link #getSampleKeys()} and {@link
       * #getSampleValues()}.  The default implementation uses makeEmptyMap()
       * and calls {@link #addSampleMappings()} to add all the mappings to the
       * map.
       * 
       * @return the map to be tested
       */
      protected Map makeFullMap() {
          Map m = makeEmptyMap();
          addSampleMappings(m);
          return m;
      }
  
      /**
       * Implements the superclass method to return the map to be tested.
       * 
       * @return the map to be tested
       */
      public Object makeObject() {
          return makeEmptyMap();
      }
  
      //-----------------------------------------------------------------------
      /**
       *  Test to ensure the test setup is working properly.  This method checks
       *  to ensure that the getSampleKeys and getSampleValues methods are
       *  returning results that look appropriate.  That is, they both return a
       *  non-null array of equal length.  The keys array must not have any
       *  duplicate values, and may only contain a (single) null key if
       *  useNullKey() returns true.  The values array must only have a null
       *  value if useNullValue() is true and may only have duplicate values if
       *  useDuplicateValues() returns true.  
       */
      public void testSampleMappings() {
        Object[] keys = getSampleKeys();
        Object[] values = getSampleValues();
        Object[] newValues = getNewSampleValues();
  
        assertTrue("failure in test: Must have keys returned from " +
                   "getSampleKeys.", keys != null);
  
        assertTrue("failure in test: Must have values returned from " +
                   "getSampleValues.", values != null);
  
        // verify keys and values have equivalent lengths (in case getSampleX are
        // overridden)
        assertEquals("failure in test: not the same number of sample " +
                     "keys and values.",  keys.length, values.length);
        
        assertEquals("failure in test: not the same number of values and new values.",
                     values.length, newValues.length);
  
        // verify there aren't duplicate keys, and check values
        for(int i = 0; i < keys.length - 1; i++) {
            for(int j = i + 1; j < keys.length; j++) {
                assertTrue("failure in test: duplicate null keys.",
                           (keys[i] != null || keys[j] != null));
                assertTrue("failure in test: duplicate non-null key.",
                           (keys[i] == null || keys[j] == null || 
                            (!keys[i].equals(keys[j]) && 
                             !keys[j].equals(keys[i]))));
            }
            assertTrue("failure in test: found null key, but useNullKey " +
                       "is false.", keys[i] != null || useNullKey());
            assertTrue("failure in test: found null value, but useNullValue " +
                       "is false.", values[i] != null || useNullValue());
            assertTrue("failure in test: found null new value, but useNullValue " +
                       "is false.", newValues[i] != null || useNullValue());
            assertTrue("failure in test: values should not be the same as new value",
                       values[i] != newValues[i] && 
                       (values[i] == null || !values[i].equals(newValues[i])));
        }
      }
      
      // tests begin here.  Each test adds a little bit of tested functionality.
      // Many methods assume previous methods passed.  That is, they do not
      // exhaustively recheck things that have already been checked in a previous
      // test methods.  
  
      /**
       *  Test to ensure that makeEmptyMap and makeFull returns a new non-null
       *  map with each invocation.  
       */
      public void testMakeMap() {
          Map em = makeEmptyMap();
          assertTrue("failure in test: makeEmptyMap must return a non-null map.",
                     em != null);
          
          Map em2 = makeEmptyMap();
          assertTrue("failure in test: makeEmptyMap must return a non-null map.",
                     em != null);
  
          assertTrue("failure in test: makeEmptyMap must return a new map " +
                     "with each invocation.", em != em2);
  
          Map fm = makeFullMap();
          assertTrue("failure in test: makeFullMap must return a non-null map.",
                     fm != null);
          
          Map fm2 = makeFullMap();
          assertTrue("failure in test: makeFullMap must return a non-null map.",
                     fm != null);
  
          assertTrue("failure in test: makeFullMap must return a new map " +
                     "with each invocation.", fm != fm2);
      }
  
      /**
       *  Tests Map.isEmpty()
       */
      public void testMapIsEmpty() {
          resetEmpty();
          assertEquals("Map.isEmpty() should return true with an empty map", 
                       true, map.isEmpty());
          verify();
  
          resetFull();
          assertEquals("Map.isEmpty() should return false with a non-empty map",
                       false, map.isEmpty());
          verify();
      }
  
      /**
       *  Tests Map.size()
       */
      public void testMapSize() {
          resetEmpty();
          assertEquals("Map.size() should be 0 with an empty map",
                       0, map.size());
          verify();
  
          resetFull();
          assertEquals("Map.size() should equal the number of entries " +
                       "in the map", getSampleKeys().length, map.size());
          verify();
      }
  
      /**
       *  Tests {@link Map#clear()}.  If the map {@link #isAddRemoveModifiable()
       *  can add and remove elements}, then {@link Map#size()} and {@link
       *  Map#isEmpty()} are used to ensure that map has no elements after a call
       *  to clear.  If the map does not support adding and removing elements,
       *  this method checks to ensure clear throws an
       *  UnsupportedOperationException.
       */
      public void testMapClear() {
          if (!isAddRemoveModifiable()) return;
  
          resetEmpty();
          map.clear();
          confirmed.clear();
          verify();
          
          resetFull();
          map.clear();
          confirmed.clear();
          verify();
      }
  
  
      /**
       *  Tests Map.containsKey(Object) by verifying it returns false for all
       *  sample keys on a map created using an empty map and returns true for
       *  all sample keys returned on a full map. 
       */
      public void testMapContainsKey() {
          Object[] keys = getSampleKeys();
  
          resetEmpty();
          for(int i = 0; i < keys.length; i++) {
              assertTrue("Map must not contain key when map is empty", 
                         !map.containsKey(keys[i]));
          }
          verify();
  
          resetFull();
          for(int i = 0; i < keys.length; i++) {
              assertTrue("Map must contain key for a mapping in the map. " +
                         "Missing: " + keys[i], map.containsKey(keys[i]));
          }
          verify();
      }
  
      /**
       *  Tests Map.containsValue(Object) by verifying it returns false for all
       *  sample values on an empty map and returns true for all sample values on
       *  a full map.
       */
      public void testMapContainsValue() {
          Object[] values = getSampleValues();
  
          resetEmpty();
          for(int i = 0; i < values.length; i++) {
              assertTrue("Empty map must not contain value", 
                         !map.containsValue(values[i]));
          }
          verify();
          
          resetFull();
          for(int i = 0; i < values.length; i++) {
              assertTrue("Map must contain value for a mapping in the map.", 
                         map.containsValue(values[i]));
          }
          verify();
      }
  
  
      /**
       *  Tests Map.equals(Object)
       */
      public void testMapEquals() {
          resetEmpty();
          assertTrue("Empty maps unequal.", map.equals(confirmed));
          verify();
  
          resetFull();
          assertTrue("Full maps unequal.", map.equals(confirmed));
          verify();
  
          resetFull();
          // modify the HashMap created from the full map and make sure this
          // change results in map.equals() to return false.
          Iterator iter = confirmed.keySet().iterator();
          iter.next();
          iter.remove();
          assertTrue("Different maps equal.", !map.equals(confirmed));
          
          resetFull();
          assertTrue("equals(null) returned true.", !map.equals(null));
          assertTrue("equals(new Object()) returned true.", 
                     !map.equals(new Object()));
          verify();
      }
  
  
      /**
       *  Tests Map.get(Object)
       */
      public void testMapGet() {
          resetEmpty();
  
          Object[] keys = getSampleKeys();
          Object[] values = getSampleValues();
  
          for (int i = 0; i < keys.length; i++) {
              assertTrue("Empty map.get() should return null.", 
                         map.get(keys[i]) == null);
          }
          verify();
  
          resetFull();
          for (int i = 0; i < keys.length; i++) {
              assertEquals("Full map.get() should return value from mapping.", 
                           values[i], map.get(keys[i]));
          }
      }
  
      /**
       *  Tests Map.hashCode()
       */
      public void testMapHashCode() {
          resetEmpty();
          assertTrue("Empty maps have different hashCodes.", 
                     map.hashCode() == confirmed.hashCode());
  
          resetFull();
          assertTrue("Equal maps have different hashCodes.", 
                     map.hashCode() == confirmed.hashCode());
      }
  
      /**
       *  Tests Map.toString().  Since the format of the string returned by the
       *  toString() method is not defined in the Map interface, there is no
       *  common way to test the results of the toString() method.  Thereforce,
       *  it is encouraged that Map implementations override this test with one
       *  that checks the format matches any format defined in its API.  This
       *  default implementation just verifies that the toString() method does
       *  not return null.
       */
      public void testMapToString() {
          resetEmpty();
          assertTrue("Empty map toString() should not return null", 
                     map.toString() != null);
          verify();
  
          resetFull();
          assertTrue("Empty map toString() should not return null", 
                     map.toString() != null);
          verify();
      }
  
  
      /**
       * Compare the current serialized form of the Map
       * against the canonical version in CVS.
       */
      public void testEmptyMapCompatibility() throws IOException, ClassNotFoundException {
          /**
           * Create canonical objects with this code
          Map map = makeEmptyMap();
          if (!(map instanceof Serializable)) return;
          
          writeExternalFormToDisk((Serializable) map, getCanonicalEmptyCollectionName(map));
          */
  
          // test to make sure the canonical form has been preserved
          Map map = makeEmptyMap();
          if(map instanceof Serializable && !skipSerializedCanonicalTests()) {
              Map map2 = (Map) readExternalFormFromDisk(getCanonicalEmptyCollectionName(map));
              assertTrue("Map is empty",map2.isEmpty());
          }
      }
  
          /**
       * Compare the current serialized form of the Map
       * against the canonical version in CVS.
       */
      public void testFullMapCompatibility() throws IOException, ClassNotFoundException {
          /**
           * Create canonical objects with this code
          Map map = makeFullMap();
          if (!(map instanceof Serializable)) return;
          
          writeExternalFormToDisk((Serializable) map, getCanonicalFullCollectionName(map));
          */
  
          // test to make sure the canonical form has been preserved
          Map map = makeFullMap();
          if(map instanceof Serializable && !skipSerializedCanonicalTests()) {
              Map map2 = (Map) readExternalFormFromDisk(getCanonicalFullCollectionName(map));
              assertEquals("Map is the right size",map2.size(), getSampleKeys().length);
          }
      }
  
      /**
       *  Tests Map.put(Object, Object)
       */
      public void testMapPut() {
          if (!isAddRemoveModifiable()) return;
  
          resetEmpty();
  
          Object[] keys = getSampleKeys();
          Object[] values = getSampleValues();
          Object[] newValues = getNewSampleValues();
  
          for(int i = 0; i < keys.length; i++) {
              Object o = map.put(keys[i], values[i]);
              confirmed.put(keys[i], values[i]);
              verify();
              assertTrue("First map.put should return null", o == null);
              assertTrue("Map should contain key after put", 
                         map.containsKey(keys[i]));
              assertTrue("Map should contain value after put", 
                         map.containsValue(values[i]));
          }
          
          for(int i = 0; i < keys.length; i++) {
              Object o = map.put(keys[i], newValues[i]);
              confirmed.put(keys[i], newValues[i]);
              verify();
              assertEquals("Second map.put should return previous value",
                           values[i], o);
              assertTrue("Map should still contain key after put",
                         map.containsKey(keys[i]));
              assertTrue("Map should contain new value after put",
                         map.containsValue(newValues[i]));
  
              // if duplicates are allowed, we're not guaranteed that the value
              // no longer exists, so don't try checking that.
              if(!useDuplicateValues()) {
                  assertTrue("Map should not contain old value after second put",
                             !map.containsValue(values[i]));
              }
          }
      }
  
      /**
       *  Tests Map.putAll(Collection)
       */
      public void testMapPutAll() {
          if (!isAddRemoveModifiable()) return;
  
          resetEmpty();
  
          Map m2 = makeFullMap();
  
          map.putAll(m2);
          confirmed.putAll(m2);
          verify();
  
          resetEmpty();
  
          m2 = new HashMap();
          Object[] keys = getSampleKeys();
          Object[] values = getSampleValues();
          for(int i = 0; i < keys.length; i++) {
              m2.put(keys[i], values[i]);
          }
  
          map.putAll(m2);
          confirmed.putAll(m2);
          verify();
      }
  
      /**
       *  Tests Map.remove(Object)
       */
      public void testMapRemove() {
          if (!isAddRemoveModifiable()) return;
  
          resetEmpty();
  
          Object[] keys = getSampleKeys();
          Object[] values = getSampleValues();
          for(int i = 0; i < keys.length; i++) {
              Object o = map.remove(keys[i]);
              assertTrue("First map.remove should return null", o == null);
          }
          verify();
  
          resetFull();
  
          for(int i = 0; i < keys.length; i++) {
              Object o = map.remove(keys[i]);
              confirmed.remove(keys[i]);
              verify();
  
              assertEquals("map.remove with valid key should return value",
                           values[i], o);
          }
  
          Object[] other = getOtherKeys();
  
          resetFull();
          int size = map.size();
          for (int i = 0; i < other.length; i++) {
              Object o = map.remove(other[i]);
              assertEquals("map.remove for nonexistent key should return null",
                           o, null);
              assertEquals("map.remove for nonexistent key should not " +
                           "shrink map", size, map.size());
          }
          verify();
      }
  
      /**
       * Tests that the {@link Map#values} collection is backed by
       * the underlying map by removing from the values collection
       * and testing if the value was removed from the map.
       * <p/>
       * We should really test the "vice versa" case--that values removed
       * from the map are removed from the values collection--also,
       * but that's a more difficult test to construct (lacking a
       * "removeValue" method.)
       * 
       * @see http://issues.apache.org/bugzilla/show_bug.cgi?id=9573
       */
      public void testValuesRemovedFromValuesCollectionAreRemovedFromMap() {
          resetFull();
          Object[] sampleValues = getSampleValues();
          Collection values = map.values();
          for(int i=0;i<sampleValues.length;i++) {
              if(map.containsValue(sampleValues[i])) {
                  while(values.contains(sampleValues[i])) {
                      try {
                          values.remove(sampleValues[i]);
                      } catch(UnsupportedOperationException e) {
                          // if values.remove is unsupported, just skip this test
                          return;
                      }
                  }
                  assertTrue("Value should have been removed from the underlying map.",!map.containsValue(sampleValues[i]));
              }
          }
      }
  
      /**
       * Tests that the {@link Map#keySet} set is backed by
       * the underlying map by removing from the keySet set
       * and testing if the key was removed from the map.
       */
      public void testValuesRemovedFromKeySetAreRemovedFromMap() {
          resetFull();
          Object[] sampleKeys = getSampleKeys();
          Set keys = map.keySet();
          for(int i=0;i<sampleKeys.length;i++) {
              try {
                  keys.remove(sampleKeys[i]);
              } catch(UnsupportedOperationException e) {
                  // if key.remove is unsupported, just skip this test
                  return;
              }
              assertTrue("Key should have been removed from the underlying map.",!map.containsKey(sampleKeys[i]));
          }
      }
  
      // TODO: Need:
      //    testValuesRemovedFromEntrySetAreRemovedFromMap
      //    same for EntrySet/KeySet/values's
      //      Iterator.remove, removeAll, retainAll, clear
      // TODO: Also need:
      //    Test that EntrySet/KeySet/values all do not allow add/addAll
  
  
      /**
       *  Utility methods to create an array of Map.Entry objects
       *  out of the given key and value arrays.<P>
       *
       *  @param keys    the array of keys
       *  @param values  the array of values
       *  @return an array of Map.Entry of those keys to those values
       */
      private Map.Entry[] makeEntryArray(Object[] keys, Object[] values) {
          Map.Entry[] result = new Map.Entry[keys.length];
          for (int i = 0; i < keys.length; i++) {
              result[i] = new DefaultMapEntry(keys[i], values[i]);
          }
          return result;
      }
  
  
      /**
       *  Bulk test {@link Map#entrySet()}.  This method runs through all of
       *  the tests in {@link TestSet}.  
       *  After modification operations, {@link #verify()} is invoked to ensure
       *  that the map and the other collection views are still valid.
       *
       *  @return a {@link TestSet} instance for testing the map's entry set
       */
      public BulkTest bulkTestMapEntrySet() {
          return new TestMapEntrySet();
      }
  
      class TestMapEntrySet extends AbstractTestSet {
          public TestMapEntrySet() {
              super("");
          }
  
          // Have to implement manually; entrySet doesn't support addAll
          protected Object[] getFullElements() {
              Object[] k = getSampleKeys();
              Object[] v = getSampleValues();
              return makeEntryArray(k, v);
          }
          
          // Have to implement manually; entrySet doesn't support addAll
          protected Object[] getOtherElements() {
              Object[] k = getOtherKeys();
              Object[] v = getOtherValues();
              return makeEntryArray(k, v);
          }
          
          protected Set makeEmptySet() {
              return makeEmptyMap().entrySet();
          }
          
          protected Set makeFullSet() {
              return makeFullMap().entrySet();
          }
          
          protected boolean isAddSupported() {
              // Collection views don't support add operations.
              return false;
          }
          
          protected boolean isRemoveSupported() {
              // Entry set should only support remove if map does
              return isAddRemoveModifiable();
          }
          
          protected void resetFull() {
              AbstractTestMap.this.resetFull();
              collection = map.entrySet();
              TestMapEntrySet.this.confirmed = AbstractTestMap.this.confirmed.entrySet();
          }
          
          protected void resetEmpty() {
              AbstractTestMap.this.resetEmpty();
              collection = map.entrySet();
              TestMapEntrySet.this.confirmed = AbstractTestMap.this.confirmed.entrySet();
          }
          
          protected void verify() {
              super.verify();
              AbstractTestMap.this.verify();
          }
      }
  
  
      /**
       *  Bulk test {@link Map#keySet()}.  This method runs through all of
       *  the tests in {@link TestSet}.  
       *  After modification operations, {@link #verify()} is invoked to ensure
       *  that the map and the other collection views are still valid.
       *
       *  @return a {@link TestSet} instance for testing the map's key set
       */
      public BulkTest bulkTestMapKeySet() {
          return new TestMapKeySet();
      }
  
      class TestMapKeySet extends AbstractTestSet {
          public TestMapKeySet() {
              super("");
          }
          protected Object[] getFullElements() {
              return getSampleKeys();
          }
          
          protected Object[] getOtherElements() {
              return getOtherKeys();
          }
          
          protected Set makeEmptySet() {
              return makeEmptyMap().keySet();
          }
          
          protected Set makeFullSet() {
              return makeFullMap().keySet();
          }
          
          protected boolean isAddSupported() {
              return false;
          }
          
          protected boolean isRemoveSupported() {
              return isAddRemoveModifiable();
          }
          
          protected void resetEmpty() {
              AbstractTestMap.this.resetEmpty();
              collection = map.keySet();
              TestMapKeySet.this.confirmed = AbstractTestMap.this.confirmed.keySet();
          }
          
          protected void resetFull() {
              AbstractTestMap.this.resetFull();
              collection = map.keySet();
              TestMapKeySet.this.confirmed = AbstractTestMap.this.confirmed.keySet();
          }
          
          protected void verify() {
              super.verify();
              AbstractTestMap.this.verify();
          }
      }
  
  
      /**
       *  Bulk test {@link Map#values()}.  This method runs through all of
       *  the tests in {@link TestCollection}.  
       *  After modification operations, {@link #verify()} is invoked to ensure
       *  that the map and the other collection views are still valid.
       *
       *  @return a {@link TestCollection} instance for testing the map's 
       *    values collection
       */
      public BulkTest bulkTestMapValues() {
          return new TestMapValues();
      }
  
      class TestMapValues extends AbstractTestCollection {
          public TestMapValues() {
              super("");
          }
  
          protected Object[] getFullElements() {
              return getSampleValues();
          }
          
          protected Object[] getOtherElements() {
              return getOtherValues();
          }
          
          protected Collection makeCollection() {
              return makeEmptyMap().values();
          }
          
          protected Collection makeFullCollection() {
              return makeFullMap().values();
          }
          
          protected boolean isAddSupported() {
              return false;
          }
          
          protected boolean isRemoveSupported() {
              return isAddRemoveModifiable();
          }
  
          protected boolean areEqualElementsDistinguishable() {
              // equal values are associated with different keys, so they are
              // distinguishable.  
              return true;
          }
  
          protected Collection makeConfirmedCollection() {
              // never gets called, reset methods are overridden
              return null;
          }
          
          protected Collection makeConfirmedFullCollection() {
              // never gets called, reset methods are overridden
              return null;
          }
          
          protected void resetFull() {
              AbstractTestMap.this.resetFull();
              collection = map.values();
              TestMapValues.this.confirmed = AbstractTestMap.this.confirmed.values();
          }
          
          protected void resetEmpty() {
              AbstractTestMap.this.resetEmpty();
              collection = map.values();
              TestMapValues.this.confirmed = AbstractTestMap.this.confirmed.values();
          }
  
          protected void verify() {
              super.verify();
              AbstractTestMap.this.verify();
          }
  
          // TODO: should test that a remove on the values collection view
          // removes the proper mapping and not just any mapping that may have
          // the value equal to the value returned from the values iterator.
      }
  
  
      /**
       *  Resets the {@link #map}, {@link #entrySet}, {@link #keySet},
       *  {@link #values} and {@link #confirmed} fields to empty.
       */
      protected void resetEmpty() {
          this.map = makeEmptyMap();
          views();
          this.confirmed = new HashMap();
      }
  
  
      /**
       *  Resets the {@link #map}, {@link #entrySet}, {@link #keySet},
       *  {@link #values} and {@link #confirmed} fields to full.
       */
      protected void resetFull() {
          this.map = makeFullMap();
          views();
          this.confirmed = new HashMap();
          Object[] k = getSampleKeys();
          Object[] v = getSampleValues();
          for (int i = 0; i < k.length; i++) {
              confirmed.put(k[i], v[i]);
          }
      }
  
  
      /**
       *  Resets the collection view fields.
       */
      private void views() {
          this.keySet = map.keySet();
          this.values = map.values();
          this.entrySet = map.entrySet();
      }
  
  
      /**
       *  Verifies that {@link #map} is still equal to {@link #confirmed}.
       *  This method checks that the map is equal to the HashMap, 
       *  <I>and</I> that the map's collection views are still equal to
       *  the HashMap's collection views.  An <Code>equals</Code> test
       *  is done on the maps and their collection views; their size and
       *  <Code>isEmpty</Code> results are compared; their hashCodes are
       *  compared; and <Code>containsAll</Code> tests are run on the 
       *  collection views.
       */
      protected void verify() {
          verifyMap();
          verifyEntrySet();
          verifyKeySet();
          verifyValues();
      }
  
      protected void verifyMap() {
          int size = confirmed.size();
          boolean empty = confirmed.isEmpty();
          assertEquals("Map should be same size as HashMap", 
                       size, map.size());
          assertEquals("Map should be empty if HashMap is", 
                       empty, map.isEmpty());
          assertEquals("hashCodes should be the same",
                       confirmed.hashCode(), map.hashCode());
          // this fails for LRUMap because confirmed.equals() somehow modifies
          // map, causing concurrent modification exceptions.
          //assertEquals("Map should still equal HashMap", confirmed, map);
          // this works though and performs the same verification:
          assertTrue("Map should still equal HashMap", map.equals(confirmed));
          // TODO: this should really be reexamined to figure out why LRU map
          // behaves like it does (the equals shouldn't modify since all accesses
          // by the confirmed collection should be through an iterator, thus not
          // causing LRUMap to change).
      }
  
      protected void verifyEntrySet() {
          int size = confirmed.size();
          boolean empty = confirmed.isEmpty();
          assertEquals("entrySet should be same size as HashMap's",
                       size, entrySet.size());
          assertEquals("entrySet should be empty if HashMap is", 
                       empty, entrySet.isEmpty());
          assertTrue("entrySet should contain all HashMap's elements",
                     entrySet.containsAll(confirmed.entrySet()));
          assertEquals("entrySet hashCodes should be the same", 
                       confirmed.entrySet().hashCode(), entrySet.hashCode());
          assertEquals("Map's entry set should still equal HashMap's", 
                       confirmed.entrySet(), entrySet);
      }
  
      protected void verifyKeySet() { 
          int size = confirmed.size();
          boolean empty = confirmed.isEmpty();
          assertEquals("keySet should be same size as HashMap's",
                       size, keySet.size());
          assertEquals("keySet should be empty if HashMap is", 
                       empty, keySet.isEmpty());
          assertTrue("keySet should contain all HashMap's elements",
                     keySet.containsAll(confirmed.keySet()));
          assertEquals("keySet hashCodes should be the same", 
                       confirmed.keySet().hashCode(), keySet.hashCode());
          assertEquals("Map's key set should still equal HashMap's",
                       confirmed.keySet(), keySet);
      }
  
      protected void verifyValues() {
          Bag bag1 = new HashBag(confirmed.values());
          Bag bag2 = new HashBag(values);
  
          int size = confirmed.size();
          boolean empty = confirmed.isEmpty();
          assertEquals("values should be same size as HashMap's",
                       size, values.size());
          assertEquals("values should be empty if HashMap is", 
                       empty, values.isEmpty());
          assertTrue("values should contain all HashMap's elements",
                     values.containsAll(confirmed.values()));
          assertEquals("Map's values should still equal HashMap's",
                       bag1, bag2);
      }
  
  
      /**
       *  Erases any leftover instance variables by setting them to null.
       */
      protected void tearDown() throws Exception {
          map = null;
          keySet = null;
          entrySet = null;
          values = null;
          confirmed = null;
      }
  
  }
  
  
  
  1.1                  jakarta-commons/collections/src/test/org/apache/commons/collections/AbstractTestSortedMap.java
  
  Index: AbstractTestSortedMap.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/AbstractTestSortedMap.java,v 1.1 2003/10/02 23:01:09 scolebourne Exp $
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.collections;
  
  /**
   * Abstract test class for {@link java.util.SortedMap} methods and contracts.
   *
   * @version $Revision: 1.1 $ $Date: 2003/10/02 23:01:09 $
   * 
   * @author Stephen Colebourne
   */
  public abstract class AbstractTestSortedMap extends AbstractTestMap {
  
      /**
       * JUnit constructor.
       * 
       * @param testName  the test name
       */
      public AbstractTestSortedMap(String testName) {
          super(testName);
      }
      
      //-----------------------------------------------------------------------
      /**
       * Can't sort null keys.
       * 
       * @return false
       */
      protected boolean useNullKey() {
          return false;
      }
  
  
      // TODO: Add the SortedMap tests!
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org