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

Comparing jsr166/src/test/tck/ForkJoinTaskTest.java (file contents):
Revision 1.31 by jsr166, Tue Mar 15 19:47:06 2011 UTC vs.
Revision 1.41 by jsr166, Sat Apr 25 04:55:30 2015 UTC

# Line 3 | Line 3
3   * Expert Group and released to the public domain, as explained at
4   * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6 < import java.util.concurrent.ExecutionException;
6 >
7 > import static java.util.concurrent.TimeUnit.MILLISECONDS;
8 > import static java.util.concurrent.TimeUnit.SECONDS;
9 >
10 > import java.util.HashSet;
11   import java.util.concurrent.CancellationException;
12 + import java.util.concurrent.ExecutionException;
13   import java.util.concurrent.ForkJoinPool;
14   import java.util.concurrent.ForkJoinTask;
10 import java.util.concurrent.ForkJoinWorkerThread;
15   import java.util.concurrent.RecursiveAction;
12 import java.util.concurrent.TimeUnit;
16   import java.util.concurrent.TimeoutException;
17   import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
18 < import static java.util.concurrent.TimeUnit.MILLISECONDS;
19 < import static java.util.concurrent.TimeUnit.SECONDS;
20 < import java.util.HashSet;
18 < import junit.framework.*;
18 >
19 > import junit.framework.Test;
20 > import junit.framework.TestSuite;
21  
22   public class ForkJoinTaskTest extends JSR166TestCase {
23  
24      public static void main(String[] args) {
25 <        junit.textui.TestRunner.run(suite());
25 >        main(suite(), args);
26      }
27  
28      public static Test suite() {
# Line 349 | Line 351 | public class ForkJoinTaskTest extends JS
351          }
352      }
353  
352
354      static final class FailingAsyncFib extends BinaryAsyncAction {
355          int number;
356          public FailingAsyncFib(int n) {
# Line 385 | Line 386 | public class ForkJoinTaskTest extends JS
386       */
387      public void testInvoke() {
388          RecursiveAction a = new CheckedRecursiveAction() {
389 <            public void realCompute() {
389 >            protected void realCompute() {
390                  AsyncFib f = new AsyncFib(8);
391                  assertNull(f.invoke());
392                  assertEquals(21, f.number);
# Line 401 | Line 402 | public class ForkJoinTaskTest extends JS
402       */
403      public void testQuietlyInvoke() {
404          RecursiveAction a = new CheckedRecursiveAction() {
405 <            public void realCompute() {
405 >            protected void realCompute() {
406                  AsyncFib f = new AsyncFib(8);
407                  f.quietlyInvoke();
408                  assertEquals(21, f.number);
# Line 415 | Line 416 | public class ForkJoinTaskTest extends JS
416       */
417      public void testForkJoin() {
418          RecursiveAction a = new CheckedRecursiveAction() {
419 <            public void realCompute() {
419 >            protected void realCompute() {
420                  AsyncFib f = new AsyncFib(8);
421                  assertSame(f, f.fork());
422                  assertNull(f.join());
# Line 430 | Line 431 | public class ForkJoinTaskTest extends JS
431       */
432      public void testForkGet() {
433          RecursiveAction a = new CheckedRecursiveAction() {
434 <            public void realCompute() throws Exception {
434 >            protected void realCompute() throws Exception {
435                  AsyncFib f = new AsyncFib(8);
436                  assertSame(f, f.fork());
437                  assertNull(f.get());
# Line 445 | Line 446 | public class ForkJoinTaskTest extends JS
446       */
447      public void testForkTimedGet() {
448          RecursiveAction a = new CheckedRecursiveAction() {
449 <            public void realCompute() throws Exception {
449 >            protected void realCompute() throws Exception {
450                  AsyncFib f = new AsyncFib(8);
451                  assertSame(f, f.fork());
452                  assertNull(f.get(LONG_DELAY_MS, MILLISECONDS));
# Line 460 | Line 461 | public class ForkJoinTaskTest extends JS
461       */
462      public void testForkTimedGetNPE() {
463          RecursiveAction a = new CheckedRecursiveAction() {
464 <            public void realCompute() throws Exception {
464 >            protected void realCompute() throws Exception {
465                  AsyncFib f = new AsyncFib(8);
466                  assertSame(f, f.fork());
467                  try {
# Line 476 | Line 477 | public class ForkJoinTaskTest extends JS
477       */
478      public void testForkQuietlyJoin() {
479          RecursiveAction a = new CheckedRecursiveAction() {
480 <            public void realCompute() {
480 >            protected void realCompute() {
481                  AsyncFib f = new AsyncFib(8);
482                  assertSame(f, f.fork());
483                  f.quietlyJoin();
# Line 486 | Line 487 | public class ForkJoinTaskTest extends JS
487          testInvokeOnPool(mainPool(), a);
488      }
489  
489
490      /**
491       * helpQuiesce returns when tasks are complete.
492       * getQueuedTaskCount returns 0 when quiescent
493       */
494      public void testForkHelpQuiesce() {
495          RecursiveAction a = new CheckedRecursiveAction() {
496 <            public void realCompute() {
496 >            protected void realCompute() {
497                  AsyncFib f = new AsyncFib(8);
498                  assertSame(f, f.fork());
499 <                f.helpQuiesce();
499 >                helpQuiesce();
500                  assertEquals(21, f.number);
501                  assertEquals(0, getQueuedTaskCount());
502                  checkCompletedNormally(f);
# Line 504 | Line 504 | public class ForkJoinTaskTest extends JS
504          testInvokeOnPool(mainPool(), a);
505      }
506  
507
507      /**
508       * invoke task throws exception when task completes abnormally
509       */
510      public void testAbnormalInvoke() {
511          RecursiveAction a = new CheckedRecursiveAction() {
512 <            public void realCompute() {
512 >            protected void realCompute() {
513                  FailingAsyncFib f = new FailingAsyncFib(8);
514                  try {
515                      f.invoke();
# Line 527 | Line 526 | public class ForkJoinTaskTest extends JS
526       */
527      public void testAbnormalQuietlyInvoke() {
528          RecursiveAction a = new CheckedRecursiveAction() {
529 <            public void realCompute() {
529 >            protected void realCompute() {
530                  FailingAsyncFib f = new FailingAsyncFib(8);
531                  f.quietlyInvoke();
532                  assertTrue(f.getException() instanceof FJException);
# Line 541 | Line 540 | public class ForkJoinTaskTest extends JS
540       */
541      public void testAbnormalForkJoin() {
542          RecursiveAction a = new CheckedRecursiveAction() {
543 <            public void realCompute() {
543 >            protected void realCompute() {
544                  FailingAsyncFib f = new FailingAsyncFib(8);
545                  assertSame(f, f.fork());
546                  try {
# Line 559 | Line 558 | public class ForkJoinTaskTest extends JS
558       */
559      public void testAbnormalForkGet() {
560          RecursiveAction a = new CheckedRecursiveAction() {
561 <            public void realCompute() throws Exception {
561 >            protected void realCompute() throws Exception {
562                  FailingAsyncFib f = new FailingAsyncFib(8);
563                  assertSame(f, f.fork());
564                  try {
# Line 579 | Line 578 | public class ForkJoinTaskTest extends JS
578       */
579      public void testAbnormalForkTimedGet() {
580          RecursiveAction a = new CheckedRecursiveAction() {
581 <            public void realCompute() throws Exception {
581 >            protected void realCompute() throws Exception {
582                  FailingAsyncFib f = new FailingAsyncFib(8);
583                  assertSame(f, f.fork());
584                  try {
# Line 599 | Line 598 | public class ForkJoinTaskTest extends JS
598       */
599      public void testAbnormalForkQuietlyJoin() {
600          RecursiveAction a = new CheckedRecursiveAction() {
601 <            public void realCompute() {
601 >            protected void realCompute() {
602                  FailingAsyncFib f = new FailingAsyncFib(8);
603                  assertSame(f, f.fork());
604                  f.quietlyJoin();
# Line 614 | Line 613 | public class ForkJoinTaskTest extends JS
613       */
614      public void testCancelledInvoke() {
615          RecursiveAction a = new CheckedRecursiveAction() {
616 <            public void realCompute() {
616 >            protected void realCompute() {
617                  AsyncFib f = new AsyncFib(8);
618                  assertTrue(f.cancel(true));
619                  try {
# Line 632 | Line 631 | public class ForkJoinTaskTest extends JS
631       */
632      public void testCancelledForkJoin() {
633          RecursiveAction a = new CheckedRecursiveAction() {
634 <            public void realCompute() {
634 >            protected void realCompute() {
635                  AsyncFib f = new AsyncFib(8);
636                  assertTrue(f.cancel(true));
637                  assertSame(f, f.fork());
# Line 651 | Line 650 | public class ForkJoinTaskTest extends JS
650       */
651      public void testCancelledForkGet() {
652          RecursiveAction a = new CheckedRecursiveAction() {
653 <            public void realCompute() throws Exception {
653 >            protected void realCompute() throws Exception {
654                  AsyncFib f = new AsyncFib(8);
655                  assertTrue(f.cancel(true));
656                  assertSame(f, f.fork());
# Line 670 | Line 669 | public class ForkJoinTaskTest extends JS
669       */
670      public void testCancelledForkTimedGet() throws Exception {
671          RecursiveAction a = new CheckedRecursiveAction() {
672 <            public void realCompute() throws Exception {
672 >            protected void realCompute() throws Exception {
673                  AsyncFib f = new AsyncFib(8);
674                  assertTrue(f.cancel(true));
675                  assertSame(f, f.fork());
# Line 689 | Line 688 | public class ForkJoinTaskTest extends JS
688       */
689      public void testCancelledForkQuietlyJoin() {
690          RecursiveAction a = new CheckedRecursiveAction() {
691 <            public void realCompute() {
691 >            protected void realCompute() {
692                  AsyncFib f = new AsyncFib(8);
693                  assertTrue(f.cancel(true));
694                  assertSame(f, f.fork());
# Line 705 | Line 704 | public class ForkJoinTaskTest extends JS
704      public void testGetPool() {
705          final ForkJoinPool mainPool = mainPool();
706          RecursiveAction a = new CheckedRecursiveAction() {
707 <            public void realCompute() {
707 >            protected void realCompute() {
708                  assertSame(mainPool, getPool());
709              }};
710          testInvokeOnPool(mainPool, a);
# Line 716 | Line 715 | public class ForkJoinTaskTest extends JS
715       */
716      public void testGetPool2() {
717          RecursiveAction a = new CheckedRecursiveAction() {
718 <            public void realCompute() {
718 >            protected void realCompute() {
719                  assertNull(getPool());
720              }};
721          assertNull(a.invoke());
# Line 727 | Line 726 | public class ForkJoinTaskTest extends JS
726       */
727      public void testInForkJoinPool() {
728          RecursiveAction a = new CheckedRecursiveAction() {
729 <            public void realCompute() {
729 >            protected void realCompute() {
730                  assertTrue(inForkJoinPool());
731              }};
732          testInvokeOnPool(mainPool(), a);
# Line 738 | Line 737 | public class ForkJoinTaskTest extends JS
737       */
738      public void testInForkJoinPool2() {
739          RecursiveAction a = new CheckedRecursiveAction() {
740 <            public void realCompute() {
740 >            protected void realCompute() {
741                  assertFalse(inForkJoinPool());
742              }};
743          assertNull(a.invoke());
# Line 749 | Line 748 | public class ForkJoinTaskTest extends JS
748       */
749      public void testSetRawResult() {
750          RecursiveAction a = new CheckedRecursiveAction() {
751 <            public void realCompute() {
751 >            protected void realCompute() {
752                  setRawResult(null);
753                  assertNull(getRawResult());
754              }};
# Line 761 | Line 760 | public class ForkJoinTaskTest extends JS
760       */
761      public void testCompleteExceptionally() {
762          RecursiveAction a = new CheckedRecursiveAction() {
763 <            public void realCompute() {
763 >            protected void realCompute() {
764                  AsyncFib f = new AsyncFib(8);
765                  f.completeExceptionally(new FJException());
766                  try {
# Line 779 | Line 778 | public class ForkJoinTaskTest extends JS
778       */
779      public void testInvokeAll2() {
780          RecursiveAction a = new CheckedRecursiveAction() {
781 <            public void realCompute() {
781 >            protected void realCompute() {
782                  AsyncFib f = new AsyncFib(8);
783                  AsyncFib g = new AsyncFib(9);
784                  invokeAll(f, g);
# Line 796 | Line 795 | public class ForkJoinTaskTest extends JS
795       */
796      public void testInvokeAll1() {
797          RecursiveAction a = new CheckedRecursiveAction() {
798 <            public void realCompute() {
798 >            protected void realCompute() {
799                  AsyncFib f = new AsyncFib(8);
800                  invokeAll(f);
801                  checkCompletedNormally(f);
# Line 810 | Line 809 | public class ForkJoinTaskTest extends JS
809       */
810      public void testInvokeAll3() {
811          RecursiveAction a = new CheckedRecursiveAction() {
812 <            public void realCompute() {
812 >            protected void realCompute() {
813                  AsyncFib f = new AsyncFib(8);
814                  AsyncFib g = new AsyncFib(9);
815                  AsyncFib h = new AsyncFib(7);
# Line 830 | Line 829 | public class ForkJoinTaskTest extends JS
829       */
830      public void testInvokeAllCollection() {
831          RecursiveAction a = new CheckedRecursiveAction() {
832 <            public void realCompute() {
832 >            protected void realCompute() {
833                  AsyncFib f = new AsyncFib(8);
834                  AsyncFib g = new AsyncFib(9);
835                  AsyncFib h = new AsyncFib(7);
# Line 849 | Line 848 | public class ForkJoinTaskTest extends JS
848          testInvokeOnPool(mainPool(), a);
849      }
850  
852
851      /**
852       * invokeAll(tasks) with any null task throws NPE
853       */
854      public void testInvokeAllNPE() {
855          RecursiveAction a = new CheckedRecursiveAction() {
856 <            public void realCompute() {
856 >            protected void realCompute() {
857                  AsyncFib f = new AsyncFib(8);
858                  AsyncFib g = new AsyncFib(9);
859                  AsyncFib h = null;
# Line 872 | Line 870 | public class ForkJoinTaskTest extends JS
870       */
871      public void testAbnormalInvokeAll2() {
872          RecursiveAction a = new CheckedRecursiveAction() {
873 <            public void realCompute() {
873 >            protected void realCompute() {
874                  AsyncFib f = new AsyncFib(8);
875                  FailingAsyncFib g = new FailingAsyncFib(9);
876                  try {
# Line 890 | Line 888 | public class ForkJoinTaskTest extends JS
888       */
889      public void testAbnormalInvokeAll1() {
890          RecursiveAction a = new CheckedRecursiveAction() {
891 <            public void realCompute() {
891 >            protected void realCompute() {
892                  FailingAsyncFib g = new FailingAsyncFib(9);
893                  try {
894                      invokeAll(g);
# Line 907 | Line 905 | public class ForkJoinTaskTest extends JS
905       */
906      public void testAbnormalInvokeAll3() {
907          RecursiveAction a = new CheckedRecursiveAction() {
908 <            public void realCompute() {
908 >            protected void realCompute() {
909                  AsyncFib f = new AsyncFib(8);
910                  FailingAsyncFib g = new FailingAsyncFib(9);
911                  AsyncFib h = new AsyncFib(7);
# Line 922 | Line 920 | public class ForkJoinTaskTest extends JS
920      }
921  
922      /**
923 <     * invokeAll(collection)  throws exception if any task does
923 >     * invokeAll(collection) throws exception if any task does
924       */
925      public void testAbnormalInvokeAllCollection() {
926          RecursiveAction a = new CheckedRecursiveAction() {
927 <            public void realCompute() {
927 >            protected void realCompute() {
928                  FailingAsyncFib f = new FailingAsyncFib(8);
929                  AsyncFib g = new AsyncFib(9);
930                  AsyncFib h = new AsyncFib(7);
# Line 950 | Line 948 | public class ForkJoinTaskTest extends JS
948       */
949      public void testTryUnfork() {
950          RecursiveAction a = new CheckedRecursiveAction() {
951 <            public void realCompute() {
951 >            protected void realCompute() {
952                  AsyncFib g = new AsyncFib(9);
953                  assertSame(g, g.fork());
954                  AsyncFib f = new AsyncFib(8);
# Line 969 | Line 967 | public class ForkJoinTaskTest extends JS
967       */
968      public void testGetSurplusQueuedTaskCount() {
969          RecursiveAction a = new CheckedRecursiveAction() {
970 <            public void realCompute() {
970 >            protected void realCompute() {
971                  AsyncFib h = new AsyncFib(7);
972                  assertSame(h, h.fork());
973                  AsyncFib g = new AsyncFib(9);
# Line 991 | Line 989 | public class ForkJoinTaskTest extends JS
989       */
990      public void testPeekNextLocalTask() {
991          RecursiveAction a = new CheckedRecursiveAction() {
992 <            public void realCompute() {
992 >            protected void realCompute() {
993                  AsyncFib g = new AsyncFib(9);
994                  assertSame(g, g.fork());
995                  AsyncFib f = new AsyncFib(8);
# Line 1011 | Line 1009 | public class ForkJoinTaskTest extends JS
1009       */
1010      public void testPollNextLocalTask() {
1011          RecursiveAction a = new CheckedRecursiveAction() {
1012 <            public void realCompute() {
1012 >            protected void realCompute() {
1013                  AsyncFib g = new AsyncFib(9);
1014                  assertSame(g, g.fork());
1015                  AsyncFib f = new AsyncFib(8);
# Line 1030 | Line 1028 | public class ForkJoinTaskTest extends JS
1028       */
1029      public void testPollTask() {
1030          RecursiveAction a = new CheckedRecursiveAction() {
1031 <            public void realCompute() {
1031 >            protected void realCompute() {
1032                  AsyncFib g = new AsyncFib(9);
1033                  assertSame(g, g.fork());
1034                  AsyncFib f = new AsyncFib(8);
# Line 1048 | Line 1046 | public class ForkJoinTaskTest extends JS
1046       */
1047      public void testPeekNextLocalTaskAsync() {
1048          RecursiveAction a = new CheckedRecursiveAction() {
1049 <            public void realCompute() {
1049 >            protected void realCompute() {
1050                  AsyncFib g = new AsyncFib(9);
1051                  assertSame(g, g.fork());
1052                  AsyncFib f = new AsyncFib(8);
# Line 1069 | Line 1067 | public class ForkJoinTaskTest extends JS
1067       */
1068      public void testPollNextLocalTaskAsync() {
1069          RecursiveAction a = new CheckedRecursiveAction() {
1070 <            public void realCompute() {
1070 >            protected void realCompute() {
1071                  AsyncFib g = new AsyncFib(9);
1072                  assertSame(g, g.fork());
1073                  AsyncFib f = new AsyncFib(8);
# Line 1089 | Line 1087 | public class ForkJoinTaskTest extends JS
1087       */
1088      public void testPollTaskAsync() {
1089          RecursiveAction a = new CheckedRecursiveAction() {
1090 <            public void realCompute() {
1090 >            protected void realCompute() {
1091                  AsyncFib g = new AsyncFib(9);
1092                  assertSame(g, g.fork());
1093                  AsyncFib f = new AsyncFib(8);
# Line 1112 | Line 1110 | public class ForkJoinTaskTest extends JS
1110       */
1111      public void testInvokeSingleton() {
1112          RecursiveAction a = new CheckedRecursiveAction() {
1113 <            public void realCompute() {
1113 >            protected void realCompute() {
1114                  AsyncFib f = new AsyncFib(8);
1115                  assertNull(f.invoke());
1116                  assertEquals(21, f.number);
# Line 1128 | Line 1126 | public class ForkJoinTaskTest extends JS
1126       */
1127      public void testQuietlyInvokeSingleton() {
1128          RecursiveAction a = new CheckedRecursiveAction() {
1129 <            public void realCompute() {
1129 >            protected void realCompute() {
1130                  AsyncFib f = new AsyncFib(8);
1131                  f.quietlyInvoke();
1132                  assertEquals(21, f.number);
# Line 1142 | Line 1140 | public class ForkJoinTaskTest extends JS
1140       */
1141      public void testForkJoinSingleton() {
1142          RecursiveAction a = new CheckedRecursiveAction() {
1143 <            public void realCompute() {
1143 >            protected void realCompute() {
1144                  AsyncFib f = new AsyncFib(8);
1145                  assertSame(f, f.fork());
1146                  assertNull(f.join());
# Line 1157 | Line 1155 | public class ForkJoinTaskTest extends JS
1155       */
1156      public void testForkGetSingleton() {
1157          RecursiveAction a = new CheckedRecursiveAction() {
1158 <            public void realCompute() throws Exception {
1158 >            protected void realCompute() throws Exception {
1159                  AsyncFib f = new AsyncFib(8);
1160                  assertSame(f, f.fork());
1161                  assertNull(f.get());
# Line 1172 | Line 1170 | public class ForkJoinTaskTest extends JS
1170       */
1171      public void testForkTimedGetSingleton() {
1172          RecursiveAction a = new CheckedRecursiveAction() {
1173 <            public void realCompute() throws Exception {
1173 >            protected void realCompute() throws Exception {
1174                  AsyncFib f = new AsyncFib(8);
1175                  assertSame(f, f.fork());
1176                  assertNull(f.get(LONG_DELAY_MS, MILLISECONDS));
# Line 1187 | Line 1185 | public class ForkJoinTaskTest extends JS
1185       */
1186      public void testForkTimedGetNPESingleton() {
1187          RecursiveAction a = new CheckedRecursiveAction() {
1188 <            public void realCompute() throws Exception {
1188 >            protected void realCompute() throws Exception {
1189                  AsyncFib f = new AsyncFib(8);
1190                  assertSame(f, f.fork());
1191                  try {
# Line 1203 | Line 1201 | public class ForkJoinTaskTest extends JS
1201       */
1202      public void testForkQuietlyJoinSingleton() {
1203          RecursiveAction a = new CheckedRecursiveAction() {
1204 <            public void realCompute() {
1204 >            protected void realCompute() {
1205                  AsyncFib f = new AsyncFib(8);
1206                  assertSame(f, f.fork());
1207                  f.quietlyJoin();
# Line 1213 | Line 1211 | public class ForkJoinTaskTest extends JS
1211          testInvokeOnPool(singletonPool(), a);
1212      }
1213  
1216
1214      /**
1215       * helpQuiesce returns when tasks are complete.
1216       * getQueuedTaskCount returns 0 when quiescent
1217       */
1218      public void testForkHelpQuiesceSingleton() {
1219          RecursiveAction a = new CheckedRecursiveAction() {
1220 <            public void realCompute() {
1220 >            protected void realCompute() {
1221                  AsyncFib f = new AsyncFib(8);
1222                  assertSame(f, f.fork());
1223 <                f.helpQuiesce();
1223 >                helpQuiesce();
1224                  assertEquals(0, getQueuedTaskCount());
1225                  assertEquals(21, f.number);
1226                  checkCompletedNormally(f);
# Line 1231 | Line 1228 | public class ForkJoinTaskTest extends JS
1228          testInvokeOnPool(singletonPool(), a);
1229      }
1230  
1234
1231      /**
1232       * invoke task throws exception when task completes abnormally
1233       */
1234      public void testAbnormalInvokeSingleton() {
1235          RecursiveAction a = new CheckedRecursiveAction() {
1236 <            public void realCompute() {
1236 >            protected void realCompute() {
1237                  FailingAsyncFib f = new FailingAsyncFib(8);
1238                  try {
1239                      f.invoke();
# Line 1254 | Line 1250 | public class ForkJoinTaskTest extends JS
1250       */
1251      public void testAbnormalQuietlyInvokeSingleton() {
1252          RecursiveAction a = new CheckedRecursiveAction() {
1253 <            public void realCompute() {
1253 >            protected void realCompute() {
1254                  FailingAsyncFib f = new FailingAsyncFib(8);
1255                  f.quietlyInvoke();
1256                  assertTrue(f.getException() instanceof FJException);
# Line 1268 | Line 1264 | public class ForkJoinTaskTest extends JS
1264       */
1265      public void testAbnormalForkJoinSingleton() {
1266          RecursiveAction a = new CheckedRecursiveAction() {
1267 <            public void realCompute() {
1267 >            protected void realCompute() {
1268                  FailingAsyncFib f = new FailingAsyncFib(8);
1269                  assertSame(f, f.fork());
1270                  try {
# Line 1286 | Line 1282 | public class ForkJoinTaskTest extends JS
1282       */
1283      public void testAbnormalForkGetSingleton() {
1284          RecursiveAction a = new CheckedRecursiveAction() {
1285 <            public void realCompute() throws Exception {
1285 >            protected void realCompute() throws Exception {
1286                  FailingAsyncFib f = new FailingAsyncFib(8);
1287                  assertSame(f, f.fork());
1288                  try {
# Line 1306 | Line 1302 | public class ForkJoinTaskTest extends JS
1302       */
1303      public void testAbnormalForkTimedGetSingleton() {
1304          RecursiveAction a = new CheckedRecursiveAction() {
1305 <            public void realCompute() throws Exception {
1305 >            protected void realCompute() throws Exception {
1306                  FailingAsyncFib f = new FailingAsyncFib(8);
1307                  assertSame(f, f.fork());
1308                  try {
# Line 1326 | Line 1322 | public class ForkJoinTaskTest extends JS
1322       */
1323      public void testAbnormalForkQuietlyJoinSingleton() {
1324          RecursiveAction a = new CheckedRecursiveAction() {
1325 <            public void realCompute() {
1325 >            protected void realCompute() {
1326                  FailingAsyncFib f = new FailingAsyncFib(8);
1327                  assertSame(f, f.fork());
1328                  f.quietlyJoin();
# Line 1341 | Line 1337 | public class ForkJoinTaskTest extends JS
1337       */
1338      public void testCancelledInvokeSingleton() {
1339          RecursiveAction a = new CheckedRecursiveAction() {
1340 <            public void realCompute() {
1340 >            protected void realCompute() {
1341                  AsyncFib f = new AsyncFib(8);
1342                  assertTrue(f.cancel(true));
1343                  try {
# Line 1359 | Line 1355 | public class ForkJoinTaskTest extends JS
1355       */
1356      public void testCancelledForkJoinSingleton() {
1357          RecursiveAction a = new CheckedRecursiveAction() {
1358 <            public void realCompute() {
1358 >            protected void realCompute() {
1359                  AsyncFib f = new AsyncFib(8);
1360                  assertTrue(f.cancel(true));
1361                  assertSame(f, f.fork());
# Line 1378 | Line 1374 | public class ForkJoinTaskTest extends JS
1374       */
1375      public void testCancelledForkGetSingleton() {
1376          RecursiveAction a = new CheckedRecursiveAction() {
1377 <            public void realCompute() throws Exception {
1377 >            protected void realCompute() throws Exception {
1378                  AsyncFib f = new AsyncFib(8);
1379                  assertTrue(f.cancel(true));
1380                  assertSame(f, f.fork());
# Line 1397 | Line 1393 | public class ForkJoinTaskTest extends JS
1393       */
1394      public void testCancelledForkTimedGetSingleton() throws Exception {
1395          RecursiveAction a = new CheckedRecursiveAction() {
1396 <            public void realCompute() throws Exception {
1396 >            protected void realCompute() throws Exception {
1397                  AsyncFib f = new AsyncFib(8);
1398                  assertTrue(f.cancel(true));
1399                  assertSame(f, f.fork());
# Line 1416 | Line 1412 | public class ForkJoinTaskTest extends JS
1412       */
1413      public void testCancelledForkQuietlyJoinSingleton() {
1414          RecursiveAction a = new CheckedRecursiveAction() {
1415 <            public void realCompute() {
1415 >            protected void realCompute() {
1416                  AsyncFib f = new AsyncFib(8);
1417                  assertTrue(f.cancel(true));
1418                  assertSame(f, f.fork());
# Line 1431 | Line 1427 | public class ForkJoinTaskTest extends JS
1427       */
1428      public void testCompleteExceptionallySingleton() {
1429          RecursiveAction a = new CheckedRecursiveAction() {
1430 <            public void realCompute() {
1430 >            protected void realCompute() {
1431                  AsyncFib f = new AsyncFib(8);
1432                  f.completeExceptionally(new FJException());
1433                  try {
# Line 1449 | Line 1445 | public class ForkJoinTaskTest extends JS
1445       */
1446      public void testInvokeAll2Singleton() {
1447          RecursiveAction a = new CheckedRecursiveAction() {
1448 <            public void realCompute() {
1448 >            protected void realCompute() {
1449                  AsyncFib f = new AsyncFib(8);
1450                  AsyncFib g = new AsyncFib(9);
1451                  invokeAll(f, g);
# Line 1466 | Line 1462 | public class ForkJoinTaskTest extends JS
1462       */
1463      public void testInvokeAll1Singleton() {
1464          RecursiveAction a = new CheckedRecursiveAction() {
1465 <            public void realCompute() {
1465 >            protected void realCompute() {
1466                  AsyncFib f = new AsyncFib(8);
1467                  invokeAll(f);
1468                  checkCompletedNormally(f);
# Line 1480 | Line 1476 | public class ForkJoinTaskTest extends JS
1476       */
1477      public void testInvokeAll3Singleton() {
1478          RecursiveAction a = new CheckedRecursiveAction() {
1479 <            public void realCompute() {
1479 >            protected void realCompute() {
1480                  AsyncFib f = new AsyncFib(8);
1481                  AsyncFib g = new AsyncFib(9);
1482                  AsyncFib h = new AsyncFib(7);
# Line 1500 | Line 1496 | public class ForkJoinTaskTest extends JS
1496       */
1497      public void testInvokeAllCollectionSingleton() {
1498          RecursiveAction a = new CheckedRecursiveAction() {
1499 <            public void realCompute() {
1499 >            protected void realCompute() {
1500                  AsyncFib f = new AsyncFib(8);
1501                  AsyncFib g = new AsyncFib(9);
1502                  AsyncFib h = new AsyncFib(7);
# Line 1519 | Line 1515 | public class ForkJoinTaskTest extends JS
1515          testInvokeOnPool(singletonPool(), a);
1516      }
1517  
1522
1518      /**
1519       * invokeAll(tasks) with any null task throws NPE
1520       */
1521      public void testInvokeAllNPESingleton() {
1522          RecursiveAction a = new CheckedRecursiveAction() {
1523 <            public void realCompute() {
1523 >            protected void realCompute() {
1524                  AsyncFib f = new AsyncFib(8);
1525                  AsyncFib g = new AsyncFib(9);
1526                  AsyncFib h = null;
# Line 1542 | Line 1537 | public class ForkJoinTaskTest extends JS
1537       */
1538      public void testAbnormalInvokeAll2Singleton() {
1539          RecursiveAction a = new CheckedRecursiveAction() {
1540 <            public void realCompute() {
1540 >            protected void realCompute() {
1541                  AsyncFib f = new AsyncFib(8);
1542                  FailingAsyncFib g = new FailingAsyncFib(9);
1543                  try {
# Line 1560 | Line 1555 | public class ForkJoinTaskTest extends JS
1555       */
1556      public void testAbnormalInvokeAll1Singleton() {
1557          RecursiveAction a = new CheckedRecursiveAction() {
1558 <            public void realCompute() {
1558 >            protected void realCompute() {
1559                  FailingAsyncFib g = new FailingAsyncFib(9);
1560                  try {
1561                      invokeAll(g);
# Line 1577 | Line 1572 | public class ForkJoinTaskTest extends JS
1572       */
1573      public void testAbnormalInvokeAll3Singleton() {
1574          RecursiveAction a = new CheckedRecursiveAction() {
1575 <            public void realCompute() {
1575 >            protected void realCompute() {
1576                  AsyncFib f = new AsyncFib(8);
1577                  FailingAsyncFib g = new FailingAsyncFib(9);
1578                  AsyncFib h = new AsyncFib(7);
# Line 1592 | Line 1587 | public class ForkJoinTaskTest extends JS
1587      }
1588  
1589      /**
1590 <     * invokeAll(collection)  throws exception if any task does
1590 >     * invokeAll(collection) throws exception if any task does
1591       */
1592      public void testAbnormalInvokeAllCollectionSingleton() {
1593          RecursiveAction a = new CheckedRecursiveAction() {
1594 <            public void realCompute() {
1594 >            protected void realCompute() {
1595                  FailingAsyncFib f = new FailingAsyncFib(8);
1596                  AsyncFib g = new AsyncFib(9);
1597                  AsyncFib h = new AsyncFib(7);
# Line 1614 | Line 1609 | public class ForkJoinTaskTest extends JS
1609          testInvokeOnPool(singletonPool(), a);
1610      }
1611  
1612 +    /**
1613 +     * ForkJoinTask.quietlyComplete returns when task completes
1614 +     * normally without setting a value. The most recent value
1615 +     * established by setRawResult(V) (or null by default) is returned
1616 +     * from invoke.
1617 +     */
1618 +    public void testQuietlyComplete() {
1619 +        RecursiveAction a = new CheckedRecursiveAction() {
1620 +                protected void realCompute() {
1621 +                    AsyncFib f = new AsyncFib(8);
1622 +                    f.quietlyComplete();
1623 +                    assertEquals(8, f.number);
1624 +                    checkCompletedNormally(f);
1625 +                }};
1626 +        testInvokeOnPool(mainPool(), a);
1627 +    }
1628 +
1629   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines