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
This commit is contained in:
parent
628bcc433a
commit
5e234b76ad
|
@ -32,7 +32,7 @@ import org.apache.commons.collections.iterators.AbstractTestMapIterator;
|
||||||
*
|
*
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractTestIterableMap extends AbstractTestMap {
|
public abstract class AbstractTestIterableMap<K, V> extends AbstractTestMap<K, V> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JUnit constructor.
|
* JUnit constructor.
|
||||||
|
@ -43,22 +43,37 @@ public abstract class AbstractTestIterableMap extends AbstractTestMap {
|
||||||
super(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() {
|
public void testFailFastEntrySet() {
|
||||||
if (isRemoveSupported() == false) return;
|
if (isRemoveSupported() == false) return;
|
||||||
|
if (isFailFastExpected() == false) return;
|
||||||
resetFull();
|
resetFull();
|
||||||
Iterator it = map.entrySet().iterator();
|
Iterator<Map.Entry<K, V>> it = getMap().entrySet().iterator();
|
||||||
Map.Entry val = (Map.Entry) it.next();
|
Map.Entry<K, V> val = it.next();
|
||||||
map.remove(val.getKey());
|
getMap().remove(val.getKey());
|
||||||
try {
|
try {
|
||||||
it.next();
|
it.next();
|
||||||
fail();
|
fail();
|
||||||
} catch (ConcurrentModificationException ex) {}
|
} catch (ConcurrentModificationException ex) {}
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
it = map.entrySet().iterator();
|
it = getMap().entrySet().iterator();
|
||||||
it.next();
|
it.next();
|
||||||
map.clear();
|
getMap().clear();
|
||||||
try {
|
try {
|
||||||
it.next();
|
it.next();
|
||||||
fail();
|
fail();
|
||||||
|
@ -67,19 +82,20 @@ public abstract class AbstractTestIterableMap extends AbstractTestMap {
|
||||||
|
|
||||||
public void testFailFastKeySet() {
|
public void testFailFastKeySet() {
|
||||||
if (isRemoveSupported() == false) return;
|
if (isRemoveSupported() == false) return;
|
||||||
|
if (isFailFastExpected() == false) return;
|
||||||
resetFull();
|
resetFull();
|
||||||
Iterator it = map.keySet().iterator();
|
Iterator<K> it = getMap().keySet().iterator();
|
||||||
Object val = it.next();
|
K val = it.next();
|
||||||
map.remove(val);
|
getMap().remove(val);
|
||||||
try {
|
try {
|
||||||
it.next();
|
it.next();
|
||||||
fail();
|
fail();
|
||||||
} catch (ConcurrentModificationException ex) {}
|
} catch (ConcurrentModificationException ex) {}
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
it = map.keySet().iterator();
|
it = getMap().keySet().iterator();
|
||||||
it.next();
|
it.next();
|
||||||
map.clear();
|
getMap().clear();
|
||||||
try {
|
try {
|
||||||
it.next();
|
it.next();
|
||||||
fail();
|
fail();
|
||||||
|
@ -88,19 +104,20 @@ public abstract class AbstractTestIterableMap extends AbstractTestMap {
|
||||||
|
|
||||||
public void testFailFastValues() {
|
public void testFailFastValues() {
|
||||||
if (isRemoveSupported() == false) return;
|
if (isRemoveSupported() == false) return;
|
||||||
|
if (isFailFastExpected() == false) return;
|
||||||
resetFull();
|
resetFull();
|
||||||
Iterator it = map.values().iterator();
|
Iterator<V> it = getMap().values().iterator();
|
||||||
it.next();
|
it.next();
|
||||||
map.remove(map.keySet().iterator().next());
|
getMap().remove(getMap().keySet().iterator().next());
|
||||||
try {
|
try {
|
||||||
it.next();
|
it.next();
|
||||||
fail();
|
fail();
|
||||||
} catch (ConcurrentModificationException ex) {}
|
} catch (ConcurrentModificationException ex) {}
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
it = map.values().iterator();
|
it = getMap().values().iterator();
|
||||||
it.next();
|
it.next();
|
||||||
map.clear();
|
getMap().clear();
|
||||||
try {
|
try {
|
||||||
it.next();
|
it.next();
|
||||||
fail();
|
fail();
|
||||||
|
@ -112,12 +129,12 @@ public abstract class AbstractTestIterableMap extends AbstractTestMap {
|
||||||
return new InnerTestMapIterator();
|
return new InnerTestMapIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class InnerTestMapIterator extends AbstractTestMapIterator {
|
public class InnerTestMapIterator extends AbstractTestMapIterator<K, V> {
|
||||||
public InnerTestMapIterator() {
|
public InnerTestMapIterator() {
|
||||||
super("InnerTestMapIterator");
|
super("InnerTestMapIterator");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] addSetValues() {
|
public V[] addSetValues() {
|
||||||
return AbstractTestIterableMap.this.getNewSampleValues();
|
return AbstractTestIterableMap.this.getNewSampleValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,24 +150,24 @@ public abstract class AbstractTestIterableMap extends AbstractTestMap {
|
||||||
return AbstractTestIterableMap.this.isSetValueSupported();
|
return AbstractTestIterableMap.this.isSetValueSupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapIterator makeEmptyMapIterator() {
|
public MapIterator<K, V> makeEmptyIterator() {
|
||||||
resetEmpty();
|
resetEmpty();
|
||||||
return ((IterableMap) AbstractTestIterableMap.this.map).mapIterator();
|
return AbstractTestIterableMap.this.getMap().mapIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapIterator makeFullMapIterator() {
|
public MapIterator<K, V> makeObject() {
|
||||||
resetFull();
|
resetFull();
|
||||||
return ((IterableMap) AbstractTestIterableMap.this.map).mapIterator();
|
return AbstractTestIterableMap.this.getMap().mapIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map getMap() {
|
public Map<K, V> getMap() {
|
||||||
// assumes makeFullMapIterator() called first
|
// assumes makeFullMapIterator() called first
|
||||||
return AbstractTestIterableMap.this.map;
|
return AbstractTestIterableMap.this.getMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map getConfirmedMap() {
|
public Map<K, V> getConfirmedMap() {
|
||||||
// assumes makeFullMapIterator() called first
|
// assumes makeFullMapIterator() called first
|
||||||
return AbstractTestIterableMap.this.confirmed;
|
return AbstractTestIterableMap.this.getConfirmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void verify() {
|
public void verify() {
|
||||||
|
@ -165,4 +182,12 @@ public abstract class AbstractTestIterableMap extends AbstractTestMap {
|
||||||
// resetFull();
|
// resetFull();
|
||||||
// writeExternalFormToDisk((Serializable) map, "D:/dev/collections/data/test/HashedMap.fullCollection.version3.obj");
|
// 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue