Repository: commons-collections
Updated Branches:
  refs/heads/master 1cdad51a0 -> 9d4f2ba88


COLLECTIONS-660: uncomment and change order of assertEquals


Project: http://git-wip-us.apache.org/repos/asf/commons-collections/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/commons-collections/commit/9d4f2ba8
Tree: http://git-wip-us.apache.org/repos/asf/commons-collections/tree/9d4f2ba8
Diff: http://git-wip-us.apache.org/repos/asf/commons-collections/diff/9d4f2ba8

Branch: refs/heads/master
Commit: 9d4f2ba886b003980f2c37a4de7a3e6c3c701820
Parents: 1cdad51
Author: Bruno P. Kinoshita <[email protected]>
Authored: Wed Oct 4 17:34:49 2017 +1300
Committer: Bruno P. Kinoshita <[email protected]>
Committed: Wed Oct 4 17:34:49 2017 +1300

----------------------------------------------------------------------
 .../commons/collections4/map/AbstractMapTest.java | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-collections/blob/9d4f2ba8/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java 
b/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java
index 280404b..ccd1fc3 100644
--- a/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java
+++ b/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java
@@ -1956,19 +1956,13 @@ public abstract class AbstractMapTest<K, V> extends 
AbstractObjectTest {
         assertEquals("Map should be same size as HashMap", size, 
getMap().size());
         assertEquals("Map should be empty if HashMap is", empty, 
getMap().isEmpty());
         assertEquals("hashCodes should be the same", 
getConfirmed().hashCode(), getMap().hashCode());
-        // this fails for LRUMap because confirmed.equals() somehow modifies
-        // map, causing concurrent modification exceptions.
-        // assertEquals("Map should still equal HashMap", confirmed, map);
-        // this works though and performs the same verification:
+        // changing the order of the assertion below fails for LRUMap because 
confirmed is
+        // another collection (e.g. treemap) and confirmed.equals() creates a 
normal iterator (not
+        // #mapIterator()), which modifies the parent expected modCount of the 
map object, causing
+        // concurrent modification exceptions.
+        // Because of this we have assertEquals(map, confirmed), and not the 
other way around.
+        assertEquals("Map should still equal HashMap", map, confirmed);
         assertTrue("Map should still equal HashMap", 
getMap().equals(getConfirmed()));
-        // TODO: this should really be reexamined to figure out why LRU map
-        // behaves like it does (the equals shouldn't modify since all accesses
-        // by the confirmed collection should be through an iterator, thus not
-        // causing LRUMap to change).
-        // When comparing two maps, the entries in the map have to be accessed
-        // (usually with the get(Object) method). In the case of the LRUMap, 
this
-        // also alters the modCount as moveToMRU is called for the retrieved 
entry.
-        // Imho, the modCount should not be increased for a read-only 
operation.
     }
 
     public void verifyEntrySet() {

Reply via email to