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

Comparing jsr166/src/test/tck/JSR166TestCase.java (file contents):
Revision 1.82 by jsr166, Tue May 24 23:34:03 2011 UTC vs.
Revision 1.83 by jsr166, Fri May 27 19:29:59 2011 UTC

# Line 260 | Line 260 | public class JSR166TestCase extends Test
260          return 50;
261      }
262  
263
263      /**
264       * Sets delays as multiples of SHORT_DELAY.
265       */
# Line 522 | Line 521 | public class JSR166TestCase extends Test
521      }
522  
523      /**
524 +     * Checks that future.get times out, with the default timeout of
525 +     * {@code timeoutMillis()}.
526 +     */
527 +    void assertFutureTimesOut(Future future) {
528 +        assertFutureTimesOut(future, timeoutMillis());
529 +    }
530 +
531 +    /**
532 +     * Checks that future.get times out, with the given millisecond timeout.
533 +     */
534 +    void assertFutureTimesOut(Future future, long timeoutMillis) {
535 +        long startTime = System.nanoTime();
536 +        try {
537 +            future.get(timeoutMillis, MILLISECONDS);
538 +            shouldThrow();
539 +        } catch (TimeoutException success) {
540 +        } catch (Exception e) {
541 +            threadUnexpectedException(e);
542 +        } finally { future.cancel(true); }
543 +        assertTrue(millisElapsedSince(startTime) >= timeoutMillis);
544 +    }
545 +
546 +    /**
547       * Fails with message "should throw exception".
548       */
549      public void shouldThrow() {
# Line 721 | Line 743 | public class JSR166TestCase extends Test
743          } catch (InterruptedException ie) {
744              threadUnexpectedException(ie);
745          } finally {
746 <            if (t.isAlive()) {
746 >            if (t.getState() != Thread.State.TERMINATED) {
747                  t.interrupt();
748                  fail("Test timed out");
749              }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines