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.17 by jsr166, Sat Nov 21 02:07:26 2009 UTC vs.
Revision 1.19 by jsr166, Sat Nov 21 17:38:05 2009 UTC

# Line 351 | Line 351 | public class ConcurrentHashMapTest exten
351          try {
352              new ConcurrentHashMap(-1,0,1);
353              shouldThrow();
354 <        } catch (IllegalArgumentException e) {}
354 >        } catch (IllegalArgumentException success) {}
355      }
356  
357      /**
# Line 361 | Line 361 | public class ConcurrentHashMapTest exten
361          try {
362              new ConcurrentHashMap(1,0,-1);
363              shouldThrow();
364 <        } catch (IllegalArgumentException e) {}
364 >        } catch (IllegalArgumentException success) {}
365      }
366  
367      /**
# Line 371 | Line 371 | public class ConcurrentHashMapTest exten
371          try {
372              new ConcurrentHashMap(-1);
373              shouldThrow();
374 <        } catch (IllegalArgumentException e) {}
374 >        } catch (IllegalArgumentException success) {}
375      }
376  
377      /**
# Line 382 | Line 382 | public class ConcurrentHashMapTest exten
382              ConcurrentHashMap c = new ConcurrentHashMap(5);
383              c.get(null);
384              shouldThrow();
385 <        } catch (NullPointerException e) {}
385 >        } catch (NullPointerException success) {}
386      }
387  
388      /**
# Line 393 | Line 393 | public class ConcurrentHashMapTest exten
393              ConcurrentHashMap c = new ConcurrentHashMap(5);
394              c.containsKey(null);
395              shouldThrow();
396 <        } catch (NullPointerException e) {}
396 >        } catch (NullPointerException success) {}
397      }
398  
399      /**
# Line 404 | Line 404 | public class ConcurrentHashMapTest exten
404              ConcurrentHashMap c = new ConcurrentHashMap(5);
405              c.containsValue(null);
406              shouldThrow();
407 <        } catch (NullPointerException e) {}
407 >        } catch (NullPointerException success) {}
408      }
409  
410      /**
# Line 415 | Line 415 | public class ConcurrentHashMapTest exten
415              ConcurrentHashMap c = new ConcurrentHashMap(5);
416              c.contains(null);
417              shouldThrow();
418 <        } catch (NullPointerException e) {}
418 >        } catch (NullPointerException success) {}
419      }
420  
421      /**
# Line 426 | Line 426 | public class ConcurrentHashMapTest exten
426              ConcurrentHashMap c = new ConcurrentHashMap(5);
427              c.put(null, "whatever");
428              shouldThrow();
429 <        } catch (NullPointerException e) {}
429 >        } catch (NullPointerException success) {}
430      }
431  
432      /**
# Line 437 | Line 437 | public class ConcurrentHashMapTest exten
437              ConcurrentHashMap c = new ConcurrentHashMap(5);
438              c.put("whatever", null);
439              shouldThrow();
440 <        } catch (NullPointerException e) {}
440 >        } catch (NullPointerException success) {}
441      }
442  
443      /**
# Line 448 | Line 448 | public class ConcurrentHashMapTest exten
448              ConcurrentHashMap c = new ConcurrentHashMap(5);
449              c.putIfAbsent(null, "whatever");
450              shouldThrow();
451 <        } catch (NullPointerException e) {}
451 >        } catch (NullPointerException success) {}
452      }
453  
454      /**
# Line 459 | Line 459 | public class ConcurrentHashMapTest exten
459              ConcurrentHashMap c = new ConcurrentHashMap(5);
460              c.replace(null, "whatever");
461              shouldThrow();
462 <        } catch (NullPointerException e) {}
462 >        } catch (NullPointerException success) {}
463      }
464  
465      /**
# Line 470 | Line 470 | public class ConcurrentHashMapTest exten
470              ConcurrentHashMap c = new ConcurrentHashMap(5);
471              c.replace(null, one, "whatever");
472              shouldThrow();
473 <        } catch (NullPointerException e) {}
473 >        } catch (NullPointerException success) {}
474      }
475  
476      /**
# Line 481 | Line 481 | public class ConcurrentHashMapTest exten
481              ConcurrentHashMap c = new ConcurrentHashMap(5);
482              c.putIfAbsent("whatever", null);
483              shouldThrow();
484 <        } catch (NullPointerException e) {}
484 >        } catch (NullPointerException success) {}
485      }
486  
487  
# Line 493 | Line 493 | public class ConcurrentHashMapTest exten
493              ConcurrentHashMap c = new ConcurrentHashMap(5);
494              c.replace("whatever", null);
495              shouldThrow();
496 <        } catch (NullPointerException e) {}
496 >        } catch (NullPointerException success) {}
497      }
498  
499      /**
# Line 504 | Line 504 | public class ConcurrentHashMapTest exten
504              ConcurrentHashMap c = new ConcurrentHashMap(5);
505              c.replace("whatever", null, "A");
506              shouldThrow();
507 <        } catch (NullPointerException e) {}
507 >        } catch (NullPointerException success) {}
508      }
509  
510      /**
# Line 515 | Line 515 | public class ConcurrentHashMapTest exten
515              ConcurrentHashMap c = new ConcurrentHashMap(5);
516              c.replace("whatever", one, null);
517              shouldThrow();
518 <        } catch (NullPointerException e) {}
518 >        } catch (NullPointerException success) {}
519      }
520  
521  
# Line 528 | Line 528 | public class ConcurrentHashMapTest exten
528              c.put("sadsdf", "asdads");
529              c.remove(null);
530              shouldThrow();
531 <        } catch (NullPointerException e) {}
531 >        } catch (NullPointerException success) {}
532      }
533  
534      /**
# Line 540 | Line 540 | public class ConcurrentHashMapTest exten
540              c.put("sadsdf", "asdads");
541              c.remove(null, "whatever");
542              shouldThrow();
543 <        } catch (NullPointerException e) {}
543 >        } catch (NullPointerException success) {}
544      }
545  
546      /**
547       * remove(x, null) returns false
548       */
549      public void testRemove3() {
550 <        try {
551 <            ConcurrentHashMap c = new ConcurrentHashMap(5);
552 <            c.put("sadsdf", "asdads");
553 <            assertFalse(c.remove("sadsdf", null));
554 <        } catch (NullPointerException e) {
555 <            fail();
556 <        }
550 >        ConcurrentHashMap c = new ConcurrentHashMap(5);
551 >        c.put("sadsdf", "asdads");
552 >        assertFalse(c.remove("sadsdf", null));
553      }
554  
555      /**
556       * A deserialized map equals original
557       */
558 <    public void testSerialization() {
558 >    public void testSerialization() throws Exception {
559          ConcurrentHashMap q = map5();
560  
561 <        try {
562 <            ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
563 <            ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
564 <            out.writeObject(q);
565 <            out.close();
566 <
567 <            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
568 <            ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
569 <            ConcurrentHashMap r = (ConcurrentHashMap)in.readObject();
570 <            assertEquals(q.size(), r.size());
571 <            assertTrue(q.equals(r));
576 <            assertTrue(r.equals(q));
577 <        } catch (Exception e) {
578 <            e.printStackTrace();
579 <            unexpectedException();
580 <        }
561 >        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
562 >        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
563 >        out.writeObject(q);
564 >        out.close();
565 >
566 >        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
567 >        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
568 >        ConcurrentHashMap r = (ConcurrentHashMap)in.readObject();
569 >        assertEquals(q.size(), r.size());
570 >        assertTrue(q.equals(r));
571 >        assertTrue(r.equals(q));
572      }
573  
574  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines