scolebourne 2003/11/04 15:35:35
Modified: collections/src/test/org/apache/commons/collections
AbstractTestMap.java
Log:
Avoid infinite loop in test framework
Simplify error messges
Revision Changes Path
1.12 +8 -7
jakarta-commons/collections/src/test/org/apache/commons/collections/AbstractTestMap.java
Index: AbstractTestMap.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/AbstractTestMap.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- AbstractTestMap.java 2 Nov 2003 15:27:05 -0000 1.11
+++ AbstractTestMap.java 4 Nov 2003 23:35:35 -0000 1.12
@@ -1027,14 +1027,17 @@
Collection values = map.values();
for (int i = 0; i < sampleValues.length; i++) {
if (map.containsValue(sampleValues[i])) {
- while (values.contains(sampleValues[i])) {
+ int j = 0; // loop counter prevents infinite loops when remove is
broken
+ while (values.contains(sampleValues[i]) && j < 10000) {
try {
values.remove(sampleValues[i]);
} catch (UnsupportedOperationException e) {
// if values.remove is unsupported, just skip this test
return;
}
+ j++;
}
+ assertTrue("values().remove(obj) is broken", j < 10000);
assertTrue(
"Value should have been removed from the underlying map.",
!map.containsValue(sampleValues[i]));
@@ -1490,8 +1493,7 @@
assertEquals("entrySet hashCodes should be the same" +
"\nTest: " + entrySet + "\nReal: " + confirmed.entrySet(),
confirmed.entrySet().hashCode(), entrySet.hashCode());
- assertEquals("Map's entry set should still equal HashMap's" +
- "\nTest: " + entrySet + "\nReal: " + confirmed.entrySet(),
+ assertEquals("Map's entry set should still equal HashMap's",
confirmed.entrySet(), entrySet);
}
@@ -1510,8 +1512,7 @@
assertEquals("keySet hashCodes should be the same" +
"\nTest: " + keySet + "\nReal: " + confirmed.keySet(),
confirmed.keySet().hashCode(), keySet.hashCode());
- assertEquals("Map's key set should still equal HashMap's" +
- "\nTest: " + keySet + "\nReal: " + confirmed.keySet(),
+ assertEquals("Map's key set should still equal HashMap's",
confirmed.keySet(), keySet);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]