87 |
|
try { p1.shutdown(); } catch (SecurityException ok) { return; } |
88 |
|
try { |
89 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
90 |
< |
} catch (InterruptedException e){ |
90 |
> |
} catch (InterruptedException e) { |
91 |
|
unexpectedException(); |
92 |
|
} |
93 |
|
assertTrue(runnable.done); |
94 |
|
try { p1.shutdown(); } catch (SecurityException ok) { return; } |
95 |
|
joinPool(p1); |
96 |
|
} |
97 |
< |
catch (Exception e){ |
97 |
> |
catch (Exception e) { |
98 |
|
unexpectedException(); |
99 |
|
} |
100 |
|
|
115 |
|
assertEquals(Boolean.TRUE, f.get()); |
116 |
|
try { p1.shutdown(); } catch (SecurityException ok) { return; } |
117 |
|
joinPool(p1); |
118 |
< |
} catch (RejectedExecutionException e){} |
119 |
< |
catch (Exception e){ |
118 |
> |
} catch (RejectedExecutionException e) {} |
119 |
> |
catch (Exception e) { |
120 |
|
e.printStackTrace(); |
121 |
|
unexpectedException(); |
122 |
|
} |
136 |
|
assertTrue(runnable.done); |
137 |
|
try { p1.shutdown(); } catch (SecurityException ok) { return; } |
138 |
|
joinPool(p1); |
139 |
< |
} catch (Exception e){ |
139 |
> |
} catch (Exception e) { |
140 |
|
unexpectedException(); |
141 |
|
} |
142 |
|
} |
154 |
|
assertTrue(runnable.done); |
155 |
|
h.cancel(true); |
156 |
|
joinPool(p1); |
157 |
< |
} catch (Exception e){ |
157 |
> |
} catch (Exception e) { |
158 |
|
unexpectedException(); |
159 |
|
} |
160 |
|
} |
177 |
|
assertTrue(runnable.done); |
178 |
|
h.cancel(true); |
179 |
|
joinPool(p1); |
180 |
< |
} catch (Exception e){ |
180 |
> |
} catch (Exception e) { |
181 |
|
unexpectedException(); |
182 |
|
} |
183 |
|
} |
199 |
|
assertTrue(c >= SMALL_DELAY_MS / SHORT_DELAY_MS); |
200 |
|
assertTrue(c <= SMALL_DELAY_MS + SHORT_DELAY_MS); |
201 |
|
joinPool(p1); |
202 |
< |
} catch (Exception e){ |
202 |
> |
} catch (Exception e) { |
203 |
|
unexpectedException(); |
204 |
|
} |
205 |
|
} |
219 |
|
assertTrue(c >= SMALL_DELAY_MS / SHORT_DELAY_MS); |
220 |
|
assertTrue(c <= SMALL_DELAY_MS + SHORT_DELAY_MS); |
221 |
|
joinPool(p1); |
222 |
< |
} catch (Exception e){ |
222 |
> |
} catch (Exception e) { |
223 |
|
unexpectedException(); |
224 |
|
} |
225 |
|
} |
234 |
|
se = new CustomExecutor(1); |
235 |
|
se.execute(null); |
236 |
|
shouldThrow(); |
237 |
< |
} catch (NullPointerException success){} |
238 |
< |
catch (Exception e){ |
237 |
> |
} catch (NullPointerException success) {} |
238 |
> |
catch (Exception e) { |
239 |
|
unexpectedException(); |
240 |
|
} |
241 |
|
|
251 |
|
TrackedCallable callable = null; |
252 |
|
Future f = se.schedule(callable, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); |
253 |
|
shouldThrow(); |
254 |
< |
} catch (NullPointerException success){} |
255 |
< |
catch (Exception e){ |
254 |
> |
} catch (NullPointerException success) {} |
255 |
> |
catch (Exception e) { |
256 |
|
unexpectedException(); |
257 |
|
} |
258 |
|
joinPool(se); |
268 |
|
se.schedule(new NoOpRunnable(), |
269 |
|
MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
270 |
|
shouldThrow(); |
271 |
< |
} catch (RejectedExecutionException success){ |
271 |
> |
} catch (RejectedExecutionException success) { |
272 |
|
} catch (SecurityException ok) { |
273 |
|
} |
274 |
|
|
286 |
|
se.schedule(new NoOpCallable(), |
287 |
|
MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
288 |
|
shouldThrow(); |
289 |
< |
} catch (RejectedExecutionException success){ |
289 |
> |
} catch (RejectedExecutionException success) { |
290 |
|
} catch (SecurityException ok) { |
291 |
|
} |
292 |
|
joinPool(se); |
302 |
|
se.schedule(new NoOpCallable(), |
303 |
|
MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
304 |
|
shouldThrow(); |
305 |
< |
} catch (RejectedExecutionException success){ |
305 |
> |
} catch (RejectedExecutionException success) { |
306 |
|
} catch (SecurityException ok) { |
307 |
|
} |
308 |
|
joinPool(se); |
318 |
|
se.scheduleAtFixedRate(new NoOpRunnable(), |
319 |
|
MEDIUM_DELAY_MS, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
320 |
|
shouldThrow(); |
321 |
< |
} catch (RejectedExecutionException success){ |
321 |
> |
} catch (RejectedExecutionException success) { |
322 |
|
} catch (SecurityException ok) { |
323 |
|
} |
324 |
|
joinPool(se); |
334 |
|
se.scheduleWithFixedDelay(new NoOpRunnable(), |
335 |
|
MEDIUM_DELAY_MS, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
336 |
|
shouldThrow(); |
337 |
< |
} catch (RejectedExecutionException success){ |
337 |
> |
} catch (RejectedExecutionException success) { |
338 |
|
} catch (SecurityException ok) { |
339 |
|
} |
340 |
|
joinPool(se); |
350 |
|
p2.execute(new SmallRunnable()); |
351 |
|
try { |
352 |
|
Thread.sleep(SHORT_DELAY_MS); |
353 |
< |
} catch (Exception e){ |
353 |
> |
} catch (Exception e) { |
354 |
|
unexpectedException(); |
355 |
|
} |
356 |
|
assertEquals(1, p2.getActiveCount()); |
367 |
|
p2.execute(new SmallRunnable()); |
368 |
|
try { |
369 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
370 |
< |
} catch (Exception e){ |
370 |
> |
} catch (Exception e) { |
371 |
|
unexpectedException(); |
372 |
|
} |
373 |
|
assertEquals(1, p2.getCompletedTaskCount()); |
394 |
|
p2.execute(new SmallRunnable()); |
395 |
|
try { |
396 |
|
Thread.sleep(SHORT_DELAY_MS); |
397 |
< |
} catch (Exception e){ |
397 |
> |
} catch (Exception e) { |
398 |
|
unexpectedException(); |
399 |
|
} |
400 |
|
assertEquals(2, p2.getLargestPoolSize()); |
424 |
|
p1.execute(new SmallRunnable()); |
425 |
|
try { |
426 |
|
Thread.sleep(SHORT_DELAY_MS); |
427 |
< |
} catch (Exception e){ |
427 |
> |
} catch (Exception e) { |
428 |
|
unexpectedException(); |
429 |
|
} |
430 |
|
assertEquals(5, p1.getTaskCount()); |
495 |
|
try { |
496 |
|
assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); |
497 |
|
assertTrue(p1.isTerminated()); |
498 |
< |
} catch (Exception e){ |
498 |
> |
} catch (Exception e) { |
499 |
|
unexpectedException(); |
500 |
|
} |
501 |
|
} |
516 |
|
assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); |
517 |
|
assertTrue(p1.isTerminated()); |
518 |
|
assertFalse(p1.isTerminating()); |
519 |
< |
} catch (Exception e){ |
519 |
> |
} catch (Exception e) { |
520 |
|
unexpectedException(); |
521 |
|
} |
522 |
|
} |
527 |
|
public void testGetQueue() { |
528 |
|
CustomExecutor p1 = new CustomExecutor(1); |
529 |
|
ScheduledFuture[] tasks = new ScheduledFuture[5]; |
530 |
< |
for (int i = 0; i < 5; i++){ |
530 |
> |
for (int i = 0; i < 5; i++) { |
531 |
|
tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), 1, TimeUnit.MILLISECONDS); |
532 |
|
} |
533 |
|
try { |
548 |
|
public void testRemove() { |
549 |
|
CustomExecutor p1 = new CustomExecutor(1); |
550 |
|
ScheduledFuture[] tasks = new ScheduledFuture[5]; |
551 |
< |
for (int i = 0; i < 5; i++){ |
551 |
> |
for (int i = 0; i < 5; i++) { |
552 |
|
tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), 1, TimeUnit.MILLISECONDS); |
553 |
|
} |
554 |
|
try { |
576 |
|
public void testPurge() { |
577 |
|
CustomExecutor p1 = new CustomExecutor(1); |
578 |
|
ScheduledFuture[] tasks = new ScheduledFuture[5]; |
579 |
< |
for (int i = 0; i < 5; i++){ |
579 |
> |
for (int i = 0; i < 5; i++) { |
580 |
|
tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS); |
581 |
|
} |
582 |
|
try { |