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.19 by jsr166, Fri Nov 20 05:25:10 2009 UTC vs.
Revision 1.28 by jsr166, Mon Oct 11 07:21:32 2010 UTC

# Line 10 | Line 10
10   import junit.framework.*;
11   import java.util.*;
12   import java.util.concurrent.*;
13 + import static java.util.concurrent.TimeUnit.MILLISECONDS;
14   import java.math.BigInteger;
15   import java.security.*;
16  
17   public class AbstractExecutorServiceTest extends JSR166TestCase {
18      public static void main(String[] args) {
19 <        junit.textui.TestRunner.run (suite());
19 >        junit.textui.TestRunner.run(suite());
20      }
21      public static Test suite() {
22          return new TestSuite(AbstractExecutorServiceTest.class);
# Line 28 | Line 29 | public class AbstractExecutorServiceTest
29      static class DirectExecutorService extends AbstractExecutorService {
30          public void execute(Runnable r) { r.run(); }
31          public void shutdown() { shutdown = true; }
32 <        public List<Runnable> shutdownNow() { shutdown = true; return Collections.EMPTY_LIST; }
32 >        public List<Runnable> shutdownNow() {
33 >            shutdown = true;
34 >            return Collections.EMPTY_LIST;
35 >        }
36          public boolean isShutdown() { return shutdown; }
37          public boolean isTerminated() { return isShutdown(); }
38 <        public boolean awaitTermination(long timeout, TimeUnit unit) { return isShutdown(); }
38 >        public boolean awaitTermination(long timeout, TimeUnit unit) {
39 >            return isShutdown();
40 >        }
41          private volatile boolean shutdown = false;
42      }
43  
# Line 80 | Line 86 | public class AbstractExecutorServiceTest
86  
87  
88      /**
89 <     * A submitted privileged action to completion
89 >     * A submitted privileged action runs to completion
90       */
91      public void testSubmitPrivilegedAction() throws Exception {
92 <        Policy savedPolicy = null;
93 <        try {
94 <            savedPolicy = Policy.getPolicy();
95 <            AdjustablePolicy policy = new AdjustablePolicy();
90 <            policy.addPermission(new RuntimePermission("getContextClassLoader"));
91 <            policy.addPermission(new RuntimePermission("setContextClassLoader"));
92 <            Policy.setPolicy(policy);
93 <        } catch (AccessControlException ok) {
94 <            return;
95 <        }
96 <        try {
97 <            ExecutorService e = new DirectExecutorService();
98 <            Future future = e.submit(Executors.callable(new PrivilegedAction() {
92 >        Runnable r = new CheckedRunnable() {
93 >            public void realRun() throws Exception {
94 >                ExecutorService e = new DirectExecutorService();
95 >                Future future = e.submit(Executors.callable(new PrivilegedAction() {
96                      public Object run() {
97                          return TEST_STRING;
98                      }}));
99  
100 <            Object result = future.get();
101 <            assertSame(TEST_STRING, result);
102 <        }
103 <        finally {
104 <            try {
105 <                Policy.setPolicy(savedPolicy);
106 <            } catch (AccessControlException ok) {
110 <                return;
111 <            }
112 <        }
100 >                assertSame(TEST_STRING, future.get());
101 >            }};
102 >
103 >        runWithPermissions(r,
104 >                           new RuntimePermission("getClassLoader"),
105 >                           new RuntimePermission("setContextClassLoader"),
106 >                           new RuntimePermission("modifyThread"));
107      }
108  
109      /**
110 <     * A submitted a privileged exception action runs to completion
110 >     * A submitted privileged exception action runs to completion
111       */
112      public void testSubmitPrivilegedExceptionAction() throws Exception {
113 <        Policy savedPolicy = null;
114 <        try {
115 <            savedPolicy = Policy.getPolicy();
116 <            AdjustablePolicy policy = new AdjustablePolicy();
123 <            policy.addPermission(new RuntimePermission("getContextClassLoader"));
124 <            policy.addPermission(new RuntimePermission("setContextClassLoader"));
125 <            Policy.setPolicy(policy);
126 <        } catch (AccessControlException ok) {
127 <            return;
128 <        }
129 <
130 <        try {
131 <            ExecutorService e = new DirectExecutorService();
132 <            Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() {
113 >        Runnable r = new CheckedRunnable() {
114 >            public void realRun() throws Exception {
115 >                ExecutorService e = new DirectExecutorService();
116 >                Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() {
117                      public Object run() {
118                          return TEST_STRING;
119                      }}));
120  
121 <            Object result = future.get();
122 <            assertSame(TEST_STRING, result);
123 <        }
124 <        finally {
141 <            Policy.setPolicy(savedPolicy);
142 <        }
121 >                assertSame(TEST_STRING, future.get());
122 >            }};
123 >
124 >        runWithPermissions(r);
125      }
126  
127      /**
128       * A submitted failed privileged exception action reports exception
129       */
130      public void testSubmitFailedPrivilegedExceptionAction() throws Exception {
131 <        Policy savedPolicy = null;
132 <        try {
133 <            savedPolicy = Policy.getPolicy();
134 <            AdjustablePolicy policy = new AdjustablePolicy();
153 <            policy.addPermission(new RuntimePermission("getContextClassLoader"));
154 <            policy.addPermission(new RuntimePermission("setContextClassLoader"));
155 <            Policy.setPolicy(policy);
156 <        } catch (AccessControlException ok) {
157 <            return;
158 <        }
159 <
160 <        try {
161 <            ExecutorService e = new DirectExecutorService();
162 <            Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() {
131 >        Runnable r = new CheckedRunnable() {
132 >            public void realRun() throws Exception {
133 >                ExecutorService e = new DirectExecutorService();
134 >                Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() {
135                      public Object run() throws Exception {
136                          throw new IndexOutOfBoundsException();
137                      }}));
138  
139 <            future.get();
140 <            shouldThrow();
141 <        } catch (ExecutionException success) {
142 <            assertTrue(success.getCause() instanceof IndexOutOfBoundsException);
143 <        }
144 <        finally {
145 <            Policy.setPolicy(savedPolicy);
146 <        }
139 >                try {
140 >                    future.get();
141 >                    shouldThrow();
142 >                } catch (ExecutionException success) {
143 >                    assertTrue(success.getCause() instanceof IndexOutOfBoundsException);
144 >                }}};
145 >
146 >        runWithPermissions(r);
147      }
148  
149      /**
# Line 198 | Line 170 | public class AbstractExecutorServiceTest
170      }
171  
172      /**
173 <     * submit(runnable) throws RejectedExecutionException if
202 <     * executor is saturated.
173 >     * submit(callable).get() throws InterruptedException if interrupted
174       */
175 <    public void testExecute1() {
176 <        ThreadPoolExecutor p =
177 <            new ThreadPoolExecutor(1, 1,
178 <                                   60, TimeUnit.SECONDS,
179 <                                   new ArrayBlockingQueue<Runnable>(1));
180 <        try {
181 <            for (int i = 0; i < 2; ++i)
182 <                p.submit(new MediumRunnable());
183 <            for (int i = 0; i < 2; ++i) {
184 <                try {
185 <                    p.submit(new MediumRunnable());
186 <                    shouldThrow();
187 <                } catch (RejectedExecutionException success) {}
188 <            }
189 <        } finally {
190 <            joinPool(p);
191 <        }
192 <    }
193 <
194 <    /**
195 <     * submit(callable) throws RejectedExecutionException
196 <     * if executor is saturated.
226 <     */
227 <    public void testExecute2() {
228 <        ThreadPoolExecutor p =
229 <            new ThreadPoolExecutor(1, 1,
230 <                                   60, TimeUnit.SECONDS,
231 <                                   new ArrayBlockingQueue<Runnable>(1));
232 <        try {
233 <            for (int i = 0; i < 2; ++i)
234 <                p.submit(new MediumRunnable());
235 <            for (int i = 0; i < 2; ++i) {
236 <                try {
237 <                    p.submit(new SmallCallable());
238 <                    shouldThrow();
239 <                } catch (RejectedExecutionException success) {}
240 <            }
175 >    public void testInterruptedSubmit() throws InterruptedException {
176 >        final CountDownLatch submitted    = new CountDownLatch(1);
177 >        final CountDownLatch quittingTime = new CountDownLatch(1);
178 >        final ExecutorService p
179 >            = new ThreadPoolExecutor(1,1,60, TimeUnit.SECONDS,
180 >                                     new ArrayBlockingQueue<Runnable>(10));
181 >        final Callable<Void> awaiter = new CheckedCallable<Void>() {
182 >            public Void realCall() throws InterruptedException {
183 >                quittingTime.await();
184 >                return null;
185 >            }};
186 >        try {
187 >            Thread t = new Thread(new CheckedInterruptedRunnable() {
188 >                public void realRun() throws Exception {
189 >                    Future<Void> future = p.submit(awaiter);
190 >                    submitted.countDown();
191 >                    future.get();
192 >                }});
193 >            t.start();
194 >            submitted.await();
195 >            t.interrupt();
196 >            t.join();
197          } finally {
198 +            quittingTime.countDown();
199              joinPool(p);
200          }
201      }
202  
246
247    /**
248     *  Blocking on submit(callable) throws InterruptedException if
249     *  caller interrupted.
250     */
251    public void testInterruptedSubmit() throws InterruptedException {
252        final ThreadPoolExecutor p = new ThreadPoolExecutor(1,1,60, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(10));
253        Thread t = new Thread(new CheckedInterruptedRunnable() {
254            public void realRun() throws Exception {
255                p.submit(new CheckedCallable<Object>() {
256                             public Object realCall()
257                                 throws InterruptedException {
258                                 Thread.sleep(SMALL_DELAY_MS);
259                                 return null;
260                             }}).get();
261            }});
262
263        t.start();
264        Thread.sleep(SHORT_DELAY_MS);
265        t.interrupt();
266        joinPool(p);
267    }
268
269    /**
270     *  get of submitted callable throws InterruptedException if callable
271     *  interrupted
272     */
273    public void testSubmitIE() throws InterruptedException {
274        final ThreadPoolExecutor p =
275            new ThreadPoolExecutor(1, 1,
276                                   60, TimeUnit.SECONDS,
277                                   new ArrayBlockingQueue<Runnable>(10));
278
279        Thread t = new Thread(new CheckedInterruptedRunnable() {
280            public void realRun() throws Exception {
281                p.submit(new SmallCallable()).get();
282            }});
283
284        t.start();
285        Thread.sleep(SHORT_DELAY_MS);
286        t.interrupt();
287        t.join();
288        joinPool(p);
289    }
290
203      /**
204 <     *  get of submit(callable) throws ExecutionException if callable
205 <     *  throws exception
204 >     * get of submit(callable) throws ExecutionException if callable
205 >     * throws exception
206       */
207      public void testSubmitEE() throws InterruptedException {
208          ThreadPoolExecutor p =
# Line 313 | Line 225 | public class AbstractExecutorServiceTest
225      /**
226       * invokeAny(null) throws NPE
227       */
228 <    public void testInvokeAny1()
317 <        throws InterruptedException, ExecutionException {
228 >    public void testInvokeAny1() throws Exception {
229          ExecutorService e = new DirectExecutorService();
230          try {
231              e.invokeAny(null);
# Line 328 | Line 239 | public class AbstractExecutorServiceTest
239      /**
240       * invokeAny(empty collection) throws IAE
241       */
242 <    public void testInvokeAny2()
332 <        throws InterruptedException, ExecutionException {
242 >    public void testInvokeAny2() throws Exception {
243          ExecutorService e = new DirectExecutorService();
244          try {
245              e.invokeAny(new ArrayList<Callable<String>>());
# Line 344 | Line 254 | public class AbstractExecutorServiceTest
254       * invokeAny(c) throws NPE if c has null elements
255       */
256      public void testInvokeAny3() throws Exception {
347        final CountDownLatch latch = new CountDownLatch(1);
257          ExecutorService e = new DirectExecutorService();
258 +        List<Callable<Integer>> l = new ArrayList<Callable<Integer>>();
259 +        l.add(new Callable<Integer>() {
260 +                  public Integer call() { return 5/0; }});
261 +        l.add(null);
262          try {
350            ArrayList<Callable<Integer>> l
351                = new ArrayList<Callable<Integer>>();
352            l.add(new Callable<Integer>() {
353                      public Integer call() { return 5/0; }});
354            l.add(null);
263              e.invokeAny(l);
264              shouldThrow();
265          } catch (NullPointerException success) {
266          } finally {
359            latch.countDown();
267              joinPool(e);
268          }
269      }
# Line 366 | Line 273 | public class AbstractExecutorServiceTest
273       */
274      public void testInvokeAny4() throws InterruptedException {
275          ExecutorService e = new DirectExecutorService();
276 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
277 +        l.add(new NPETask());
278          try {
370            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
371            l.add(new NPETask());
279              e.invokeAny(l);
280              shouldThrow();
281          } catch (ExecutionException success) {
# Line 384 | Line 291 | public class AbstractExecutorServiceTest
291      public void testInvokeAny5() throws Exception {
292          ExecutorService e = new DirectExecutorService();
293          try {
294 <            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
294 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
295              l.add(new StringTask());
296              l.add(new StringTask());
297              String result = e.invokeAny(l);
# Line 426 | Line 333 | public class AbstractExecutorServiceTest
333       */
334      public void testInvokeAll3() throws InterruptedException {
335          ExecutorService e = new DirectExecutorService();
336 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
337 +        l.add(new StringTask());
338 +        l.add(null);
339          try {
430            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
431            l.add(new StringTask());
432            l.add(null);
340              e.invokeAll(l);
341              shouldThrow();
342          } catch (NullPointerException success) {
# Line 444 | Line 351 | public class AbstractExecutorServiceTest
351      public void testInvokeAll4() throws Exception {
352          ExecutorService e = new DirectExecutorService();
353          try {
354 <            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
354 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
355              l.add(new NPETask());
356 <            List<Future<String>> result = e.invokeAll(l);
357 <            assertEquals(1, result.size());
358 <            for (Future<String> future : result) {
359 <                try {
360 <                    future.get();
361 <                    shouldThrow();
362 <                } catch (ExecutionException success) {
456 <                    Throwable cause = success.getCause();
457 <                    assertTrue(cause instanceof NullPointerException);
458 <                }
356 >            List<Future<String>> futures = e.invokeAll(l);
357 >            assertEquals(1, futures.size());
358 >            try {
359 >                futures.get(0).get();
360 >                shouldThrow();
361 >            } catch (ExecutionException success) {
362 >                assertTrue(success.getCause() instanceof NullPointerException);
363              }
364          } finally {
365              joinPool(e);
# Line 468 | Line 372 | public class AbstractExecutorServiceTest
372      public void testInvokeAll5() throws Exception {
373          ExecutorService e = new DirectExecutorService();
374          try {
375 <            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
375 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
376              l.add(new StringTask());
377              l.add(new StringTask());
378 <            List<Future<String>> result = e.invokeAll(l);
379 <            assertEquals(2, result.size());
380 <            for (Future<String> future : result)
378 >            List<Future<String>> futures = e.invokeAll(l);
379 >            assertEquals(2, futures.size());
380 >            for (Future<String> future : futures)
381                  assertSame(TEST_STRING, future.get());
382          } finally {
383              joinPool(e);
# Line 487 | Line 391 | public class AbstractExecutorServiceTest
391      public void testTimedInvokeAny1() throws Exception {
392          ExecutorService e = new DirectExecutorService();
393          try {
394 <            e.invokeAny(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
394 >            e.invokeAny(null, MEDIUM_DELAY_MS, MILLISECONDS);
395              shouldThrow();
396          } catch (NullPointerException success) {
397          } finally {
# Line 500 | Line 404 | public class AbstractExecutorServiceTest
404       */
405      public void testTimedInvokeAnyNullTimeUnit() throws Exception {
406          ExecutorService e = new DirectExecutorService();
407 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
408 +        l.add(new StringTask());
409          try {
504            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
505            l.add(new StringTask());
410              e.invokeAny(l, MEDIUM_DELAY_MS, null);
411              shouldThrow();
412          } catch (NullPointerException success) {
# Line 517 | Line 421 | public class AbstractExecutorServiceTest
421      public void testTimedInvokeAny2() throws Exception {
422          ExecutorService e = new DirectExecutorService();
423          try {
424 <            e.invokeAny(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
424 >            e.invokeAny(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, MILLISECONDS);
425              shouldThrow();
426          } catch (IllegalArgumentException success) {
427          } finally {
# Line 529 | Line 433 | public class AbstractExecutorServiceTest
433       * timed invokeAny(c) throws NPE if c has null elements
434       */
435      public void testTimedInvokeAny3() throws Exception {
532        final CountDownLatch latch = new CountDownLatch(1);
436          ExecutorService e = new DirectExecutorService();
437 +        List<Callable<Integer>> l = new ArrayList<Callable<Integer>>();
438 +        l.add(new Callable<Integer>() {
439 +                  public Integer call() { return 5/0; }});
440 +        l.add(null);
441          try {
442 <            ArrayList<Callable<Integer>> l
536 <                = new ArrayList<Callable<Integer>>();
537 <            l.add(new Callable<Integer>() {
538 <                      public Integer call() { return 5/0; }});
539 <            l.add(null);
540 <            e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
442 >            e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
443              shouldThrow();
444          } catch (NullPointerException success) {
445          } finally {
544            latch.countDown();
446              joinPool(e);
447          }
448      }
# Line 551 | Line 452 | public class AbstractExecutorServiceTest
452       */
453      public void testTimedInvokeAny4() throws Exception {
454          ExecutorService e = new DirectExecutorService();
455 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
456 +        l.add(new NPETask());
457          try {
458 <            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
556 <            l.add(new NPETask());
557 <            e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
458 >            e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
459              shouldThrow();
460          } catch (ExecutionException success) {
461              assertTrue(success.getCause() instanceof NullPointerException);
# Line 569 | Line 470 | public class AbstractExecutorServiceTest
470      public void testTimedInvokeAny5() throws Exception {
471          ExecutorService e = new DirectExecutorService();
472          try {
473 <            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
473 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
474              l.add(new StringTask());
475              l.add(new StringTask());
476 <            String result = e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
476 >            String result = e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
477              assertSame(TEST_STRING, result);
478          } finally {
479              joinPool(e);
# Line 585 | Line 486 | public class AbstractExecutorServiceTest
486      public void testTimedInvokeAll1() throws InterruptedException {
487          ExecutorService e = new DirectExecutorService();
488          try {
489 <            e.invokeAll(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
489 >            e.invokeAll(null, MEDIUM_DELAY_MS, MILLISECONDS);
490              shouldThrow();
491          } catch (NullPointerException success) {
492          } finally {
# Line 598 | Line 499 | public class AbstractExecutorServiceTest
499       */
500      public void testTimedInvokeAllNullTimeUnit() throws InterruptedException {
501          ExecutorService e = new DirectExecutorService();
502 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
503 +        l.add(new StringTask());
504          try {
602            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
603            l.add(new StringTask());
505              e.invokeAll(l, MEDIUM_DELAY_MS, null);
506              shouldThrow();
507          } catch (NullPointerException success) {
# Line 615 | Line 516 | public class AbstractExecutorServiceTest
516      public void testTimedInvokeAll2() throws InterruptedException {
517          ExecutorService e = new DirectExecutorService();
518          try {
519 <            List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
519 >            List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, MILLISECONDS);
520              assertTrue(r.isEmpty());
521          } finally {
522              joinPool(e);
# Line 627 | Line 528 | public class AbstractExecutorServiceTest
528       */
529      public void testTimedInvokeAll3() throws InterruptedException {
530          ExecutorService e = new DirectExecutorService();
531 +        List<Callable<String>> l = new ArrayList<Callable<String>>();
532 +        l.add(new StringTask());
533 +        l.add(null);
534          try {
535 <            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
632 <            l.add(new StringTask());
633 <            l.add(null);
634 <            e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
535 >            e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
536              shouldThrow();
537          } catch (NullPointerException success) {
538          } finally {
# Line 645 | Line 546 | public class AbstractExecutorServiceTest
546      public void testTimedInvokeAll4() throws Exception {
547          ExecutorService e = new DirectExecutorService();
548          try {
549 <            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
549 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
550              l.add(new NPETask());
551 <            List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
552 <            assertEquals(1, result.size());
553 <            for (Future<String> future : result) {
554 <                try {
555 <                    future.get();
556 <                } catch (ExecutionException success) {
557 <                    assertTrue(success.getCause() instanceof NullPointerException);
558 <                }
551 >            List<Future<String>> futures =
552 >                e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
553 >            assertEquals(1, futures.size());
554 >            try {
555 >                futures.get(0).get();
556 >                shouldThrow();
557 >            } catch (ExecutionException success) {
558 >                assertTrue(success.getCause() instanceof NullPointerException);
559              }
560          } finally {
561              joinPool(e);
# Line 667 | Line 568 | public class AbstractExecutorServiceTest
568      public void testTimedInvokeAll5() throws Exception {
569          ExecutorService e = new DirectExecutorService();
570          try {
571 <            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
571 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
572              l.add(new StringTask());
573              l.add(new StringTask());
574 <            List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
575 <            assertEquals(2, result.size());
576 <            for (Future<String> future : result)
574 >            List<Future<String>> futures =
575 >                e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
576 >            assertEquals(2, futures.size());
577 >            for (Future<String> future : futures)
578                  assertSame(TEST_STRING, future.get());
579          } finally {
580              joinPool(e);
# Line 685 | Line 587 | public class AbstractExecutorServiceTest
587      public void testTimedInvokeAll6() throws InterruptedException {
588          ExecutorService e = new DirectExecutorService();
589          try {
590 <            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
590 >            List<Callable<String>> l = new ArrayList<Callable<String>>();
591              l.add(new StringTask());
592              l.add(Executors.callable(new MediumPossiblyInterruptedRunnable(), TEST_STRING));
593              l.add(new StringTask());
594 <            List<Future<String>> result = e.invokeAll(l, SMALL_DELAY_MS, TimeUnit.MILLISECONDS);
595 <            assertEquals(3, result.size());
596 <            Iterator<Future<String>> it = result.iterator();
594 >            List<Future<String>> futures =
595 >                e.invokeAll(l, SMALL_DELAY_MS, MILLISECONDS);
596 >            assertEquals(3, futures.size());
597 >            Iterator<Future<String>> it = futures.iterator();
598              Future<String> f1 = it.next();
599              Future<String> f2 = it.next();
600              Future<String> f3 = it.next();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines