33 |
|
try { p1.shutdown(); } catch (SecurityException ok) { return; } |
34 |
|
try { |
35 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
36 |
< |
} catch (InterruptedException e){ |
36 |
> |
} catch (InterruptedException e) { |
37 |
|
unexpectedException(); |
38 |
|
} |
39 |
|
assertTrue(runnable.done); |
40 |
|
try { p1.shutdown(); } catch (SecurityException ok) { return; } |
41 |
|
joinPool(p1); |
42 |
|
} |
43 |
< |
catch (Exception e){ |
43 |
> |
catch (Exception e) { |
44 |
|
unexpectedException(); |
45 |
|
} |
46 |
|
|
61 |
|
assertEquals(Boolean.TRUE, f.get()); |
62 |
|
try { p1.shutdown(); } catch (SecurityException ok) { return; } |
63 |
|
joinPool(p1); |
64 |
< |
} catch (RejectedExecutionException e){} |
65 |
< |
catch (Exception e){ |
64 |
> |
} catch (RejectedExecutionException e) {} |
65 |
> |
catch (Exception e) { |
66 |
|
e.printStackTrace(); |
67 |
|
unexpectedException(); |
68 |
|
} |
82 |
|
assertTrue(runnable.done); |
83 |
|
try { p1.shutdown(); } catch (SecurityException ok) { return; } |
84 |
|
joinPool(p1); |
85 |
< |
} catch (Exception e){ |
85 |
> |
} catch (Exception e) { |
86 |
|
unexpectedException(); |
87 |
|
} |
88 |
|
} |
100 |
|
assertTrue(runnable.done); |
101 |
|
h.cancel(true); |
102 |
|
joinPool(p1); |
103 |
< |
} catch (Exception e){ |
103 |
> |
} catch (Exception e) { |
104 |
|
unexpectedException(); |
105 |
|
} |
106 |
|
} |
123 |
|
assertTrue(runnable.done); |
124 |
|
h.cancel(true); |
125 |
|
joinPool(p1); |
126 |
< |
} catch (Exception e){ |
126 |
> |
} catch (Exception e) { |
127 |
|
unexpectedException(); |
128 |
|
} |
129 |
|
} |
145 |
|
assertTrue(c >= SMALL_DELAY_MS / SHORT_DELAY_MS); |
146 |
|
assertTrue(c <= SMALL_DELAY_MS + SHORT_DELAY_MS); |
147 |
|
joinPool(p1); |
148 |
< |
} catch (Exception e){ |
148 |
> |
} catch (Exception e) { |
149 |
|
unexpectedException(); |
150 |
|
} |
151 |
|
} |
165 |
|
assertTrue(c >= SMALL_DELAY_MS / SHORT_DELAY_MS); |
166 |
|
assertTrue(c <= SMALL_DELAY_MS + SHORT_DELAY_MS); |
167 |
|
joinPool(p1); |
168 |
< |
} catch (Exception e){ |
168 |
> |
} catch (Exception e) { |
169 |
|
unexpectedException(); |
170 |
|
} |
171 |
|
} |
180 |
|
se = new ScheduledThreadPoolExecutor(1); |
181 |
|
se.execute(null); |
182 |
|
shouldThrow(); |
183 |
< |
} catch (NullPointerException success){} |
184 |
< |
catch (Exception e){ |
183 |
> |
} catch (NullPointerException success) {} |
184 |
> |
catch (Exception e) { |
185 |
|
unexpectedException(); |
186 |
|
} |
187 |
|
|
197 |
|
TrackedCallable callable = null; |
198 |
|
Future f = se.schedule(callable, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); |
199 |
|
shouldThrow(); |
200 |
< |
} catch (NullPointerException success){} |
201 |
< |
catch (Exception e){ |
200 |
> |
} catch (NullPointerException success) {} |
201 |
> |
catch (Exception e) { |
202 |
|
unexpectedException(); |
203 |
|
} |
204 |
|
joinPool(se); |
214 |
|
se.schedule(new NoOpRunnable(), |
215 |
|
MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
216 |
|
shouldThrow(); |
217 |
< |
} catch (RejectedExecutionException success){ |
217 |
> |
} catch (RejectedExecutionException success) { |
218 |
|
} catch (SecurityException ok) { |
219 |
|
} |
220 |
|
|
232 |
|
se.schedule(new NoOpCallable(), |
233 |
|
MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
234 |
|
shouldThrow(); |
235 |
< |
} catch (RejectedExecutionException success){ |
235 |
> |
} catch (RejectedExecutionException success) { |
236 |
|
} catch (SecurityException ok) { |
237 |
|
} |
238 |
|
joinPool(se); |
248 |
|
se.schedule(new NoOpCallable(), |
249 |
|
MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
250 |
|
shouldThrow(); |
251 |
< |
} catch (RejectedExecutionException success){ |
251 |
> |
} catch (RejectedExecutionException success) { |
252 |
|
} catch (SecurityException ok) { |
253 |
|
} |
254 |
|
joinPool(se); |
264 |
|
se.scheduleAtFixedRate(new NoOpRunnable(), |
265 |
|
MEDIUM_DELAY_MS, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
266 |
|
shouldThrow(); |
267 |
< |
} catch (RejectedExecutionException success){ |
267 |
> |
} catch (RejectedExecutionException success) { |
268 |
|
} catch (SecurityException ok) { |
269 |
|
} |
270 |
|
joinPool(se); |
280 |
|
se.scheduleWithFixedDelay(new NoOpRunnable(), |
281 |
|
MEDIUM_DELAY_MS, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
282 |
|
shouldThrow(); |
283 |
< |
} catch (RejectedExecutionException success){ |
283 |
> |
} catch (RejectedExecutionException success) { |
284 |
|
} catch (SecurityException ok) { |
285 |
|
} |
286 |
|
joinPool(se); |
296 |
|
p2.execute(new SmallRunnable()); |
297 |
|
try { |
298 |
|
Thread.sleep(SHORT_DELAY_MS); |
299 |
< |
} catch (Exception e){ |
299 |
> |
} catch (Exception e) { |
300 |
|
unexpectedException(); |
301 |
|
} |
302 |
|
assertEquals(1, p2.getActiveCount()); |
313 |
|
p2.execute(new SmallRunnable()); |
314 |
|
try { |
315 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
316 |
< |
} catch (Exception e){ |
316 |
> |
} catch (Exception e) { |
317 |
|
unexpectedException(); |
318 |
|
} |
319 |
|
assertEquals(1, p2.getCompletedTaskCount()); |
340 |
|
p2.execute(new SmallRunnable()); |
341 |
|
try { |
342 |
|
Thread.sleep(SHORT_DELAY_MS); |
343 |
< |
} catch (Exception e){ |
343 |
> |
} catch (Exception e) { |
344 |
|
unexpectedException(); |
345 |
|
} |
346 |
|
assertEquals(2, p2.getLargestPoolSize()); |
370 |
|
p1.execute(new SmallRunnable()); |
371 |
|
try { |
372 |
|
Thread.sleep(SHORT_DELAY_MS); |
373 |
< |
} catch (Exception e){ |
373 |
> |
} catch (Exception e) { |
374 |
|
unexpectedException(); |
375 |
|
} |
376 |
|
assertEquals(5, p1.getTaskCount()); |
441 |
|
try { |
442 |
|
assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); |
443 |
|
assertTrue(p1.isTerminated()); |
444 |
< |
} catch (Exception e){ |
444 |
> |
} catch (Exception e) { |
445 |
|
unexpectedException(); |
446 |
|
} |
447 |
|
} |
462 |
|
assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); |
463 |
|
assertTrue(p1.isTerminated()); |
464 |
|
assertFalse(p1.isTerminating()); |
465 |
< |
} catch (Exception e){ |
465 |
> |
} catch (Exception e) { |
466 |
|
unexpectedException(); |
467 |
|
} |
468 |
|
} |
473 |
|
public void testGetQueue() { |
474 |
|
ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); |
475 |
|
ScheduledFuture[] tasks = new ScheduledFuture[5]; |
476 |
< |
for (int i = 0; i < 5; i++){ |
476 |
> |
for (int i = 0; i < 5; i++) { |
477 |
|
tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), 1, TimeUnit.MILLISECONDS); |
478 |
|
} |
479 |
|
try { |
494 |
|
public void testRemove() { |
495 |
|
ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); |
496 |
|
ScheduledFuture[] tasks = new ScheduledFuture[5]; |
497 |
< |
for (int i = 0; i < 5; i++){ |
497 |
> |
for (int i = 0; i < 5; i++) { |
498 |
|
tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), 1, TimeUnit.MILLISECONDS); |
499 |
|
} |
500 |
|
try { |
522 |
|
public void testPurge() { |
523 |
|
ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); |
524 |
|
ScheduledFuture[] tasks = new ScheduledFuture[5]; |
525 |
< |
for (int i = 0; i < 5; i++){ |
525 |
> |
for (int i = 0; i < 5; i++) { |
526 |
|
tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS); |
527 |
|
} |
528 |
|
try { |