commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections/map AbstractTestIterableMap.java AbstractTestOrderedMap.java AbstractTestMap.java
Date Sun, 07 Dec 2003 01:21:52 GMT
scolebourne    2003/12/06 17:21:52

  Modified:    collections/src/test/org/apache/commons/collections/iterators
                        AbstractTestOrderedMapIterator.java
                        AbstractTestMapIterator.java
               collections/src/test/org/apache/commons/collections/map
                        AbstractTestIterableMap.java
                        AbstractTestOrderedMap.java AbstractTestMap.java
  Log:
  Enable LRUMap testing by adding isGetStructuralModify()
  
  Revision  Changes    Path
  1.5       +5 -4      jakarta-commons/collections/src/test/org/apache/commons/collections/iterators/AbstractTestOrderedMapIterator.java
  
  Index: AbstractTestOrderedMapIterator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/iterators/AbstractTestOrderedMapIterator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AbstractTestOrderedMapIterator.java	3 Dec 2003 19:03:21 -0000	1.4
  +++ AbstractTestOrderedMapIterator.java	7 Dec 2003 01:21:51 -0000	1.5
  @@ -146,9 +146,10 @@
               
               // getValue
               Object value = it.getValue();
  -            assertSame("Value must be mapped to key", map.get(key), value);
  +            if (isGetStructuralModify() == false) {
  +                assertSame("Value must be mapped to key", map.get(key), value);
  +            }
               assertTrue("Value must be in map",  map.containsValue(value));
  -            assertSame("Value must be mapped to key", map.get(key), value);
   
               assertEquals(true, it.hasPrevious());
               
  
  
  
  1.9       +18 -6     jakarta-commons/collections/src/test/org/apache/commons/collections/iterators/AbstractTestMapIterator.java
  
  Index: AbstractTestMapIterator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/iterators/AbstractTestMapIterator.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AbstractTestMapIterator.java	2 Dec 2003 21:56:34 -0000	1.8
  +++ AbstractTestMapIterator.java	7 Dec 2003 01:21:51 -0000	1.9
  @@ -149,6 +149,16 @@
       }
   
       /**
  +     * Whether the get operation on the map structurally modifies the map,
  +     * such as with LRUMap. Default is false.
  +     * 
  +     * @return true if the get method structurally modifies the map
  +     */
  +    public boolean isGetStructuralModify() {
  +        return false;
  +    }
  +    
  +    /**
        * The values to be used in the add and set tests.
        * Default is two strings.
        */
  @@ -227,9 +237,10 @@
               
               // getValue
               Object value = it.getValue();
  -            assertSame("Value must be mapped to key", map.get(key), value);
  +            if (isGetStructuralModify() == false) {
  +                assertSame("Value must be mapped to key", map.get(key), value);
  +            }
               assertTrue("Value must be in map",  map.containsValue(value));
  -            assertSame("Value must be mapped to key", map.get(key), value);
   
               verify();
           }
  @@ -257,14 +268,15 @@
               } catch (UnsupportedOperationException ex) {}
               return;
           }
  -        
           Object old = it.setValue(newValue);
           confirmed.put(key, newValue);
           assertSame("Key must not change after setValue", key, it.getKey());
           assertSame("Value must be changed after setValue", newValue, it.getValue());
           assertSame("setValue must return old value", value, old);
           assertEquals("Map must contain key", true, map.containsKey(key));
  -        assertEquals("Map must not contain old value", false, map.containsValue(old));
  +        // test against confirmed, as map may contain value twice
  +        assertEquals("Map must not contain old value", 
  +            confirmed.containsValue(old), map.containsValue(old));
           assertEquals("Map must contain new value", true, map.containsValue(newValue));
           verify();
           
  
  
  
  1.2       +6 -2      jakarta-commons/collections/src/test/org/apache/commons/collections/map/AbstractTestIterableMap.java
  
  Index: AbstractTestIterableMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/map/AbstractTestIterableMap.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractTestIterableMap.java	2 Dec 2003 23:51:49 -0000	1.1
  +++ AbstractTestIterableMap.java	7 Dec 2003 01:21:51 -0000	1.2
  @@ -165,6 +165,10 @@
           public boolean supportsRemove() {
               return AbstractTestIterableMap.this.isRemoveSupported();
           }
  +        
  +        public boolean isGetStructuralModify() {
  +            return AbstractTestIterableMap.this.isGetStructuralModify();
  +        }
   
           public boolean supportsSetValue() {
               return AbstractTestIterableMap.this.isSetValueSupported();
  
  
  
  1.5       +6 -2      jakarta-commons/collections/src/test/org/apache/commons/collections/map/AbstractTestOrderedMap.java
  
  Index: AbstractTestOrderedMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/map/AbstractTestOrderedMap.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AbstractTestOrderedMap.java	2 Dec 2003 23:51:49 -0000	1.4
  +++ AbstractTestOrderedMap.java	7 Dec 2003 01:21:51 -0000	1.5
  @@ -227,6 +227,10 @@
               return AbstractTestOrderedMap.this.isRemoveSupported();
           }
   
  +        public boolean isGetStructuralModify() {
  +            return AbstractTestOrderedMap.this.isGetStructuralModify();
  +        }
  +        
           public boolean supportsSetValue() {
               return AbstractTestOrderedMap.this.isSetValueSupported();
           }
  
  
  
  1.3       +21 -3     jakarta-commons/collections/src/test/org/apache/commons/collections/map/AbstractTestMap.java
  
  Index: AbstractTestMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/map/AbstractTestMap.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractTestMap.java	18 Nov 2003 22:37:17 -0000	1.2
  +++ AbstractTestMap.java	7 Dec 2003 01:21:51 -0000	1.3
  @@ -105,6 +105,7 @@
    * <li> {@link #isPutChangeSupported()}
    * <li> {@link #isSetValueSupported()}
    * <li> {@link #isRemoveSupported()}
  + * <li> {@link #isGetStructuralModify()}
    * <li> {@link #isAllowDuplicateValues()}
    * <li> {@link #isAllowNullKey()}
    * <li> {@link #isAllowNullValue()}
  @@ -249,6 +250,18 @@
       /**
        * Returns true if the maps produced by 
        * {@link #makeEmptyMap()} and {@link #makeFullMap()}
  +     * can cause structural modification on a get(). The example is LRUMap.
  +     * <p>
  +     * Default implementation returns false.
  +     * Override if your map class structurally modifies on get.
  +     */
  +    public boolean isGetStructuralModify() {
  +        return false;
  +    }
  +
  +    /**
  +     * Returns true if the maps produced by 
  +     * {@link #makeEmptyMap()} and {@link #makeFullMap()}
        * supports null keys.
        * <p>
        * Default implementation returns true.
  @@ -1159,6 +1172,9 @@
               // Entry set should only support remove if map does
               return AbstractTestMap.this.isRemoveSupported();
           }
  +        public boolean isGetStructuralModify() {
  +            return AbstractTestMap.this.isGetStructuralModify();
  +        }
           public boolean supportsEmptyCollections() {
               return AbstractTestMap.this.supportsEmptyCollections();
           }
  @@ -1186,7 +1202,9 @@
                   Map.Entry entry = (Map.Entry) it.next();
                   assertEquals(true, AbstractTestMap.this.map.containsKey(entry.getKey()));
                   assertEquals(true, AbstractTestMap.this.map.containsValue(entry.getValue()));
  -                assertEquals(AbstractTestMap.this.map.get(entry.getKey()), entry.getValue());
  +                if (isGetStructuralModify() == false) {
  +                    assertEquals(AbstractTestMap.this.map.get(entry.getKey()), entry.getValue());
  +                }
                   count++;
               }
               assertEquals(collection.size(), count);
  
  
  

---------------------------------------------------------------------
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