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

Comparing jsr166/src/test/tck/ScheduledExecutorTest.java (file contents):
Revision 1.5 by dl, Sat Sep 20 18:20:08 2003 UTC vs.
Revision 1.9 by dl, Thu Dec 4 20:54:46 2003 UTC

# Line 17 | Line 17 | public class ScheduledExecutorTest exten
17          return new TestSuite(ScheduledExecutorTest.class);
18      }
19  
20    static class MyRunnable implements Runnable {
21        volatile boolean done = false;
22        public void run() {
23            try {
24                Thread.sleep(SMALL_DELAY_MS);
25                done = true;
26            } catch(Exception e){
27            }
28        }
29    }
30
31    static class MyCallable implements Callable {
32        volatile boolean done = false;
33        public Object call() {
34            try {
35                Thread.sleep(SMALL_DELAY_MS);
36                done = true;
37            } catch(Exception e){
38            }
39            return Boolean.TRUE;
40        }
41    }
20  
21      /**
22 <     *
22 >     * execute successfully executes a runnable
23       */
24      public void testExecute() {
25          try {
26 <            MyRunnable runnable =new MyRunnable();
27 <            ScheduledExecutor p1 = new ScheduledExecutor(1);
26 >            TrackedShortRunnable runnable =new TrackedShortRunnable();
27 >            ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
28              p1.execute(runnable);
29              assertFalse(runnable.done);
30              Thread.sleep(SHORT_DELAY_MS);
# Line 66 | Line 44 | public class ScheduledExecutorTest exten
44          
45      }
46  
47 +
48      /**
49 <     *
49 >     * delayed schedule of callable successfully executes after delay
50       */
51      public void testSchedule1() {
52          try {
53 <            MyCallable callable = new MyCallable();
54 <            ScheduledExecutor p1 = new ScheduledExecutor(1);
53 >            TrackedCallable callable = new TrackedCallable();
54 >            ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
55              Future f = p1.schedule(callable, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
56              assertFalse(callable.done);
57              Thread.sleep(MEDIUM_DELAY_MS);
# Line 82 | Line 61 | public class ScheduledExecutorTest exten
61              joinPool(p1);
62          } catch(RejectedExecutionException e){}
63          catch(Exception e){
64 +            e.printStackTrace();
65              unexpectedException();
66          }
67      }
68  
69      /**
70 <     *  
70 >     *  delayed schedule of runnable successfully executes after delay
71       */
72      public void testSchedule3() {
73          try {
74 <            MyRunnable runnable = new MyRunnable();
75 <            ScheduledExecutor p1 = new ScheduledExecutor(1);
74 >            TrackedShortRunnable runnable = new TrackedShortRunnable();
75 >            ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
76              p1.schedule(runnable, SMALL_DELAY_MS, TimeUnit.MILLISECONDS);
77              Thread.sleep(SHORT_DELAY_MS);
78              assertFalse(runnable.done);
# Line 106 | Line 86 | public class ScheduledExecutorTest exten
86      }
87      
88      /**
89 <     *
89 >     * scheduleAtFixedRate executes runnable after given initial delay
90       */
91      public void testSchedule4() {
92          try {
93 <            MyRunnable runnable = new MyRunnable();
94 <            ScheduledExecutor p1 = new ScheduledExecutor(1);
95 <            p1.schedule(runnable, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
93 >            TrackedShortRunnable runnable = new TrackedShortRunnable();
94 >            ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
95 >            ScheduledFuture h = p1.scheduleAtFixedRate(runnable, SHORT_DELAY_MS, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
96              assertFalse(runnable.done);
97              Thread.sleep(MEDIUM_DELAY_MS);
98              assertTrue(runnable.done);
99 +            h.cancel(true);
100 +            p1.shutdown();
101 +            joinPool(p1);
102 +        } catch(Exception e){
103 +            unexpectedException();
104 +        }
105 +    }
106 +
107 +    /**
108 +     * scheduleWithFixedDelay executes runnable after given initial delay
109 +     */
110 +    public void testSchedule5() {
111 +        try {
112 +            TrackedShortRunnable runnable = new TrackedShortRunnable();
113 +            ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
114 +            ScheduledFuture h = p1.scheduleWithFixedDelay(runnable, SHORT_DELAY_MS, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
115 +            assertFalse(runnable.done);
116 +            Thread.sleep(MEDIUM_DELAY_MS);
117 +            assertTrue(runnable.done);
118 +            h.cancel(true);
119              p1.shutdown();
120              joinPool(p1);
121          } catch(Exception e){
# Line 123 | Line 123 | public class ScheduledExecutorTest exten
123          }
124      }
125      
126 <  
127 <    // exception tests
126 >    /**
127 >     *  execute (null) throws NPE
128 >     */
129 >    public void testExecuteNull() {
130 >        ScheduledThreadPoolExecutor se = null;
131 >        try {
132 >            se = new ScheduledThreadPoolExecutor(1);
133 >            se.execute(null);
134 >            shouldThrow();
135 >        } catch(NullPointerException success){}
136 >        catch(Exception e){
137 >            unexpectedException();
138 >        }
139 >        
140 >        joinPool(se);
141 >    }
142  
143      /**
144 <     *   schedule(Runnable, long) throws RejectedExecutionException
145 <     *  This occurs on an attempt to schedule a task on a shutdown executor
144 >     * schedule (null) throws NPE
145 >     */
146 >    public void testScheduleNull() {
147 >        ScheduledThreadPoolExecutor se = new ScheduledThreadPoolExecutor(1);
148 >        try {
149 >            TrackedCallable callable = null;
150 >            Future f = se.schedule(callable, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
151 >            shouldThrow();
152 >        } catch(NullPointerException success){}
153 >        catch(Exception e){
154 >            unexpectedException();
155 >        }
156 >        joinPool(se);
157 >    }
158 >  
159 >    /**
160 >     * execute throws RejectedExecutionException if shutdown
161       */
162      public void testSchedule1_RejectedExecutionException() {
163 <        ScheduledExecutor se = new ScheduledExecutor(1);
163 >        ScheduledThreadPoolExecutor se = new ScheduledThreadPoolExecutor(1);
164          try {
165              se.shutdown();
166              se.schedule(new NoOpRunnable(),
# Line 144 | Line 173 | public class ScheduledExecutorTest exten
173      }
174  
175      /**
176 <     *   schedule(Callable, long, TimeUnit) throws RejectedExecutionException
148 <     *  This occurs on an attempt to schedule a task on a shutdown executor
176 >     * schedule throws RejectedExecutionException if shutdown
177       */
178      public void testSchedule2_RejectedExecutionException() {
179 <        ScheduledExecutor se = new ScheduledExecutor(1);
179 >        ScheduledThreadPoolExecutor se = new ScheduledThreadPoolExecutor(1);
180          try {
181              se.shutdown();
182              se.schedule(new NoOpCallable(),
# Line 160 | Line 188 | public class ScheduledExecutorTest exten
188      }
189  
190      /**
191 <     *   schedule(Callable, long) throws RejectedExecutionException
164 <     *  This occurs on an attempt to schedule a task on a shutdown executor
191 >     * schedule callable throws RejectedExecutionException if shutdown
192       */
193       public void testSchedule3_RejectedExecutionException() {
194 <         ScheduledExecutor se = new ScheduledExecutor(1);
194 >         ScheduledThreadPoolExecutor se = new ScheduledThreadPoolExecutor(1);
195           try {
196              se.shutdown();
197              se.schedule(new NoOpCallable(),
# Line 176 | Line 203 | public class ScheduledExecutorTest exten
203      }
204  
205      /**
206 <     *   scheduleAtFixedRate(Runnable, long, long, TimeUnit) throws
180 <     *  RejectedExecutionException.
181 <     *  This occurs on an attempt to schedule a task on a shutdown executor
206 >     *  scheduleAtFixedRate throws RejectedExecutionException if shutdown
207       */
208      public void testScheduleAtFixedRate1_RejectedExecutionException() {
209 <        ScheduledExecutor se = new ScheduledExecutor(1);
209 >        ScheduledThreadPoolExecutor se = new ScheduledThreadPoolExecutor(1);
210          try {
211              se.shutdown();
212              se.scheduleAtFixedRate(new NoOpRunnable(),
# Line 193 | Line 218 | public class ScheduledExecutorTest exten
218      }
219      
220      /**
221 <     *   scheduleAtFixedRate(Runnable, long, long, TimeUnit) throws
197 <     *  RejectedExecutionException.
198 <     *  This occurs on an attempt to schedule a task on a shutdown executor
199 <     */
200 <    public void testScheduleAtFixedRate2_RejectedExecutionException() {
201 <        ScheduledExecutor se = new ScheduledExecutor(1);
202 <        try {
203 <            se.shutdown();
204 <            se.scheduleAtFixedRate(new NoOpRunnable(),
205 <                                   1, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
206 <            shouldThrow();
207 <        } catch(RejectedExecutionException success){
208 <        }
209 <        joinPool(se);
210 <    }
211 <
212 <    /**
213 <     *   scheduleWithFixedDelay(Runnable, long, long, TimeUnit) throws
214 <     *  RejectedExecutionException.
215 <     *  This occurs on an attempt to schedule a task on a shutdown executor
221 >     * scheduleWithFixedDelay throws RejectedExecutionException if shutdown
222       */
223      public void testScheduleWithFixedDelay1_RejectedExecutionException() {
224 <        ScheduledExecutor se = new ScheduledExecutor(1);
224 >        ScheduledThreadPoolExecutor se = new ScheduledThreadPoolExecutor(1);
225          try {
226              se.shutdown();
227              se.scheduleWithFixedDelay(new NoOpRunnable(),
# Line 227 | Line 233 | public class ScheduledExecutorTest exten
233      }
234  
235      /**
236 <     *   scheduleWithFixedDelay(Runnable, long, long, TimeUnit) throws
237 <     *  RejectedExecutionException.
232 <     *  This occurs on an attempt to schedule a task on a shutdown executor
233 <     */
234 <     public void testScheduleWithFixedDelay2_RejectedExecutionException() {
235 <         ScheduledExecutor se = new ScheduledExecutor(1);
236 <        try {
237 <            se.shutdown();
238 <            se.scheduleWithFixedDelay(new NoOpRunnable(),
239 <                                      1, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
240 <            shouldThrow();
241 <        } catch(RejectedExecutionException success){
242 <        }
243 <        joinPool(se);
244 <    }
245 <
246 <    /**
247 <     *   execute throws RejectedExecutionException
248 <     *  This occurs on an attempt to schedule a task on a shutdown executor
249 <     */
250 <    public void testExecute_RejectedExecutionException() {
251 <        ScheduledExecutor se = new ScheduledExecutor(1);
252 <        try {
253 <            se.shutdown();
254 <            se.execute(new NoOpRunnable());
255 <            shouldThrow();
256 <        } catch(RejectedExecutionException success){
257 <        }
258 <        joinPool(se);
259 <    }
260 <
261 <    /**
262 <     *   getActiveCount gives correct values
236 >     *  getActiveCount increases but doesn't overestimate, when a
237 >     *  thread becomes active
238       */
239      public void testGetActiveCount() {
240 <        ScheduledExecutor p2 = new ScheduledExecutor(2);
240 >        ScheduledThreadPoolExecutor p2 = new ScheduledThreadPoolExecutor(2);
241          assertEquals(0, p2.getActiveCount());
242          p2.execute(new SmallRunnable());
243          try {
# Line 275 | Line 250 | public class ScheduledExecutorTest exten
250      }
251      
252      /**
253 <     *   getCompleteTaskCount gives correct values
253 >     *    getCompletedTaskCount increases, but doesn't overestimate,
254 >     *   when tasks complete
255       */
256      public void testGetCompletedTaskCount() {
257 <        ScheduledExecutor p2 = new ScheduledExecutor(2);
257 >        ScheduledThreadPoolExecutor p2 = new ScheduledThreadPoolExecutor(2);
258          assertEquals(0, p2.getCompletedTaskCount());
259          p2.execute(new SmallRunnable());
260          try {
# Line 291 | Line 267 | public class ScheduledExecutorTest exten
267      }
268      
269      /**
270 <     *   getCorePoolSize gives correct values
270 >     *  getCorePoolSize returns size given in constructor if not otherwise set
271       */
272      public void testGetCorePoolSize() {
273 <        ScheduledExecutor p1 = new ScheduledExecutor(1);
273 >        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
274          assertEquals(1, p1.getCorePoolSize());
275          joinPool(p1);
276      }
277      
278      /**
279 <     *   getLargestPoolSize gives correct values
279 >     *    getLargestPoolSize increases, but doesn't overestimate, when
280 >     *   multiple threads active
281       */
282      public void testGetLargestPoolSize() {
283 <        ScheduledExecutor p2 = new ScheduledExecutor(2);
283 >        ScheduledThreadPoolExecutor p2 = new ScheduledThreadPoolExecutor(2);
284          assertEquals(0, p2.getLargestPoolSize());
285          p2.execute(new SmallRunnable());
286          p2.execute(new SmallRunnable());
# Line 317 | Line 294 | public class ScheduledExecutorTest exten
294      }
295      
296      /**
297 <     *   getPoolSize gives correct values
297 >     *   getPoolSize increases, but doesn't overestimate, when threads
298 >     *   become active
299       */
300      public void testGetPoolSize() {
301 <        ScheduledExecutor p1 = new ScheduledExecutor(1);
301 >        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
302          assertEquals(0, p1.getPoolSize());
303          p1.execute(new SmallRunnable());
304          assertEquals(1, p1.getPoolSize());
# Line 328 | Line 306 | public class ScheduledExecutorTest exten
306      }
307      
308      /**
309 <     *   getTaskCount gives correct values
309 >     *    getTaskCount increases, but doesn't overestimate, when tasks
310 >     *    submitted
311       */
312      public void testGetTaskCount() {
313 <        ScheduledExecutor p1 = new ScheduledExecutor(1);
313 >        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
314          assertEquals(0, p1.getTaskCount());
315          for(int i = 0; i < 5; i++)
316              p1.execute(new SmallRunnable());
# Line 343 | Line 322 | public class ScheduledExecutorTest exten
322          assertEquals(5, p1.getTaskCount());
323          joinPool(p1);
324      }
325 +
326 +    /**
327 +     * getThreadFactory returns factory in constructor if not set
328 +     */
329 +    public void testGetThreadFactory() {
330 +        ThreadFactory tf = new SimpleThreadFactory();
331 +        ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1, tf);
332 +        assertSame(tf, p.getThreadFactory());
333 +        p.shutdown();
334 +        joinPool(p);
335 +    }
336 +
337 +    /**
338 +     * setThreadFactory sets the thread factory returned by getThreadFactory
339 +     */
340 +    public void testSetThreadFactory() {
341 +        ThreadFactory tf = new SimpleThreadFactory();
342 +        ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1);
343 +        p.setThreadFactory(tf);
344 +        assertSame(tf, p.getThreadFactory());
345 +        p.shutdown();
346 +        joinPool(p);
347 +    }
348 +
349 +    /**
350 +     * setThreadFactory(null) throws NPE
351 +     */
352 +    public void testSetThreadFactoryNull() {
353 +        ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1);
354 +        try {
355 +            p.setThreadFactory(null);
356 +            shouldThrow();
357 +        } catch (NullPointerException success) {
358 +        } finally {
359 +            joinPool(p);
360 +        }
361 +    }
362      
363      /**
364 <     *   isShutDown gives correct values
364 >     *   is isShutDown is false before shutdown, true after
365       */
366      public void testIsShutdown() {
367          
368 <        ScheduledExecutor p1 = new ScheduledExecutor(1);
368 >        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
369          try {
370              assertFalse(p1.isShutdown());
371          }
# Line 361 | Line 377 | public class ScheduledExecutorTest exten
377  
378          
379      /**
380 <     *  isTerminated gives correct values
380 >     *   isTerminated is false before termination, true after
381       */
382      public void testIsTerminated() {
383 <        ScheduledExecutor p1 = new ScheduledExecutor(1);
383 >        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
384          try {
385              p1.execute(new SmallRunnable());
386          } finally {
# Line 379 | Line 395 | public class ScheduledExecutorTest exten
395      }
396  
397      /**
398 <     *  isTerminating gives correct values
398 >     *  isTerminating is not true when running or when terminated
399       */
400      public void testIsTerminating() {
401 <        ScheduledExecutor p1 = new ScheduledExecutor(1);
401 >        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
402          assertFalse(p1.isTerminating());
403          try {
404              p1.execute(new SmallRunnable());
# Line 400 | Line 416 | public class ScheduledExecutorTest exten
416      }
417  
418      /**
419 <     *   that purge correctly removes cancelled tasks
420 <     *  from the queue
419 >     * getQueue returns the work queue, which contains queued tasks
420 >     */
421 >    public void testGetQueue() {
422 >        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
423 >        ScheduledFuture[] tasks = new ScheduledFuture[5];
424 >        for(int i = 0; i < 5; i++){
425 >            tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), 1, TimeUnit.MILLISECONDS);
426 >        }
427 >        try {
428 >            Thread.sleep(SHORT_DELAY_MS);
429 >            BlockingQueue<Runnable> q = p1.getQueue();
430 >            assertTrue(q.contains(tasks[4]));
431 >            assertFalse(q.contains(tasks[0]));
432 >            p1.shutdownNow();
433 >        } catch(Exception e) {
434 >            unexpectedException();
435 >        } finally {
436 >            joinPool(p1);
437 >        }
438 >    }
439 >
440 >    /**
441 >     * remove(task) removes queued task, and fails to remove active task
442 >     */
443 >    public void testRemove() {
444 >        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
445 >        ScheduledFuture[] tasks = new ScheduledFuture[5];
446 >        for(int i = 0; i < 5; i++){
447 >            tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), 1, TimeUnit.MILLISECONDS);
448 >        }
449 >        try {
450 >            Thread.sleep(SHORT_DELAY_MS);
451 >            BlockingQueue<Runnable> q = p1.getQueue();
452 >            assertFalse(p1.remove((Runnable)tasks[0]));
453 >            assertTrue(q.contains((Runnable)tasks[4]));
454 >            assertTrue(q.contains((Runnable)tasks[3]));
455 >            assertTrue(p1.remove((Runnable)tasks[4]));
456 >            assertFalse(p1.remove((Runnable)tasks[4]));
457 >            assertFalse(q.contains((Runnable)tasks[4]));
458 >            assertTrue(q.contains((Runnable)tasks[3]));
459 >            assertTrue(p1.remove((Runnable)tasks[3]));
460 >            assertFalse(q.contains((Runnable)tasks[3]));
461 >            p1.shutdownNow();
462 >        } catch(Exception e) {
463 >            unexpectedException();
464 >        } finally {
465 >            joinPool(p1);
466 >        }
467 >    }
468 >
469 >    /**
470 >     *  purge removes cancelled tasks from the queue
471       */
472      public void testPurge() {
473 <        ScheduledExecutor p1 = new ScheduledExecutor(1);
474 <        ScheduledCancellable[] tasks = new ScheduledCancellable[5];
473 >        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
474 >        ScheduledFuture[] tasks = new ScheduledFuture[5];
475          for(int i = 0; i < 5; i++){
476 <            tasks[i] = p1.schedule(new SmallRunnable(), 1, TimeUnit.MILLISECONDS);
476 >            tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), 1, TimeUnit.MILLISECONDS);
477          }
478          int max = 5;
479          if (tasks[4].cancel(true)) --max;
# Line 419 | Line 485 | public class ScheduledExecutorTest exten
485      }
486  
487      /**
488 <     *   shutDownNow returns a list
423 <     *  containing the correct number of elements
488 >     *  shutDownNow returns a list containing tasks that were not run
489       */
490      public void testShutDownNow() {
491 <        ScheduledExecutor p1 = new ScheduledExecutor(1);
491 >        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
492          for(int i = 0; i < 5; i++)
493 <            p1.schedule(new SmallRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
493 >            p1.schedule(new SmallPossiblyInterruptedRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
494          List l = p1.shutdownNow();
495          assertTrue(p1.isShutdown());
496          assertTrue(l.size() > 0 && l.size() <= 5);
# Line 433 | Line 498 | public class ScheduledExecutorTest exten
498      }
499  
500      /**
501 <     *
501 >     * In default setting, shutdown cancels periodic but not delayed
502 >     * tasks at shutdown
503       */
504      public void testShutDown1() {
505          try {
506 <            ScheduledExecutor p1 = new ScheduledExecutor(1);
506 >            ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
507              assertTrue(p1.getExecuteExistingDelayedTasksAfterShutdownPolicy());
508              assertFalse(p1.getContinueExistingPeriodicTasksAfterShutdownPolicy());
509  
510 <            ScheduledCancellable[] tasks = new ScheduledCancellable[5];
510 >            ScheduledFuture[] tasks = new ScheduledFuture[5];
511              for(int i = 0; i < 5; i++)
512                  tasks[i] = p1.schedule(new NoOpRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
513              p1.shutdown();
514              BlockingQueue q = p1.getQueue();
515              for (Iterator it = q.iterator(); it.hasNext();) {
516 <                ScheduledCancellable t = (ScheduledCancellable)it.next();
516 >                ScheduledFuture t = (ScheduledFuture)it.next();
517                  assertFalse(t.isCancelled());
518              }
519              assertTrue(p1.isShutdown());
# Line 465 | Line 531 | public class ScheduledExecutorTest exten
531  
532  
533      /**
534 <     *
534 >     * If setExecuteExistingDelayedTasksAfterShutdownPolicy is false,
535 >     * delayed tasks are cancelled at shutdown
536       */
537      public void testShutDown2() {
538          try {
539 <            ScheduledExecutor p1 = new ScheduledExecutor(1);
539 >            ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
540              p1.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
541 <            ScheduledCancellable[] tasks = new ScheduledCancellable[5];
541 >            ScheduledFuture[] tasks = new ScheduledFuture[5];
542              for(int i = 0; i < 5; i++)
543                  tasks[i] = p1.schedule(new NoOpRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
544              p1.shutdown();
# Line 488 | Line 555 | public class ScheduledExecutorTest exten
555  
556  
557      /**
558 <     *
558 >     * If setContinueExistingPeriodicTasksAfterShutdownPolicy is set false,
559 >     * periodic tasks are not cancelled at shutdown
560       */
561      public void testShutDown3() {
562          try {
563 <            ScheduledExecutor p1 = new ScheduledExecutor(1);
563 >            ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
564              p1.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
565 <            ScheduledCancellable task =
565 >            ScheduledFuture task =
566                  p1.scheduleAtFixedRate(new NoOpRunnable(), 5, 5, TimeUnit.MILLISECONDS);
567              p1.shutdown();
568              assertTrue(p1.isShutdown());
# Line 509 | Line 577 | public class ScheduledExecutorTest exten
577      }
578  
579      /**
580 <     *
580 >     * if setContinueExistingPeriodicTasksAfterShutdownPolicy is true,
581 >     * periodic tasks are cancelled at shutdown
582       */
583      public void testShutDown4() {
584 <        ScheduledExecutor p1 = new ScheduledExecutor(1);
584 >        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
585          try {
586              p1.setContinueExistingPeriodicTasksAfterShutdownPolicy(true);
587 <            ScheduledCancellable task =
587 >            ScheduledFuture task =
588                  p1.scheduleAtFixedRate(new NoOpRunnable(), 5, 5, TimeUnit.MILLISECONDS);
589              assertFalse(task.isCancelled());
590              p1.shutdown();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines