1083 |
|
} |
1084 |
|
|
1085 |
|
/** |
1086 |
+ |
* Checks that thread does not terminate within the default |
1087 |
+ |
* millisecond delay of {@code timeoutMillis()}. |
1088 |
+ |
* TODO: REMOVEME |
1089 |
+ |
*/ |
1090 |
+ |
void assertThreadStaysAlive(Thread thread) { |
1091 |
+ |
assertThreadStaysAlive(thread, timeoutMillis()); |
1092 |
+ |
} |
1093 |
+ |
|
1094 |
+ |
/** |
1095 |
+ |
* Checks that thread does not terminate within the given millisecond delay. |
1096 |
+ |
* TODO: REMOVEME |
1097 |
+ |
*/ |
1098 |
+ |
void assertThreadStaysAlive(Thread thread, long millis) { |
1099 |
+ |
try { |
1100 |
+ |
// No need to optimize the failing case via Thread.join. |
1101 |
+ |
delay(millis); |
1102 |
+ |
assertTrue(thread.isAlive()); |
1103 |
+ |
} catch (InterruptedException fail) { |
1104 |
+ |
threadFail("Unexpected InterruptedException"); |
1105 |
+ |
} |
1106 |
+ |
} |
1107 |
+ |
|
1108 |
+ |
/** |
1109 |
+ |
* Checks that the threads do not terminate within the default |
1110 |
+ |
* millisecond delay of {@code timeoutMillis()}. |
1111 |
+ |
* TODO: REMOVEME |
1112 |
+ |
*/ |
1113 |
+ |
void assertThreadsStayAlive(Thread... threads) { |
1114 |
+ |
assertThreadsStayAlive(timeoutMillis(), threads); |
1115 |
+ |
} |
1116 |
+ |
|
1117 |
+ |
/** |
1118 |
+ |
* Checks that the threads do not terminate within the given millisecond delay. |
1119 |
+ |
* TODO: REMOVEME |
1120 |
+ |
*/ |
1121 |
+ |
void assertThreadsStayAlive(long millis, Thread... threads) { |
1122 |
+ |
try { |
1123 |
+ |
// No need to optimize the failing case via Thread.join. |
1124 |
+ |
delay(millis); |
1125 |
+ |
for (Thread thread : threads) |
1126 |
+ |
assertTrue(thread.isAlive()); |
1127 |
+ |
} catch (InterruptedException fail) { |
1128 |
+ |
threadFail("Unexpected InterruptedException"); |
1129 |
+ |
} |
1130 |
+ |
} |
1131 |
+ |
|
1132 |
+ |
/** |
1133 |
|
* Checks that future.get times out, with the default timeout of |
1134 |
|
* {@code timeoutMillis()}. |
1135 |
|
*/ |