From 5e234b76ad6057fbffa7a28bfd3f467dd77cd15a Mon Sep 17 00:00:00 2001 From: Henri Yandell Date: Tue, 15 Sep 2009 05:57:20 +0000 Subject: [PATCH] Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: ------------------------------------------------------------------------ r740150 | mbenson | 2009-02-02 15:24:00 -0800 (Mon, 02 Feb 2009) | 1 line make all [collections] maps implement IterableMap ------------------------------------------------------------------------ git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@815122 13f79535-47bb-0310-9956-ffa450edef68 --- .../map/AbstractTestIterableMap.java | 107 +++++++++++------- 1 file changed, 66 insertions(+), 41 deletions(-) diff --git a/src/test/org/apache/commons/collections/map/AbstractTestIterableMap.java b/src/test/org/apache/commons/collections/map/AbstractTestIterableMap.java index b31f474aa..5213f93d3 100644 --- a/src/test/org/apache/commons/collections/map/AbstractTestIterableMap.java +++ b/src/test/org/apache/commons/collections/map/AbstractTestIterableMap.java @@ -32,99 +32,116 @@ import org.apache.commons.collections.iterators.AbstractTestMapIterator; * * @author Stephen Colebourne */ -public abstract class AbstractTestIterableMap extends AbstractTestMap { +public abstract class AbstractTestIterableMap extends AbstractTestMap { /** * JUnit constructor. - * + * * @param testName the test name */ public AbstractTestIterableMap(String testName) { super(testName); } - + + /** + * {@inheritDoc} + */ + @Override + public abstract IterableMap makeObject(); + + /** + * {@inheritDoc} + */ + @Override + public IterableMap makeFullMap() { + return (IterableMap) super.makeFullMap(); + } + //----------------------------------------------------------------------- public void testFailFastEntrySet() { if (isRemoveSupported() == false) return; + if (isFailFastExpected() == false) return; resetFull(); - Iterator it = map.entrySet().iterator(); - Map.Entry val = (Map.Entry) it.next(); - map.remove(val.getKey()); + Iterator> it = getMap().entrySet().iterator(); + Map.Entry val = it.next(); + getMap().remove(val.getKey()); try { it.next(); fail(); } catch (ConcurrentModificationException ex) {} - + resetFull(); - it = map.entrySet().iterator(); + it = getMap().entrySet().iterator(); it.next(); - map.clear(); + getMap().clear(); try { it.next(); fail(); } catch (ConcurrentModificationException ex) {} } - + public void testFailFastKeySet() { if (isRemoveSupported() == false) return; + if (isFailFastExpected() == false) return; resetFull(); - Iterator it = map.keySet().iterator(); - Object val = it.next(); - map.remove(val); + Iterator it = getMap().keySet().iterator(); + K val = it.next(); + getMap().remove(val); try { it.next(); fail(); } catch (ConcurrentModificationException ex) {} - + resetFull(); - it = map.keySet().iterator(); + it = getMap().keySet().iterator(); it.next(); - map.clear(); + getMap().clear(); try { it.next(); fail(); } catch (ConcurrentModificationException ex) {} } - + public void testFailFastValues() { if (isRemoveSupported() == false) return; + if (isFailFastExpected() == false) return; resetFull(); - Iterator it = map.values().iterator(); + Iterator it = getMap().values().iterator(); it.next(); - map.remove(map.keySet().iterator().next()); + getMap().remove(getMap().keySet().iterator().next()); try { it.next(); fail(); } catch (ConcurrentModificationException ex) {} - + resetFull(); - it = map.values().iterator(); + it = getMap().values().iterator(); it.next(); - map.clear(); + getMap().clear(); try { it.next(); fail(); } catch (ConcurrentModificationException ex) {} } - + //----------------------------------------------------------------------- public BulkTest bulkTestMapIterator() { return new InnerTestMapIterator(); } - - public class InnerTestMapIterator extends AbstractTestMapIterator { + + public class InnerTestMapIterator extends AbstractTestMapIterator { public InnerTestMapIterator() { super("InnerTestMapIterator"); } - - public Object[] addSetValues() { + + public V[] addSetValues() { return AbstractTestIterableMap.this.getNewSampleValues(); } - + public boolean supportsRemove() { return AbstractTestIterableMap.this.isRemoveSupported(); } - + public boolean isGetStructuralModify() { return AbstractTestIterableMap.this.isGetStructuralModify(); } @@ -133,36 +150,44 @@ public abstract class AbstractTestIterableMap extends AbstractTestMap { return AbstractTestIterableMap.this.isSetValueSupported(); } - public MapIterator makeEmptyMapIterator() { + public MapIterator makeEmptyIterator() { resetEmpty(); - return ((IterableMap) AbstractTestIterableMap.this.map).mapIterator(); + return AbstractTestIterableMap.this.getMap().mapIterator(); } - public MapIterator makeFullMapIterator() { + public MapIterator makeObject() { resetFull(); - return ((IterableMap) AbstractTestIterableMap.this.map).mapIterator(); + return AbstractTestIterableMap.this.getMap().mapIterator(); } - - public Map getMap() { + + public Map getMap() { // assumes makeFullMapIterator() called first - return AbstractTestIterableMap.this.map; + return AbstractTestIterableMap.this.getMap(); } - - public Map getConfirmedMap() { + + public Map getConfirmedMap() { // assumes makeFullMapIterator() called first - return AbstractTestIterableMap.this.confirmed; + return AbstractTestIterableMap.this.getConfirmed(); } - + public void verify() { super.verify(); AbstractTestIterableMap.this.verify(); } } - + // public void testCreate() throws Exception { // resetEmpty(); // writeExternalFormToDisk((Serializable) map, "D:/dev/collections/data/test/HashedMap.emptyCollection.version3.obj"); // resetFull(); // writeExternalFormToDisk((Serializable) map, "D:/dev/collections/data/test/HashedMap.fullCollection.version3.obj"); // } + + /** + * {@inheritDoc} + */ + @Override + public IterableMap getMap() { + return (IterableMap) super.getMap(); + } }