186 |
|
return (regex == null) ? null : Pattern.compile(regex); |
187 |
|
} |
188 |
|
|
189 |
< |
protected void runTest() throws Throwable { |
189 |
> |
public void runBare() throws Throwable { |
190 |
|
if (methodFilter == null |
191 |
< |
|| methodFilter.matcher(toString()).find()) { |
192 |
< |
for (int i = 0; i < runsPerTest; i++) { |
193 |
< |
if (profileTests) |
194 |
< |
runTestProfiled(); |
195 |
< |
else |
196 |
< |
super.runTest(); |
197 |
< |
} |
191 |
> |
|| methodFilter.matcher(toString()).find()) |
192 |
> |
super.runBare(); |
193 |
> |
} |
194 |
> |
|
195 |
> |
protected void runTest() throws Throwable { |
196 |
> |
for (int i = 0; i < runsPerTest; i++) { |
197 |
> |
if (profileTests) |
198 |
> |
runTestProfiled(); |
199 |
> |
else |
200 |
> |
super.runTest(); |
201 |
|
} |
202 |
|
} |
203 |
|
|
743 |
|
} |
744 |
|
|
745 |
|
/** |
746 |
+ |
* Allows use of try-with-resources with per-test thread pools. |
747 |
+ |
*/ |
748 |
+ |
static class PoolCloser<T extends ExecutorService> |
749 |
+ |
implements AutoCloseable { |
750 |
+ |
public final T pool; |
751 |
+ |
public PoolCloser(T pool) { this.pool = pool; } |
752 |
+ |
public void close() { joinPool(pool); } |
753 |
+ |
} |
754 |
+ |
|
755 |
+ |
/** |
756 |
|
* Waits out termination of a thread pool or fails doing so. |
757 |
|
*/ |
758 |
< |
void joinPool(ExecutorService pool) { |
758 |
> |
static void joinPool(ExecutorService pool) { |
759 |
|
try { |
760 |
|
pool.shutdown(); |
761 |
|
if (!pool.awaitTermination(2 * LONG_DELAY_MS, MILLISECONDS)) |
1264 |
|
}}; |
1265 |
|
} |
1266 |
|
|
1267 |
+ |
public Runnable countDowner(final CountDownLatch latch) { |
1268 |
+ |
return new CheckedRunnable() { |
1269 |
+ |
public void realRun() throws InterruptedException { |
1270 |
+ |
latch.countDown(); |
1271 |
+ |
}}; |
1272 |
+ |
} |
1273 |
+ |
|
1274 |
|
public Runnable awaiter(final CountDownLatch latch) { |
1275 |
|
return new CheckedRunnable() { |
1276 |
|
public void realRun() throws InterruptedException { |