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

Comparing jsr166/src/test/tck/ScheduledExecutorSubclassTest.java (file contents):
Revision 1.1 by dl, Fri May 20 16:30:17 2005 UTC vs.
Revision 1.5 by jsr166, Fri Nov 20 16:00:19 2009 UTC

# Line 11 | Line 11 | import java.util.concurrent.atomic.*;
11  
12   public class ScheduledExecutorSubclassTest extends JSR166TestCase {
13      public static void main(String[] args) {
14 <        junit.textui.TestRunner.run (suite());  
14 >        junit.textui.TestRunner.run (suite());
15      }
16      public static Test suite() {
17 <        return new TestSuite(ScheduledExecutorTest.class);
17 >        return new TestSuite(ScheduledExecutorSubclassTest.class);
18      }
19  
20 <    static class CustomTask<V> implements RunnableScheduledFuture<V> {
20 >    static class CustomTask<V> implements RunnableScheduledFuture<V> {
21          RunnableScheduledFuture<V> task;
22          volatile boolean ran;
23          CustomTask(RunnableScheduledFuture<V> t) { task = t; }
24          public boolean isPeriodic() { return task.isPeriodic(); }
25 <        public void run() {
25 >        public void run() {
26              ran = true;
27 <            task.run();
27 >            task.run();
28          }
29          public long getDelay(TimeUnit unit) { return task.getDelay(unit); }
30          public int compareTo(Delayed t) {
31 <            return task.compareTo(((CustomTask)t).task);
31 >            return task.compareTo(((CustomTask)t).task);
32          }
33          public boolean cancel(boolean mayInterruptIfRunning) {
34              return task.cancel(mayInterruptIfRunning);
# Line 46 | Line 46 | public class ScheduledExecutorSubclassTe
46              return v;
47          }
48      }
49 <    
49 >
50  
51      public class CustomExecutor extends ScheduledThreadPoolExecutor {
52  
# Line 65 | Line 65 | public class ScheduledExecutorSubclassTe
65          CustomExecutor(int corePoolSize, ThreadFactory threadFactory) {
66              super(corePoolSize, threadFactory);
67          }
68 <        CustomExecutor(int corePoolSize, ThreadFactory threadFactory,
68 >        CustomExecutor(int corePoolSize, ThreadFactory threadFactory,
69                         RejectedExecutionHandler handler) {
70              super(corePoolSize, threadFactory, handler);
71          }
72 <        
72 >
73      }
74 <
74 >
75  
76  
77      /**
# Line 84 | Line 84 | public class ScheduledExecutorSubclassTe
84              p1.execute(runnable);
85              assertFalse(runnable.done);
86              Thread.sleep(SHORT_DELAY_MS);
87 <            try { p1.shutdown(); } catch(SecurityException ok) { return; }
87 >            try { p1.shutdown(); } catch (SecurityException ok) { return; }
88              try {
89                  Thread.sleep(MEDIUM_DELAY_MS);
90 <            } catch(InterruptedException e){
90 >            } catch (InterruptedException e) {
91                  unexpectedException();
92              }
93              assertTrue(runnable.done);
94 <            try { p1.shutdown(); } catch(SecurityException ok) { return; }
94 >            try { p1.shutdown(); } catch (SecurityException ok) { return; }
95              joinPool(p1);
96          }
97 <        catch(Exception e){
97 >        catch (Exception e) {
98              unexpectedException();
99          }
100 <        
100 >
101      }
102  
103  
# Line 113 | Line 113 | public class ScheduledExecutorSubclassTe
113              Thread.sleep(MEDIUM_DELAY_MS);
114              assertTrue(callable.done);
115              assertEquals(Boolean.TRUE, f.get());
116 <            try { p1.shutdown(); } catch(SecurityException ok) { return; }
116 >            try { p1.shutdown(); } catch (SecurityException ok) { return; }
117              joinPool(p1);
118 <        } catch(RejectedExecutionException e){}
119 <        catch(Exception e){
118 >        } catch (RejectedExecutionException e) {}
119 >        catch (Exception e) {
120              e.printStackTrace();
121              unexpectedException();
122          }
# Line 134 | Line 134 | public class ScheduledExecutorSubclassTe
134              assertFalse(runnable.done);
135              Thread.sleep(MEDIUM_DELAY_MS);
136              assertTrue(runnable.done);
137 <            try { p1.shutdown(); } catch(SecurityException ok) { return; }
137 >            try { p1.shutdown(); } catch (SecurityException ok) { return; }
138              joinPool(p1);
139 <        } catch(Exception e){
139 >        } catch (Exception e) {
140              unexpectedException();
141          }
142      }
143 <    
143 >
144      /**
145       * scheduleAtFixedRate executes runnable after given initial delay
146       */
# Line 154 | Line 154 | public class ScheduledExecutorSubclassTe
154              assertTrue(runnable.done);
155              h.cancel(true);
156              joinPool(p1);
157 <        } catch(Exception e){
157 >        } catch (Exception e) {
158              unexpectedException();
159          }
160      }
# Line 177 | Line 177 | public class ScheduledExecutorSubclassTe
177              assertTrue(runnable.done);
178              h.cancel(true);
179              joinPool(p1);
180 <        } catch(Exception e){
180 >        } catch (Exception e) {
181              unexpectedException();
182          }
183      }
184 <    
184 >
185      /**
186       * scheduleAtFixedRate executes series of tasks at given rate
187       */
# Line 189 | Line 189 | public class ScheduledExecutorSubclassTe
189          try {
190              CustomExecutor p1 = new CustomExecutor(1);
191              RunnableCounter counter = new RunnableCounter();
192 <            ScheduledFuture h =
192 >            ScheduledFuture h =
193                  p1.scheduleAtFixedRate(counter, 0, 1, TimeUnit.MILLISECONDS);
194              Thread.sleep(SMALL_DELAY_MS);
195              h.cancel(true);
# Line 199 | Line 199 | public class ScheduledExecutorSubclassTe
199              assertTrue(c >= SMALL_DELAY_MS / SHORT_DELAY_MS);
200              assertTrue(c <= SMALL_DELAY_MS + SHORT_DELAY_MS);
201              joinPool(p1);
202 <        } catch(Exception e){
202 >        } catch (Exception e) {
203              unexpectedException();
204          }
205      }
# Line 211 | Line 211 | public class ScheduledExecutorSubclassTe
211          try {
212              CustomExecutor p1 = new CustomExecutor(1);
213              RunnableCounter counter = new RunnableCounter();
214 <            ScheduledFuture h =
214 >            ScheduledFuture h =
215                  p1.scheduleWithFixedDelay(counter, 0, 1, TimeUnit.MILLISECONDS);
216              Thread.sleep(SMALL_DELAY_MS);
217              h.cancel(true);
# Line 219 | Line 219 | public class ScheduledExecutorSubclassTe
219              assertTrue(c >= SMALL_DELAY_MS / SHORT_DELAY_MS);
220              assertTrue(c <= SMALL_DELAY_MS + SHORT_DELAY_MS);
221              joinPool(p1);
222 <        } catch(Exception e){
222 >        } catch (Exception e) {
223              unexpectedException();
224          }
225      }
# Line 234 | Line 234 | public class ScheduledExecutorSubclassTe
234              se = new CustomExecutor(1);
235              se.execute(null);
236              shouldThrow();
237 <        } catch(NullPointerException success){}
238 <        catch(Exception e){
237 >        } catch (NullPointerException success) {}
238 >        catch (Exception e) {
239              unexpectedException();
240          }
241 <        
241 >
242          joinPool(se);
243      }
244  
# Line 251 | Line 251 | public class ScheduledExecutorSubclassTe
251              TrackedCallable callable = null;
252              Future f = se.schedule(callable, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
253              shouldThrow();
254 <        } catch(NullPointerException success){}
255 <        catch(Exception e){
254 >        } catch (NullPointerException success) {}
255 >        catch (Exception e) {
256              unexpectedException();
257          }
258          joinPool(se);
259      }
260 <  
260 >
261      /**
262       * execute throws RejectedExecutionException if shutdown
263       */
# Line 268 | Line 268 | public class ScheduledExecutorSubclassTe
268              se.schedule(new NoOpRunnable(),
269                          MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
270              shouldThrow();
271 <        } catch(RejectedExecutionException success){
271 >        } catch (RejectedExecutionException success) {
272          } catch (SecurityException ok) {
273          }
274 <        
274 >
275          joinPool(se);
276  
277      }
# Line 286 | Line 286 | public class ScheduledExecutorSubclassTe
286              se.schedule(new NoOpCallable(),
287                          MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
288              shouldThrow();
289 <        } catch(RejectedExecutionException success){
289 >        } catch (RejectedExecutionException success) {
290          } catch (SecurityException ok) {
291          }
292          joinPool(se);
# Line 302 | Line 302 | public class ScheduledExecutorSubclassTe
302              se.schedule(new NoOpCallable(),
303                          MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
304              shouldThrow();
305 <        } catch(RejectedExecutionException success){
305 >        } catch (RejectedExecutionException success) {
306          } catch (SecurityException ok) {
307          }
308           joinPool(se);
# Line 318 | Line 318 | public class ScheduledExecutorSubclassTe
318              se.scheduleAtFixedRate(new NoOpRunnable(),
319                                     MEDIUM_DELAY_MS, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
320              shouldThrow();
321 <        } catch(RejectedExecutionException success){
321 >        } catch (RejectedExecutionException success) {
322          } catch (SecurityException ok) {
323 <        }
323 >        }
324          joinPool(se);
325      }
326 <    
326 >
327      /**
328       * scheduleWithFixedDelay throws RejectedExecutionException if shutdown
329       */
# Line 334 | Line 334 | public class ScheduledExecutorSubclassTe
334              se.scheduleWithFixedDelay(new NoOpRunnable(),
335                                        MEDIUM_DELAY_MS, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
336              shouldThrow();
337 <        } catch(RejectedExecutionException success){
337 >        } catch (RejectedExecutionException success) {
338          } catch (SecurityException ok) {
339 <        }
339 >        }
340          joinPool(se);
341      }
342  
# Line 350 | Line 350 | public class ScheduledExecutorSubclassTe
350          p2.execute(new SmallRunnable());
351          try {
352              Thread.sleep(SHORT_DELAY_MS);
353 <        } catch(Exception e){
353 >        } catch (Exception e) {
354              unexpectedException();
355          }
356          assertEquals(1, p2.getActiveCount());
357          joinPool(p2);
358      }
359 <    
359 >
360      /**
361       *    getCompletedTaskCount increases, but doesn't overestimate,
362       *   when tasks complete
# Line 367 | Line 367 | public class ScheduledExecutorSubclassTe
367          p2.execute(new SmallRunnable());
368          try {
369              Thread.sleep(MEDIUM_DELAY_MS);
370 <        } catch(Exception e){
370 >        } catch (Exception e) {
371              unexpectedException();
372          }
373          assertEquals(1, p2.getCompletedTaskCount());
374          joinPool(p2);
375      }
376 <    
376 >
377      /**
378 <     *  getCorePoolSize returns size given in constructor if not otherwise set
378 >     *  getCorePoolSize returns size given in constructor if not otherwise set
379       */
380      public void testGetCorePoolSize() {
381          CustomExecutor p1 = new CustomExecutor(1);
382          assertEquals(1, p1.getCorePoolSize());
383          joinPool(p1);
384      }
385 <    
385 >
386      /**
387       *    getLargestPoolSize increases, but doesn't overestimate, when
388       *   multiple threads active
# Line 394 | Line 394 | public class ScheduledExecutorSubclassTe
394          p2.execute(new SmallRunnable());
395          try {
396              Thread.sleep(SHORT_DELAY_MS);
397 <        } catch(Exception e){
397 >        } catch (Exception e) {
398              unexpectedException();
399          }
400          assertEquals(2, p2.getLargestPoolSize());
401          joinPool(p2);
402      }
403 <    
403 >
404      /**
405       *   getPoolSize increases, but doesn't overestimate, when threads
406       *   become active
# Line 412 | Line 412 | public class ScheduledExecutorSubclassTe
412          assertEquals(1, p1.getPoolSize());
413          joinPool(p1);
414      }
415 <    
415 >
416      /**
417       *    getTaskCount increases, but doesn't overestimate, when tasks
418       *    submitted
# Line 420 | Line 420 | public class ScheduledExecutorSubclassTe
420      public void testGetTaskCount() {
421          CustomExecutor p1 = new CustomExecutor(1);
422          assertEquals(0, p1.getTaskCount());
423 <        for(int i = 0; i < 5; i++)
423 >        for (int i = 0; i < 5; i++)
424              p1.execute(new SmallRunnable());
425          try {
426              Thread.sleep(SHORT_DELAY_MS);
427 <        } catch(Exception e){
427 >        } catch (Exception e) {
428              unexpectedException();
429          }
430          assertEquals(5, p1.getTaskCount());
431          joinPool(p1);
432      }
433  
434 <    /**
434 >    /**
435       * getThreadFactory returns factory in constructor if not set
436       */
437      public void testGetThreadFactory() {
# Line 441 | Line 441 | public class ScheduledExecutorSubclassTe
441          joinPool(p);
442      }
443  
444 <    /**
444 >    /**
445       * setThreadFactory sets the thread factory returned by getThreadFactory
446       */
447      public void testSetThreadFactory() {
# Line 452 | Line 452 | public class ScheduledExecutorSubclassTe
452          joinPool(p);
453      }
454  
455 <    /**
455 >    /**
456       * setThreadFactory(null) throws NPE
457       */
458      public void testSetThreadFactoryNull() {
# Line 465 | Line 465 | public class ScheduledExecutorSubclassTe
465              joinPool(p);
466          }
467      }
468 <    
468 >
469      /**
470       *   is isShutDown is false before shutdown, true after
471       */
472      public void testIsShutdown() {
473 <        
473 >
474          CustomExecutor p1 = new CustomExecutor(1);
475          try {
476              assertFalse(p1.isShutdown());
477          }
478          finally {
479 <            try { p1.shutdown(); } catch(SecurityException ok) { return; }
479 >            try { p1.shutdown(); } catch (SecurityException ok) { return; }
480          }
481          assertTrue(p1.isShutdown());
482      }
483  
484 <        
484 >
485      /**
486       *   isTerminated is false before termination, true after
487       */
# Line 490 | Line 490 | public class ScheduledExecutorSubclassTe
490          try {
491              p1.execute(new SmallRunnable());
492          } finally {
493 <            try { p1.shutdown(); } catch(SecurityException ok) { return; }
493 >            try { p1.shutdown(); } catch (SecurityException ok) { return; }
494          }
495          try {
496              assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS));
497              assertTrue(p1.isTerminated());
498 <        } catch(Exception e){
498 >        } catch (Exception e) {
499              unexpectedException();
500 <        }      
500 >        }
501      }
502  
503      /**
# Line 510 | Line 510 | public class ScheduledExecutorSubclassTe
510              p1.execute(new SmallRunnable());
511              assertFalse(p1.isTerminating());
512          } finally {
513 <            try { p1.shutdown(); } catch(SecurityException ok) { return; }
513 >            try { p1.shutdown(); } catch (SecurityException ok) { return; }
514          }
515          try {
516              assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS));
517              assertTrue(p1.isTerminated());
518              assertFalse(p1.isTerminating());
519 <        } catch(Exception e){
519 >        } catch (Exception e) {
520              unexpectedException();
521 <        }      
521 >        }
522      }
523  
524      /**
# Line 527 | Line 527 | public class ScheduledExecutorSubclassTe
527      public void testGetQueue() {
528          CustomExecutor p1 = new CustomExecutor(1);
529          ScheduledFuture[] tasks = new ScheduledFuture[5];
530 <        for(int i = 0; i < 5; i++){
530 >        for (int i = 0; i < 5; i++) {
531              tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), 1, TimeUnit.MILLISECONDS);
532          }
533          try {
# Line 535 | Line 535 | public class ScheduledExecutorSubclassTe
535              BlockingQueue<Runnable> q = p1.getQueue();
536              assertTrue(q.contains(tasks[4]));
537              assertFalse(q.contains(tasks[0]));
538 <        } catch(Exception e) {
538 >        } catch (Exception e) {
539              unexpectedException();
540          } finally {
541              joinPool(p1);
# Line 548 | Line 548 | public class ScheduledExecutorSubclassTe
548      public void testRemove() {
549          CustomExecutor p1 = new CustomExecutor(1);
550          ScheduledFuture[] tasks = new ScheduledFuture[5];
551 <        for(int i = 0; i < 5; i++){
551 >        for (int i = 0; i < 5; i++) {
552              tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), 1, TimeUnit.MILLISECONDS);
553          }
554          try {
# Line 563 | Line 563 | public class ScheduledExecutorSubclassTe
563              assertTrue(q.contains((Runnable)tasks[3]));
564              assertTrue(p1.remove((Runnable)tasks[3]));
565              assertFalse(q.contains((Runnable)tasks[3]));
566 <        } catch(Exception e) {
566 >        } catch (Exception e) {
567              unexpectedException();
568          } finally {
569              joinPool(p1);
# Line 576 | Line 576 | public class ScheduledExecutorSubclassTe
576      public void testPurge() {
577          CustomExecutor p1 = new CustomExecutor(1);
578          ScheduledFuture[] tasks = new ScheduledFuture[5];
579 <        for(int i = 0; i < 5; i++){
579 >        for (int i = 0; i < 5; i++) {
580              tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
581          }
582          try {
# Line 594 | Line 594 | public class ScheduledExecutorSubclassTe
594                  Thread.sleep(1);
595              }
596              assertTrue(k < SMALL_DELAY_MS);
597 <        } catch(Exception e) {
597 >        } catch (Exception e) {
598              unexpectedException();
599          } finally {
600              joinPool(p1);
# Line 606 | Line 606 | public class ScheduledExecutorSubclassTe
606       */
607      public void testShutDownNow() {
608          CustomExecutor p1 = new CustomExecutor(1);
609 <        for(int i = 0; i < 5; i++)
609 >        for (int i = 0; i < 5; i++)
610              p1.schedule(new SmallPossiblyInterruptedRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
611          List l;
612          try {
613              l = p1.shutdownNow();
614 <        } catch (SecurityException ok) {
614 >        } catch (SecurityException ok) {
615              return;
616          }
617          assertTrue(p1.isShutdown());
# Line 630 | Line 630 | public class ScheduledExecutorSubclassTe
630              assertFalse(p1.getContinueExistingPeriodicTasksAfterShutdownPolicy());
631  
632              ScheduledFuture[] tasks = new ScheduledFuture[5];
633 <            for(int i = 0; i < 5; i++)
633 >            for (int i = 0; i < 5; i++)
634                  tasks[i] = p1.schedule(new NoOpRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
635 <            try { p1.shutdown(); } catch(SecurityException ok) { return; }
635 >            try { p1.shutdown(); } catch (SecurityException ok) { return; }
636              BlockingQueue q = p1.getQueue();
637              for (Iterator it = q.iterator(); it.hasNext();) {
638                  ScheduledFuture t = (ScheduledFuture)it.next();
# Line 644 | Line 644 | public class ScheduledExecutorSubclassTe
644                  assertTrue(tasks[i].isDone());
645                  assertFalse(tasks[i].isCancelled());
646              }
647 <            
647 >
648          }
649 <        catch(Exception ex) {
649 >        catch (Exception ex) {
650              unexpectedException();
651          }
652      }
# Line 661 | Line 661 | public class ScheduledExecutorSubclassTe
661              CustomExecutor p1 = new CustomExecutor(1);
662              p1.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
663              ScheduledFuture[] tasks = new ScheduledFuture[5];
664 <            for(int i = 0; i < 5; i++)
664 >            for (int i = 0; i < 5; i++)
665                  tasks[i] = p1.schedule(new NoOpRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
666 <            try { p1.shutdown(); } catch(SecurityException ok) { return; }
666 >            try { p1.shutdown(); } catch (SecurityException ok) { return; }
667              assertTrue(p1.isShutdown());
668              BlockingQueue q = p1.getQueue();
669              assertTrue(q.isEmpty());
670              Thread.sleep(SMALL_DELAY_MS);
671              assertTrue(p1.isTerminated());
672          }
673 <        catch(Exception ex) {
673 >        catch (Exception ex) {
674              unexpectedException();
675          }
676      }
# Line 686 | Line 686 | public class ScheduledExecutorSubclassTe
686              p1.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
687              ScheduledFuture task =
688                  p1.scheduleAtFixedRate(new NoOpRunnable(), 5, 5, TimeUnit.MILLISECONDS);
689 <            try { p1.shutdown(); } catch(SecurityException ok) { return; }
689 >            try { p1.shutdown(); } catch (SecurityException ok) { return; }
690              assertTrue(p1.isShutdown());
691              BlockingQueue q = p1.getQueue();
692              assertTrue(q.isEmpty());
693              Thread.sleep(SHORT_DELAY_MS);
694              assertTrue(p1.isTerminated());
695          }
696 <        catch(Exception ex) {
696 >        catch (Exception ex) {
697              unexpectedException();
698          }
699      }
# Line 709 | Line 709 | public class ScheduledExecutorSubclassTe
709              ScheduledFuture task =
710                  p1.scheduleAtFixedRate(new NoOpRunnable(), 1, 1, TimeUnit.MILLISECONDS);
711              assertFalse(task.isCancelled());
712 <            try { p1.shutdown(); } catch(SecurityException ok) { return; }
712 >            try { p1.shutdown(); } catch (SecurityException ok) { return; }
713              assertFalse(task.isCancelled());
714              assertFalse(p1.isTerminated());
715              assertTrue(p1.isShutdown());
# Line 720 | Line 720 | public class ScheduledExecutorSubclassTe
720              Thread.sleep(SHORT_DELAY_MS);
721              assertTrue(p1.isTerminated());
722          }
723 <        catch(Exception ex) {
723 >        catch (Exception ex) {
724              unexpectedException();
725          }
726 <        finally {
726 >        finally {
727              joinPool(p1);
728          }
729      }
# Line 796 | Line 796 | public class ScheduledExecutorSubclassTe
796          try {
797              e.invokeAny(null);
798          } catch (NullPointerException success) {
799 <        } catch(Exception ex) {
799 >        } catch (Exception ex) {
800              unexpectedException();
801          } finally {
802              joinPool(e);
# Line 811 | Line 811 | public class ScheduledExecutorSubclassTe
811          try {
812              e.invokeAny(new ArrayList<Callable<String>>());
813          } catch (IllegalArgumentException success) {
814 <        } catch(Exception ex) {
814 >        } catch (Exception ex) {
815              unexpectedException();
816          } finally {
817              joinPool(e);
# Line 829 | Line 829 | public class ScheduledExecutorSubclassTe
829              l.add(null);
830              e.invokeAny(l);
831          } catch (NullPointerException success) {
832 <        } catch(Exception ex) {
832 >        } catch (Exception ex) {
833              unexpectedException();
834          } finally {
835              joinPool(e);
# Line 846 | Line 846 | public class ScheduledExecutorSubclassTe
846              l.add(new NPETask());
847              e.invokeAny(l);
848          } catch (ExecutionException success) {
849 <        } catch(Exception ex) {
849 >        } catch (Exception ex) {
850              unexpectedException();
851          } finally {
852              joinPool(e);
# Line 865 | Line 865 | public class ScheduledExecutorSubclassTe
865              String result = e.invokeAny(l);
866              assertSame(TEST_STRING, result);
867          } catch (ExecutionException success) {
868 <        } catch(Exception ex) {
868 >        } catch (Exception ex) {
869              unexpectedException();
870          } finally {
871              joinPool(e);
# Line 880 | Line 880 | public class ScheduledExecutorSubclassTe
880          try {
881              e.invokeAll(null);
882          } catch (NullPointerException success) {
883 <        } catch(Exception ex) {
883 >        } catch (Exception ex) {
884              unexpectedException();
885          } finally {
886              joinPool(e);
# Line 895 | Line 895 | public class ScheduledExecutorSubclassTe
895          try {
896              List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>());
897              assertTrue(r.isEmpty());
898 <        } catch(Exception ex) {
898 >        } catch (Exception ex) {
899              unexpectedException();
900          } finally {
901              joinPool(e);
# Line 913 | Line 913 | public class ScheduledExecutorSubclassTe
913              l.add(null);
914              e.invokeAll(l);
915          } catch (NullPointerException success) {
916 <        } catch(Exception ex) {
916 >        } catch (Exception ex) {
917              unexpectedException();
918          } finally {
919              joinPool(e);
# Line 930 | Line 930 | public class ScheduledExecutorSubclassTe
930              l.add(new NPETask());
931              List<Future<String>> result = e.invokeAll(l);
932              assertEquals(1, result.size());
933 <            for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
933 >            for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
934                  it.next().get();
935 <        } catch(ExecutionException success) {
936 <        } catch(Exception ex) {
935 >        } catch (ExecutionException success) {
936 >        } catch (Exception ex) {
937              unexpectedException();
938          } finally {
939              joinPool(e);
# Line 951 | Line 951 | public class ScheduledExecutorSubclassTe
951              l.add(new StringTask());
952              List<Future<String>> result = e.invokeAll(l);
953              assertEquals(2, result.size());
954 <            for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
954 >            for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
955                  assertSame(TEST_STRING, it.next().get());
956          } catch (ExecutionException success) {
957 <        } catch(Exception ex) {
957 >        } catch (Exception ex) {
958              unexpectedException();
959          } finally {
960              joinPool(e);
# Line 969 | Line 969 | public class ScheduledExecutorSubclassTe
969          try {
970              e.invokeAny(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
971          } catch (NullPointerException success) {
972 <        } catch(Exception ex) {
972 >        } catch (Exception ex) {
973              unexpectedException();
974          } finally {
975              joinPool(e);
# Line 986 | Line 986 | public class ScheduledExecutorSubclassTe
986              l.add(new StringTask());
987              e.invokeAny(l, MEDIUM_DELAY_MS, null);
988          } catch (NullPointerException success) {
989 <        } catch(Exception ex) {
989 >        } catch (Exception ex) {
990              unexpectedException();
991          } finally {
992              joinPool(e);
# Line 1001 | Line 1001 | public class ScheduledExecutorSubclassTe
1001          try {
1002              e.invokeAny(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1003          } catch (IllegalArgumentException success) {
1004 <        } catch(Exception ex) {
1004 >        } catch (Exception ex) {
1005              unexpectedException();
1006          } finally {
1007              joinPool(e);
# Line 1019 | Line 1019 | public class ScheduledExecutorSubclassTe
1019              l.add(null);
1020              e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1021          } catch (NullPointerException success) {
1022 <        } catch(Exception ex) {
1022 >        } catch (Exception ex) {
1023              ex.printStackTrace();
1024              unexpectedException();
1025          } finally {
# Line 1036 | Line 1036 | public class ScheduledExecutorSubclassTe
1036              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1037              l.add(new NPETask());
1038              e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1039 <        } catch(ExecutionException success) {
1040 <        } catch(Exception ex) {
1039 >        } catch (ExecutionException success) {
1040 >        } catch (Exception ex) {
1041              unexpectedException();
1042          } finally {
1043              joinPool(e);
# Line 1056 | Line 1056 | public class ScheduledExecutorSubclassTe
1056              String result = e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1057              assertSame(TEST_STRING, result);
1058          } catch (ExecutionException success) {
1059 <        } catch(Exception ex) {
1059 >        } catch (Exception ex) {
1060              unexpectedException();
1061          } finally {
1062              joinPool(e);
# Line 1071 | Line 1071 | public class ScheduledExecutorSubclassTe
1071          try {
1072              e.invokeAll(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1073          } catch (NullPointerException success) {
1074 <        } catch(Exception ex) {
1074 >        } catch (Exception ex) {
1075              unexpectedException();
1076          } finally {
1077              joinPool(e);
# Line 1088 | Line 1088 | public class ScheduledExecutorSubclassTe
1088              l.add(new StringTask());
1089              e.invokeAll(l, MEDIUM_DELAY_MS, null);
1090          } catch (NullPointerException success) {
1091 <        } catch(Exception ex) {
1091 >        } catch (Exception ex) {
1092              unexpectedException();
1093          } finally {
1094              joinPool(e);
# Line 1103 | Line 1103 | public class ScheduledExecutorSubclassTe
1103          try {
1104              List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1105              assertTrue(r.isEmpty());
1106 <        } catch(Exception ex) {
1106 >        } catch (Exception ex) {
1107              unexpectedException();
1108          } finally {
1109              joinPool(e);
# Line 1121 | Line 1121 | public class ScheduledExecutorSubclassTe
1121              l.add(null);
1122              e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1123          } catch (NullPointerException success) {
1124 <        } catch(Exception ex) {
1124 >        } catch (Exception ex) {
1125              unexpectedException();
1126          } finally {
1127              joinPool(e);
# Line 1138 | Line 1138 | public class ScheduledExecutorSubclassTe
1138              l.add(new NPETask());
1139              List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1140              assertEquals(1, result.size());
1141 <            for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
1141 >            for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
1142                  it.next().get();
1143 <        } catch(ExecutionException success) {
1144 <        } catch(Exception ex) {
1143 >        } catch (ExecutionException success) {
1144 >        } catch (Exception ex) {
1145              unexpectedException();
1146          } finally {
1147              joinPool(e);
# Line 1159 | Line 1159 | public class ScheduledExecutorSubclassTe
1159              l.add(new StringTask());
1160              List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1161              assertEquals(2, result.size());
1162 <            for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
1162 >            for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
1163                  assertSame(TEST_STRING, it.next().get());
1164          } catch (ExecutionException success) {
1165 <        } catch(Exception ex) {
1165 >        } catch (Exception ex) {
1166              unexpectedException();
1167          } finally {
1168              joinPool(e);
# Line 1181 | Line 1181 | public class ScheduledExecutorSubclassTe
1181              l.add(new StringTask());
1182              List<Future<String>> result = e.invokeAll(l, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
1183              assertEquals(3, result.size());
1184 <            Iterator<Future<String>> it = result.iterator();
1184 >            Iterator<Future<String>> it = result.iterator();
1185              Future<String> f1 = it.next();
1186              Future<String> f2 = it.next();
1187              Future<String> f3 = it.next();
# Line 1190 | Line 1190 | public class ScheduledExecutorSubclassTe
1190              assertTrue(f3.isDone());
1191              assertFalse(f1.isCancelled());
1192              assertTrue(f2.isCancelled());
1193 <        } catch(Exception ex) {
1193 >        } catch (Exception ex) {
1194              unexpectedException();
1195          } finally {
1196              joinPool(e);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines