scolebourne    2003/01/15 14:02:33

  Modified:    collections/src/test/org/apache/commons/collections
                        TestIteratorUtils.java
  Log:
  Test Unmodifiable/Resetable combination iterators
  
  
  Revision  Changes    Path
  1.4       +39 -9     
jakarta-commons/collections/src/test/org/apache/commons/collections/TestIteratorUtils.java
  
  Index: TestIteratorUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestIteratorUtils.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestIteratorUtils.java    8 Dec 2002 15:42:35 -0000       1.3
  +++ TestIteratorUtils.java    15 Jan 2003 22:02:33 -0000      1.4
  @@ -1,13 +1,10 @@
   /*
    * $Header$
  - * $Revision$
  - * $Date$
  - *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -23,11 +20,11 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:
  + *    any, must include the following acknowledgment:
    *       "This product includes software developed by the
    *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  + *    Alternately, this acknowledgment may appear in the software itself,
  + *    if and wherever such third-party acknowledgments normally appear.
    *
    * 4. The names "The Jakarta Project", "Commons", and "Apache Software
    *    Foundation" must not be used to endorse or promote products derived
  @@ -36,7 +33,7 @@
    *
    * 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 Group.
  + *    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
  @@ -67,6 +64,9 @@
   import java.util.ListIterator;
   
   import junit.framework.Test;
  +
  +import org.apache.commons.collections.iterators.ResetableIterator;
  +import org.apache.commons.collections.iterators.ResetableListIterator;
   /**
    *  Tests for IteratorUtils.
    */
  @@ -161,6 +161,21 @@
       }
   
       /**
  +     * Test resetability
  +     */
  +    public void testResetableUnmodifiableIterator() {
  +        Integer four = new Integer(4);
  +        ResetableIterator it = (ResetableIterator) 
  +            
IteratorUtils.unmodifiableIterator(IteratorUtils.singletonIterator(four));
  +        
  +        assertEquals(true, it.hasNext());
  +        assertSame(four, it.next());
  +        assertEquals(false, it.hasNext());
  +        it.reset();
  +        assertEquals(true, it.hasNext());
  +    }
  +    
  +    /**
        * Test next(), hasNext(), previous() and hasPrevious() for an immutable
        * ListIterator.
        */
  @@ -211,6 +226,21 @@
           assertTrue(listIterator.hasNext());
       }
   
  +    /**
  +     * Test resetability
  +     */
  +    public void testResetableUnmodifiableListIterator() {
  +        Integer four = new Integer(4);
  +        ResetableListIterator it = (ResetableListIterator) 
  +            
IteratorUtils.unmodifiableListIterator(IteratorUtils.singletonListIterator(four));
  +        
  +        assertEquals(true, it.hasNext());
  +        assertSame(four, it.next());
  +        assertEquals(false, it.hasNext());
  +        it.reset();
  +        assertEquals(true, it.hasNext());
  +    }
  +    
       /**
        * Test remove() for an immutable Iterator.
        */
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to