351 |
|
try { |
352 |
|
new ConcurrentHashMap(-1,0,1); |
353 |
|
shouldThrow(); |
354 |
< |
} catch (IllegalArgumentException e) {} |
354 |
> |
} catch (IllegalArgumentException success) {} |
355 |
|
} |
356 |
|
|
357 |
|
/** |
361 |
|
try { |
362 |
|
new ConcurrentHashMap(1,0,-1); |
363 |
|
shouldThrow(); |
364 |
< |
} catch (IllegalArgumentException e) {} |
364 |
> |
} catch (IllegalArgumentException success) {} |
365 |
|
} |
366 |
|
|
367 |
|
/** |
371 |
|
try { |
372 |
|
new ConcurrentHashMap(-1); |
373 |
|
shouldThrow(); |
374 |
< |
} catch (IllegalArgumentException e) {} |
374 |
> |
} catch (IllegalArgumentException success) {} |
375 |
|
} |
376 |
|
|
377 |
|
/** |
382 |
|
ConcurrentHashMap c = new ConcurrentHashMap(5); |
383 |
|
c.get(null); |
384 |
|
shouldThrow(); |
385 |
< |
} catch (NullPointerException e) {} |
385 |
> |
} catch (NullPointerException success) {} |
386 |
|
} |
387 |
|
|
388 |
|
/** |
393 |
|
ConcurrentHashMap c = new ConcurrentHashMap(5); |
394 |
|
c.containsKey(null); |
395 |
|
shouldThrow(); |
396 |
< |
} catch (NullPointerException e) {} |
396 |
> |
} catch (NullPointerException success) {} |
397 |
|
} |
398 |
|
|
399 |
|
/** |
404 |
|
ConcurrentHashMap c = new ConcurrentHashMap(5); |
405 |
|
c.containsValue(null); |
406 |
|
shouldThrow(); |
407 |
< |
} catch (NullPointerException e) {} |
407 |
> |
} catch (NullPointerException success) {} |
408 |
|
} |
409 |
|
|
410 |
|
/** |
415 |
|
ConcurrentHashMap c = new ConcurrentHashMap(5); |
416 |
|
c.contains(null); |
417 |
|
shouldThrow(); |
418 |
< |
} catch (NullPointerException e) {} |
418 |
> |
} catch (NullPointerException success) {} |
419 |
|
} |
420 |
|
|
421 |
|
/** |
426 |
|
ConcurrentHashMap c = new ConcurrentHashMap(5); |
427 |
|
c.put(null, "whatever"); |
428 |
|
shouldThrow(); |
429 |
< |
} catch (NullPointerException e) {} |
429 |
> |
} catch (NullPointerException success) {} |
430 |
|
} |
431 |
|
|
432 |
|
/** |
437 |
|
ConcurrentHashMap c = new ConcurrentHashMap(5); |
438 |
|
c.put("whatever", null); |
439 |
|
shouldThrow(); |
440 |
< |
} catch (NullPointerException e) {} |
440 |
> |
} catch (NullPointerException success) {} |
441 |
|
} |
442 |
|
|
443 |
|
/** |
448 |
|
ConcurrentHashMap c = new ConcurrentHashMap(5); |
449 |
|
c.putIfAbsent(null, "whatever"); |
450 |
|
shouldThrow(); |
451 |
< |
} catch (NullPointerException e) {} |
451 |
> |
} catch (NullPointerException success) {} |
452 |
|
} |
453 |
|
|
454 |
|
/** |
459 |
|
ConcurrentHashMap c = new ConcurrentHashMap(5); |
460 |
|
c.replace(null, "whatever"); |
461 |
|
shouldThrow(); |
462 |
< |
} catch (NullPointerException e) {} |
462 |
> |
} catch (NullPointerException success) {} |
463 |
|
} |
464 |
|
|
465 |
|
/** |
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 |
|
/** |
481 |
|
ConcurrentHashMap c = new ConcurrentHashMap(5); |
482 |
|
c.putIfAbsent("whatever", null); |
483 |
|
shouldThrow(); |
484 |
< |
} catch (NullPointerException e) {} |
484 |
> |
} catch (NullPointerException success) {} |
485 |
|
} |
486 |
|
|
487 |
|
|
493 |
|
ConcurrentHashMap c = new ConcurrentHashMap(5); |
494 |
|
c.replace("whatever", null); |
495 |
|
shouldThrow(); |
496 |
< |
} catch (NullPointerException e) {} |
496 |
> |
} catch (NullPointerException success) {} |
497 |
|
} |
498 |
|
|
499 |
|
/** |
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 |
|
/** |
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 |
|
|
528 |
|
c.put("sadsdf", "asdads"); |
529 |
|
c.remove(null); |
530 |
|
shouldThrow(); |
531 |
< |
} catch (NullPointerException e) {} |
531 |
> |
} catch (NullPointerException success) {} |
532 |
|
} |
533 |
|
|
534 |
|
/** |
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 |
|
|