116 |
|
Boolean.getBoolean("jsr166.expensiveTests"); |
117 |
|
|
118 |
|
/** |
119 |
+ |
* If true, also run tests that are not part of the official tck |
120 |
+ |
* because they test unspecified implementation details. |
121 |
+ |
*/ |
122 |
+ |
protected static final boolean testImplementationDetails = |
123 |
+ |
Boolean.getBoolean("jsr166.testImplementationDetails"); |
124 |
+ |
|
125 |
+ |
/** |
126 |
|
* If true, report on stdout all "slow" tests, that is, ones that |
127 |
|
* take more than profileThreshold milliseconds to execute. |
128 |
|
*/ |
630 |
|
void joinPool(ExecutorService exec) { |
631 |
|
try { |
632 |
|
exec.shutdown(); |
633 |
< |
assertTrue("ExecutorService did not terminate in a timely manner", |
634 |
< |
exec.awaitTermination(2 * LONG_DELAY_MS, MILLISECONDS)); |
633 |
> |
if (!exec.awaitTermination(2 * LONG_DELAY_MS, MILLISECONDS)) |
634 |
> |
fail("ExecutorService " + exec + |
635 |
> |
" did not terminate in a timely manner"); |
636 |
|
} catch (SecurityException ok) { |
637 |
|
// Allowed in case test doesn't have privs |
638 |
|
} catch (InterruptedException ie) { |
910 |
|
* startNanoTime, which must have been previously returned from a |
911 |
|
* call to {@link System.nanoTime()}. |
912 |
|
*/ |
913 |
< |
long millisElapsedSince(long startNanoTime) { |
913 |
> |
static long millisElapsedSince(long startNanoTime) { |
914 |
|
return NANOSECONDS.toMillis(System.nanoTime() - startNanoTime); |
915 |
|
} |
916 |
|
|
917 |
+ |
// void assertTerminatesPromptly(long timeoutMillis, Runnable r) { |
918 |
+ |
// long startTime = System.nanoTime(); |
919 |
+ |
// try { |
920 |
+ |
// r.run(); |
921 |
+ |
// } catch (Throwable fail) { threadUnexpectedException(fail); } |
922 |
+ |
// if (millisElapsedSince(startTime) > timeoutMillis/2) |
923 |
+ |
// throw new AssertionFailedError("did not return promptly"); |
924 |
+ |
// } |
925 |
+ |
|
926 |
+ |
// void assertTerminatesPromptly(Runnable r) { |
927 |
+ |
// assertTerminatesPromptly(LONG_DELAY_MS/2, r); |
928 |
+ |
// } |
929 |
+ |
|
930 |
+ |
/** |
931 |
+ |
* Checks that timed f.get() returns the expected value, and does not |
932 |
+ |
* wait for the timeout to elapse before returning. |
933 |
+ |
*/ |
934 |
+ |
<T> void checkTimedGet(Future<T> f, T expectedValue, long timeoutMillis) { |
935 |
+ |
long startTime = System.nanoTime(); |
936 |
+ |
try { |
937 |
+ |
assertEquals(expectedValue, f.get(timeoutMillis, MILLISECONDS)); |
938 |
+ |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
939 |
+ |
if (millisElapsedSince(startTime) > timeoutMillis/2) |
940 |
+ |
throw new AssertionFailedError("timed get did not return promptly"); |
941 |
+ |
} |
942 |
+ |
|
943 |
+ |
<T> void checkTimedGet(Future<T> f, T expectedValue) { |
944 |
+ |
checkTimedGet(f, expectedValue, LONG_DELAY_MS); |
945 |
+ |
} |
946 |
+ |
|
947 |
|
/** |
948 |
|
* Returns a new started daemon Thread running the given runnable. |
949 |
|
*/ |