You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ba...@apache.org on 2009/09/15 07:57:20 UTC
svn commit: r815122 -
/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestIterableMap.java
Author: bayard
Date: Tue Sep 15 05:57:20 2009
New Revision: 815122
URL: http://svn.apache.org/viewvc?rev=815122&view=rev
Log:
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
------------------------------------------------------------------------
Modified:
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestIterableMap.java
Modified: commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestIterableMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestIterableMap.java?rev=815122&r1=815121&r2=815122&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestIterableMap.java (original)
+++ commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/AbstractTestIterableMap.java Tue Sep 15 05:57:20 2009
@@ -32,99 +32,116 @@
*
* @author Stephen Colebourne
*/
-public abstract class AbstractTestIterableMap extends AbstractTestMap {
+public abstract class AbstractTestIterableMap<K, V> extends AbstractTestMap<K, V> {
/**
* JUnit constructor.
- *
+ *
* @param testName the test name
*/
public AbstractTestIterableMap(String testName) {
super(testName);
}
-
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public abstract IterableMap<K, V> makeObject();
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public IterableMap<K, V> makeFullMap() {
+ return (IterableMap<K, V>) 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<Map.Entry<K, V>> it = getMap().entrySet().iterator();
+ Map.Entry<K, V> 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<K> 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<V> 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<K, V> {
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 @@
return AbstractTestIterableMap.this.isSetValueSupported();
}
- public MapIterator makeEmptyMapIterator() {
+ public MapIterator<K, V> makeEmptyIterator() {
resetEmpty();
- return ((IterableMap) AbstractTestIterableMap.this.map).mapIterator();
+ return AbstractTestIterableMap.this.getMap().mapIterator();
}
- public MapIterator makeFullMapIterator() {
+ public MapIterator<K, V> makeObject() {
resetFull();
- return ((IterableMap) AbstractTestIterableMap.this.map).mapIterator();
+ return AbstractTestIterableMap.this.getMap().mapIterator();
}
-
- public Map getMap() {
+
+ public Map<K, V> getMap() {
// assumes makeFullMapIterator() called first
- return AbstractTestIterableMap.this.map;
+ return AbstractTestIterableMap.this.getMap();
}
-
- public Map getConfirmedMap() {
+
+ public Map<K, V> 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<K, V> getMap() {
+ return (IterableMap<K, V>) super.getMap();
+ }
}