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 TestIteratorUtils.java
Date Sat, 08 Nov 2003 19:26:29 GMT
scolebourne    2003/11/08 11:26:29

  Modified:    collections/src/java/org/apache/commons/collections
                        IteratorUtils.java
               collections/src/java/org/apache/commons/collections/iterators
                        OrderedMapIterator.java
                        ResetableOrderedMapIterator.java
               collections/src/test/org/apache/commons/collections
                        TestIteratorUtils.java
  Added:       collections/src/java/org/apache/commons/collections/iterators
                        ResetableOrderedIterator.java OrderedIterator.java
  Log:
  Add OrderedIterator
  
  Revision  Changes    Path
  1.16      +59 -168   jakarta-commons/collections/src/java/org/apache/commons/collections/IteratorUtils.java
  
  Index: IteratorUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/IteratorUtils.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- IteratorUtils.java	8 Nov 2003 18:43:12 -0000	1.15
  +++ IteratorUtils.java	8 Nov 2003 19:26:28 -0000	1.16
  @@ -57,7 +57,6 @@
    */
   package org.apache.commons.collections;
   
  -import java.io.Serializable;
   import java.lang.reflect.Array;
   import java.lang.reflect.Method;
   import java.util.ArrayList;
  @@ -81,15 +80,20 @@
   import org.apache.commons.collections.iterators.IteratorEnumeration;
   import org.apache.commons.collections.iterators.ListIteratorWrapper;
   import org.apache.commons.collections.iterators.LoopingIterator;
  +import org.apache.commons.collections.iterators.MapIterator;
   import org.apache.commons.collections.iterators.ObjectArrayIterator;
   import org.apache.commons.collections.iterators.ObjectArrayListIterator;
   import org.apache.commons.collections.iterators.ResetableIterator;
   import org.apache.commons.collections.iterators.ResetableListIterator;
   import org.apache.commons.collections.iterators.ResetableMapIterator;
  +import org.apache.commons.collections.iterators.ResetableOrderedIterator;
   import org.apache.commons.collections.iterators.ResetableOrderedMapIterator;
   import org.apache.commons.collections.iterators.SingletonIterator;
   import org.apache.commons.collections.iterators.SingletonListIterator;
   import org.apache.commons.collections.iterators.TransformIterator;
  +import org.apache.commons.collections.iterators.UnmodifiableIterator;
  +import org.apache.commons.collections.iterators.UnmodifiableListIterator;
  +import org.apache.commons.collections.iterators.UnmodifiableMapIterator;
   
   /**
    * Provides static utility methods and decorators for {@link Iterator} 
  @@ -115,11 +119,15 @@
        */    
       public static final ResetableListIterator EMPTY_LIST_ITERATOR = new EmptyListIterator();
       /**
  +     * An ordered iterator over no elements
  +     */    
  +    public static final ResetableOrderedIterator EMPTY_ORDERED_ITERATOR = new EmptyOrderedIterator();
  +    /**
        * A map iterator over no elements
        */    
       public static final ResetableMapIterator EMPTY_MAP_ITERATOR = new EmptyMapIterator();
       /**
  -     * A map iterator over no elements
  +     * An ordered map iterator over no elements
        */    
       public static final ResetableOrderedMapIterator EMPTY_ORDERED_MAP_ITERATOR = new EmptyOrderedMapIterator();
   
  @@ -157,12 +165,24 @@
       }
   
       /**
  +     * Gets an empty ordered iterator.
  +     * <p>
  +     * This iterator is a valid iterator object that will iterate 
  +     * over nothing.
  +     *
  +     * @return  an ordered iterator over nothing
  +     */
  +    public static ResetableOrderedIterator emptyOrderedIterator() {
  +        return EMPTY_ORDERED_ITERATOR;
  +    }
  +
  +    /**
        * Gets an empty map iterator.
        * <p>
        * This iterator is a valid map iterator object that will iterate 
        * over nothing.
        *
  -     * @return  a list iterator over nothing
  +     * @return  a map iterator over nothing
        */
       public static ResetableMapIterator emptyMapIterator() {
           return EMPTY_MAP_ITERATOR;
  @@ -174,7 +194,7 @@
        * This iterator is a valid map iterator object that will iterate 
        * over nothing.
        *
  -     * @return  a list iterator over nothing
  +     * @return  a map iterator over nothing
        */
       public static ResetableOrderedMapIterator emptyOrderedMapIterator() {
           return EMPTY_ORDERED_MAP_ITERATOR;
  @@ -403,10 +423,7 @@
        * @return an immutable version of the iterator
        */
       public static Iterator unmodifiableIterator(Iterator iterator) {
  -        if (iterator instanceof ResetableIterator) {
  -            return new ResetableUnmodifiableIterator((ResetableIterator) iterator);
  -        }
  -        return new UnmodifiableIterator(iterator);
  +        return UnmodifiableIterator.decorate(iterator);
       }
       
       /**
  @@ -419,10 +436,19 @@
        * @return an immutable version of the iterator
        */
       public static ListIterator unmodifiableListIterator(ListIterator listIterator) {
  -        if (listIterator instanceof ResetableListIterator) {
  -            return new ResetableUnmodifiableListIterator((ResetableListIterator) listIterator);
  -        }
  -        return new UnmodifiableListIterator(listIterator);
  +        return UnmodifiableListIterator.decorate(listIterator);
  +    }
  +
  +    /**
  +     * Gets an immutable version of a {@link MapIterator}. The returned object
  +     * will always throw an {@link UnsupportedOperationException} for
  +     * the {@link Iterator#remove}, {@link MapIterator#setValue(Object)} methods.
  +     *
  +     * @param mapIterator  the iterator to make immutable
  +     * @return an immutable version of the iterator
  +     */
  +    public static MapIterator unmodifiableMapIterator(MapIterator mapIterator) {
  +        return UnmodifiableMapIterator.decorate(mapIterator);
       }
   
       /**
  @@ -859,6 +885,25 @@
   
       //-----------------------------------------------------------------------    
       /**
  +     * EmptyOrderedIterator class
  +     */
  +    static class EmptyOrderedIterator extends EmptyIterator implements ResetableOrderedIterator
{
  +        
  +        EmptyOrderedIterator() {
  +            super();
  +        }
  +        
  +        public boolean hasPrevious() {
  +            return false;
  +        }
  +        
  +        public Object previous() {
  +            throw new NoSuchElementException("Iterator contains no elements");
  +        }
  +    }
  +
  +    //-----------------------------------------------------------------------    
  +    /**
        * EmptyMapIterator class
        */
       static class EmptyMapIterator extends EmptyIterator implements ResetableMapIterator
{
  @@ -899,158 +944,4 @@
           }
       }
   
  -    //-----------------------------------------------------------------------    
  -    /**
  -     * A wrapper for an {@link java.util.Iterator} which makes it immutable. All
  -     * calls are passed through to the delegate. The {@link #remove()} method
  -     * always throws an {@link java.lang.UnsupportedOperationException}.
  -     *
  -     * @author <a href="mailto:rich@rd.gen.nz">Rich Dougherty</a>
  -     * @author Stephen Colebourne
  -     */
  -    static class UnmodifiableIterator implements Iterator, Serializable {
  -
  -        /**
  -         * All calls to this iterator are passed to the delegate.
  -         */
  -        protected Iterator delegate;
  -
  -        /**
  -         * Create an UnmodifiableIterator.
  -         *
  -         * @param delegate  the delegate to pass all calls to
  -         */
  -        public UnmodifiableIterator(Iterator delegate) {
  -            this.delegate = delegate;
  -        }
  -
  -        public boolean hasNext() {
  -            return delegate.hasNext();
  -        }
  -
  -        public Object next() {
  -            return delegate.next();
  -        }
  -
  -        public void remove() {
  -            throw new UnsupportedOperationException("This iterator is immutable");
  -        }
  -
  -    }
  -
  -    //-----------------------------------------------------------------------
  -    /**
  -     * An unmodifiable resetable iterator.
  -     *
  -     * @author Stephen Colebourne
  -     */
  -    static class ResetableUnmodifiableIterator extends UnmodifiableIterator implements
ResetableIterator {
  -        
  -        /**
  -         * Create a ResetableUnmodifiableIterator.
  -         *
  -         * @param delegate  the delegate to pass all calls to
  -         */
  -        public ResetableUnmodifiableIterator(ResetableIterator delegate) {
  -            super(delegate);
  -        }
  -
  -        /**
  -         * Reset the iterator
  -         */
  -        public void reset() {
  -            ((ResetableIterator) delegate).reset();
  -        }
  -
  -    }
  -    
  -    //-----------------------------------------------------------------------
  -    /**
  -     * A wrapper for an {@link java.util.ListIterator} which makes it immutable.
  -     * All calls are passed through to the delegate. The {@link #remove()},
  -     * {@link #add(Object)} and (@link #set(Object)} methods always throw an
  -     * {@link java.lang.UnsupportedOperationException}.
  -     *
  -     * @author <a href="mailto:rich@rd.gen.nz">Rich Dougherty</a>
  -     */
  -    static class UnmodifiableListIterator
  -        implements ListIterator, Serializable {
  -
  -        /**
  -         * All calls to this iterator are passed to the delegate.
  -         */
  -        protected ListIterator delegate;
  -
  -        /**
  -         * Create an UnmodifiableListIterator.
  -         *
  -         * @param delegate The delegate to pass all calls to.
  -         */
  -        public UnmodifiableListIterator(ListIterator delegate) {
  -            this.delegate = delegate;
  -        }
  -
  -        public boolean hasNext() {
  -            return delegate.hasNext();
  -        }
  -
  -        public Object next() {
  -            return delegate.next();
  -        }
  -
  -        public boolean hasPrevious() {
  -            return delegate.hasPrevious();
  -        }
  -
  -        public Object previous() {
  -            return delegate.previous();
  -        }
  -
  -        public int nextIndex() {
  -            return delegate.nextIndex();
  -        }
  -
  -        public int previousIndex() {
  -            return delegate.previousIndex();
  -        }
  -
  -        public void remove() {
  -            throw new UnsupportedOperationException("This iterator is immutable");
  -        }
  -
  -        public void set(Object o) {
  -            throw new UnsupportedOperationException("This iterator is immutable");
  -        }
  -
  -        public void add(Object o) {
  -            throw new UnsupportedOperationException("This iterator is immutable");
  -        }
  -    }
  -    
  -    //-----------------------------------------------------------------------
  -    /**
  -     * An unmodifiable resetable list iterator.
  -     *
  -     * @author Stephen Colebourne
  -     */
  -    static class ResetableUnmodifiableListIterator extends UnmodifiableListIterator implements
ResetableListIterator {
  -            
  -        /**
  -         * Create a ResetableUnmodifiableListIterator.
  -         *
  -         * @param delegate  the delegate to pass all calls to
  -         */
  -        public ResetableUnmodifiableListIterator(ResetableListIterator delegate) {
  -            super(delegate);
  -        }
  -    
  -        /**
  -         * Reset the iterator
  -         */
  -        public void reset() {
  -            ((ResetableListIterator) delegate).reset();
  -        }
  -    
  -    }
  -        
   }
  
  
  
  1.2       +3 -3      jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/OrderedMapIterator.java
  
  Index: OrderedMapIterator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/OrderedMapIterator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- OrderedMapIterator.java	8 Nov 2003 18:43:12 -0000	1.1
  +++ OrderedMapIterator.java	8 Nov 2003 19:26:28 -0000	1.2
  @@ -67,7 +67,7 @@
    *
    * @author Stephen Colebourne
    */
  -public interface OrderedMapIterator extends MapIterator {
  +public interface OrderedMapIterator extends MapIterator, OrderedIterator {
       
       /**
        * Checks to see if there is a previous entry that can be iterated to.
  
  
  
  1.2       +4 -3      jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/ResetableOrderedMapIterator.java
  
  Index: ResetableOrderedMapIterator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/ResetableOrderedMapIterator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ResetableOrderedMapIterator.java	8 Nov 2003 18:43:13 -0000	1.1
  +++ ResetableOrderedMapIterator.java	8 Nov 2003 19:26:28 -0000	1.2
  @@ -66,7 +66,8 @@
    * 
    * @author Stephen Colebourne
    */
  -public interface ResetableOrderedMapIterator extends OrderedMapIterator, ResetableMapIterator
{
  +public interface ResetableOrderedMapIterator
  +        extends OrderedMapIterator, ResetableMapIterator, ResetableOrderedIterator {
   
       /**
        * Resets the iterator back to the position at which the iterator
  
  
  
  1.1                  jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/ResetableOrderedIterator.java
  
  Index: ResetableOrderedIterator.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/ResetableOrderedIterator.java,v
1.1 2003/11/08 19:26:28 scolebourne Exp $
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 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 Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.collections.iterators;
  
  /** 
   * Interface implemented by those ordered iterators that can be reset back 
   * to an initial state.
   *
   * @since Commons Collections 3.0
   * @version $Revision: 1.1 $ $Date: 2003/11/08 19:26:28 $
   * 
   * @author Stephen Colebourne
   */
  public interface ResetableOrderedIterator extends OrderedIterator, ResetableIterator {
  
      /**
       * Resets the iterator back to the position at which the iterator
       * was created.
       */
      public void reset();
  
  }
  
  
  
  1.1                  jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/OrderedIterator.java
  
  Index: OrderedIterator.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/OrderedIterator.java,v
1.1 2003/11/08 19:26:28 scolebourne Exp $
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 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 Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.collections.iterators;
  
  import java.util.Iterator;
  
  /**
   * Defines an iterator that operates over a ordered collections.
   * <p>
   * This iterator allows both forward and reverse iteration through the collection.
   *  
   * @since Commons Collections 3.0
   * @version $Revision: 1.1 $ $Date: 2003/11/08 19:26:28 $
   *
   * @author Stephen Colebourne
   */
  public interface OrderedIterator extends Iterator {
      
      /**
       * Checks to see if there is a previous entry that can be iterated to.
       *
       * @return <code>true</code> if the iterator has a previous element
       */
      boolean hasPrevious();
  
      /**
       * Gets the previous element from the collection.
       *
       * @return the previous key in the iteration
       * @throws NoSuchElementException if the iteration is finished
       */
      Object previous();
  
  }
  
  
  
  1.10      +33 -32    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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TestIteratorUtils.java	8 Nov 2003 18:47:38 -0000	1.9
  +++ TestIteratorUtils.java	8 Nov 2003 19:26:29 -0000	1.10
  @@ -67,10 +67,12 @@
   import junit.framework.Test;
   
   import org.apache.commons.collections.iterators.MapIterator;
  +import org.apache.commons.collections.iterators.OrderedIterator;
   import org.apache.commons.collections.iterators.OrderedMapIterator;
   import org.apache.commons.collections.iterators.ResetableIterator;
   import org.apache.commons.collections.iterators.ResetableListIterator;
   import org.apache.commons.collections.iterators.ResetableMapIterator;
  +import org.apache.commons.collections.iterators.ResetableOrderedIterator;
   import org.apache.commons.collections.iterators.ResetableOrderedMapIterator;
   
   /**
  @@ -525,12 +527,41 @@
       /**
        * Test empty map iterator
        */
  +    public void testEmptyOrderedIterator() {
  +        assertTrue(IteratorUtils.EMPTY_ORDERED_ITERATOR instanceof Iterator);
  +        assertTrue(IteratorUtils.EMPTY_ORDERED_ITERATOR instanceof OrderedIterator);
  +        assertTrue(IteratorUtils.EMPTY_ORDERED_ITERATOR instanceof ResetableIterator);
  +        assertTrue(IteratorUtils.EMPTY_ORDERED_ITERATOR instanceof ResetableOrderedIterator);
  +        assertEquals(false, IteratorUtils.EMPTY_ORDERED_ITERATOR.hasNext());
  +        assertEquals(false, IteratorUtils.EMPTY_ORDERED_ITERATOR.hasPrevious());
  +        IteratorUtils.EMPTY_ORDERED_ITERATOR.reset();
  +        assertSame(IteratorUtils.EMPTY_ORDERED_ITERATOR, IteratorUtils.EMPTY_ORDERED_ITERATOR);
  +        assertSame(IteratorUtils.EMPTY_ORDERED_ITERATOR, IteratorUtils.emptyOrderedIterator());
  +        try {
  +            IteratorUtils.EMPTY_ORDERED_ITERATOR.next();
  +            fail();
  +        } catch (NoSuchElementException ex) {}
  +        try {
  +            IteratorUtils.EMPTY_ORDERED_ITERATOR.previous();
  +            fail();
  +        } catch (NoSuchElementException ex) {}
  +        try {
  +            IteratorUtils.EMPTY_ORDERED_ITERATOR.remove();
  +            fail();
  +        } catch (IllegalStateException ex) {}
  +    }
  +    
  +    //-----------------------------------------------------------------------
  +    /**
  +     * Test empty map iterator
  +     */
       public void testEmptyOrderedMapIterator() {
           assertTrue(IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR instanceof Iterator);
           assertTrue(IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR instanceof MapIterator);
           assertTrue(IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR instanceof OrderedMapIterator);
           assertTrue(IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR instanceof ResetableIterator);
           assertTrue(IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR instanceof ResetableMapIterator);
  +        assertTrue(IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR instanceof ResetableOrderedIterator);
           assertTrue(IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR instanceof ResetableOrderedMapIterator);
           assertEquals(false, IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR.hasNext());
           assertEquals(false, IteratorUtils.EMPTY_ORDERED_MAP_ITERATOR.hasPrevious());
  @@ -590,21 +621,6 @@
       }
   
       /**
  -     * 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.
        */
  @@ -655,21 +671,6 @@
           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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message