diff --git a/build.xml b/build.xml index 1e99c9890..a4f8eb1f8 100644 --- a/build.xml +++ b/build.xml @@ -1,4 +1,4 @@ - + @@ -38,7 +38,12 @@ + + + + + diff --git a/src/test/org/apache/commons/collections/AbstractTestCollection.java b/src/test/org/apache/commons/collections/AbstractTestCollection.java index cd99928bf..62cc4b276 100644 --- a/src/test/org/apache/commons/collections/AbstractTestCollection.java +++ b/src/test/org/apache/commons/collections/AbstractTestCollection.java @@ -1,5 +1,5 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/AbstractTestCollection.java,v 1.8 2003/11/04 23:34:46 scolebourne Exp $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/AbstractTestCollection.java,v 1.9 2003/11/16 21:39:42 scolebourne Exp $ * ==================================================================== * * The Apache Software License, Version 1.1 @@ -63,14 +63,13 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.ConcurrentModificationException; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; -import org.apache.commons.collections.pairs.DefaultMapEntry; - /** * Abstract test class for {@link java.util.Collection} methods and contracts. *

@@ -148,7 +147,7 @@ import org.apache.commons.collections.pairs.DefaultMapEntry; * you may still use this base set of cases. Simply override the * test case (method) your {@link Collection} fails. * - * @version $Revision: 1.8 $ $Date: 2003/11/04 23:34:46 $ + * @version $Revision: 1.9 $ $Date: 2003/11/16 21:39:42 $ * * @author Rodney Waldhoff * @author Paul Jack @@ -405,6 +404,15 @@ public abstract class AbstractTestCollection extends AbstractTestObject { return makeCollection(); } + /** + * Creates a new Map Entry that is independent of the first and the map. + */ + protected Map.Entry cloneMapEntry(Map.Entry entry) { + HashMap map = new HashMap(); + map.put(entry.getKey(), entry.getValue()); + return (Map.Entry) map.entrySet().iterator().next(); + } + //----------------------------------------------------------------------- /** * Returns an array of objects that are contained in a collection @@ -850,7 +858,7 @@ public abstract class AbstractTestCollection extends AbstractTestObject { // TreeMap reuses the Map Entry, so the verify below fails // Clone it here if necessary if (o instanceof Map.Entry) { - o = new DefaultMapEntry((Map.Entry) o); + o = cloneMapEntry((Map.Entry) o); } iter.remove(); diff --git a/src/test/org/apache/commons/collections/AbstractTestMap.java b/src/test/org/apache/commons/collections/AbstractTestMap.java index 13ea1f577..79226fd2e 100644 --- a/src/test/org/apache/commons/collections/AbstractTestMap.java +++ b/src/test/org/apache/commons/collections/AbstractTestMap.java @@ -1,5 +1,5 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/AbstractTestMap.java,v 1.12 2003/11/04 23:35:35 scolebourne Exp $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/AbstractTestMap.java,v 1.13 2003/11/16 21:39:42 scolebourne Exp $ * ==================================================================== * * The Apache Software License, Version 1.1 @@ -153,7 +153,7 @@ import java.util.Set; * @author Rodney Waldhoff * @author Paul Jack * @author Stephen Colebourne - * @version $Revision: 1.12 $ $Date: 2003/11/04 23:35:35 $ + * @version $Revision: 1.13 $ $Date: 2003/11/16 21:39:42 $ */ public abstract class AbstractTestMap extends AbstractTestObject { @@ -435,6 +435,15 @@ public abstract class AbstractTestMap extends AbstractTestObject { return new HashMap(); } + /** + * Creates a new Map Entry that is independent of the first and the map. + */ + protected Map.Entry cloneMapEntry(Map.Entry entry) { + HashMap map = new HashMap(); + map.put(entry.getKey(), entry.getValue()); + return (Map.Entry) map.entrySet().iterator().next(); + } + //----------------------------------------------------------------------- /** * Test to ensure the test setup is working properly. This method checks diff --git a/src/test/org/apache/commons/collections/bidimap/AbstractTestSortedBidiMap.java b/src/test/org/apache/commons/collections/bidimap/AbstractTestSortedBidiMap.java index 93ac3b0a6..604db6cd5 100644 --- a/src/test/org/apache/commons/collections/bidimap/AbstractTestSortedBidiMap.java +++ b/src/test/org/apache/commons/collections/bidimap/AbstractTestSortedBidiMap.java @@ -1,5 +1,5 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/bidimap/AbstractTestSortedBidiMap.java,v 1.1 2003/11/16 20:35:46 scolebourne Exp $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/bidimap/AbstractTestSortedBidiMap.java,v 1.2 2003/11/16 21:39:42 scolebourne Exp $ * ==================================================================== * * The Apache Software License, Version 1.1 @@ -71,12 +71,11 @@ import java.util.TreeSet; import org.apache.commons.collections.AbstractTestSortedMap; import org.apache.commons.collections.BulkTest; -import org.apache.commons.collections.pairs.DefaultMapEntry; /** - * Abstract test class for {@link BidiMap} methods and contracts. + * Abstract test class for {@link SortedBidiMap} methods and contracts. * - * @version $Revision: 1.1 $ $Date: 2003/11/16 20:35:46 $ + * @version $Revision: 1.2 $ $Date: 2003/11/16 21:39:42 $ * * @author Matthew Hawthorne * @author Stephen Colebourne @@ -253,8 +252,8 @@ public abstract class AbstractTestSortedBidiMap extends AbstractTestOrderedBidiM assertEquals(2, set.size()); Iterator it2 = set.iterator(); - Map.Entry firstEntry = new DefaultMapEntry((Map.Entry) it2.next()); - Map.Entry secondEntry = new DefaultMapEntry((Map.Entry) it2.next()); + Map.Entry firstEntry = cloneMapEntry((Map.Entry) it2.next()); + Map.Entry secondEntry = cloneMapEntry((Map.Entry) it2.next()); assertEquals(true, sm.containsKey(first)); assertEquals(true, sub.containsKey(first)); assertEquals(true, set.contains(firstEntry)); @@ -418,8 +417,8 @@ public abstract class AbstractTestSortedBidiMap extends AbstractTestOrderedBidiM Set set = sub.entrySet(); Iterator it2 = set.iterator(); Object fromEntry = it2.next(); - Map.Entry firstEntry = new DefaultMapEntry((Map.Entry) it2.next()); - Map.Entry secondEntry = new DefaultMapEntry((Map.Entry) it2.next()); + Map.Entry firstEntry = cloneMapEntry((Map.Entry) it2.next()); + Map.Entry secondEntry = cloneMapEntry((Map.Entry) it2.next()); assertEquals(true, sm.containsKey(first)); assertEquals(true, sub.containsKey(first)); assertEquals(true, set.contains(firstEntry)); @@ -601,8 +600,8 @@ public abstract class AbstractTestSortedBidiMap extends AbstractTestOrderedBidiM assertEquals(3, set.size()); Iterator it2 = set.iterator(); Object fromEntry = it2.next(); - Map.Entry firstEntry = new DefaultMapEntry((Map.Entry) it2.next()); - Map.Entry secondEntry = new DefaultMapEntry((Map.Entry) it2.next()); + Map.Entry firstEntry = cloneMapEntry((Map.Entry) it2.next()); + Map.Entry secondEntry = cloneMapEntry((Map.Entry) it2.next()); assertEquals(true, sm.containsKey(first)); assertEquals(true, sub.containsKey(first)); assertEquals(true, set.contains(firstEntry));