17 |
|
return new TestSuite(ThreadPoolExecutorTest.class); |
18 |
|
} |
19 |
|
|
20 |
– |
/** |
21 |
– |
* For use as ThreadFactory in constructors |
22 |
– |
*/ |
23 |
– |
static class MyThreadFactory implements ThreadFactory{ |
24 |
– |
public Thread newThread(Runnable r){ |
25 |
– |
return new Thread(r); |
26 |
– |
} |
27 |
– |
} |
20 |
|
|
21 |
|
/** |
30 |
– |
* For use as RejectedExecutionHandler in constructors |
31 |
– |
*/ |
32 |
– |
static class MyREHandler implements RejectedExecutionHandler{ |
33 |
– |
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor){} |
34 |
– |
} |
35 |
– |
|
36 |
– |
/** |
22 |
|
* execute successfully executes a runnable |
23 |
|
*/ |
24 |
|
public void testExecute() { |
313 |
|
*/ |
314 |
|
public void testConstructor6() { |
315 |
|
try { |
316 |
< |
new ThreadPoolExecutor(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new MyThreadFactory()); |
316 |
> |
new ThreadPoolExecutor(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory()); |
317 |
|
shouldThrow(); |
318 |
|
} catch (IllegalArgumentException success){} |
319 |
|
} |
323 |
|
*/ |
324 |
|
public void testConstructor7() { |
325 |
|
try { |
326 |
< |
new ThreadPoolExecutor(1,-1,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new MyThreadFactory()); |
326 |
> |
new ThreadPoolExecutor(1,-1,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory()); |
327 |
|
shouldThrow(); |
328 |
|
} |
329 |
|
catch (IllegalArgumentException success){} |
334 |
|
*/ |
335 |
|
public void testConstructor8() { |
336 |
|
try { |
337 |
< |
new ThreadPoolExecutor(1,0,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new MyThreadFactory()); |
337 |
> |
new ThreadPoolExecutor(1,0,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory()); |
338 |
|
shouldThrow(); |
339 |
|
} |
340 |
|
catch (IllegalArgumentException success){} |
345 |
|
*/ |
346 |
|
public void testConstructor9() { |
347 |
|
try { |
348 |
< |
new ThreadPoolExecutor(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new MyThreadFactory()); |
348 |
> |
new ThreadPoolExecutor(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory()); |
349 |
|
shouldThrow(); |
350 |
|
} |
351 |
|
catch (IllegalArgumentException success){} |
356 |
|
*/ |
357 |
|
public void testConstructor10() { |
358 |
|
try { |
359 |
< |
new ThreadPoolExecutor(2,1,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new MyThreadFactory()); |
359 |
> |
new ThreadPoolExecutor(2,1,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory()); |
360 |
|
shouldThrow(); |
361 |
|
} |
362 |
|
catch (IllegalArgumentException success){} |
367 |
|
*/ |
368 |
|
public void testNullPointerException2() { |
369 |
|
try { |
370 |
< |
new ThreadPoolExecutor(1,2,SHORT_DELAY_MS, TimeUnit.MILLISECONDS,null,new MyThreadFactory()); |
370 |
> |
new ThreadPoolExecutor(1,2,SHORT_DELAY_MS, TimeUnit.MILLISECONDS,null,new SimpleThreadFactory()); |
371 |
|
shouldThrow(); |
372 |
|
} |
373 |
|
catch (NullPointerException success){} |
391 |
|
*/ |
392 |
|
public void testConstructor11() { |
393 |
|
try { |
394 |
< |
new ThreadPoolExecutor(-1,1,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new MyREHandler()); |
394 |
> |
new ThreadPoolExecutor(-1,1,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler()); |
395 |
|
shouldThrow(); |
396 |
|
} |
397 |
|
catch (IllegalArgumentException success){} |
402 |
|
*/ |
403 |
|
public void testConstructor12() { |
404 |
|
try { |
405 |
< |
new ThreadPoolExecutor(1,-1,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new MyREHandler()); |
405 |
> |
new ThreadPoolExecutor(1,-1,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler()); |
406 |
|
shouldThrow(); |
407 |
|
} |
408 |
|
catch (IllegalArgumentException success){} |
413 |
|
*/ |
414 |
|
public void testConstructor13() { |
415 |
|
try { |
416 |
< |
new ThreadPoolExecutor(1,0,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new MyREHandler()); |
416 |
> |
new ThreadPoolExecutor(1,0,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler()); |
417 |
|
shouldThrow(); |
418 |
|
} |
419 |
|
catch (IllegalArgumentException success){} |
424 |
|
*/ |
425 |
|
public void testConstructor14() { |
426 |
|
try { |
427 |
< |
new ThreadPoolExecutor(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new MyREHandler()); |
427 |
> |
new ThreadPoolExecutor(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler()); |
428 |
|
shouldThrow(); |
429 |
|
} |
430 |
|
catch (IllegalArgumentException success){} |
435 |
|
*/ |
436 |
|
public void testConstructor15() { |
437 |
|
try { |
438 |
< |
new ThreadPoolExecutor(2,1,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new MyREHandler()); |
438 |
> |
new ThreadPoolExecutor(2,1,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler()); |
439 |
|
shouldThrow(); |
440 |
|
} |
441 |
|
catch (IllegalArgumentException success){} |
446 |
|
*/ |
447 |
|
public void testNullPointerException4() { |
448 |
|
try { |
449 |
< |
new ThreadPoolExecutor(1,2,SHORT_DELAY_MS, TimeUnit.MILLISECONDS,null,new MyREHandler()); |
449 |
> |
new ThreadPoolExecutor(1,2,SHORT_DELAY_MS, TimeUnit.MILLISECONDS,null,new NoOpREHandler()); |
450 |
|
shouldThrow(); |
451 |
|
} |
452 |
|
catch (NullPointerException success){} |
470 |
|
*/ |
471 |
|
public void testConstructor16() { |
472 |
|
try { |
473 |
< |
new ThreadPoolExecutor(-1,1,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new MyThreadFactory(),new MyREHandler()); |
473 |
> |
new ThreadPoolExecutor(-1,1,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler()); |
474 |
|
shouldThrow(); |
475 |
|
} |
476 |
|
catch (IllegalArgumentException success){} |
481 |
|
*/ |
482 |
|
public void testConstructor17() { |
483 |
|
try { |
484 |
< |
new ThreadPoolExecutor(1,-1,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new MyThreadFactory(),new MyREHandler()); |
484 |
> |
new ThreadPoolExecutor(1,-1,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler()); |
485 |
|
shouldThrow(); |
486 |
|
} |
487 |
|
catch (IllegalArgumentException success){} |
492 |
|
*/ |
493 |
|
public void testConstructor18() { |
494 |
|
try { |
495 |
< |
new ThreadPoolExecutor(1,0,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new MyThreadFactory(),new MyREHandler()); |
495 |
> |
new ThreadPoolExecutor(1,0,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler()); |
496 |
|
shouldThrow(); |
497 |
|
} |
498 |
|
catch (IllegalArgumentException success){} |
503 |
|
*/ |
504 |
|
public void testConstructor19() { |
505 |
|
try { |
506 |
< |
new ThreadPoolExecutor(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new MyThreadFactory(),new MyREHandler()); |
506 |
> |
new ThreadPoolExecutor(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler()); |
507 |
|
shouldThrow(); |
508 |
|
} |
509 |
|
catch (IllegalArgumentException success){} |
514 |
|
*/ |
515 |
|
public void testConstructor20() { |
516 |
|
try { |
517 |
< |
new ThreadPoolExecutor(2,1,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new MyThreadFactory(),new MyREHandler()); |
517 |
> |
new ThreadPoolExecutor(2,1,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler()); |
518 |
|
shouldThrow(); |
519 |
|
} |
520 |
|
catch (IllegalArgumentException success){} |
525 |
|
*/ |
526 |
|
public void testNullPointerException6() { |
527 |
|
try { |
528 |
< |
new ThreadPoolExecutor(1,2,SHORT_DELAY_MS, TimeUnit.MILLISECONDS,null,new MyThreadFactory(),new MyREHandler()); |
528 |
> |
new ThreadPoolExecutor(1,2,SHORT_DELAY_MS, TimeUnit.MILLISECONDS,null,new SimpleThreadFactory(),new NoOpREHandler()); |
529 |
|
shouldThrow(); |
530 |
|
} |
531 |
|
catch (NullPointerException success){} |
537 |
|
public void testNullPointerException7() { |
538 |
|
try { |
539 |
|
RejectedExecutionHandler r = null; |
540 |
< |
new ThreadPoolExecutor(1,2,SHORT_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),new MyThreadFactory(),r); |
540 |
> |
new ThreadPoolExecutor(1,2,SHORT_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),r); |
541 |
|
shouldThrow(); |
542 |
|
} |
543 |
|
catch (NullPointerException success){} |
549 |
|
public void testNullPointerException8() { |
550 |
|
try { |
551 |
|
ThreadFactory f = null; |
552 |
< |
new ThreadPoolExecutor(1,2,SHORT_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),f,new MyREHandler()); |
552 |
> |
new ThreadPoolExecutor(1,2,SHORT_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),f,new NoOpREHandler()); |
553 |
|
shouldThrow(); |
554 |
|
} |
555 |
|
catch (NullPointerException successdn8){} |