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 |
|
} |