add generic TestMap test for http://issues.apache.org/bugzilla/show_bug.cgi?id=9573 (values isn't backed by map), but override the test in TestMultiHashMap for now
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130860 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0cb8046cd3
commit
aa959e46cf
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestMap.java,v 1.21 2002/11/01 19:07:53 rwaldhoff Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestMap.java,v 1.22 2002/11/01 19:36:54 rwaldhoff Exp $
|
||||||
* $Revision: 1.21 $
|
* $Revision: 1.22 $
|
||||||
* $Date: 2002/11/01 19:07:53 $
|
* $Date: 2002/11/01 19:36:54 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
|
@ -152,7 +152,7 @@ import java.util.Set;
|
||||||
* @author Michael Smith
|
* @author Michael Smith
|
||||||
* @author Rodney Waldhoff
|
* @author Rodney Waldhoff
|
||||||
* @author Paul Jack
|
* @author Paul Jack
|
||||||
* @version $Revision: 1.21 $ $Date: 2002/11/01 19:07:53 $
|
* @version $Revision: 1.22 $ $Date: 2002/11/01 19:36:54 $
|
||||||
*/
|
*/
|
||||||
public abstract class TestMap extends TestObject {
|
public abstract class TestMap extends TestObject {
|
||||||
|
|
||||||
|
@ -769,6 +769,36 @@ public abstract class TestMap extends TestObject {
|
||||||
verify();
|
verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that the {@link Map#values} collection is backed by
|
||||||
|
* the underlying map by removing from the values collection
|
||||||
|
* and testing if the value was removed from the map.
|
||||||
|
* <p/>
|
||||||
|
* We should really test the "vice versa" case--that values removed
|
||||||
|
* from the map are removed from the values collection--also,
|
||||||
|
* but that's a more difficult test to construct (lacking a
|
||||||
|
* "removeValue" method.)
|
||||||
|
*
|
||||||
|
* @see http://issues.apache.org/bugzilla/show_bug.cgi?id=9573
|
||||||
|
*/
|
||||||
|
public void testValuesRemovedFromValuesCollectionAreRemovedFromMap() {
|
||||||
|
resetFull();
|
||||||
|
Object[] sampleValues = getSampleValues();
|
||||||
|
Collection values = map.values();
|
||||||
|
for(int i=0;i<sampleValues.length;i++) {
|
||||||
|
if(map.containsValue(sampleValues[i])) {
|
||||||
|
while(values.contains(sampleValues[i])) {
|
||||||
|
try {
|
||||||
|
values.remove(sampleValues[i]);
|
||||||
|
} catch(UnsupportedOperationException e) {
|
||||||
|
// if values.remove is unsupported, just skip this test
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertTrue("Value should have been removed from the underlying map.",!map.containsValue(sampleValues[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility methods to create an array of Map.Entry objects
|
* Utility methods to create an array of Map.Entry objects
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestMultiHashMap.java,v 1.6 2002/10/12 22:36:22 scolebourne Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestMultiHashMap.java,v 1.7 2002/11/01 19:36:54 rwaldhoff Exp $
|
||||||
* $Revision: 1.6 $
|
* $Revision: 1.7 $
|
||||||
* $Date: 2002/10/12 22:36:22 $
|
* $Date: 2002/11/01 19:36:54 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
|
@ -268,6 +268,15 @@ public class TestMultiHashMap extends TestMap
|
||||||
public void testMapHashCode() {
|
public void testMapHashCode() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// since the MultiHashMap.values Collection isn't currently
|
||||||
|
// backed by the map, we need to skip this test for now
|
||||||
|
// fix bug 9573 <http://issues.apache.org/bugzilla/show_bug.cgi?id=9573>
|
||||||
|
// and enable this test
|
||||||
|
public void testValuesRemovedFromValuesCollectionAreRemovedFromMap() {
|
||||||
|
// TODO: fix bug 9573 <http://issues.apache.org/bugzilla/show_bug.cgi?id=9573>
|
||||||
|
// and enable this test
|
||||||
|
}
|
||||||
|
|
||||||
// The verification for the map and its entry set must also be overridden
|
// The verification for the map and its entry set must also be overridden
|
||||||
// because the values are not going to be the same as the values in the
|
// because the values are not going to be the same as the values in the
|
||||||
// confirmed map (they're going to be collections of values instead).
|
// confirmed map (they're going to be collections of values instead).
|
||||||
|
|
Loading…
Reference in New Issue