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

Comparing jsr166/src/test/tck/ForkJoinPoolTest.java (file contents):
Revision 1.73 by jsr166, Sat Mar 25 21:41:10 2017 UTC vs.
Revision 1.75 by jsr166, Mon May 29 22:44:27 2017 UTC

# Line 11 | Line 11 | import java.security.PrivilegedAction;
11   import java.security.PrivilegedExceptionAction;
12   import java.util.ArrayList;
13   import java.util.Collection;
14 + import java.util.Collections;
15   import java.util.List;
16   import java.util.concurrent.Callable;
17   import java.util.concurrent.CountDownLatch;
# Line 240 | Line 241 | public class ForkJoinPoolTest extends JS
241              assertFalse(p.awaitTermination(Long.MIN_VALUE, MILLISECONDS));
242              assertFalse(p.awaitTermination(-1L, NANOSECONDS));
243              assertFalse(p.awaitTermination(-1L, MILLISECONDS));
244 <            assertFalse(p.awaitTermination(0L, NANOSECONDS));
245 <            assertFalse(p.awaitTermination(0L, MILLISECONDS));
244 >            assertFalse(p.awaitTermination(randomExpiredTimeout(),
245 >                                           randomTimeUnit()));
246              long timeoutNanos = 999999L;
247              long startTime = System.nanoTime();
248              assertFalse(p.awaitTermination(timeoutNanos, NANOSECONDS));
# Line 422 | Line 423 | public class ForkJoinPoolTest extends JS
423                      done.set(true);
424                  }});
425              assertNull(future.get());
426 <            assertNull(future.get(0, MILLISECONDS));
426 >            assertNull(future.get(randomExpiredTimeout(), randomTimeUnit()));
427              assertTrue(done.get());
428              assertTrue(future.isDone());
429              assertFalse(future.isCancelled());
# Line 703 | Line 704 | public class ForkJoinPoolTest extends JS
704      }
705  
706      /**
707 <     * invokeAll(empty collection) returns empty collection
707 >     * invokeAll(empty collection) returns empty list
708       */
709      public void testInvokeAll2() throws InterruptedException {
710          ExecutorService e = new ForkJoinPool(1);
711 +        final Collection<Callable<String>> emptyCollection
712 +            = Collections.emptyList();
713          try (PoolCleaner cleaner = cleaner(e)) {
714 <            List<Future<String>> r
712 <                = e.invokeAll(new ArrayList<Callable<String>>());
714 >            List<Future<String>> r = e.invokeAll(emptyCollection);
715              assertTrue(r.isEmpty());
716          }
717      }
# Line 773 | Line 775 | public class ForkJoinPoolTest extends JS
775          ExecutorService e = new ForkJoinPool(1);
776          try (PoolCleaner cleaner = cleaner(e)) {
777              try {
778 <                e.invokeAny(null, MEDIUM_DELAY_MS, MILLISECONDS);
778 >                e.invokeAny(null, randomTimeout(), randomTimeUnit());
779                  shouldThrow();
780              } catch (NullPointerException success) {}
781          }
# Line 788 | Line 790 | public class ForkJoinPoolTest extends JS
790              List<Callable<String>> l = new ArrayList<>();
791              l.add(new StringTask());
792              try {
793 <                e.invokeAny(l, MEDIUM_DELAY_MS, null);
793 >                e.invokeAny(l, randomTimeout(), null);
794                  shouldThrow();
795              } catch (NullPointerException success) {}
796          }
# Line 802 | Line 804 | public class ForkJoinPoolTest extends JS
804          try (PoolCleaner cleaner = cleaner(e)) {
805              try {
806                  e.invokeAny(new ArrayList<Callable<String>>(),
807 <                            MEDIUM_DELAY_MS, MILLISECONDS);
807 >                            randomTimeout(), randomTimeUnit());
808                  shouldThrow();
809              } catch (IllegalArgumentException success) {}
810          }
# Line 819 | Line 821 | public class ForkJoinPoolTest extends JS
821              l.add(latchAwaitingStringTask(latch));
822              l.add(null);
823              try {
824 <                e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
824 >                e.invokeAny(l, randomTimeout(), randomTimeUnit());
825                  shouldThrow();
826              } catch (NullPointerException success) {}
827              latch.countDown();
# Line 868 | Line 870 | public class ForkJoinPoolTest extends JS
870          ExecutorService e = new ForkJoinPool(1);
871          try (PoolCleaner cleaner = cleaner(e)) {
872              try {
873 <                e.invokeAll(null, MEDIUM_DELAY_MS, MILLISECONDS);
873 >                e.invokeAll(null, randomTimeout(), randomTimeUnit());
874                  shouldThrow();
875              } catch (NullPointerException success) {}
876          }
# Line 883 | Line 885 | public class ForkJoinPoolTest extends JS
885              List<Callable<String>> l = new ArrayList<>();
886              l.add(new StringTask());
887              try {
888 <                e.invokeAll(l, MEDIUM_DELAY_MS, null);
888 >                e.invokeAll(l, randomTimeout(), null);
889                  shouldThrow();
890              } catch (NullPointerException success) {}
891          }
892      }
893  
894      /**
895 <     * timed invokeAll(empty collection) returns empty collection
895 >     * timed invokeAll(empty collection) returns empty list
896       */
897      public void testTimedInvokeAll2() throws InterruptedException {
898          ExecutorService e = new ForkJoinPool(1);
899 +        final Collection<Callable<String>> emptyCollection
900 +            = Collections.emptyList();
901          try (PoolCleaner cleaner = cleaner(e)) {
902              List<Future<String>> r
903 <                = e.invokeAll(new ArrayList<Callable<String>>(),
904 <                              MEDIUM_DELAY_MS, MILLISECONDS);
903 >                = e.invokeAll(emptyCollection,
904 >                              randomTimeout(), randomTimeUnit());
905              assertTrue(r.isEmpty());
906          }
907      }
# Line 912 | Line 916 | public class ForkJoinPoolTest extends JS
916              l.add(new StringTask());
917              l.add(null);
918              try {
919 <                e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
919 >                e.invokeAll(l, randomTimeout(), randomTimeUnit());
920                  shouldThrow();
921              } catch (NullPointerException success) {}
922          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines