478 |
|
} |
479 |
|
} |
480 |
|
|
481 |
+ |
/** |
482 |
+ |
* Checks that thread does not terminate within timeoutMillis |
483 |
+ |
* milliseconds (that is, Thread.join times out). |
484 |
+ |
*/ |
485 |
+ |
public void assertThreadJoinTimesOut(Thread thread, long timeoutMillis) { |
486 |
+ |
try { |
487 |
+ |
long startTime = System.nanoTime(); |
488 |
+ |
thread.join(timeoutMillis); |
489 |
+ |
assertTrue(thread.isAlive()); |
490 |
+ |
assertTrue(millisElapsedSince(startTime) >= timeoutMillis); |
491 |
+ |
} catch (InterruptedException ie) { |
492 |
+ |
fail("Unexpected InterruptedException"); |
493 |
+ |
} |
494 |
+ |
} |
495 |
|
|
496 |
|
/** |
497 |
|
* Fails with message "should throw exception". |