commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections TestMultiHashMap.java
Date Fri, 14 May 2004 22:33:58 GMT
scolebourne    2004/05/14 15:33:58

  Modified:    collections/src/test/org/apache/commons/collections
                        TestMultiHashMap.java
  Log:
  Ensure constructor and clone method correctly clone multimaps
  bug 28972
  
  Revision  Changes    Path
  1.19      +47 -2     jakarta-commons/collections/src/test/org/apache/commons/collections/TestMultiHashMap.java
  
  Index: TestMultiHashMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestMultiHashMap.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- TestMultiHashMap.java	14 Mar 2004 17:05:24 -0000	1.18
  +++ TestMultiHashMap.java	14 May 2004 22:33:58 -0000	1.19
  @@ -344,5 +344,50 @@
           assertEquals(true, map.containsValue("A", "Z"));
           assertEquals(true, map.containsValue("A", "M"));
       }
  -    
  +
  +    public void testClone() {
  +        MultiHashMap map = new MultiHashMap();
  +        map.put("A", "1");
  +        map.put("A", "2");
  +        Collection coll = (Collection) map.get("A");
  +        assertEquals(1, map.size());
  +        assertEquals(2, coll.size());
  +        
  +        MultiHashMap cloned = (MultiHashMap) map.clone();
  +        Collection clonedColl = (Collection) cloned.get("A");
  +        assertNotSame(map, cloned);
  +        assertNotSame(coll, clonedColl);
  +        assertEquals(1, map.size());
  +        assertEquals(2, coll.size());
  +        assertEquals(1, cloned.size());
  +        assertEquals(2, clonedColl.size());
  +        map.put("A", "3");
  +        assertEquals(1, map.size());
  +        assertEquals(3, coll.size());
  +        assertEquals(1, cloned.size());
  +        assertEquals(2, clonedColl.size());
  +    }
  +
  +    public void testConstructor() {
  +        MultiHashMap map = new MultiHashMap();
  +        map.put("A", "1");
  +        map.put("A", "2");
  +        Collection coll = (Collection) map.get("A");
  +        assertEquals(1, map.size());
  +        assertEquals(2, coll.size());
  +        
  +        MultiHashMap newMap = new MultiHashMap(map);
  +        Collection newColl = (Collection) newMap.get("A");
  +        assertNotSame(map, newMap);
  +        assertNotSame(coll, newColl);
  +        assertEquals(1, map.size());
  +        assertEquals(2, coll.size());
  +        assertEquals(1, newMap.size());
  +        assertEquals(2, newColl.size());
  +        map.put("A", "3");
  +        assertEquals(1, map.size());
  +        assertEquals(3, coll.size());
  +        assertEquals(1, newMap.size());
  +        assertEquals(2, newColl.size());
  +    }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message