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.37 by dl, Tue Feb 22 01:18:58 2011 UTC vs.
Revision 1.41 by jsr166, Fri May 27 19:42:42 2011 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7   import junit.framework.*;
# Line 198 | Line 198 | public class ForkJoinPoolTest extends JS
198          } catch (NullPointerException success) {}
199      }
200  
201
201      /**
202       * getParallelism returns size set in constructor
203       */
# Line 251 | Line 250 | public class ForkJoinPoolTest extends JS
250      }
251  
252      /**
253 <     * After invoking a single task, isQuiescent is true,
254 <     * queues are empty, threads are not active, and
255 <     * construction parameters continue to hold
253 >     * After invoking a single task, isQuiescent eventually becomes
254 >     * true, at which time queues are empty, threads are not active,
255 >     * the task has completed successfully, and construction
256 >     * parameters continue to hold
257       */
258 <    public void testisQuiescent() throws InterruptedException {
258 >    public void testisQuiescent() throws Exception {
259          ForkJoinPool p = new ForkJoinPool(2);
260          try {
261              assertTrue(p.isQuiescent());
262 <            p.invoke(new FibTask(20));
262 >            long startTime = System.nanoTime();
263 >            FibTask f = new FibTask(20);
264 >            p.invoke(f);
265              assertSame(ForkJoinPool.defaultForkJoinWorkerThreadFactory,
266                         p.getFactory());
267 <            Thread.sleep(SMALL_DELAY_MS);
267 >            while (! p.isQuiescent()) {
268 >                if (millisElapsedSince(startTime) > LONG_DELAY_MS)
269 >                    throw new AssertionFailedError("timed out");
270 >                assertFalse(p.getAsyncMode());
271 >                assertFalse(p.isShutdown());
272 >                assertFalse(p.isTerminating());
273 >                assertFalse(p.isTerminated());
274 >                Thread.yield();
275 >            }
276 >
277              assertTrue(p.isQuiescent());
278              assertFalse(p.getAsyncMode());
279              assertEquals(0, p.getActiveThreadCount());
# Line 272 | Line 283 | public class ForkJoinPoolTest extends JS
283              assertFalse(p.isShutdown());
284              assertFalse(p.isTerminating());
285              assertFalse(p.isTerminated());
286 +            assertTrue(f.isDone());
287 +            assertEquals(6765, (int) f.get());
288          } finally {
289              joinPool(p);
290          }
# Line 365 | Line 378 | public class ForkJoinPoolTest extends JS
378          }
379      }
380  
368
381      // FJ Versions of AbstractExecutorService tests
382  
383      /**
# Line 387 | Line 399 | public class ForkJoinPoolTest extends JS
399          }
400      }
401  
390
402      /**
403       * Completed submit(callable) returns result
404       */
# Line 506 | Line 517 | public class ForkJoinPoolTest extends JS
517          }
518      }
519  
509
520      /**
521       * submit(null callable) throws NullPointerException
522       */
# Line 521 | Line 531 | public class ForkJoinPoolTest extends JS
531          }
532      }
533  
524
534      /**
535       * submit(callable).get() throws InterruptedException if interrupted
536       */
# Line 750 | Line 759 | public class ForkJoinPoolTest extends JS
759          }
760      }
761  
753
762      /**
763       * timed invokeAny(null) throws NullPointerException
764       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines