commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwaldh...@apache.org
Subject cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections TestMap.java TestMultiHashMap.java
Date Fri, 01 Nov 2002 19:36:54 GMT
rwaldhoff    2002/11/01 11:36:54

  Modified:    collections/src/test/org/apache/commons/collections
                        TestMap.java TestMultiHashMap.java
  Log:
  add generic TestMap test for http://issues.apache.org/bugzilla/show_bug.cgi?id=9573 (values
isn't backed by map), but override the test in TestMultiHashMap for now
  
  Revision  Changes    Path
  1.22      +34 -4     jakarta-commons/collections/src/test/org/apache/commons/collections/TestMap.java
  
  Index: TestMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestMap.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- TestMap.java	1 Nov 2002 19:07:53 -0000	1.21
  +++ TestMap.java	1 Nov 2002 19:36:54 -0000	1.22
  @@ -769,6 +769,36 @@
           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]));
  +            }
  +        }
  +    }
   
       /**
        *  Utility methods to create an array of Map.Entry objects
  
  
  
  1.7       +12 -3     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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TestMultiHashMap.java	12 Oct 2002 22:36:22 -0000	1.6
  +++ TestMultiHashMap.java	1 Nov 2002 19:36:54 -0000	1.7
  @@ -268,6 +268,15 @@
       public void testMapHashCode() {
       }
   
  +    // since the MultiHashMap.values Collection isn't currently
  +    // backed by the map, we need to skip this test for now
  +    // fix bug 9573 <http://issues.apache.org/bugzilla/show_bug.cgi?id=9573>
  +    // and enable this test
  +    public void testValuesRemovedFromValuesCollectionAreRemovedFromMap() {
  +        // TODO: fix bug 9573 <http://issues.apache.org/bugzilla/show_bug.cgi?id=9573>
  +        // and enable this test
  +    }
  +
       // The verification for the map and its entry set must also be overridden
       // because the values are not going to be the same as the values in the
       // confirmed map (they're going to be collections of values instead).
  
  
  

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


Mime
View raw message