You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/01/12 15:32:03 UTC

[commons-collections] branch master updated (de7cb01 -> 22560c3)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-collections.git.


    from de7cb01  Javadoc: Add missing tags.
     new a963a12  Sort methods.
     new 45eee00  Sort Sort methods.
     new 22560c3  [COLLECTIONS-780] Add org.apache.commons.collections4.EnumerationUtils.asIterable(Enumeration).

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/changes/changes.xml                            |   3 +
 .../commons/collections4/EnumerationUtils.java     |  21 +-
 .../commons/collections4/EnumerationUtilsTest.java |  92 +++--
 .../commons/collections4/IteratorUtilsTest.java    | 370 ++++++++++-----------
 4 files changed, 266 insertions(+), 220 deletions(-)


[commons-collections] 01/03: Sort methods.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-collections.git

commit a963a123f73a0dde67d7c8f0c6ebb88a1e43aac4
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jan 12 10:17:05 2020 -0500

    Sort methods.
---
 .../commons/collections4/IteratorUtilsTest.java    | 370 ++++++++++-----------
 1 file changed, 185 insertions(+), 185 deletions(-)

diff --git a/src/test/java/org/apache/commons/collections4/IteratorUtilsTest.java b/src/test/java/org/apache/commons/collections4/IteratorUtilsTest.java
index ce2291b..87d9437 100644
--- a/src/test/java/org/apache/commons/collections4/IteratorUtilsTest.java
+++ b/src/test/java/org/apache/commons/collections4/IteratorUtilsTest.java
@@ -436,6 +436,11 @@ public class IteratorUtilsTest {
         }
     }
 
+    @Test(expected = NullPointerException.class)
+    public void testAsEnumerationNull() {
+        IteratorUtils.asEnumeration(null);
+    }
+
     @Test
     public void testAsIterable() {
         final List<Integer> list = new ArrayList<>();
@@ -467,6 +472,37 @@ public class IteratorUtilsTest {
         }
     }
 
+    @Test(expected = NullPointerException.class)
+    public void testAsIterator() {
+        final Vector<String> vector = new Vector<>();
+        vector.addElement("zero");
+        vector.addElement("one");
+        Enumeration<String> en = vector.elements();
+        assertTrue("create instance fail", IteratorUtils.asIterator(en) instanceof Iterator);
+        IteratorUtils.asIterator(null);
+    }
+
+    @Test
+    public void testAsIteratorNull() {
+        Collection coll = new ArrayList();
+        coll.add("test");
+        final Vector<String> vector = new Vector<>();
+        vector.addElement("test");
+        vector.addElement("one");
+        Enumeration<String> en = vector.elements();
+        assertTrue("create instance fail", IteratorUtils.asIterator(en, coll) instanceof Iterator);
+        try {
+            IteratorUtils.asIterator(null, coll);
+        } catch (NullPointerException npe) {
+            //
+        }
+        try {
+            IteratorUtils.asIterator(en, null);
+        } catch (NullPointerException npe) {
+            //
+        }
+    }
+
     @Test
     public void testAsMultipleIterable() {
         final List<Integer> list = new ArrayList<>();
@@ -504,6 +540,16 @@ public class IteratorUtilsTest {
         }
     }
 
+    @Test
+    public void testChainedIterator() {
+        ArrayList arrayList = new ArrayList();
+        Iterator ie = arrayList.iterator();
+        assertTrue("create instance fail", IteratorUtils.chainedIterator(ie) instanceof Iterator);
+        final Collection<Iterator<?>> coll = new ArrayList();
+        assertTrue("create instance fail", IteratorUtils.chainedIterator(coll) instanceof Iterator);
+
+    }
+
     /**
      * Tests methods collatedIterator(...)
      */
@@ -553,6 +599,42 @@ public class IteratorUtilsTest {
         assertEquals(combinedList, result);
     }
 
+    @Test(expected = NullPointerException.class)
+    public void testCollatedIteratorCollectionNull() {
+        Collection<Iterator<?>> coll = new ArrayList<>();
+        coll.add(collectionOdd.iterator());
+        // natural ordering
+        Iterator<?> it = IteratorUtils.collatedIterator(null, coll);
+        List<?> result = IteratorUtils.toList(it);
+        assertEquals(6, result.size());
+        IteratorUtils.collatedIterator(null, (Collection<Iterator<?>>) null);
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void testCollatedIteratorNull() {
+        ArrayList arrayList = new ArrayList();
+        // natural ordering
+        Iterator<Integer> it = IteratorUtils.collatedIterator(null, collectionOdd.iterator(), collectionOdd.iterator(),
+                collectionOdd.iterator());
+
+        List<Integer> result = IteratorUtils.toList(it);
+        assertEquals(18, result.size());
+
+        it = IteratorUtils.collatedIterator(null, collectionOdd.iterator());
+        result = IteratorUtils.toList(it);
+        assertEquals(collectionOdd, result);
+
+        final Comparator<Integer> reverseComparator = ComparatorUtils
+                .reversedComparator(ComparatorUtils.<Integer>naturalComparator());
+
+        Collections.reverse(collectionOdd);
+
+        it = IteratorUtils.collatedIterator(reverseComparator, collectionOdd.iterator());
+        result = IteratorUtils.toList(it);
+        assertEquals(collectionOdd, result);
+        IteratorUtils.collatedIterator(null, arrayList.iterator(), arrayList.listIterator(), null);
+    }
+
     // -----------------------------------------------------------------------
     /**
      * Test empty iterator
@@ -759,6 +841,41 @@ public class IteratorUtilsTest {
     }
 
     @Test
+    public void testFilteredIterator() {
+        ArrayList arrayList = new ArrayList();
+        Iterator ie = arrayList.iterator();
+        try {
+            IteratorUtils.filteredIterator(ie, null);
+        } catch (NullPointerException npe) {
+            //
+        }
+        try {
+            IteratorUtils.filteredIterator(null, null);
+        } catch (NullPointerException npe) {
+            //
+        }
+    }
+
+    @Test
+    public void testFilteredListIterator() {
+        List arrayList = new ArrayList();
+        arrayList.add("test");
+        Predicate predicate = INSTANCE;
+        assertTrue("create instance fail",
+                IteratorUtils.filteredListIterator(arrayList.listIterator(), predicate) instanceof ListIterator);
+        try {
+            IteratorUtils.filteredListIterator(null, predicate);
+        } catch (NullPointerException npe) {
+            //
+        }
+        try {
+            IteratorUtils.filteredListIterator(arrayList.listIterator(), null);
+        } catch (NullPointerException npe) {
+            //
+        }
+    }
+
+    @Test
     public void testFind() {
         Predicate<Number> testPredicate = equalPredicate((Number) 4);
         Integer test = IteratorUtils.find(iterableA.iterator(), testPredicate);
@@ -906,6 +1023,26 @@ public class IteratorUtilsTest {
         }
     }
 
+    @Test(expected = NullPointerException.class)
+    public void testLoopingIterator() {
+        ArrayList arrayList = new ArrayList();
+        arrayList.add("test");
+        Collection coll = new ArrayList();
+        coll.add("test");
+        Iterator ie = arrayList.iterator();
+        assertTrue("create instance fail", IteratorUtils.loopingIterator(coll) instanceof ResettableIterator);
+        IteratorUtils.loopingIterator(null);
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void testLoopingListIterator() {
+        ArrayList arrayList = new ArrayList();
+        arrayList.add("test");
+        Iterator ie = arrayList.iterator();
+        assertTrue("create instance fail", IteratorUtils.loopingListIterator(arrayList) instanceof ResettableIterator);
+        IteratorUtils.loopingListIterator(null);
+    }
+
     /**
      * Tests method nodeListIterator(Node)
      */
@@ -968,6 +1105,38 @@ public class IteratorUtilsTest {
     }
 
     @Test
+    public void testObjectGraphIterator() {
+        assertTrue("create instance fail", IteratorUtils.objectGraphIterator(null, null) instanceof Iterator);
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void testPeekingIterator() {
+        ArrayList arrayList = new ArrayList();
+        Iterator ie = arrayList.iterator();
+        assertTrue("create instance fail", IteratorUtils.peekingIterator(ie) instanceof Iterator);
+        IteratorUtils.peekingIterator(null);
+
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void testPushBackIterator() {
+        ArrayList arrayList = new ArrayList();
+        Iterator ie = arrayList.iterator();
+        assertTrue("create instance fail", IteratorUtils.pushbackIterator(ie) instanceof Iterator);
+        IteratorUtils.pushbackIterator(null);
+    }
+
+    @Test
+    public void testSingletonIterator() {
+        assertTrue("create instance fail", IteratorUtils.singletonIterator(new Object()) instanceof ResettableIterator);
+    }
+
+    @Test
+    public void testSingletonListIterator() {
+        assertTrue("create instance fail", IteratorUtils.singletonListIterator(new Object()) instanceof Iterator);
+    }
+
+    @Test
     public void testToArray() {
         final List<Object> list = new ArrayList<>();
         list.add(Integer.valueOf(1));
@@ -1059,6 +1228,22 @@ public class IteratorUtilsTest {
         }
     }
 
+    @Test
+    public void testTransformedIterator() {
+        ArrayList arrayList = new ArrayList();
+        Iterator ie = arrayList.iterator();
+        try {
+            IteratorUtils.transformedIterator(ie, null);
+        } catch (NullPointerException npe) {
+            //
+        }
+        try {
+            IteratorUtils.transformedIterator(null, null);
+        } catch (NullPointerException npe) {
+            //
+        }
+    }
+
     /**
      * Test remove() for an immutable Iterator.
      */
@@ -1223,23 +1408,6 @@ public class IteratorUtilsTest {
     }
 
     @Test(expected = NullPointerException.class)
-    public void testPushBackIterator() {
-        ArrayList arrayList = new ArrayList();
-        Iterator ie = arrayList.iterator();
-        assertTrue("create instance fail", IteratorUtils.pushbackIterator(ie) instanceof Iterator);
-        IteratorUtils.pushbackIterator(null);
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void testPeekingIterator() {
-        ArrayList arrayList = new ArrayList();
-        Iterator ie = arrayList.iterator();
-        assertTrue("create instance fail", IteratorUtils.peekingIterator(ie) instanceof Iterator);
-        IteratorUtils.peekingIterator(null);
-
-    }
-
-    @Test(expected = NullPointerException.class)
     public void testUnmodifiableMapIterator() {
         Set<?> set = new LinkedHashSet<>();
         final MapIterator ie = (MapIterator) new EntrySetToMapIteratorAdapter(set);
@@ -1249,178 +1417,10 @@ public class IteratorUtilsTest {
     }
 
     @Test
-    public void testChainedIterator() {
-        ArrayList arrayList = new ArrayList();
-        Iterator ie = arrayList.iterator();
-        assertTrue("create instance fail", IteratorUtils.chainedIterator(ie) instanceof Iterator);
-        final Collection<Iterator<?>> coll = new ArrayList();
-        assertTrue("create instance fail", IteratorUtils.chainedIterator(coll) instanceof Iterator);
-
-    }
-
-    @Test
-    public void testSingletonIterator() {
-        assertTrue("create instance fail", IteratorUtils.singletonIterator(new Object()) instanceof ResettableIterator);
-    }
-
-    @Test
-    public void testSingletonListIterator() {
-        assertTrue("create instance fail", IteratorUtils.singletonListIterator(new Object()) instanceof Iterator);
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void testAsEnumerationNull() {
-        IteratorUtils.asEnumeration(null);
-    }
-
-    @Test
-    public void testObjectGraphIterator() {
-        assertTrue("create instance fail", IteratorUtils.objectGraphIterator(null, null) instanceof Iterator);
-    }
-
-    @Test
     public void testZippingIterator() {
         ArrayList arrayList = new ArrayList();
         Iterator ie = arrayList.iterator();
         assertTrue("create instance fail", IteratorUtils.zippingIterator(ie, ie, ie) instanceof ZippingIterator);
         assertTrue("create instance fail", IteratorUtils.zippingIterator(ie, ie) instanceof ZippingIterator);
     }
-
-    @Test
-    public void testFilteredIterator() {
-        ArrayList arrayList = new ArrayList();
-        Iterator ie = arrayList.iterator();
-        try {
-            IteratorUtils.filteredIterator(ie, null);
-        } catch (NullPointerException npe) {
-            //
-        }
-        try {
-            IteratorUtils.filteredIterator(null, null);
-        } catch (NullPointerException npe) {
-            //
-        }
-    }
-
-    @Test
-    public void testTransformedIterator() {
-        ArrayList arrayList = new ArrayList();
-        Iterator ie = arrayList.iterator();
-        try {
-            IteratorUtils.transformedIterator(ie, null);
-        } catch (NullPointerException npe) {
-            //
-        }
-        try {
-            IteratorUtils.transformedIterator(null, null);
-        } catch (NullPointerException npe) {
-            //
-        }
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void testAsIterator() {
-        final Vector<String> vector = new Vector<>();
-        vector.addElement("zero");
-        vector.addElement("one");
-        Enumeration<String> en = vector.elements();
-        assertTrue("create instance fail", IteratorUtils.asIterator(en) instanceof Iterator);
-        IteratorUtils.asIterator(null);
-    }
-
-    @Test
-    public void testAsIteratorNull() {
-        Collection coll = new ArrayList();
-        coll.add("test");
-        final Vector<String> vector = new Vector<>();
-        vector.addElement("test");
-        vector.addElement("one");
-        Enumeration<String> en = vector.elements();
-        assertTrue("create instance fail", IteratorUtils.asIterator(en, coll) instanceof Iterator);
-        try {
-            IteratorUtils.asIterator(null, coll);
-        } catch (NullPointerException npe) {
-            //
-        }
-        try {
-            IteratorUtils.asIterator(en, null);
-        } catch (NullPointerException npe) {
-            //
-        }
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void testLoopingIterator() {
-        ArrayList arrayList = new ArrayList();
-        arrayList.add("test");
-        Collection coll = new ArrayList();
-        coll.add("test");
-        Iterator ie = arrayList.iterator();
-        assertTrue("create instance fail", IteratorUtils.loopingIterator(coll) instanceof ResettableIterator);
-        IteratorUtils.loopingIterator(null);
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void testLoopingListIterator() {
-        ArrayList arrayList = new ArrayList();
-        arrayList.add("test");
-        Iterator ie = arrayList.iterator();
-        assertTrue("create instance fail", IteratorUtils.loopingListIterator(arrayList) instanceof ResettableIterator);
-        IteratorUtils.loopingListIterator(null);
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void testCollatedIteratorNull() {
-        ArrayList arrayList = new ArrayList();
-        // natural ordering
-        Iterator<Integer> it = IteratorUtils.collatedIterator(null, collectionOdd.iterator(), collectionOdd.iterator(),
-                collectionOdd.iterator());
-
-        List<Integer> result = IteratorUtils.toList(it);
-        assertEquals(18, result.size());
-
-        it = IteratorUtils.collatedIterator(null, collectionOdd.iterator());
-        result = IteratorUtils.toList(it);
-        assertEquals(collectionOdd, result);
-
-        final Comparator<Integer> reverseComparator = ComparatorUtils
-                .reversedComparator(ComparatorUtils.<Integer>naturalComparator());
-
-        Collections.reverse(collectionOdd);
-
-        it = IteratorUtils.collatedIterator(reverseComparator, collectionOdd.iterator());
-        result = IteratorUtils.toList(it);
-        assertEquals(collectionOdd, result);
-        IteratorUtils.collatedIterator(null, arrayList.iterator(), arrayList.listIterator(), null);
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void testCollatedIteratorCollectionNull() {
-        Collection<Iterator<?>> coll = new ArrayList<>();
-        coll.add(collectionOdd.iterator());
-        // natural ordering
-        Iterator<?> it = IteratorUtils.collatedIterator(null, coll);
-        List<?> result = IteratorUtils.toList(it);
-        assertEquals(6, result.size());
-        IteratorUtils.collatedIterator(null, (Collection<Iterator<?>>) null);
-    }
-
-    @Test
-    public void testFilteredListIterator() {
-        List arrayList = new ArrayList();
-        arrayList.add("test");
-        Predicate predicate = INSTANCE;
-        assertTrue("create instance fail",
-                IteratorUtils.filteredListIterator(arrayList.listIterator(), predicate) instanceof ListIterator);
-        try {
-            IteratorUtils.filteredListIterator(null, predicate);
-        } catch (NullPointerException npe) {
-            //
-        }
-        try {
-            IteratorUtils.filteredListIterator(arrayList.listIterator(), null);
-        } catch (NullPointerException npe) {
-            //
-        }
-    }
 }


[commons-collections] 03/03: [COLLECTIONS-780] Add org.apache.commons.collections4.EnumerationUtils.asIterable(Enumeration).

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-collections.git

commit 22560c3077cf042f546428db6462c371bf9a2fa7
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jan 12 10:32:00 2020 -0500

    [COLLECTIONS-780] Add
    org.apache.commons.collections4.EnumerationUtils.asIterable(Enumeration).
---
 src/changes/changes.xml                            |  3 +++
 .../commons/collections4/EnumerationUtils.java     | 21 +++++++++++++++--
 .../commons/collections4/EnumerationUtilsTest.java | 26 ++++++++++++++++++++++
 3 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c2e2453..a3be7b5 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -108,6 +108,9 @@
     <action dev="ggregory" type="fix" due-to="Dominik Stadler">
       Fix links to release notes and update contents for 4.4 #127.
     </action>
+    <action issue="COLLECTIONS-780" dev="ggregory" type="add" due-to="Gary Gregory">
+      Add org.apache.commons.collections4.EnumerationUtils.asIterable(Enumeration).
+    </action>
   </release>
   <release version="4.4" date="2019-07-05" description="Maintenance release.">
     <action issue="COLLECTIONS-710" dev="ggregory" type="fix" due-to="Yu Shi, Gary Gregory">
diff --git a/src/main/java/org/apache/commons/collections4/EnumerationUtils.java b/src/main/java/org/apache/commons/collections4/EnumerationUtils.java
index 224ab53..8918f67 100644
--- a/src/main/java/org/apache/commons/collections4/EnumerationUtils.java
+++ b/src/main/java/org/apache/commons/collections4/EnumerationUtils.java
@@ -22,6 +22,7 @@ import java.util.List;
 import java.util.StringTokenizer;
 
 import org.apache.commons.collections4.iterators.EnumerationIterator;
+import org.apache.commons.collections4.iterators.IteratorIterable;
 
 /**
  * Provides utility methods for {@link Enumeration} instances.
@@ -33,7 +34,22 @@ public class EnumerationUtils {
     /**
      * EnumerationUtils is not normally instantiated.
      */
-    private EnumerationUtils() {}
+    private EnumerationUtils() {
+        // no instances.
+    }
+
+    /**
+     * Creates an {@link Iterable} that wraps an {@link Enumeration}. The returned {@link Iterable} can be used for a
+     * single iteration.
+     *
+     * @param <T> the element type
+     * @param enumeration the enumeration to use, may not be null
+     * @return a new, single use {@link Iterable}
+     * @since 4.5
+     */
+    public static <T> Iterable<T> asIterable(final Enumeration<T> enumeration) {
+        return new IteratorIterable<>(new EnumerationIterator<>(enumeration));
+    }
 
     /**
      * Returns the {@code index}-th value in the {@link Enumeration}, throwing
@@ -51,8 +67,8 @@ public class EnumerationUtils {
      * @since 4.1
      */
     public static <T> T get(final Enumeration<T> e, final int index) {
+        CollectionUtils.checkIndexBounds(index);
         int i = index;
-        CollectionUtils.checkIndexBounds(i);
         while (e.hasMoreElements()) {
             i--;
             if (i == -1) {
@@ -92,4 +108,5 @@ public class EnumerationUtils {
         }
         return result;
     }
+
 }
diff --git a/src/test/java/org/apache/commons/collections4/EnumerationUtilsTest.java b/src/test/java/org/apache/commons/collections4/EnumerationUtilsTest.java
index c263c79..d4e0577 100644
--- a/src/test/java/org/apache/commons/collections4/EnumerationUtilsTest.java
+++ b/src/test/java/org/apache/commons/collections4/EnumerationUtilsTest.java
@@ -18,11 +18,13 @@ package org.apache.commons.collections4;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.fail;
 
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.Hashtable;
+import java.util.Iterator;
 import java.util.List;
 import java.util.StringTokenizer;
 import java.util.Vector;
@@ -59,6 +61,30 @@ public class EnumerationUtilsTest {
     }
 
     @Test
+    public void testAsIterableFor() {
+        final Vector<String> vector = new Vector<>();
+        vector.addElement("zero");
+        vector.addElement("one");
+        Enumeration<String> en = vector.elements();
+        final Iterator<String> iterator = EnumerationUtils.asIterable(en).iterator();
+        assertTrue(iterator.hasNext());
+        assertEquals("zero", iterator.next());
+        assertTrue(iterator.hasNext());
+        assertEquals("one", iterator.next());
+        assertFalse(iterator.hasNext());
+    }
+
+    @Test
+    public void testAsIterableForNull() {
+        try {
+            EnumerationUtils.asIterable((Enumeration) null).iterator().next();
+            fail("Expecting NullPointerException");
+        } catch (final NullPointerException ex) {
+            // success
+        }
+    }
+
+    @Test
     public void testToListWithHashtable() {
         final Hashtable<String, Integer> expected = new Hashtable<>();
         expected.put("one", Integer.valueOf(1));


[commons-collections] 02/03: Sort Sort methods.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-collections.git

commit 45eee00385886461b0c0538496a9777c69637de5
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jan 12 10:25:21 2020 -0500

    Sort Sort methods.
---
 .../commons/collections4/EnumerationUtilsTest.java | 66 +++++++++++-----------
 1 file changed, 33 insertions(+), 33 deletions(-)

diff --git a/src/test/java/org/apache/commons/collections4/EnumerationUtilsTest.java b/src/test/java/org/apache/commons/collections4/EnumerationUtilsTest.java
index 057f9f9..c263c79 100644
--- a/src/test/java/org/apache/commons/collections4/EnumerationUtilsTest.java
+++ b/src/test/java/org/apache/commons/collections4/EnumerationUtilsTest.java
@@ -38,21 +38,24 @@ public class EnumerationUtilsTest {
     public static final String TO_LIST_FIXTURE = "this is a test";
 
     @Test
-    public void testToListWithStringTokenizer() {
-        final List<String> expectedList1 = new ArrayList<>();
-        final StringTokenizer st = new StringTokenizer(TO_LIST_FIXTURE);
-             while (st.hasMoreTokens()) {
-                 expectedList1.add(st.nextToken());
-             }
-        final List<String> expectedList2 = new ArrayList<>();
-        expectedList2.add("this");
-        expectedList2.add("is");
-        expectedList2.add("a");
-        expectedList2.add("test");
-        final List<String> actualList = EnumerationUtils.toList(new StringTokenizer(TO_LIST_FIXTURE));
-        assertEquals(expectedList1, expectedList2);
-        assertEquals(expectedList1, actualList);
-        assertEquals(expectedList2, actualList);
+    public void getFromEnumeration() throws Exception {
+        // Enumeration, entry exists
+        final Vector<String> vector = new Vector<>();
+        vector.addElement("zero");
+        vector.addElement("one");
+        Enumeration<String> en = vector.elements();
+        assertEquals("zero", EnumerationUtils.get(en, 0));
+        en = vector.elements();
+        assertEquals("one", EnumerationUtils.get(en, 1));
+
+        // Enumerator, non-existent entry
+        try {
+            EnumerationUtils.get(en, 3);
+            fail("Expecting IndexOutOfBoundsException.");
+        } catch (final IndexOutOfBoundsException e) {
+            // expected
+        }
+        assertTrue(!en.hasMoreElements());
     }
 
     @Test
@@ -87,24 +90,21 @@ public class EnumerationUtilsTest {
     }
 
     @Test
-    public void getFromEnumeration() throws Exception {
-        // Enumeration, entry exists
-        final Vector<String> vector = new Vector<>();
-        vector.addElement("zero");
-        vector.addElement("one");
-        Enumeration<String> en = vector.elements();
-        assertEquals("zero", EnumerationUtils.get(en, 0));
-        en = vector.elements();
-        assertEquals("one", EnumerationUtils.get(en, 1));
-
-        // Enumerator, non-existent entry
-        try {
-            EnumerationUtils.get(en, 3);
-            fail("Expecting IndexOutOfBoundsException.");
-        } catch (final IndexOutOfBoundsException e) {
-            // expected
-        }
-        assertTrue(!en.hasMoreElements());
+    public void testToListWithStringTokenizer() {
+        final List<String> expectedList1 = new ArrayList<>();
+        final StringTokenizer st = new StringTokenizer(TO_LIST_FIXTURE);
+             while (st.hasMoreTokens()) {
+                 expectedList1.add(st.nextToken());
+             }
+        final List<String> expectedList2 = new ArrayList<>();
+        expectedList2.add("this");
+        expectedList2.add("is");
+        expectedList2.add("a");
+        expectedList2.add("test");
+        final List<String> actualList = EnumerationUtils.toList(new StringTokenizer(TO_LIST_FIXTURE));
+        assertEquals(expectedList1, expectedList2);
+        assertEquals(expectedList1, actualList);
+        assertEquals(expectedList2, actualList);
     }
 
 }