diff --git a/src/test/org/apache/commons/collections/TestCollectionUtils.java b/src/test/org/apache/commons/collections/TestCollectionUtils.java index c101555ef..bc8afaf1a 100644 --- a/src/test/org/apache/commons/collections/TestCollectionUtils.java +++ b/src/test/org/apache/commons/collections/TestCollectionUtils.java @@ -1,5 +1,5 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestCollectionUtils.java,v 1.26 2003/10/09 10:39:16 rwaldhoff Exp $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestCollectionUtils.java,v 1.27 2003/10/09 10:48:19 rwaldhoff Exp $ * ==================================================================== * * The Apache Software License, Version 1.1 @@ -89,7 +89,7 @@ import org.apache.commons.collections.decorators.UnmodifiableCollection; * @author Stephen Colebourne * @author Phil Steitz * - * @version $Revision: 1.26 $ $Date: 2003/10/09 10:39:16 $ + * @version $Revision: 1.27 $ $Date: 2003/10/09 10:48:19 $ */ public class TestCollectionUtils extends TestCase { @@ -593,31 +593,33 @@ public class TestCollectionUtils extends TestCase { public void testGet() { // Unordered map, entries exist - Map map = new HashMap(); - map.put("zeroKey", "zero"); - map.put("oneKey", "one"); - - Object test = CollectionUtils.get(map, 0); - assertEquals("zeroKey",((Map.Entry) test).getKey()); - assertEquals("zero",((Map.Entry) test).getValue()); - test = CollectionUtils.get(map, 1); - assertEquals("oneKey",((Map.Entry) test).getKey()); - assertEquals("one",((Map.Entry) test).getValue()); + { + Map expected = new HashMap(); + expected.put("zeroKey", "zero"); + expected.put("oneKey", "one"); - // Map index out of range - try { - test = CollectionUtils.get(map, 2); - fail("Expecting IndexOutOfBoundsException."); - } catch (IndexOutOfBoundsException e) { - // expected + Map found = new HashMap(); + Map.Entry entry = (Map.Entry)(CollectionUtils.get(expected, 0)); + found.put(entry.getKey(),entry.getValue()); + entry = (Map.Entry)(CollectionUtils.get(expected, 1)); + found.put(entry.getKey(),entry.getValue()); + assertEquals(expected,found); + + // Map index out of range + try { + CollectionUtils.get(expected, 2); + fail("Expecting IndexOutOfBoundsException."); + } catch (IndexOutOfBoundsException e) { + // expected + } + try { + CollectionUtils.get(expected, -2); + fail("Expecting IndexOutOfBoundsException."); + } catch (IndexOutOfBoundsException e) { + // expected + } } - try { - test = CollectionUtils.get(map, -2); - fail("Expecting IndexOutOfBoundsException."); - } catch (IndexOutOfBoundsException e) { - // expected - } - + Object test; // Sorted map, entries exist, should respect order SortedMap map2 = new TreeMap(); map2.put("zeroKey", "zero");