ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/AbstractExecutorServiceTest.java
(Generate patch)

Comparing jsr166/src/test/tck/AbstractExecutorServiceTest.java (file contents):
Revision 1.10 by dl, Sat Dec 27 19:26:42 2003 UTC vs.
Revision 1.14 by dl, Thu Jan 15 14:51:33 2004 UTC

# Line 36 | Line 36 | public class AbstractExecutorServiceTest
36      }
37  
38      /**
39 <     * execute of runnable runs it to completion
39 >     * execute(runnable) runs it to completion
40       */
41      public void testExecuteRunnable() {
42          try {
# Line 57 | Line 57 | public class AbstractExecutorServiceTest
57  
58  
59      /**
60 <     * completed submit of callable returns result
60 >     * Completed submit(callable) returns result
61       */
62      public void testSubmitCallable() {
63          try {
# Line 75 | Line 75 | public class AbstractExecutorServiceTest
75      }
76  
77      /**
78 <     * completed submit of runnable returns successfully
78 >     * Completed submit(runnable) returns successfully
79       */
80      public void testSubmitRunnable() {
81          try {
# Line 93 | Line 93 | public class AbstractExecutorServiceTest
93      }
94  
95      /**
96 <     * completed submit of (runnable, result) returns result
96 >     * Completed submit(runnable, result) returns result
97       */
98      public void testSubmitRunnable2() {
99          try {
# Line 112 | Line 112 | public class AbstractExecutorServiceTest
112  
113  
114      /**
115 <     * submit of a privileged action runs it to completion
115 >     * A submitted privileged action to completion
116       */
117      public void testSubmitPrivilegedAction() {
118          Policy savedPolicy = Policy.getPolicy();
# Line 142 | Line 142 | public class AbstractExecutorServiceTest
142      }
143  
144      /**
145 <     * submit of a privileged exception action runs it to completion
145 >     * A submitted a privileged exception action runs to completion
146       */
147      public void testSubmitPrivilegedExceptionAction() {
148          Policy savedPolicy = Policy.getPolicy();
# Line 172 | Line 172 | public class AbstractExecutorServiceTest
172      }
173  
174      /**
175 <     * submit of a failed privileged exception action reports exception
175 >     * A submitted failed privileged exception action reports exception
176       */
177      public void testSubmitFailedPrivilegedExceptionAction() {
178          Policy savedPolicy = Policy.getPolicy();
# Line 201 | Line 201 | public class AbstractExecutorServiceTest
201      }
202  
203      /**
204 <     * execute with a null runnable throws NPE
204 >     * execute(null runnable) throws NPE
205       */
206      public void testExecuteNullRunnable() {
207          try {
# Line 219 | Line 219 | public class AbstractExecutorServiceTest
219  
220  
221      /**
222 <     * submit of a null callable throws NPE
222 >     * submit(null callable) throws NPE
223       */
224      public void testSubmitNullCallable() {
225          try {
# Line 236 | Line 236 | public class AbstractExecutorServiceTest
236      }
237  
238      /**
239 <     * submit of Runnable throws RejectedExecutionException if
240 <     * saturated.
239 >     * submit(runnable) throws RejectedExecutionException if
240 >     * executor is saturated.
241       */
242      public void testExecute1() {
243 <        ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1));
243 >        ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(1));
244          try {
245  
246              for(int i = 0; i < 5; ++i){
# Line 252 | Line 252 | public class AbstractExecutorServiceTest
252      }
253  
254      /**
255 <     * Completed submit of Callable throws RejectedExecutionException
256 <     *  if saturated.
255 >     * submit(callable) throws RejectedExecutionException
256 >     * if executor is saturated.
257       */
258      public void testExecute2() {
259 <         ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1));
259 >         ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(1));
260          try {
261              for(int i = 0; i < 5; ++i) {
262                  p.submit(new SmallCallable());
# Line 268 | Line 268 | public class AbstractExecutorServiceTest
268  
269  
270      /**
271 <     *  blocking on submit of Callable throws InterruptedException if
271 >     *  Blocking on submit(callable) throws InterruptedException if
272       *  caller interrupted.
273       */
274      public void testInterruptedSubmit() {
275 <        final ThreadPoolExecutor p = new ThreadPoolExecutor(1,1,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
275 >        final ThreadPoolExecutor p = new ThreadPoolExecutor(1,1,60, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(10));
276          Thread t = new Thread(new Runnable() {
277                  public void run() {
278                      try {
# Line 304 | Line 304 | public class AbstractExecutorServiceTest
304      }
305  
306      /**
307 <     *  get of submit of Callable throws Exception if callable
307 >     *  get of submitted callable throws Exception if callable
308       *  interrupted
309       */
310      public void testSubmitIE() {
311 <        final ThreadPoolExecutor p = new ThreadPoolExecutor(1,1,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
311 >        final ThreadPoolExecutor p = new ThreadPoolExecutor(1,1,60, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(10));
312  
313          final Callable c = new Callable() {
314                  public Object call() {
# Line 344 | Line 344 | public class AbstractExecutorServiceTest
344      }
345  
346      /**
347 <     *  completed submit of Callable throws ExecutionException if
348 <     *  callable throws exception
347 >     *  get of submit(callable) throws ExecutionException if callable
348 >     *  throws exception
349       */
350      public void testSubmitEE() {
351 <        ThreadPoolExecutor p = new ThreadPoolExecutor(1,1,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
351 >        ThreadPoolExecutor p = new ThreadPoolExecutor(1,1,60, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(10));
352  
353          try {
354              Callable c = new Callable() {
# Line 421 | Line 421 | public class AbstractExecutorServiceTest
421      }
422  
423      /**
424 <     * invokeAny(c) throws ExecutionException if no task completes
424 >     * invokeAny(c) throws ExecutionException if no task in c completes
425       */
426      public void testInvokeAny4() {
427          ExecutorService e = new DirectExecutorService();
# Line 438 | Line 438 | public class AbstractExecutorServiceTest
438      }
439  
440      /**
441 <     * invokeAny(c) returns result of some task
441 >     * invokeAny(c) returns result of some task in c if at least one completes
442       */
443      public void testInvokeAny5() {
444          ExecutorService e = new DirectExecutorService();
# Line 505 | Line 505 | public class AbstractExecutorServiceTest
505      }
506  
507      /**
508 <     * get of element of invokeAll(c) throws exception on failed task
508 >     * get of returned element of invokeAll(c) throws exception on failed task
509       */
510      public void testInvokeAll4() {
511          ExecutorService e = new DirectExecutorService();
# Line 525 | Line 525 | public class AbstractExecutorServiceTest
525      }
526  
527      /**
528 <     * invokeAll(c) returns results of all completed tasks
528 >     * invokeAll(c) returns results of all completed tasks in c
529       */
530      public void testInvokeAll5() {
531          ExecutorService e = new DirectExecutorService();
# Line 562 | Line 562 | public class AbstractExecutorServiceTest
562      }
563  
564      /**
565 <     * timed invokeAny(,,null) throws NPE
565 >     * timed invokeAny(null time unit) throws NPE
566       */
567      public void testTimedInvokeAnyNullTimeUnit() {
568          ExecutorService e = new DirectExecutorService();
# Line 630 | Line 630 | public class AbstractExecutorServiceTest
630      }
631  
632      /**
633 <     * timed invokeAny(c) returns result of some task
633 >     * timed invokeAny(c) returns result of some task in c
634       */
635      public void testTimedInvokeAny5() {
636          ExecutorService e = new DirectExecutorService();
# Line 664 | Line 664 | public class AbstractExecutorServiceTest
664      }
665  
666      /**
667 <     * timed invokeAll(,,null) throws NPE
667 >     * timed invokeAll(null time unit) throws NPE
668       */
669      public void testTimedInvokeAllNullTimeUnit() {
670          ExecutorService e = new DirectExecutorService();
# Line 714 | Line 714 | public class AbstractExecutorServiceTest
714      }
715  
716      /**
717 <     * get of element of invokeAll(c) throws exception on failed task
717 >     * get of returned element of invokeAll(c) throws exception on failed task
718       */
719      public void testTimedInvokeAll4() {
720          ExecutorService e = new DirectExecutorService();
# Line 734 | Line 734 | public class AbstractExecutorServiceTest
734      }
735  
736      /**
737 <     * timed invokeAll(c) returns results of all completed tasks
737 >     * timed invokeAll(c) returns results of all completed tasks in c
738       */
739      public void testTimedInvokeAll5() {
740          ExecutorService e = new DirectExecutorService();
# Line 755 | Line 755 | public class AbstractExecutorServiceTest
755      }
756  
757      /**
758 <     * timed invokeAll(c) cancels tasks not completed by timeout
758 >     * timed invokeAll cancels tasks not completed by timeout
759       */
760      public void testTimedInvokeAll6() {
761          ExecutorService e = new DirectExecutorService();
762          try {
763              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
764              l.add(new StringTask());
765 <            l.add(Executors.callable(new LongPossiblyInterruptedRunnable(), TEST_STRING));
766 <            List<Future<String>> result = e.invokeAll(l, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
767 <            assertEquals(2, result.size());
765 >            l.add(Executors.callable(new MediumPossiblyInterruptedRunnable(), TEST_STRING));
766 >            l.add(new StringTask());
767 >            List<Future<String>> result = e.invokeAll(l, SMALL_DELAY_MS, TimeUnit.MILLISECONDS);
768 >            assertEquals(3, result.size());
769              Iterator<Future<String>> it = result.iterator();
770              Future<String> f1 = it.next();
771              Future<String> f2 = it.next();
772 +            Future<String> f3 = it.next();
773              assertTrue(f1.isDone());
774              assertFalse(f1.isCancelled());
775              assertTrue(f2.isDone());
776 <            //            assertTrue(f2.isCancelled());
776 >            assertTrue(f3.isDone());
777 >            assertTrue(f3.isCancelled());
778          } catch(Exception ex) {
779              unexpectedException();
780          } finally {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines