ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/ConcurrentHashMapTest.java
(Generate patch)

Comparing jsr166/src/test/tck/ConcurrentHashMapTest.java (file contents):
Revision 1.5 by dl, Sat Sep 20 18:20:07 2003 UTC vs.
Revision 1.6 by dl, Fri Nov 28 12:38:08 2003 UTC

# Line 435 | Line 435 | public class ConcurrentHashMapTest exten
435              unexpectedException();
436          }
437      }
438 +
439 +
440 +    /**
441 +     * SetValue of an EntrySet entry sets value in the map.
442 +     */
443 +    public void testSetValueWriteThrough() {
444 +        // Adapted from a bug report by Eric Zoerner
445 +        ConcurrentHashMap map = new ConcurrentHashMap(2, 5.0f, 1);
446 +        assertTrue(map.isEmpty());
447 +        for (int i = 0; i < 20; i++)
448 +            map.put(new Integer(i), new Integer(i));
449 +        assertFalse(map.isEmpty());
450 +        Map.Entry entry1 = (Map.Entry)map.entrySet().iterator().next();
451 +        
452 +        // assert that entry1 is not 16
453 +        assertTrue("entry is 16, test not valid",
454 +                   !entry1.getKey().equals(new Integer(16)));
455 +        
456 +        // remove 16 (a different key) from map
457 +        // which just happens to cause entry1 to be cloned in map
458 +        map.remove(new Integer(16));
459 +        entry1.setValue("XYZ");
460 +        assertTrue(map.containsValue("XYZ")); // fails
461 +    }
462      
463   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines