289 |
|
* threadFail with message "should throw exception" |
290 |
|
*/ |
291 |
|
public void threadShouldThrow() { |
292 |
< |
try { |
293 |
< |
threadFailed = true; |
294 |
< |
fail("should throw exception"); |
295 |
< |
} catch (AssertionFailedError e) { |
296 |
< |
e.printStackTrace(); |
297 |
< |
throw e; |
298 |
< |
} |
292 |
> |
threadFailed = true; |
293 |
> |
fail("should throw exception"); |
294 |
|
} |
295 |
|
|
296 |
|
/** |
395 |
|
public void refresh() {} |
396 |
|
} |
397 |
|
|
398 |
+ |
/** |
399 |
+ |
* Sleep until the timeout has elapsed, or interrupted. |
400 |
+ |
* Does <em>NOT</em> throw InterruptedException. |
401 |
+ |
*/ |
402 |
+ |
void sleepTillInterrupted(long timeoutMillis) { |
403 |
+ |
try { |
404 |
+ |
Thread.sleep(timeoutMillis); |
405 |
+ |
} catch (InterruptedException wakeup) { |
406 |
+ |
} |
407 |
+ |
} |
408 |
+ |
|
409 |
+ |
/** |
410 |
+ |
* Returns a new started Thread running the given runnable. |
411 |
+ |
*/ |
412 |
+ |
Thread newStartedThread(Runnable runnable) { |
413 |
+ |
Thread t = new Thread(runnable); |
414 |
+ |
t.start(); |
415 |
+ |
return t; |
416 |
+ |
} |
417 |
|
|
418 |
|
// Some convenient Runnable classes |
419 |
|
|
566 |
|
try { |
567 |
|
Thread.sleep(SMALL_DELAY_MS); |
568 |
|
done = true; |
569 |
< |
} catch (Exception e) { |
569 |
> |
} catch (InterruptedException ok) { |
570 |
|
} |
571 |
|
} |
572 |
|
} |
577 |
|
try { |
578 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
579 |
|
done = true; |
580 |
< |
} catch (Exception e) { |
580 |
> |
} catch (InterruptedException ok) { |
581 |
|
} |
582 |
|
} |
583 |
|
} |
588 |
|
try { |
589 |
|
Thread.sleep(LONG_DELAY_MS); |
590 |
|
done = true; |
591 |
< |
} catch (Exception e) { |
591 |
> |
} catch (InterruptedException ok) { |
592 |
|
} |
593 |
|
} |
594 |
|
} |
606 |
|
try { |
607 |
|
Thread.sleep(SMALL_DELAY_MS); |
608 |
|
done = true; |
609 |
< |
} catch (Exception e) { |
609 |
> |
} catch (InterruptedException ok) { |
610 |
|
} |
611 |
|
return Boolean.TRUE; |
612 |
|
} |