Tighten Map tests
Javadoc git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131256 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e7ea37d1a7
commit
a18bc1ca43
|
@ -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.4 2003/10/07 22:20:57 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.5 2003/10/07 22:35:59 scolebourne Exp $
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
* The Apache Software License, Version 1.1
|
* The Apache Software License, Version 1.1
|
||||||
|
@ -152,7 +152,7 @@ import java.util.Set;
|
||||||
* @author Rodney Waldhoff
|
* @author Rodney Waldhoff
|
||||||
* @author Paul Jack
|
* @author Paul Jack
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
* @version $Revision: 1.4 $ $Date: 2003/10/07 22:20:57 $
|
* @version $Revision: 1.5 $ $Date: 2003/10/07 22:35:59 $
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractTestMap extends AbstractTestObject {
|
public abstract class AbstractTestMap extends AbstractTestObject {
|
||||||
|
|
||||||
|
@ -527,10 +527,10 @@ public abstract class AbstractTestMap extends AbstractTestObject {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link Map#clear()}. If the map {@link #isRemoveSupported()}
|
* Tests {@link Map#clear()}. If the map {@link #isRemoveSupported()}
|
||||||
* can add and remove elements}, then {@link Map#size()} and {@link
|
* can add and remove elements}, then {@link Map#size()} and
|
||||||
* Map#isEmpty()} are used to ensure that map has no elements after a call
|
* {@link Map#isEmpty()} are used to ensure that map has no elements after
|
||||||
* to clear. If the map does not support adding and removing elements,
|
* a call to clear. If the map does not support adding and removing
|
||||||
* this method checks to ensure clear throws an
|
* elements, this method checks to ensure clear throws an
|
||||||
* UnsupportedOperationException.
|
* UnsupportedOperationException.
|
||||||
*/
|
*/
|
||||||
public void testMapClear() {
|
public void testMapClear() {
|
||||||
|
@ -768,9 +768,22 @@ public abstract class AbstractTestMap extends AbstractTestObject {
|
||||||
!map.containsValue(values[i]));
|
!map.containsValue(values[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
map.put(keys[0], newValues[0]);
|
||||||
|
fail("Expected UnsupportedOperationException on put (change)");
|
||||||
|
} catch (UnsupportedOperationException ex) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (isPutChangeSupported()) {
|
} else if (isPutChangeSupported()) {
|
||||||
|
resetEmpty();
|
||||||
|
try {
|
||||||
|
map.put(keys[0], values[0]);
|
||||||
|
fail("Expected UnsupportedOperationException or IllegalArgumentException on put (add) when fixed size");
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
} catch (UnsupportedOperationException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Iterator it = map.keySet().iterator(); it.hasNext() && i < newValues.length; i++) {
|
for (Iterator it = map.keySet().iterator(); it.hasNext() && i < newValues.length; i++) {
|
||||||
|
@ -792,14 +805,29 @@ public abstract class AbstractTestMap extends AbstractTestObject {
|
||||||
!map.containsValue(values[i]));
|
!map.containsValue(values[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
map.put(keys[0], values[0]);
|
||||||
|
fail("Expected UnsupportedOperationException on put (add)");
|
||||||
|
} catch (UnsupportedOperationException ex) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests Map.putAll(Collection)
|
* Tests Map.putAll(map)
|
||||||
*/
|
*/
|
||||||
public void testMapPutAll() {
|
public void testMapPutAll() {
|
||||||
if (!isPutAddSupported()) return;
|
if (!isPutAddSupported()) {
|
||||||
|
if (!isPutChangeSupported()) {
|
||||||
|
Map temp = makeFullMap();
|
||||||
|
resetEmpty();
|
||||||
|
try {
|
||||||
|
map.putAll(temp);
|
||||||
|
fail("Expected UnsupportedOperationException on putAll");
|
||||||
|
} catch (UnsupportedOperationException ex) {}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
resetEmpty();
|
resetEmpty();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue