9 |
|
import junit.framework.*; |
10 |
|
import java.util.*; |
11 |
|
import java.util.concurrent.*; |
12 |
+ |
import static java.util.concurrent.TimeUnit.MILLISECONDS; |
13 |
|
import java.io.*; |
14 |
|
import java.security.*; |
15 |
|
|
289 |
|
* threadFail with message "should throw exception" |
290 |
|
*/ |
291 |
|
public void threadShouldThrow() { |
292 |
< |
try { |
293 |
< |
threadFailed = true; |
293 |
< |
fail("should throw exception"); |
294 |
< |
} catch (AssertionFailedError e) { |
295 |
< |
e.printStackTrace(); |
296 |
< |
throw e; |
297 |
< |
} |
292 |
> |
threadFailed = true; |
293 |
> |
fail("should throw exception"); |
294 |
|
} |
295 |
|
|
296 |
|
/** |
316 |
|
public void joinPool(ExecutorService exec) { |
317 |
|
try { |
318 |
|
exec.shutdown(); |
319 |
< |
assertTrue(exec.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); |
319 |
> |
assertTrue(exec.awaitTermination(LONG_DELAY_MS, MILLISECONDS)); |
320 |
|
} catch (SecurityException ok) { |
321 |
|
// Allowed in case test doesn't have privs |
322 |
|
} catch (InterruptedException ie) { |
339 |
|
fail("Unexpected exception"); |
340 |
|
} |
341 |
|
|
342 |
+ |
/** |
343 |
+ |
* fail with message "Unexpected exception", with argument |
344 |
+ |
*/ |
345 |
+ |
public void unexpectedException(Throwable ex) { |
346 |
+ |
ex.printStackTrace(); |
347 |
+ |
fail("Unexpected exception: " + ex); |
348 |
+ |
} |
349 |
+ |
|
350 |
|
|
351 |
|
/** |
352 |
|
* The number of elements to place in collections, arrays, etc. |