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.3 by dl, Fri Dec 19 14:44:25 2003 UTC vs.
Revision 1.4 by dl, Fri Dec 19 20:38:55 2003 UTC

# Line 48 | Line 48 | public class AbstractExecutorServiceTest
48              ExecutorService e = new DirectExecutorService();
49              TrackedShortRunnable task = new TrackedShortRunnable();
50              assertFalse(task.done);
51 <            Future<?> future = e.submit(task, null);
51 >            Future<?> future = e.submit(task);
52              future.get();
53              assertTrue(task.done);
54          }
# Line 60 | Line 60 | public class AbstractExecutorServiceTest
60          }
61      }
62  
63    /**
64     * invoke of a runnable runs it to completion
65     */
66    public void testInvokeRunnable() {
67        try {
68            ExecutorService e = new DirectExecutorService();
69            TrackedShortRunnable task = new TrackedShortRunnable();
70            assertFalse(task.done);
71            e.invoke(task);
72            assertTrue(task.done);
73        }
74        catch (ExecutionException ex) {
75            unexpectedException();
76        }
77        catch (InterruptedException ex) {
78            unexpectedException();
79        }
80    }
63  
64      /**
65       * execute of a callable runs it to completion
# Line 188 | Line 170 | public class AbstractExecutorServiceTest
170      }
171  
172      /**
173 <     * invoke of a collable runs it to completion
173 >     * invoke of a callable runs it to completion
174       */
175      public void testInvokeCallable() {
176          try {
# Line 212 | Line 194 | public class AbstractExecutorServiceTest
194          try {
195              ExecutorService e = new DirectExecutorService();
196              TrackedShortRunnable task = null;
197 <            Future<?> future = e.submit(task, null);
197 >            Future<?> future = e.submit(task);
198              shouldThrow();
199          }
200          catch (NullPointerException success) {
# Line 222 | Line 204 | public class AbstractExecutorServiceTest
204          }
205      }
206  
225    /**
226     * invoke of a null runnable throws NPE
227     */
228    public void testInvokeNullRunnable() {
229        try {
230            ExecutorService e = new DirectExecutorService();
231            TrackedShortRunnable task = null;
232            e.invoke(task);
233            shouldThrow();
234        }
235        catch (NullPointerException success) {
236        }
237        catch (Exception ex) {
238            unexpectedException();
239        }
240    }
207  
208      /**
209       * execute of a null callable throws NPE
# Line 282 | Line 248 | public class AbstractExecutorServiceTest
248          try {
249  
250              for(int i = 0; i < 5; ++i){
251 <                p.submit(new MediumRunnable(), null);
251 >                p.submit(new MediumRunnable());
252              }
253              shouldThrow();
254          } catch(RejectedExecutionException success){}
# Line 306 | Line 272 | public class AbstractExecutorServiceTest
272  
273  
274      /**
275 <     *  invoke(Executor, Runnable) throws InterruptedException if
275 >     *  invoke(Executor, Callable) throws InterruptedException if
276       *  caller interrupted.
277       */
278      public void testInterruptedInvoke() {
# Line 314 | Line 280 | public class AbstractExecutorServiceTest
280          Thread t = new Thread(new Runnable() {
281                  public void run() {
282                      try {
283 <                        p.invoke(new Runnable() {
284 <                                public void run() {
283 >                        p.invoke(new Callable<Object>() {
284 >                                public Object call() {
285                                      try {
286                                          Thread.sleep(MEDIUM_DELAY_MS);
287                                          shouldThrow();
288                                      } catch(InterruptedException e){
289                                      }
290 +                                    return null;
291                                  }
292                              });
293                      } catch(InterruptedException success){
# Line 341 | Line 308 | public class AbstractExecutorServiceTest
308      }
309  
310      /**
344     *  invoke(Executor, Runnable) throws ExecutionException if
345     *  runnable throws exception.
346     */
347    public void testInvoke3() {
348        ThreadPoolExecutor p = new ThreadPoolExecutor(1,1,SHORT_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
349        try {
350            Runnable r = new Runnable() {
351                    public void run() {
352                        int i = 5/0;
353                    }
354                };
355
356            for(int i =0; i < 5; i++){
357                p.invoke(r);
358            }
359
360            shouldThrow();
361        } catch(ExecutionException success){
362        } catch(Exception e){
363            unexpectedException();
364        }
365        joinPool(p);
366    }
367
368
369
370    /**
311       *  invoke(Executor, Callable) throws InterruptedException if
312       *  callable throws exception
313       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines