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

Comparing jsr166/src/test/tck/ScheduledExecutorSubclassTest.java (file contents):
Revision 1.10 by jsr166, Tue Dec 1 09:48:12 2009 UTC vs.
Revision 1.11 by jsr166, Tue Dec 1 22:51:44 2009 UTC

# Line 707 | Line 707 | public class ScheduledExecutorSubclassTe
707       * invokeAny(c) throws NPE if c has null elements
708       */
709      public void testInvokeAny3() throws Exception {
710 <        final CountDownLatch latch = new CountDownLatch(1);
710 >        CountDownLatch latch = new CountDownLatch(1);
711          ExecutorService e = new CustomExecutor(2);
712 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
713 +        l.add(latchAwaitingStringTask(latch));
714 +        l.add(null);
715          try {
713            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
714            l.add(new Callable<String>() {
715                      public String call() {
716                          try {
717                              latch.await();
718                          } catch (InterruptedException quittingTime) {}
719                          return TEST_STRING;
720                      }});
721            l.add(null);
716              e.invokeAny(l);
717              shouldThrow();
718          } catch (NullPointerException success) {
# Line 733 | Line 727 | public class ScheduledExecutorSubclassTe
727       */
728      public void testInvokeAny4() throws Exception {
729          ExecutorService e = new CustomExecutor(2);
730 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
731 +        l.add(new NPETask());
732          try {
737            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
738            l.add(new NPETask());
733              e.invokeAny(l);
734              shouldThrow();
735          } catch (ExecutionException success) {
# Line 751 | Line 745 | public class ScheduledExecutorSubclassTe
745      public void testInvokeAny5() throws Exception {
746          ExecutorService e = new CustomExecutor(2);
747          try {
748 <            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
748 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
749              l.add(new StringTask());
750              l.add(new StringTask());
751              String result = e.invokeAny(l);
# Line 793 | Line 787 | public class ScheduledExecutorSubclassTe
787       */
788      public void testInvokeAll3() throws Exception {
789          ExecutorService e = new CustomExecutor(2);
790 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
791 +        l.add(new StringTask());
792 +        l.add(null);
793          try {
797            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
798            l.add(new StringTask());
799            l.add(null);
794              e.invokeAll(l);
795              shouldThrow();
796          } catch (NullPointerException success) {
# Line 810 | Line 804 | public class ScheduledExecutorSubclassTe
804       */
805      public void testInvokeAll4() throws Exception {
806          ExecutorService e = new CustomExecutor(2);
807 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
808 +        l.add(new NPETask());
809 +        List<Future<String>> futures = e.invokeAll(l);
810 +        assertEquals(1, futures.size());
811          try {
812 <            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
815 <            l.add(new NPETask());
816 <            List<Future<String>> result = e.invokeAll(l);
817 <            assertEquals(1, result.size());
818 <            for (Future<String> future : result)
819 <                future.get();
812 >            futures.get(0).get();
813              shouldThrow();
814          } catch (ExecutionException success) {
815              assertTrue(success.getCause() instanceof NullPointerException);
# Line 831 | Line 824 | public class ScheduledExecutorSubclassTe
824      public void testInvokeAll5() throws Exception {
825          ExecutorService e = new CustomExecutor(2);
826          try {
827 <            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
827 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
828              l.add(new StringTask());
829              l.add(new StringTask());
830 <            List<Future<String>> result = e.invokeAll(l);
831 <            assertEquals(2, result.size());
832 <            for (Future<String> future : result)
830 >            List<Future<String>> futures = e.invokeAll(l);
831 >            assertEquals(2, futures.size());
832 >            for (Future<String> future : futures)
833                  assertSame(TEST_STRING, future.get());
834          } finally {
835              joinPool(e);
# Line 862 | Line 855 | public class ScheduledExecutorSubclassTe
855       */
856      public void testTimedInvokeAnyNullTimeUnit() throws Exception {
857          ExecutorService e = new CustomExecutor(2);
858 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
859 +        l.add(new StringTask());
860          try {
866            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
867            l.add(new StringTask());
861              e.invokeAny(l, MEDIUM_DELAY_MS, null);
862              shouldThrow();
863          } catch (NullPointerException success) {
# Line 891 | Line 884 | public class ScheduledExecutorSubclassTe
884       * timed invokeAny(c) throws NPE if c has null elements
885       */
886      public void testTimedInvokeAny3() throws Exception {
887 <        final CountDownLatch latch = new CountDownLatch(1);
887 >        CountDownLatch latch = new CountDownLatch(1);
888          ExecutorService e = new CustomExecutor(2);
889 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
890 +        l.add(latchAwaitingStringTask(latch));
891 +        l.add(null);
892          try {
897            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
898            l.add(new Callable<String>() {
899                      public String call() {
900                          try {
901                              latch.await();
902                          } catch (InterruptedException quittingTime) {}
903                          return TEST_STRING;
904                      }});
905            l.add(null);
893              e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
894              shouldThrow();
895          } catch (NullPointerException success) {
# Line 917 | Line 904 | public class ScheduledExecutorSubclassTe
904       */
905      public void testTimedInvokeAny4() throws Exception {
906          ExecutorService e = new CustomExecutor(2);
907 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
908 +        l.add(new NPETask());
909          try {
921            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
922            l.add(new NPETask());
910              e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
911              shouldThrow();
912          } catch (ExecutionException success) {
# Line 935 | Line 922 | public class ScheduledExecutorSubclassTe
922      public void testTimedInvokeAny5() throws Exception {
923          ExecutorService e = new CustomExecutor(2);
924          try {
925 <            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
925 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
926              l.add(new StringTask());
927              l.add(new StringTask());
928              String result = e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
# Line 964 | Line 951 | public class ScheduledExecutorSubclassTe
951       */
952      public void testTimedInvokeAllNullTimeUnit() throws Exception {
953          ExecutorService e = new CustomExecutor(2);
954 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
955 +        l.add(new StringTask());
956          try {
968            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
969            l.add(new StringTask());
957              e.invokeAll(l, MEDIUM_DELAY_MS, null);
958              shouldThrow();
959          } catch (NullPointerException success) {
# Line 993 | Line 980 | public class ScheduledExecutorSubclassTe
980       */
981      public void testTimedInvokeAll3() throws Exception {
982          ExecutorService e = new CustomExecutor(2);
983 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
984 +        l.add(new StringTask());
985 +        l.add(null);
986          try {
997            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
998            l.add(new StringTask());
999            l.add(null);
987              e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
988              shouldThrow();
989          } catch (NullPointerException success) {
# Line 1010 | Line 997 | public class ScheduledExecutorSubclassTe
997       */
998      public void testTimedInvokeAll4() throws Exception {
999          ExecutorService e = new CustomExecutor(2);
1000 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
1001 +        l.add(new NPETask());
1002 +        List<Future<String>> futures =
1003 +            e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
1004 +        assertEquals(1, futures.size());
1005          try {
1006 <            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1015 <            l.add(new NPETask());
1016 <            List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
1017 <            assertEquals(1, result.size());
1018 <            for (Future<String> future : result)
1019 <                future.get();
1006 >            futures.get(0).get();
1007              shouldThrow();
1008          } catch (ExecutionException success) {
1009              assertTrue(success.getCause() instanceof NullPointerException);
# Line 1031 | Line 1018 | public class ScheduledExecutorSubclassTe
1018      public void testTimedInvokeAll5() throws Exception {
1019          ExecutorService e = new CustomExecutor(2);
1020          try {
1021 <            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1021 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
1022              l.add(new StringTask());
1023              l.add(new StringTask());
1024 <            List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
1025 <            assertEquals(2, result.size());
1026 <            for (Future<String> future : result)
1024 >            List<Future<String>> futures =
1025 >                e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
1026 >            assertEquals(2, futures.size());
1027 >            for (Future<String> future : futures)
1028                  assertSame(TEST_STRING, future.get());
1029          } finally {
1030              joinPool(e);
# Line 1049 | Line 1037 | public class ScheduledExecutorSubclassTe
1037      public void testTimedInvokeAll6() throws Exception {
1038          ExecutorService e = new CustomExecutor(2);
1039          try {
1040 <            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1040 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
1041              l.add(new StringTask());
1042              l.add(Executors.callable(new MediumPossiblyInterruptedRunnable(), TEST_STRING));
1043              l.add(new StringTask());
1044 <            List<Future<String>> result = e.invokeAll(l, SHORT_DELAY_MS, MILLISECONDS);
1045 <            assertEquals(3, result.size());
1046 <            Iterator<Future<String>> it = result.iterator();
1044 >            List<Future<String>> futures =
1045 >                e.invokeAll(l, SHORT_DELAY_MS, MILLISECONDS);
1046 >            assertEquals(3, futures.size());
1047 >            Iterator<Future<String>> it = futures.iterator();
1048              Future<String> f1 = it.next();
1049              Future<String> f2 = it.next();
1050              Future<String> f3 = it.next();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines