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/11/02 20:47:11 UTC

cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections/iterators AbstractTestIterator.java AbstractTestMapIterator.java

scolebourne    2003/11/02 11:47:10

  Modified:    collections/src/test/org/apache/commons/collections/iterators
                        AbstractTestIterator.java
                        AbstractTestMapIterator.java
  Log:
  Enable iterator testing to better integrate with collection/map tests
  
  Revision  Changes    Path
  1.3       +14 -2     jakarta-commons/collections/src/test/org/apache/commons/collections/iterators/AbstractTestIterator.java
  
  Index: AbstractTestIterator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/iterators/AbstractTestIterator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractTestIterator.java	2 Oct 2003 22:14:34 -0000	1.2
  +++ AbstractTestIterator.java	2 Nov 2003 19:47:10 -0000	1.3
  @@ -141,6 +141,13 @@
           return true;
       }
   
  +    /**
  +     * Allows subclasses to add complex cross verification
  +     */
  +    protected void verify() {
  +        // do nothing
  +    }
  +
       //-----------------------------------------------------------------------
       /**
        * Test the empty iterator.
  @@ -161,6 +168,7 @@
               fail("NoSuchElementException must be thrown when Iterator is exhausted");
           } catch (NoSuchElementException e) {
           }
  +        verify();
       }
   
       /**
  @@ -186,6 +194,7 @@
           // iterate through
           while (it.hasNext()) {
               it.next();
  +            verify();
           }
   
           // next() must throw NoSuchElementException now
  @@ -215,16 +224,19 @@
               it.remove();
               fail();
           } catch (IllegalStateException ex) {}
  +        verify();
           
           // remove after next should be fine
           it.next();
           it.remove();
  +        verify();
           
           // should throw IllegalStateException for second remove()
           try {
               it.remove();
               fail();
           } catch (IllegalStateException ex) {}
  +        verify();
       }
       
   }
  
  
  
  1.2       +11 -2     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractTestMapIterator.java	2 Nov 2003 18:29:59 -0000	1.1
  +++ AbstractTestMapIterator.java	2 Nov 2003 19:47:10 -0000	1.2
  @@ -166,6 +166,7 @@
           }
   
           MapIterator it = makeEmptyMapIterator();
  +        Map map = getMap();
           assertEquals(false, it.hasNext());
           
           // next() should throw a NoSuchElementException
  @@ -253,6 +254,7 @@
               lastEntry = entry;
               lastKey = key;
               lastValue = value;
  +            verify();
           }
       }
       
  @@ -290,6 +292,7 @@
               assertTrue("Value must be in map",  map.containsValue(newValue));
               assertSame("Value must be mapped to key", map.get(key), newValue);
           }
  +        verify();
           
           it.setValue(newValue);  // same value - should be OK
           assertSame("Key must not change after setValue", key, it.getKey());
  @@ -302,6 +305,7 @@
               assertTrue("Value must be in map",  map.containsValue(newValue));
               assertSame("Value must be mapped to key", map.get(key), newValue);
           }
  +        verify();
       }
   
       //-----------------------------------------------------------------------
  @@ -338,6 +342,7 @@
               assertTrue("Value must be in map",  map.containsValue(newValue));
               assertSame("Value must be mapped to key", map.get(key), newValue);
           }
  +        verify();
           
           entry.setValue(newValue);  // same value - should be OK
           assertSame("Key must not change after setValue", key, it.getKey());
  @@ -350,6 +355,7 @@
               assertTrue("Value must be in map",  map.containsValue(newValue));
               assertSame("Value must be mapped to key", map.get(key), newValue);
           }
  +        verify();
       }
   
       //-----------------------------------------------------------------------
  @@ -360,16 +366,19 @@
           Object newValue = addSetValue();
           
           MapIterator it = makeFullMapIterator();
  +        Map map = getMap();
           assertEquals(true, it.hasNext());
           Object key = it.next();
           
           it.setValue(newValue);
           it.remove();
  +        verify();
           
           try {
               it.setValue(newValue);
               fail();
           } catch (IllegalStateException ex) {}
  +        verify();
       }
   
   }
  
  
  

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