commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections TestMap.java
Date Thu, 02 Oct 2003 04:04:22 GMT
bayard      2003/10/01 21:04:22

  Modified:    collections/src/test/org/apache/commons/collections
                        TestMap.java
  Log:
  Added a test to prove that a Map's keySet method is backed by the map. Also added a series
of TODOs to cover all the other backing/non-backing possibilities.
  
  Revision  Changes    Path
  1.28      +32 -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.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- TestMap.java	2 Oct 2003 03:42:03 -0000	1.27
  +++ TestMap.java	2 Oct 2003 04:04:22 -0000	1.28
  @@ -818,6 +818,34 @@
       }
   
       /**
  +     * 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>
        *
  
  
  

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


Mime
View raw message