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.6 by dl, Fri Nov 28 12:38:08 2003 UTC vs.
Revision 1.7 by dl, Wed Dec 3 21:08:24 2003 UTC

# Line 210 | Line 210 | public class ConcurrentHashMapTest exten
210       */
211      public void testPutIfAbsent() {
212          ConcurrentHashMap map = map5();
213 <        map.putIfAbsent(new Integer(6), "Z");
214 <        assertTrue(map.containsKey(new Integer(6)));
213 >        map.putIfAbsent(six, "Z");
214 >        assertTrue(map.containsKey(six));
215      }
216  
217      /**
# Line 223 | Line 223 | public class ConcurrentHashMapTest exten
223      }
224  
225      /**
226 +     *   replace fails when the given key is not present
227 +     */
228 +    public void testReplace() {
229 +        ConcurrentHashMap map = map5();
230 +        assertFalse(map.replace(six, "Z"));
231 +        assertFalse(map.containsKey(six));
232 +    }
233 +
234 +    /**
235 +     *   replace succeeds if the key is already present
236 +     */
237 +    public void testReplace2() {
238 +        ConcurrentHashMap map = map5();
239 +        assertTrue(map.replace(one, "Z"));
240 +        assertEquals("Z", map.get(one));
241 +    }
242 +
243 +
244 +    /**
245 +     * replace value fails when the given key not mapped to expected value
246 +     */
247 +    public void testReplaceValue() {
248 +        ConcurrentHashMap map = map5();
249 +        assertEquals("A", map.get(one));
250 +        assertFalse(map.replace(one, "Z", "Z"));
251 +        assertEquals("A", map.get(one));
252 +    }
253 +
254 +    /**
255 +     * replace value succeeds when the given key mapped to expected value
256 +     */
257 +    public void testReplaceValue2() {
258 +        ConcurrentHashMap map = map5();
259 +        assertEquals("A", map.get(one));
260 +        assertTrue(map.replace(one, "A", "Z"));
261 +        assertEquals("Z", map.get(one));
262 +    }
263 +
264 +
265 +    /**
266       *   remove removes the correct key-value pair from the map
267       */
268      public void testRemove() {
# Line 377 | Line 417 | public class ConcurrentHashMapTest exten
417      }
418  
419      /**
420 +     * replace(null, x) throws NPE
421 +     */
422 +    public void testReplace_NullPointerException() {
423 +        try {
424 +            ConcurrentHashMap c = new ConcurrentHashMap(5);
425 +            c.replace(null, "whatever");
426 +            shouldThrow();
427 +        } catch(NullPointerException e){}
428 +    }
429 +
430 +    /**
431 +     * replace(null, x, y) throws NPE
432 +     */
433 +    public void testReplaceValue_NullPointerException() {
434 +        try {
435 +            ConcurrentHashMap c = new ConcurrentHashMap(5);
436 +            c.replace(null, one, "whatever");
437 +            shouldThrow();
438 +        } catch(NullPointerException e){}
439 +    }
440 +
441 +    /**
442       * putIfAbsent(x, null) throws NPE
443       */
444      public void testPutIfAbsent2_NullPointerException() {
# Line 386 | Line 448 | public class ConcurrentHashMapTest exten
448              shouldThrow();
449          } catch(NullPointerException e){}
450      }
451 +
452 +
453 +    /**
454 +     * replace(x, null) throws NPE
455 +     */
456 +    public void testReplace2_NullPointerException() {
457 +        try {
458 +            ConcurrentHashMap c = new ConcurrentHashMap(5);
459 +            c.replace("whatever", null);
460 +            shouldThrow();
461 +        } catch(NullPointerException e){}
462 +    }
463 +
464 +    /**
465 +     * replace(x, null, y) throws NPE
466 +     */
467 +    public void testReplaceValue2_NullPointerException() {
468 +        try {
469 +            ConcurrentHashMap c = new ConcurrentHashMap(5);
470 +            c.replace("whatever", null, "A");
471 +            shouldThrow();
472 +        } catch(NullPointerException e){}
473 +    }
474 +
475 +    /**
476 +     * replace(x, y, null) throws NPE
477 +     */
478 +    public void testReplaceValue3_NullPointerException() {
479 +        try {
480 +            ConcurrentHashMap c = new ConcurrentHashMap(5);
481 +            c.replace("whatever", one, null);
482 +            shouldThrow();
483 +        } catch(NullPointerException e){}
484 +    }
485  
486  
487      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines