harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sean Qiu (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-4603) [classlib][util] LinkedHashMap.clone() has problem when override the removeEldestEntry method
Date Tue, 07 Aug 2007 05:33:59 GMT
[classlib][util] LinkedHashMap.clone() has problem when override the removeEldestEntry method
---------------------------------------------------------------------------------------------

                 Key: HARMONY-4603
                 URL: https://issues.apache.org/jira/browse/HARMONY-4603
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Sean Qiu


 LinkedHashMap.clone() has problem when override the removeEldestEntry method

===== Test =====
public class LinkedHashMapTest extends TestCase {
    public void test_clone() {
        LinkedHashMap hashMap = new MockMap();
        String value = "value a";
        hashMap.put("key", value);
        MockMap cloneMap = (MockMap) hashMap.clone();
        assertEquals(value, cloneMap.get("key"));
        assertEquals(hashMap, cloneMap);
        assertEquals(1, cloneMap.num);

        hashMap.put("key", "value b");
        assertFalse(hashMap.equals(cloneMap));
    }

    class MockMap extends LinkedHashMap {
        int num;

        public Object put(Object k, Object v) {
            num++;
            return super.put(k, v);
        }

        protected boolean removeEldestEntry(Map.Entry e) {
            return num > 1;
        }
    }
}

=== Result ===
RI:           Pass
Harmy:   Fail

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message