192 |
|
|
193 |
|
|
194 |
|
/** |
195 |
< |
* execute successfully executes a runnable |
195 |
> |
* execute successfully executes a runnable |
196 |
|
*/ |
197 |
|
public void testExecute() throws InterruptedException { |
198 |
|
ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
205 |
|
} |
206 |
|
|
207 |
|
/** |
208 |
< |
* getActiveCount increases but doesn't overestimate, when a |
209 |
< |
* thread becomes active |
208 |
> |
* getActiveCount increases but doesn't overestimate, when a |
209 |
> |
* thread becomes active |
210 |
|
*/ |
211 |
|
public void testGetActiveCount() throws InterruptedException { |
212 |
|
ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
218 |
|
} |
219 |
|
|
220 |
|
/** |
221 |
< |
* prestartCoreThread starts a thread if under corePoolSize, else doesn't |
221 |
> |
* prestartCoreThread starts a thread if under corePoolSize, else doesn't |
222 |
|
*/ |
223 |
|
public void testPrestartCoreThread() { |
224 |
|
ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
233 |
|
} |
234 |
|
|
235 |
|
/** |
236 |
< |
* prestartAllCoreThreads starts all corePoolSize threads |
236 |
> |
* prestartAllCoreThreads starts all corePoolSize threads |
237 |
|
*/ |
238 |
|
public void testPrestartAllCoreThreads() { |
239 |
|
ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
246 |
|
} |
247 |
|
|
248 |
|
/** |
249 |
< |
* getCompletedTaskCount increases, but doesn't overestimate, |
250 |
< |
* when tasks complete |
249 |
> |
* getCompletedTaskCount increases, but doesn't overestimate, |
250 |
> |
* when tasks complete |
251 |
|
*/ |
252 |
|
public void testGetCompletedTaskCount() throws InterruptedException { |
253 |
|
ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
260 |
|
} |
261 |
|
|
262 |
|
/** |
263 |
< |
* getCorePoolSize returns size given in constructor if not otherwise set |
263 |
> |
* getCorePoolSize returns size given in constructor if not otherwise set |
264 |
|
*/ |
265 |
|
public void testGetCorePoolSize() { |
266 |
|
ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
269 |
|
} |
270 |
|
|
271 |
|
/** |
272 |
< |
* getKeepAliveTime returns value given in constructor if not otherwise set |
272 |
> |
* getKeepAliveTime returns value given in constructor if not otherwise set |
273 |
|
*/ |
274 |
|
public void testGetKeepAliveTime() { |
275 |
|
ThreadPoolExecutor p2 = new CustomTPE(2, 2, 1000, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
353 |
|
|
354 |
|
|
355 |
|
/** |
356 |
< |
* getLargestPoolSize increases, but doesn't overestimate, when |
357 |
< |
* multiple threads active |
356 |
> |
* getLargestPoolSize increases, but doesn't overestimate, when |
357 |
> |
* multiple threads active |
358 |
|
*/ |
359 |
|
public void testGetLargestPoolSize() throws InterruptedException { |
360 |
|
ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
367 |
|
} |
368 |
|
|
369 |
|
/** |
370 |
< |
* getMaximumPoolSize returns value given in constructor if not |
371 |
< |
* otherwise set |
370 |
> |
* getMaximumPoolSize returns value given in constructor if not |
371 |
> |
* otherwise set |
372 |
|
*/ |
373 |
|
public void testGetMaximumPoolSize() { |
374 |
|
ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
377 |
|
} |
378 |
|
|
379 |
|
/** |
380 |
< |
* getPoolSize increases, but doesn't overestimate, when threads |
381 |
< |
* become active |
380 |
> |
* getPoolSize increases, but doesn't overestimate, when threads |
381 |
> |
* become active |
382 |
|
*/ |
383 |
|
public void testGetPoolSize() { |
384 |
|
ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
389 |
|
} |
390 |
|
|
391 |
|
/** |
392 |
< |
* getTaskCount increases, but doesn't overestimate, when tasks submitted |
392 |
> |
* getTaskCount increases, but doesn't overestimate, when tasks submitted |
393 |
|
*/ |
394 |
|
public void testGetTaskCount() throws InterruptedException { |
395 |
|
ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
401 |
|
} |
402 |
|
|
403 |
|
/** |
404 |
< |
* isShutDown is false before shutdown, true after |
404 |
> |
* isShutDown is false before shutdown, true after |
405 |
|
*/ |
406 |
|
public void testIsShutdown() { |
407 |
|
|
414 |
|
|
415 |
|
|
416 |
|
/** |
417 |
< |
* isTerminated is false before termination, true after |
417 |
> |
* isTerminated is false before termination, true after |
418 |
|
*/ |
419 |
|
public void testIsTerminated() throws InterruptedException { |
420 |
|
ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
429 |
|
} |
430 |
|
|
431 |
|
/** |
432 |
< |
* isTerminating is not true when running or when terminated |
432 |
> |
* isTerminating is not true when running or when terminated |
433 |
|
*/ |
434 |
|
public void testIsTerminating() throws InterruptedException { |
435 |
|
ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
498 |
|
} |
499 |
|
|
500 |
|
/** |
501 |
< |
* purge removes cancelled tasks from the queue |
501 |
> |
* purge removes cancelled tasks from the queue |
502 |
|
*/ |
503 |
|
public void testPurge() { |
504 |
|
ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
516 |
|
} |
517 |
|
|
518 |
|
/** |
519 |
< |
* shutDownNow returns a list containing tasks that were not run |
519 |
> |
* shutDownNow returns a list containing tasks that were not run |
520 |
|
*/ |
521 |
|
public void testShutDownNow() { |
522 |
|
ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
794 |
|
} |
795 |
|
|
796 |
|
/** |
797 |
< |
* Constructor throws if workQueue is set to null |
797 |
> |
* Constructor throws if workQueue is null |
798 |
|
*/ |
799 |
|
public void testConstructorNullPointerException6() { |
800 |
|
try { |
804 |
|
} |
805 |
|
|
806 |
|
/** |
807 |
< |
* Constructor throws if handler is set to null |
807 |
> |
* Constructor throws if handler is null |
808 |
|
*/ |
809 |
|
public void testConstructorNullPointerException7() { |
810 |
|
try { |
815 |
|
} |
816 |
|
|
817 |
|
/** |
818 |
< |
* Constructor throws if ThreadFactory is set top null |
818 |
> |
* Constructor throws if ThreadFactory is null |
819 |
|
*/ |
820 |
|
public void testConstructorNullPointerException8() { |
821 |
|
try { |
827 |
|
|
828 |
|
|
829 |
|
/** |
830 |
< |
* execute throws RejectedExecutionException |
831 |
< |
* if saturated. |
830 |
> |
* execute throws RejectedExecutionException if saturated. |
831 |
|
*/ |
832 |
|
public void testSaturatedExecute() { |
833 |
|
ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1)); |
842 |
|
} |
843 |
|
|
844 |
|
/** |
845 |
< |
* executor using CallerRunsPolicy runs task if saturated. |
845 |
> |
* executor using CallerRunsPolicy runs task if saturated. |
846 |
|
*/ |
847 |
|
public void testSaturatedExecute2() { |
848 |
|
RejectedExecutionHandler h = new CustomTPE.CallerRunsPolicy(); |
868 |
|
} |
869 |
|
|
870 |
|
/** |
871 |
< |
* executor using DiscardPolicy drops task if saturated. |
871 |
> |
* executor using DiscardPolicy drops task if saturated. |
872 |
|
*/ |
873 |
|
public void testSaturatedExecute3() { |
874 |
|
RejectedExecutionHandler h = new CustomTPE.DiscardPolicy(); |
893 |
|
} |
894 |
|
|
895 |
|
/** |
896 |
< |
* executor using DiscardOldestPolicy drops oldest task if saturated. |
896 |
> |
* executor using DiscardOldestPolicy drops oldest task if saturated. |
897 |
|
*/ |
898 |
|
public void testSaturatedExecute4() { |
899 |
|
RejectedExecutionHandler h = new CustomTPE.DiscardOldestPolicy(); |
914 |
|
} |
915 |
|
|
916 |
|
/** |
917 |
< |
* execute throws RejectedExecutionException if shutdown |
917 |
> |
* execute throws RejectedExecutionException if shutdown |
918 |
|
*/ |
919 |
|
public void testRejectedExecutionExceptionOnShutdown() { |
920 |
|
ThreadPoolExecutor tpe = |
929 |
|
} |
930 |
|
|
931 |
|
/** |
932 |
< |
* execute using CallerRunsPolicy drops task on shutdown |
932 |
> |
* execute using CallerRunsPolicy drops task on shutdown |
933 |
|
*/ |
934 |
|
public void testCallerRunsOnShutdown() { |
935 |
|
RejectedExecutionHandler h = new CustomTPE.CallerRunsPolicy(); |
946 |
|
} |
947 |
|
|
948 |
|
/** |
949 |
< |
* execute using DiscardPolicy drops task on shutdown |
949 |
> |
* execute using DiscardPolicy drops task on shutdown |
950 |
|
*/ |
951 |
|
public void testDiscardOnShutdown() { |
952 |
|
RejectedExecutionHandler h = new CustomTPE.DiscardPolicy(); |
964 |
|
|
965 |
|
|
966 |
|
/** |
967 |
< |
* execute using DiscardOldestPolicy drops task on shutdown |
967 |
> |
* execute using DiscardOldestPolicy drops task on shutdown |
968 |
|
*/ |
969 |
|
public void testDiscardOldestOnShutdown() { |
970 |
|
RejectedExecutionHandler h = new CustomTPE.DiscardOldestPolicy(); |
982 |
|
|
983 |
|
|
984 |
|
/** |
985 |
< |
* execute (null) throws NPE |
985 |
> |
* execute(null) throws NPE |
986 |
|
*/ |
987 |
|
public void testExecuteNull() { |
988 |
|
ThreadPoolExecutor tpe = null; |
996 |
|
} |
997 |
|
|
998 |
|
/** |
999 |
< |
* setCorePoolSize of negative value throws IllegalArgumentException |
999 |
> |
* setCorePoolSize of negative value throws IllegalArgumentException |
1000 |
|
*/ |
1001 |
|
public void testCorePoolSizeIllegalArgumentException() { |
1002 |
|
ThreadPoolExecutor tpe = |
1012 |
|
} |
1013 |
|
|
1014 |
|
/** |
1015 |
< |
* setMaximumPoolSize(int) throws IllegalArgumentException if |
1016 |
< |
* given a value less the core pool size |
1015 |
> |
* setMaximumPoolSize(int) throws IllegalArgumentException |
1016 |
> |
* if given a value less the core pool size |
1017 |
|
*/ |
1018 |
|
public void testMaximumPoolSizeIllegalArgumentException() { |
1019 |
|
ThreadPoolExecutor tpe = |
1029 |
|
} |
1030 |
|
|
1031 |
|
/** |
1032 |
< |
* setMaximumPoolSize throws IllegalArgumentException |
1033 |
< |
* if given a negative value |
1032 |
> |
* setMaximumPoolSize throws IllegalArgumentException |
1033 |
> |
* if given a negative value |
1034 |
|
*/ |
1035 |
|
public void testMaximumPoolSizeIllegalArgumentException2() { |
1036 |
|
ThreadPoolExecutor tpe = |
1047 |
|
|
1048 |
|
|
1049 |
|
/** |
1050 |
< |
* setKeepAliveTime throws IllegalArgumentException |
1051 |
< |
* when given a negative value |
1050 |
> |
* setKeepAliveTime throws IllegalArgumentException |
1051 |
> |
* when given a negative value |
1052 |
|
*/ |
1053 |
|
public void testKeepAliveTimeIllegalArgumentException() { |
1054 |
|
ThreadPoolExecutor tpe = |