You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by eb...@apache.org on 2013/11/20 08:51:32 UTC

svn commit: r1543728 - in /commons/proper/collections/trunk/src: main/java/org/apache/commons/collections4/iterators/IteratorEnumeration.java test/java/org/apache/commons/collections4/iterators/IteratorEnumerationTest.java

Author: ebourg
Date: Wed Nov 20 07:51:32 2013
New Revision: 1543728

URL: http://svn.apache.org/r1543728
Log:
Added a test for IteratorEnumeration

Added:
    commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/IteratorEnumerationTest.java   (with props)
Modified:
    commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/iterators/IteratorEnumeration.java

Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/iterators/IteratorEnumeration.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/iterators/IteratorEnumeration.java?rev=1543728&r1=1543727&r2=1543728&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/iterators/IteratorEnumeration.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/iterators/IteratorEnumeration.java Wed Nov 20 07:51:32 2013
@@ -36,7 +36,6 @@ public class IteratorEnumeration<E> impl
      * until {@link #setIterator(Iterator) setIterator} is invoked.
      */
     public IteratorEnumeration() {
-        super();
     }
 
     /**
@@ -46,7 +45,6 @@ public class IteratorEnumeration<E> impl
      * @param iterator the iterator to use
      */
     public IteratorEnumeration(final Iterator<? extends E> iterator) {
-        super();
         this.iterator = iterator;
     }
 

Added: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/IteratorEnumerationTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/IteratorEnumerationTest.java?rev=1543728&view=auto
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/IteratorEnumerationTest.java (added)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/IteratorEnumerationTest.java Wed Nov 20 07:51:32 2013
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.collections4.iterators;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests the IteratorEnumeration.
+ * 
+ * @version $Id$
+ */
+public class IteratorEnumerationTest extends TestCase {
+    
+    public void testEnumeration() {
+        Iterator<String> iterator = Arrays.asList("a", "b", "c").iterator();
+        IteratorEnumeration<String> enumeration = new IteratorEnumeration<String>(iterator);
+        
+        assertEquals(iterator, enumeration.getIterator());
+        
+        assertTrue(enumeration.hasMoreElements());
+        assertEquals("a", enumeration.nextElement());
+        assertEquals("b", enumeration.nextElement());
+        assertEquals("c", enumeration.nextElement());
+        assertFalse(enumeration.hasMoreElements());
+
+        try {
+            enumeration.nextElement();
+            fail("NoSuchElementException expected");
+        } catch (NoSuchElementException e) {
+            // expected
+        }
+    }
+}

Propchange: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/IteratorEnumerationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/iterators/IteratorEnumerationTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL