Enhance Map tests pre-release of testframework

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131255 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2003-10-07 22:20:58 +00:00
parent b943acfc64
commit e7ea37d1a7
15 changed files with 288 additions and 189 deletions

View File

@ -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.3 2003/10/05 20:47:37 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.4 2003/10/07 22:20:57 scolebourne Exp $
* ==================================================================== * ====================================================================
* *
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
@ -79,32 +79,33 @@ import java.util.Set;
* override one or more of the other protected methods. They're described * override one or more of the other protected methods. They're described
* below. * below.
* <p> * <p>
* <B>Entry Population Methods</B><P> * <b>Entry Population Methods</b>
* * <p>
* Override these methods if your map requires special entries: * Override these methods if your map requires special entries:
* *
* <UL> * <ul>
* <LI>{@link #getSampleKeys()} * <li>{@link #getSampleKeys()}
* <LI>{@link #getSampleValues()} * <li>{@link #getSampleValues()}
* <LI>{@link #getNewSampleValues()} * <li>{@link #getNewSampleValues()}
* <LI>{@link #getOtherKeys()} * <li>{@link #getOtherKeys()}
* <LI>{@link #getOtherValues()} * <li>{@link #getOtherValues()}
* </UL> * </ul>
*
* <B>Supported Operation Methods</B><P>
* *
* <b>Supported Operation Methods</b>
* <p>
* Override these methods if your map doesn't support certain operations: * Override these methods if your map doesn't support certain operations:
* *
* <UL> * <ul>
* <LI> {@link #useDuplicateValues()} * <li> {@link #isPutAddSupported()}
* <LI> {@link #useNullKey()} * <li> {@link #isPutChangeSupported()}
* <LI> {@link #useNullValue()} * <li> {@link #isRemoveSupported()}
* <LI> {@link #isAddRemoveModifiable()} * <li> {@link #isAllowDuplicateValues()}
* <LI> {@link #isChangeable()} * <li> {@link #isAllowNullKey()}
* </UL> * <li> {@link #isAllowNullValue()}
* * </ul>
* <B>Fixture Methods</B><P>
* *
* <b>Fixture Methods</b>
* <p>
* For tests on modification operations (puts and removes), fixtures are used * For tests on modification operations (puts and removes), fixtures are used
* to verify that that operation results in correct state for the map and its * to verify that that operation results in correct state for the map and its
* collection views. Basically, the modification is performed against your * collection views. Basically, the modification is performed against your
@ -139,19 +140,19 @@ import java.util.Set;
* {@link #verifyValues()} method to verify that the values are unique and in * {@link #verifyValues()} method to verify that the values are unique and in
* ascending order.<P> * ascending order.<P>
* *
* <B>Other Notes</B><P> * <b>Other Notes</b>
* * <p>
* If your {@link Map} fails one of these tests by design, you may still use * If your {@link Map} fails one of these tests by design, you may still use
* this base set of cases. Simply override the test case (method) your {@link * this base set of cases. Simply override the test case (method) your map
* Map} fails and/or the methods that define the assumptions used by the test * fails and/or the methods that define the assumptions used by the test
* cases. For example, if your map does not allow duplicate values, override * cases. For example, if your map does not allow duplicate values, override
* {@link #useDuplicateValues()} and have it return <code>false</code> * {@link #isAllowDuplicateValues()} and have it return <code>false</code>
* *
* @author Michael Smith * @author Michael Smith
* @author Rodney Waldhoff * @author Rodney Waldhoff
* @author Paul Jack * @author Paul Jack
* @author Stephen Colebourne * @author Stephen Colebourne
* @version $Revision: 1.3 $ $Date: 2003/10/05 20:47:37 $ * @version $Revision: 1.4 $ $Date: 2003/10/07 22:20:57 $
*/ */
public abstract class AbstractTestMap extends AbstractTestObject { public abstract class AbstractTestMap extends AbstractTestObject {
@ -179,7 +180,6 @@ public abstract class AbstractTestMap extends AbstractTestObject {
/** HashMap created by reset(). */ /** HashMap created by reset(). */
protected Map confirmed; protected Map confirmed;
/** /**
* JUnit constructor. * JUnit constructor.
* *
@ -189,44 +189,77 @@ public abstract class AbstractTestMap extends AbstractTestObject {
super(testName); super(testName);
} }
/** /**
* Override if your map does not allow a <code>null</code> key. The * Returns true if the maps produced by
* default implementation returns <code>true</code> * {@link #makeEmptyMap()} and {@link #makeFullMap()}
* support the <code>put</code> and <code>putAll</code> operations
* adding new mappings.
* <p>
* Default implementation returns true.
* Override if your collection class does not support put adding.
*/ */
protected boolean useNullKey() { protected boolean isPutAddSupported() {
return true; return true;
} }
/** /**
* Override if your map does not allow <code>null</code> values. The * Returns true if the maps produced by
* default implementation returns <code>true</code>. * {@link #makeEmptyMap()} and {@link #makeFullMap()}
* support the <code>put</code> and <code>putAll</code> operations
* changing existing mappings.
* <p>
* Default implementation returns true.
* Override if your collection class does not support put changing.
*/ */
protected boolean useNullValue() { protected boolean isPutChangeSupported() {
return true; return true;
} }
/** /**
* Override if your map does not allow duplicate values. The default * Returns true if the maps produced by
* implementation returns <code>true</code>. * {@link #makeEmptyMap()} and {@link #makeFullMap()}
* support the <code>remove</code> and <code>clear</code> operations.
* <p>
* Default implementation returns true.
* Override if your collection class does not support removal operations.
*/ */
protected boolean useDuplicateValues() { protected boolean isRemoveSupported() {
return true; return true;
} }
/** /**
* Override if your map allows its mappings to be changed to new values. * Returns true if the maps produced by
* The default implementation returns <code>true</code>. * {@link #makeEmptyMap()} and {@link #makeFullMap()}
* supports null keys.
* <p>
* Default implementation returns true.
* Override if your collection class does not support null keys.
*/ */
protected boolean isChangeable() { protected boolean isAllowNullKey() {
return true; return true;
} }
/** /**
* Override if your map does not allow add/remove modifications. The * Returns true if the maps produced by
* default implementation returns <code>true</code>. * {@link #makeEmptyMap()} and {@link #makeFullMap()}
* supports null values.
* <p>
* Default implementation returns true.
* Override if your collection class does not support null values.
*/ */
protected boolean isAddRemoveModifiable() { protected boolean isAllowNullValue() {
return true;
}
/**
* Returns true if the maps produced by
* {@link #makeEmptyMap()} and {@link #makeFullMap()}
* supports duplicate values.
* <p>
* Default implementation returns true.
* Override if your collection class does not support duplicate values.
*/
protected boolean isAllowDuplicateValues() {
return true; return true;
} }
@ -235,7 +268,7 @@ public abstract class AbstractTestMap extends AbstractTestObject {
* method must return an array with the same length as {@link * method must return an array with the same length as {@link
* #getSampleValues()} and all array elements must be different. The * #getSampleValues()} and all array elements must be different. The
* default implementation constructs a set of String keys, and includes a * default implementation constructs a set of String keys, and includes a
* single null key if {@link #useNullKey()} returns <code>true</code>. * single null key if {@link #isAllowNullKey()} returns <code>true</code>.
*/ */
protected Object[] getSampleKeys() { protected Object[] getSampleKeys() {
Object[] result = new Object[] { Object[] result = new Object[] {
@ -243,7 +276,7 @@ public abstract class AbstractTestMap extends AbstractTestObject {
"hello", "goodbye", "we'll", "see", "you", "all", "again", "hello", "goodbye", "we'll", "see", "you", "all", "again",
"key", "key",
"key2", "key2",
(useNullKey()) ? null : "nonnullkey" (isAllowNullKey()) ? null : "nonnullkey"
}; };
return result; return result;
} }
@ -272,20 +305,20 @@ public abstract class AbstractTestMap extends AbstractTestObject {
/** /**
* Returns the set of values in the mappings used to test the map. This * Returns the set of values in the mappings used to test the map. This
* method must return an array with the same length as {@link * method must return an array with the same length as
* #getSampleKeys()}. The default implementation constructs a set of * {@link #getSampleKeys()}. The default implementation constructs a set of
* String values and includes a single null value if {@link * String values and includes a single null value if
* #useNullValue()} returns <code>true</code>, and includes two values * {@link #isNullValueSupported()} returns <code>true</code>, and includes
* that are the same if {@link #useDuplicateValues()} returns * two values that are the same if {@link #isAllowDuplicateValues()} returns
* <code>true</code>. * <code>true</code>.
*/ */
protected Object[] getSampleValues() { protected Object[] getSampleValues() {
Object[] result = new Object[] { Object[] result = new Object[] {
"blahv", "foov", "barv", "bazv", "tmpv", "goshv", "gollyv", "geev", "blahv", "foov", "barv", "bazv", "tmpv", "goshv", "gollyv", "geev",
"hellov", "goodbyev", "we'llv", "seev", "youv", "allv", "againv", "hellov", "goodbyev", "we'llv", "seev", "youv", "allv", "againv",
(useNullValue()) ? null : "nonnullvalue", (isAllowNullValue()) ? null : "nonnullvalue",
"value", "value",
(useDuplicateValues()) ? "value" : "value2", (isAllowDuplicateValues()) ? "value" : "value2",
}; };
return result; return result;
} }
@ -296,16 +329,16 @@ public abstract class AbstractTestMap extends AbstractTestObject {
* array with the same length as {@link #getSampleValues()}. The values * array with the same length as {@link #getSampleValues()}. The values
* returned from this method should not be the same as those returned from * returned from this method should not be the same as those returned from
* {@link #getSampleValues()}. The default implementation constructs a * {@link #getSampleValues()}. The default implementation constructs a
* set of String values and includes a single null value if {@link * set of String values and includes a single null value if
* #useNullValue()} returns <code>true</code>, and includes two values * {@link #isNullValueSupported()} returns <code>true</code>, and includes two values
* that are the same if {@link #useDuplicateValues()} returns * that are the same if {@link #isAllowDuplicateValues()} returns
* <code>true</code>. * <code>true</code>.
*/ */
protected Object[] getNewSampleValues() { protected Object[] getNewSampleValues() {
Object[] result = new Object[] { Object[] result = new Object[] {
(useNullValue() && useDuplicateValues()) ? null : "newnonnullvalue", (isAllowNullValue() && isAllowDuplicateValues()) ? null : "newnonnullvalue",
"newvalue", "newvalue",
(useDuplicateValues()) ? "newvalue" : "newvalue2", (isAllowDuplicateValues()) ? "newvalue" : "newvalue2",
"newblahv", "newfoov", "newbarv", "newbazv", "newtmpv", "newgoshv", "newblahv", "newfoov", "newbarv", "newbazv", "newtmpv", "newgoshv",
"newgollyv", "newgeev", "newhellov", "newgoodbyev", "newwe'llv", "newgollyv", "newgeev", "newhellov", "newgoodbyev", "newwe'llv",
"newseev", "newyouv", "newallv", "newagainv", "newseev", "newyouv", "newallv", "newagainv",
@ -331,12 +364,12 @@ public abstract class AbstractTestMap extends AbstractTestObject {
keys[i] == null || values[i] == null); keys[i] == null || values[i] == null);
assertTrue("NullPointerException on null key, but " + assertTrue("NullPointerException on null key, but " +
"useNullKey is not overridden to return false.", "isNullKeySupported is not overridden to return false.",
keys[i] == null || !useNullKey()); keys[i] == null || !isAllowNullKey());
assertTrue("NullPointerException on null value, but " + assertTrue("NullPointerException on null value, but " +
"useNullValue is not overridden to return false.", "isNullValueSupported is not overridden to return false.",
values[i] == null || !useNullValue()); values[i] == null || !isAllowNullValue());
assertTrue("Unknown reason for NullPointer.", false); assertTrue("Unknown reason for NullPointer.", false);
} }
@ -384,9 +417,9 @@ public abstract class AbstractTestMap extends AbstractTestObject {
* returning results that look appropriate. That is, they both return a * returning results that look appropriate. That is, they both return a
* non-null array of equal length. The keys array must not have any * non-null array of equal length. The keys array must not have any
* duplicate values, and may only contain a (single) null key if * duplicate values, and may only contain a (single) null key if
* useNullKey() returns true. The values array must only have a null * isNullKeySupported() returns true. The values array must only have a null
* value if useNullValue() is true and may only have duplicate values if * value if useNullValue() is true and may only have duplicate values if
* useDuplicateValues() returns true. * isAllowDuplicateValues() returns true.
*/ */
public void testSampleMappings() { public void testSampleMappings() {
Object[] keys = getSampleKeys(); Object[] keys = getSampleKeys();
@ -417,12 +450,12 @@ public abstract class AbstractTestMap extends AbstractTestObject {
(!keys[i].equals(keys[j]) && (!keys[i].equals(keys[j]) &&
!keys[j].equals(keys[i])))); !keys[j].equals(keys[i]))));
} }
assertTrue("failure in test: found null key, but useNullKey " + assertTrue("failure in test: found null key, but isNullKeySupported " +
"is false.", keys[i] != null || useNullKey()); "is false.", keys[i] != null || isAllowNullKey());
assertTrue("failure in test: found null value, but useNullValue " + assertTrue("failure in test: found null value, but isNullValueSupported " +
"is false.", values[i] != null || useNullValue()); "is false.", values[i] != null || isAllowNullValue());
assertTrue("failure in test: found null new value, but useNullValue " + assertTrue("failure in test: found null new value, but isNullValueSupported " +
"is false.", newValues[i] != null || useNullValue()); "is false.", newValues[i] != null || isAllowNullValue());
assertTrue("failure in test: values should not be the same as new value", assertTrue("failure in test: values should not be the same as new value",
values[i] != newValues[i] && values[i] != newValues[i] &&
(values[i] == null || !values[i].equals(newValues[i]))); (values[i] == null || !values[i].equals(newValues[i])));
@ -493,7 +526,7 @@ public abstract class AbstractTestMap extends AbstractTestObject {
} }
/** /**
* Tests {@link Map#clear()}. If the map {@link #isAddRemoveModifiable() * 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 {@link
* Map#isEmpty()} are used to ensure that map has no elements after a call * Map#isEmpty()} are used to ensure that map has no elements after a call
* to clear. If the map does not support adding and removing elements, * to clear. If the map does not support adding and removing elements,
@ -501,7 +534,14 @@ public abstract class AbstractTestMap extends AbstractTestObject {
* UnsupportedOperationException. * UnsupportedOperationException.
*/ */
public void testMapClear() { public void testMapClear() {
if (!isAddRemoveModifiable()) return; if (!isRemoveSupported()) {
try {
resetFull();
map.clear();
fail("Expected UnsupportedOperationException on clear");
} catch (UnsupportedOperationException ex) {}
return;
}
resetEmpty(); resetEmpty();
map.clear(); map.clear();
@ -693,15 +733,13 @@ public abstract class AbstractTestMap extends AbstractTestObject {
* Tests Map.put(Object, Object) * Tests Map.put(Object, Object)
*/ */
public void testMapPut() { public void testMapPut() {
if (!isAddRemoveModifiable()) return;
resetEmpty(); resetEmpty();
Object[] keys = getSampleKeys(); Object[] keys = getSampleKeys();
Object[] values = getSampleValues(); Object[] values = getSampleValues();
Object[] newValues = getNewSampleValues(); Object[] newValues = getNewSampleValues();
for(int i = 0; i < keys.length; i++) { if (isPutAddSupported()) {
for (int i = 0; i < keys.length; i++) {
Object o = map.put(keys[i], values[i]); Object o = map.put(keys[i], values[i]);
confirmed.put(keys[i], values[i]); confirmed.put(keys[i], values[i]);
verify(); verify();
@ -711,32 +749,57 @@ public abstract class AbstractTestMap extends AbstractTestObject {
assertTrue("Map should contain value after put", assertTrue("Map should contain value after put",
map.containsValue(values[i])); map.containsValue(values[i]));
} }
if (isPutChangeSupported()) {
for(int i = 0; i < keys.length; i++) { for (int i = 0; i < keys.length; i++) {
Object o = map.put(keys[i], newValues[i]); Object o = map.put(keys[i], newValues[i]);
confirmed.put(keys[i], newValues[i]); confirmed.put(keys[i], newValues[i]);
verify(); verify();
assertEquals("Second map.put should return previous value", assertEquals("Map.put should return previous value when changed",
values[i], o); values[i], o);
assertTrue("Map should still contain key after put", assertTrue("Map should still contain key after put when changed",
map.containsKey(keys[i])); map.containsKey(keys[i]));
assertTrue("Map should contain new value after put", assertTrue("Map should contain new value after put when changed",
map.containsValue(newValues[i])); map.containsValue(newValues[i]));
// if duplicates are allowed, we're not guaranteed that the value // if duplicates are allowed, we're not guaranteed that the value
// no longer exists, so don't try checking that. // no longer exists, so don't try checking that.
if(!useDuplicateValues()) { if (!isAllowDuplicateValues()) {
assertTrue("Map should not contain old value after second put", assertTrue("Map should not contain old value after put when changed",
!map.containsValue(values[i])); !map.containsValue(values[i]));
} }
} }
} }
} else if (isPutChangeSupported()) {
resetFull();
int i = 0;
for (Iterator it = map.keySet().iterator(); it.hasNext() && i < newValues.length; i++) {
Object key = (Object) it.next();
Object o = map.put(key, newValues[i]);
Object value = confirmed.put(key, newValues[i]);
verify();
assertEquals("Map.put should return previous value when changed",
value, o);
assertTrue("Map should still contain key after put when changed",
map.containsKey(key));
assertTrue("Map should contain new value after put when changed",
map.containsValue(newValues[i]));
// if duplicates are allowed, we're not guaranteed that the value
// no longer exists, so don't try checking that.
if (!isAllowDuplicateValues()) {
assertTrue("Map should not contain old value after put when changed",
!map.containsValue(values[i]));
}
}
}
}
/** /**
* Tests Map.putAll(Collection) * Tests Map.putAll(Collection)
*/ */
public void testMapPutAll() { public void testMapPutAll() {
if (!isAddRemoveModifiable()) return; if (!isPutAddSupported()) return;
resetEmpty(); resetEmpty();
@ -764,7 +827,14 @@ public abstract class AbstractTestMap extends AbstractTestObject {
* Tests Map.remove(Object) * Tests Map.remove(Object)
*/ */
public void testMapRemove() { public void testMapRemove() {
if (!isAddRemoveModifiable()) return; if (!isRemoveSupported()) {
try {
resetFull();
map.remove(map.keySet().iterator().next());
fail("Expected UnsupportedOperationException on remove");
} catch (UnsupportedOperationException ex) {}
return;
}
resetEmpty(); resetEmpty();
@ -807,7 +877,7 @@ public abstract class AbstractTestMap extends AbstractTestObject {
* the underlying map for clear(). * the underlying map for clear().
*/ */
public void testValuesClearChangesMap() { public void testValuesClearChangesMap() {
if (!isAddRemoveModifiable()) return; if (!isRemoveSupported()) return;
// clear values, reflected in map // clear values, reflected in map
resetFull(); resetFull();
@ -833,7 +903,7 @@ public abstract class AbstractTestMap extends AbstractTestObject {
* the underlying map for clear(). * the underlying map for clear().
*/ */
public void testKeySetClearChangesMap() { public void testKeySetClearChangesMap() {
if (!isAddRemoveModifiable()) return; if (!isRemoveSupported()) return;
// clear values, reflected in map // clear values, reflected in map
resetFull(); resetFull();
@ -859,7 +929,7 @@ public abstract class AbstractTestMap extends AbstractTestObject {
* the underlying map for clear(). * the underlying map for clear().
*/ */
public void testEntrySetClearChangesMap() { public void testEntrySetClearChangesMap() {
if (!isAddRemoveModifiable()) return; if (!isRemoveSupported()) return;
// clear values, reflected in map // clear values, reflected in map
resetFull(); resetFull();
@ -1007,7 +1077,7 @@ public abstract class AbstractTestMap extends AbstractTestObject {
protected boolean isRemoveSupported() { protected boolean isRemoveSupported() {
// Entry set should only support remove if map does // Entry set should only support remove if map does
return isAddRemoveModifiable(); return AbstractTestMap.this.isRemoveSupported();
} }
protected void resetFull() { protected void resetFull() {
@ -1066,7 +1136,7 @@ public abstract class AbstractTestMap extends AbstractTestObject {
} }
protected boolean isRemoveSupported() { protected boolean isRemoveSupported() {
return isAddRemoveModifiable(); return AbstractTestMap.this.isRemoveSupported();
} }
protected void resetEmpty() { protected void resetEmpty() {
@ -1127,7 +1197,7 @@ public abstract class AbstractTestMap extends AbstractTestObject {
} }
protected boolean isRemoveSupported() { protected boolean isRemoveSupported() {
return isAddRemoveModifiable(); return AbstractTestMap.this.isRemoveSupported();
} }
protected boolean areEqualElementsDistinguishable() { protected boolean areEqualElementsDistinguishable() {

View File

@ -1,5 +1,5 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/AbstractTestSortedMap.java,v 1.2 2003/10/06 23:44:56 scolebourne Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/AbstractTestSortedMap.java,v 1.3 2003/10/07 22:20:57 scolebourne Exp $
* ==================================================================== * ====================================================================
* *
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
@ -63,7 +63,7 @@ import java.util.SortedMap;
/** /**
* Abstract test class for {@link java.util.SortedMap} methods and contracts. * Abstract test class for {@link java.util.SortedMap} methods and contracts.
* *
* @version $Revision: 1.2 $ $Date: 2003/10/06 23:44:56 $ * @version $Revision: 1.3 $ $Date: 2003/10/07 22:20:57 $
* *
* @author Stephen Colebourne * @author Stephen Colebourne
*/ */
@ -84,7 +84,7 @@ public abstract class AbstractTestSortedMap extends AbstractTestMap {
* *
* @return false * @return false
*/ */
protected boolean useNullKey() { protected boolean isAllowNullKey() {
return false; return false;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestBeanMap.java,v 1.12 2003/10/05 20:46:40 scolebourne Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestBeanMap.java,v 1.13 2003/10/07 22:20:57 scolebourne Exp $
* ==================================================================== * ====================================================================
* *
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
@ -66,7 +66,7 @@ import junit.framework.Test;
/** /**
* Test cases for BeanMap * Test cases for BeanMap
* *
* @version $Revision: 1.12 $ $Date: 2003/10/05 20:46:40 $ * @version $Revision: 1.13 $ $Date: 2003/10/07 22:20:57 $
* *
* @author Morgan Delagrange * @author Morgan Delagrange
*/ */
@ -256,8 +256,17 @@ public class TestBeanMap extends AbstractTestMap {
* The mappings in a BeanMap are fixed on the properties the underlying * The mappings in a BeanMap are fixed on the properties the underlying
* bean has. Adding and removing mappings is not possible, thus this * bean has. Adding and removing mappings is not possible, thus this
* method is overridden to return false. * method is overridden to return false.
**/ */
protected boolean isAddRemoveModifiable() { protected boolean isPutAddSupported() {
return false;
}
/**
* The mappings in a BeanMap are fixed on the properties the underlying
* bean has. Adding and removing mappings is not possible, thus this
* method is overridden to return false.
*/
protected boolean isRemoveSupported() {
return false; return false;
} }
@ -305,12 +314,20 @@ public class TestBeanMap extends AbstractTestMap {
* testClear() methods checks that the clear method throws an * testClear() methods checks that the clear method throws an
* UnsupportedOperationException since this class is not add/remove * UnsupportedOperationException since this class is not add/remove
* modifiable. In our case though, we do not always throw that exception. * modifiable. In our case though, we do not always throw that exception.
**/ */
public void testClear() { public void testMapClear() {
//TODO: make sure a call to BeanMap.clear returns the bean to its //TODO: make sure a call to BeanMap.clear returns the bean to its
//default initialization values. //default initialization values.
} }
/**
* Need to override this method because the "put()" method on the bean
* doesn't work for this type of Map.
*/
public void testMapPut() {
// see testBeanMapPutAllWriteable
}
public void testBeanMapClone() { public void testBeanMapClone() {
BeanMap map = (BeanMap)makeFullMap(); BeanMap map = (BeanMap)makeFullMap();
try { try {

View File

@ -1,5 +1,5 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestBidiMap.java,v 1.5 2003/10/06 23:47:17 scolebourne Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestBidiMap.java,v 1.6 2003/10/07 22:20:57 scolebourne Exp $
* ==================================================================== * ====================================================================
* *
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
@ -63,7 +63,7 @@ import java.util.Map;
/** /**
* JUnit tests. * JUnit tests.
* *
* @version $Revision: 1.5 $ $Date: 2003/10/06 23:47:17 $ * @version $Revision: 1.6 $ $Date: 2003/10/07 22:20:57 $
* *
* @author Matthew Hawthorne * @author Matthew Hawthorne
*/ */
@ -128,7 +128,7 @@ public abstract class TestBidiMap extends AbstractTestMap {
/** /**
* Override to indicate to AbstractTestMap this is a BidiMap. * Override to indicate to AbstractTestMap this is a BidiMap.
*/ */
protected boolean useDuplicateValues() { protected boolean isAllowDuplicateValues() {
return false; return false;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestDoubleOrderedMap.java,v 1.9 2003/10/05 21:11:06 scolebourne Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestDoubleOrderedMap.java,v 1.10 2003/10/07 22:20:57 scolebourne Exp $
* ==================================================================== * ====================================================================
* *
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
@ -77,7 +77,7 @@ import junit.framework.Test;
* Map that does not support duplicate keys, duplicate * Map that does not support duplicate keys, duplicate
* values, or null values. * values, or null values.
* *
* @version $Revision: 1.9 $ $Date: 2003/10/05 21:11:06 $ * @version $Revision: 1.10 $ $Date: 2003/10/07 22:20:57 $
* *
* @author Marc Johnson (marcj at users dot sourceforge dot net) * @author Marc Johnson (marcj at users dot sourceforge dot net)
*/ */
@ -104,7 +104,7 @@ public class TestDoubleOrderedMap extends AbstractTestMap {
/** /**
* The default comparator in double ordered map does not allow null keys. * The default comparator in double ordered map does not allow null keys.
**/ **/
public boolean useNullKey() { public boolean isAllowNullKey() {
return false; return false;
} }
@ -112,14 +112,14 @@ public class TestDoubleOrderedMap extends AbstractTestMap {
* The default comparator in double ordered map does not allow null keys, * The default comparator in double ordered map does not allow null keys,
* and values are keys in this map. * and values are keys in this map.
**/ **/
public boolean useNullValue() { public boolean isAllowNullValue() {
return false; return false;
} }
/** /**
* Double ordered map does not support duplicate values * Double ordered map does not support duplicate values
**/ **/
public boolean useDuplicateValues() { public boolean isAllowDuplicateValues() {
return false; return false;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestFastHashMap.java,v 1.11 2003/10/05 21:11:06 scolebourne Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestFastHashMap.java,v 1.12 2003/10/07 22:20:57 scolebourne Exp $
* ==================================================================== * ====================================================================
* *
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
@ -64,7 +64,7 @@ import junit.framework.Test;
/** /**
* Tests FastHashMap. * Tests FastHashMap.
* *
* @version $Revision: 1.11 $ $Date: 2003/10/05 21:11:06 $ * @version $Revision: 1.12 $ $Date: 2003/10/07 22:20:57 $
* *
* @author Jason van Zyl * @author Jason van Zyl
*/ */
@ -93,7 +93,7 @@ public class TestFastHashMap extends AbstractTestMap {
* There is a bug in JDK1.2 HashMap; the keySet() will incorrectly * There is a bug in JDK1.2 HashMap; the keySet() will incorrectly
* return false when a null value is removed. * return false when a null value is removed.
*/ */
public boolean useNullValue() { public boolean isAllowNullValue() {
return false; return false;
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestFastTreeMap.java,v 1.11 2003/10/05 21:11:06 scolebourne Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestFastTreeMap.java,v 1.12 2003/10/07 22:20:57 scolebourne Exp $
* ==================================================================== * ====================================================================
* *
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
@ -65,7 +65,7 @@ import junit.framework.Test;
/** /**
* Tests FastTreeMap. * Tests FastTreeMap.
* *
* @version $Revision: 1.11 $ $Date: 2003/10/05 21:11:06 $ * @version $Revision: 1.12 $ $Date: 2003/10/07 22:20:57 $
* *
* @author Jason van Zyl * @author Jason van Zyl
*/ */
@ -97,7 +97,7 @@ public class TestFastTreeMap extends TestTreeMap {
/** /**
* The comparator for the fast tree map does not support null keys. * The comparator for the fast tree map does not support null keys.
**/ **/
public boolean useNullKey() { public boolean isAllowNullKey() {
return false; return false;
} }
@ -105,7 +105,7 @@ public class TestFastTreeMap extends TestTreeMap {
* There is a bug in JDK1.2.2 TreeMap; the keySet will incorrectly * There is a bug in JDK1.2.2 TreeMap; the keySet will incorrectly
* return false when a null value is removed * return false when a null value is removed
*/ */
public boolean useNullValue() { public boolean isAllowNullValue() {
return false; return false;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestMapUtils.java,v 1.17 2003/10/05 21:17:40 scolebourne Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestMapUtils.java,v 1.18 2003/10/07 22:20:57 scolebourne Exp $
* ==================================================================== * ====================================================================
* *
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
@ -76,7 +76,7 @@ import org.apache.commons.collections.decorators.PredicatedMap;
/** /**
* Tests for MapUtils. * Tests for MapUtils.
* *
* @version $Revision: 1.17 $ $Date: 2003/10/05 21:17:40 $ * @version $Revision: 1.18 $ $Date: 2003/10/07 22:20:57 $
* *
* @author Stephen Colebourne * @author Stephen Colebourne
* @author Arun Mammen Thomas * @author Arun Mammen Thomas
@ -163,11 +163,11 @@ public class TestMapUtils extends BulkTest {
public BulkTest bulkTestTypedMap() { public BulkTest bulkTestTypedMap() {
return new AbstractTestMap("") { return new AbstractTestMap("") {
public boolean useNullKey() { public boolean isAllowNullKey() {
return false; return false;
} }
public boolean useNullValue() { public boolean isAllowNullValue() {
return false; return false;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestReferenceMap.java,v 1.12 2003/10/05 21:23:21 scolebourne Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestReferenceMap.java,v 1.13 2003/10/07 22:20:57 scolebourne Exp $
* ==================================================================== * ====================================================================
* *
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
@ -65,7 +65,7 @@ import junit.framework.Test;
/** /**
* Tests for ReferenceMap. * Tests for ReferenceMap.
* *
* @version $Revision: 1.12 $ $Date: 2003/10/05 21:23:21 $ * @version $Revision: 1.13 $ $Date: 2003/10/07 22:20:57 $
* *
* @author Paul Jack * @author Paul Jack
*/ */
@ -89,11 +89,11 @@ public class TestReferenceMap extends AbstractTestMap {
return map; return map;
} }
public boolean useNullKey() { public boolean isAllowNullKey() {
return false; return false;
} }
public boolean useNullValue() { public boolean isAllowNullValue() {
return false; return false;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestTreeMap.java,v 1.9 2003/10/05 21:23:21 scolebourne Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestTreeMap.java,v 1.10 2003/10/07 22:20:57 scolebourne Exp $
* ==================================================================== * ====================================================================
* *
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
@ -62,7 +62,7 @@ import java.util.TreeMap;
/** /**
* Tests TreeMap. * Tests TreeMap.
* *
* @version $Revision: 1.9 $ $Date: 2003/10/05 21:23:21 $ * @version $Revision: 1.10 $ $Date: 2003/10/07 22:20:57 $
* *
* @author Jason van Zyl * @author Jason van Zyl
*/ */
@ -77,7 +77,7 @@ public abstract class TestTreeMap extends AbstractTestMap {
junit.textui.TestRunner.main(testCaseName); junit.textui.TestRunner.main(testCaseName);
} }
public boolean useNullKey() { public boolean isAllowNullKey() {
return false; return false;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/decorators/Attic/TestFixedSizeMap.java,v 1.4 2003/10/02 23:01:09 scolebourne Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/decorators/Attic/TestFixedSizeMap.java,v 1.5 2003/10/07 22:20:58 scolebourne Exp $
* ==================================================================== * ====================================================================
* *
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
@ -70,7 +70,7 @@ import org.apache.commons.collections.AbstractTestMap;
* implementation. * implementation.
* *
* @since Commons Collections 3.0 * @since Commons Collections 3.0
* @version $Revision: 1.4 $ $Date: 2003/10/02 23:01:09 $ * @version $Revision: 1.5 $ $Date: 2003/10/07 22:20:58 $
* *
* @author Stephen Colebourne * @author Stephen Colebourne
*/ */
@ -99,7 +99,11 @@ public class TestFixedSizeMap extends AbstractTestMap {
return FixedSizeMap.decorate(map); return FixedSizeMap.decorate(map);
} }
protected boolean isAddRemoveModifiable() { protected boolean isPutAddSupported() {
return false;
}
protected boolean isRemoveSupported() {
return false; return false;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/decorators/Attic/TestFixedSizeSortedMap.java,v 1.4 2003/10/02 23:01:09 scolebourne Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/decorators/Attic/TestFixedSizeSortedMap.java,v 1.5 2003/10/07 22:20:58 scolebourne Exp $
* ==================================================================== * ====================================================================
* *
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
@ -71,7 +71,7 @@ import org.apache.commons.collections.AbstractTestSortedMap;
* implementation. * implementation.
* *
* @since Commons Collections 3.0 * @since Commons Collections 3.0
* @version $Revision: 1.4 $ $Date: 2003/10/02 23:01:09 $ * @version $Revision: 1.5 $ $Date: 2003/10/07 22:20:58 $
* *
* @author Stephen Colebourne * @author Stephen Colebourne
*/ */
@ -100,7 +100,11 @@ public class TestFixedSizeSortedMap extends AbstractTestSortedMap {
return FixedSizeSortedMap.decorate(map); return FixedSizeSortedMap.decorate(map);
} }
protected boolean isAddRemoveModifiable() { protected boolean isPutAddSupported() {
return false;
}
protected boolean isRemoveSupported() {
return false; return false;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/decorators/Attic/TestLazySortedMap.java,v 1.2 2003/09/20 17:05:36 scolebourne Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/decorators/Attic/TestLazySortedMap.java,v 1.3 2003/10/07 22:20:58 scolebourne Exp $
* ==================================================================== * ====================================================================
* *
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
@ -74,7 +74,7 @@ import org.apache.commons.collections.TransformerUtils;
* {@link LazySortedMap} implementation. * {@link LazySortedMap} implementation.
* *
* @since Commons Collections 3.0 * @since Commons Collections 3.0
* @version $Revision: 1.2 $ $Date: 2003/09/20 17:05:36 $ * @version $Revision: 1.3 $ $Date: 2003/10/07 22:20:58 $
* *
* @author Phil Steitz * @author Phil Steitz
*/ */
@ -103,7 +103,7 @@ public class TestLazySortedMap extends TestLazyMap {
return decorateMap(new TreeMap(), nullFactory); return decorateMap(new TreeMap(), nullFactory);
} }
protected boolean useNullKey() { protected boolean isAllowNullKey() {
return false; return false;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/decorators/Attic/TestPredicatedSortedMap.java,v 1.2 2003/09/20 17:05:36 scolebourne Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/decorators/Attic/TestPredicatedSortedMap.java,v 1.3 2003/10/07 22:20:58 scolebourne Exp $
* ==================================================================== * ====================================================================
* *
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
@ -72,7 +72,7 @@ import org.apache.commons.collections.Predicate;
* {@link PredicatedSortedMap} implementation. * {@link PredicatedSortedMap} implementation.
* *
* @since Commons Collections 3.0 * @since Commons Collections 3.0
* @version $Revision: 1.2 $ $Date: 2003/09/20 17:05:36 $ * @version $Revision: 1.3 $ $Date: 2003/10/07 22:20:58 $
* *
* @author Phil Steitz * @author Phil Steitz
*/ */
@ -106,7 +106,7 @@ public class TestPredicatedSortedMap extends TestPredicatedMap{
return decorateMap(new TreeMap(), testPredicate, testPredicate); return decorateMap(new TreeMap(), testPredicate, testPredicate);
} }
protected boolean useNullKey() { protected boolean isAllowNullKey() {
return false; return false;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/decorators/Attic/TestUnmodifiableMap.java,v 1.1 2003/10/06 05:06:05 psteitz Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/decorators/Attic/TestUnmodifiableMap.java,v 1.2 2003/10/07 22:20:58 scolebourne Exp $
* ==================================================================== * ====================================================================
* *
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
@ -74,7 +74,7 @@ import org.apache.commons.collections.AbstractTestMap;
* {@link UnmodifiableMap} implementation. * {@link UnmodifiableMap} implementation.
* *
* @since Commons Collections 3.0 * @since Commons Collections 3.0
* @version $Revision: 1.1 $ $Date: 2003/10/06 05:06:05 $ * @version $Revision: 1.2 $ $Date: 2003/10/07 22:20:58 $
* *
* @author Phil Steitz * @author Phil Steitz
*/ */
@ -99,11 +99,15 @@ public class TestUnmodifiableMap extends AbstractTestMap{
return UnmodifiableMap.decorate(new HashMap()); return UnmodifiableMap.decorate(new HashMap());
} }
protected boolean isChangeable() { protected boolean isPutChangeSupported() {
return false; return false;
} }
protected boolean isAddRemoveModifiable() { protected boolean isPutAddSupported() {
return false;
}
protected boolean isRemoveSupported() {
return false; return false;
} }