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

Comparing jsr166/src/test/tck/Atomic8Test.java (file contents):
Revision 1.9 by jsr166, Wed Jan 4 06:09:58 2017 UTC vs.
Revision 1.10 by jsr166, Fri Feb 22 19:27:47 2019 UTC

# Line 491 | Line 491 | public class Atomic8Test extends JSR166T
491       * null function argument
492       */
493      public void testGetAndUpdateNPE() {
494 <        Runnable[] throwingActions = {
494 >        assertThrows(
495 >            NullPointerException.class,
496              () -> new AtomicLong().getAndUpdate(null),
497              () -> new AtomicInteger().getAndUpdate(null),
498              () -> new AtomicReference().getAndUpdate(null),
# Line 500 | Line 501 | public class Atomic8Test extends JSR166T
501              () -> new AtomicReferenceArray(1).getAndUpdate(0, null),
502              () -> aLongFieldUpdater().getAndUpdate(this, null),
503              () -> anIntFieldUpdater().getAndUpdate(this, null),
504 <            () -> anIntegerFieldUpdater().getAndUpdate(this, null),
504 <        };
505 <        assertThrows(NullPointerException.class, throwingActions);
504 >            () -> anIntegerFieldUpdater().getAndUpdate(this, null));
505      }
506  
507      /**
508       * All Atomic updateAndGet methods throw NullPointerException on null function argument
509       */
510      public void testUpdateAndGetNPE() {
511 <        Runnable[] throwingActions = {
511 >        assertThrows(
512 >            NullPointerException.class,
513              () -> new AtomicLong().updateAndGet(null),
514              () -> new AtomicInteger().updateAndGet(null),
515              () -> new AtomicReference().updateAndGet(null),
# Line 518 | Line 518 | public class Atomic8Test extends JSR166T
518              () -> new AtomicReferenceArray(1).updateAndGet(0, null),
519              () -> aLongFieldUpdater().updateAndGet(this, null),
520              () -> anIntFieldUpdater().updateAndGet(this, null),
521 <            () -> anIntegerFieldUpdater().updateAndGet(this, null),
522 <        };
523 <        assertThrows(NullPointerException.class, throwingActions);
521 >            () -> anIntegerFieldUpdater().updateAndGet(this, null));
522      }
523  
524      /**
# Line 528 | Line 526 | public class Atomic8Test extends JSR166T
526       * on null function argument
527       */
528      public void testGetAndAccumulateNPE() {
529 <        Runnable[] throwingActions = {
529 >        assertThrows(
530 >            NullPointerException.class,
531              () -> new AtomicLong().getAndAccumulate(1L, null),
532              () -> new AtomicInteger().getAndAccumulate(1, null),
533              () -> new AtomicReference().getAndAccumulate(one, null),
# Line 537 | Line 536 | public class Atomic8Test extends JSR166T
536              () -> new AtomicReferenceArray(1).getAndAccumulate(0, one, null),
537              () -> aLongFieldUpdater().getAndAccumulate(this, 1L, null),
538              () -> anIntFieldUpdater().getAndAccumulate(this, 1, null),
539 <            () -> anIntegerFieldUpdater().getAndAccumulate(this, one, null),
541 <        };
542 <        assertThrows(NullPointerException.class, throwingActions);
539 >            () -> anIntegerFieldUpdater().getAndAccumulate(this, one, null));
540      }
541  
542      /**
# Line 547 | Line 544 | public class Atomic8Test extends JSR166T
544       * on null function argument
545       */
546      public void testAccumulateAndGetNPE() {
547 <        Runnable[] throwingActions = {
547 >        assertThrows(
548 >            NullPointerException.class,
549              () -> new AtomicLong().accumulateAndGet(1L, null),
550              () -> new AtomicInteger().accumulateAndGet(1, null),
551              () -> new AtomicReference().accumulateAndGet(one, null),
# Line 556 | Line 554 | public class Atomic8Test extends JSR166T
554              () -> new AtomicReferenceArray(1).accumulateAndGet(0, one, null),
555              () -> aLongFieldUpdater().accumulateAndGet(this, 1L, null),
556              () -> anIntFieldUpdater().accumulateAndGet(this, 1, null),
557 <            () -> anIntegerFieldUpdater().accumulateAndGet(this, one, null),
560 <        };
561 <        assertThrows(NullPointerException.class, throwingActions);
557 >            () -> anIntegerFieldUpdater().accumulateAndGet(this, one, null));
558      }
559  
560      /**
# Line 571 | Line 567 | public class Atomic8Test extends JSR166T
567          final AtomicLongFieldUpdater longUpdater = aLongFieldUpdater();
568          final AtomicIntegerFieldUpdater intUpdater = anIntFieldUpdater();
569          final AtomicReferenceFieldUpdater refUpdater = anIntegerFieldUpdater();
574        final Object obj = new Object();
570          for (Object x : new Object[]{ new Object(), null }) {
571 <            Runnable[] throwingActions = {
571 >            assertThrows(
572 >                ClassCastException.class,
573                  () -> longUpdater.get(x),
574                  () -> intUpdater.get(x),
575                  () -> refUpdater.get(x),
# Line 591 | Line 587 | public class Atomic8Test extends JSR166T
587  
588                  () -> longUpdater.compareAndSet(x, 17L, 42L),
589                  () -> intUpdater.compareAndSet(x, 17, 42),
590 <                () -> refUpdater.compareAndSet(x, (Integer) 17, (Integer) 42),
595 <            };
596 <            assertThrows(ClassCastException.class, throwingActions);
590 >                () -> refUpdater.compareAndSet(x, (Integer) 17, (Integer) 42));
591          }
592      }
593  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines