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 |
|
*/ |
909 |
|
* startNanoTime, which must have been previously returned from a |
910 |
|
* call to {@link System.nanoTime()}. |
911 |
|
*/ |
912 |
< |
long millisElapsedSince(long startNanoTime) { |
912 |
> |
static long millisElapsedSince(long startNanoTime) { |
913 |
|
return NANOSECONDS.toMillis(System.nanoTime() - startNanoTime); |
914 |
|
} |
915 |
|
|
916 |
+ |
// void assertTerminatesPromptly(long timeoutMillis, Runnable r) { |
917 |
+ |
// long startTime = System.nanoTime(); |
918 |
+ |
// try { |
919 |
+ |
// r.run(); |
920 |
+ |
// } catch (Throwable fail) { threadUnexpectedException(fail); } |
921 |
+ |
// if (millisElapsedSince(startTime) > timeoutMillis/2) |
922 |
+ |
// throw new AssertionFailedError("did not return promptly"); |
923 |
+ |
// } |
924 |
+ |
|
925 |
+ |
// void assertTerminatesPromptly(Runnable r) { |
926 |
+ |
// assertTerminatesPromptly(LONG_DELAY_MS/2, r); |
927 |
+ |
// } |
928 |
+ |
|
929 |
+ |
/** |
930 |
+ |
* Checks that timed f.get() returns the expected value, and does not |
931 |
+ |
* wait for the timeout to elapse before returning. |
932 |
+ |
*/ |
933 |
+ |
<T> void checkTimedGet(Future<T> f, T expectedValue, long timeoutMillis) { |
934 |
+ |
long startTime = System.nanoTime(); |
935 |
+ |
try { |
936 |
+ |
assertEquals(expectedValue, f.get(timeoutMillis, MILLISECONDS)); |
937 |
+ |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
938 |
+ |
if (millisElapsedSince(startTime) > timeoutMillis/2) |
939 |
+ |
throw new AssertionFailedError("timed get did not return promptly"); |
940 |
+ |
} |
941 |
+ |
|
942 |
+ |
<T> void checkTimedGet(Future<T> f, T expectedValue) { |
943 |
+ |
checkTimedGet(f, expectedValue, LONG_DELAY_MS); |
944 |
+ |
} |
945 |
+ |
|
946 |
|
/** |
947 |
|
* Returns a new started daemon Thread running the given runnable. |
948 |
|
*/ |