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.16 by dl, Thu Jan 8 01:29:46 2004 UTC vs.
Revision 1.17 by dl, Tue Jan 20 20:20:56 2004 UTC

# Line 29 | Line 29 | public class ScheduledExecutorTest exten
29              p1.execute(runnable);
30              assertFalse(runnable.done);
31              Thread.sleep(SHORT_DELAY_MS);
32 <            p1.shutdown();
32 >            try { p1.shutdown(); } catch(SecurityException ok) { return; }
33              try {
34                  Thread.sleep(MEDIUM_DELAY_MS);
35              } catch(InterruptedException e){
36                  unexpectedException();
37              }
38              assertTrue(runnable.done);
39 <            p1.shutdown();
39 >            try { p1.shutdown(); } catch(SecurityException ok) { return; }
40              joinPool(p1);
41          }
42          catch(Exception e){
# Line 58 | Line 58 | public class ScheduledExecutorTest exten
58              Thread.sleep(MEDIUM_DELAY_MS);
59              assertTrue(callable.done);
60              assertEquals(Boolean.TRUE, f.get());
61 <            p1.shutdown();
61 >            try { p1.shutdown(); } catch(SecurityException ok) { return; }
62              joinPool(p1);
63          } catch(RejectedExecutionException e){}
64          catch(Exception e){
# Line 79 | Line 79 | public class ScheduledExecutorTest exten
79              assertFalse(runnable.done);
80              Thread.sleep(MEDIUM_DELAY_MS);
81              assertTrue(runnable.done);
82 <            p1.shutdown();
82 >            try { p1.shutdown(); } catch(SecurityException ok) { return; }
83              joinPool(p1);
84          } catch(Exception e){
85              unexpectedException();
# Line 98 | Line 98 | public class ScheduledExecutorTest exten
98              Thread.sleep(MEDIUM_DELAY_MS);
99              assertTrue(runnable.done);
100              h.cancel(true);
101            p1.shutdown();
101              joinPool(p1);
102          } catch(Exception e){
103              unexpectedException();
# Line 117 | Line 116 | public class ScheduledExecutorTest exten
116              Thread.sleep(MEDIUM_DELAY_MS);
117              assertTrue(runnable.done);
118              h.cancel(true);
120            p1.shutdown();
119              joinPool(p1);
120          } catch(Exception e){
121              unexpectedException();
# Line 168 | Line 166 | public class ScheduledExecutorTest exten
166                          MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
167              shouldThrow();
168          } catch(RejectedExecutionException success){
169 +        } catch (SecurityException ok) {
170          }
171 +        
172          joinPool(se);
173  
174      }
# Line 184 | Line 184 | public class ScheduledExecutorTest exten
184                          MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
185              shouldThrow();
186          } catch(RejectedExecutionException success){
187 +        } catch (SecurityException ok) {
188          }
189          joinPool(se);
190      }
# Line 199 | Line 200 | public class ScheduledExecutorTest exten
200                          MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
201              shouldThrow();
202          } catch(RejectedExecutionException success){
203 <        }
203 >        } catch (SecurityException ok) {
204 >        }
205           joinPool(se);
206      }
207  
# Line 214 | Line 216 | public class ScheduledExecutorTest exten
216                                     MEDIUM_DELAY_MS, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
217              shouldThrow();
218          } catch(RejectedExecutionException success){
219 +        } catch (SecurityException ok) {
220          }
221          joinPool(se);
222      }
# Line 229 | Line 232 | public class ScheduledExecutorTest exten
232                                        MEDIUM_DELAY_MS, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
233              shouldThrow();
234          } catch(RejectedExecutionException success){
235 +        } catch (SecurityException ok) {
236          }
237          joinPool(se);
238      }
# Line 331 | Line 335 | public class ScheduledExecutorTest exten
335          ThreadFactory tf = new SimpleThreadFactory();
336          ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1, tf);
337          assertSame(tf, p.getThreadFactory());
334        p.shutdown();
338          joinPool(p);
339      }
340  
# Line 343 | Line 346 | public class ScheduledExecutorTest exten
346          ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1);
347          p.setThreadFactory(tf);
348          assertSame(tf, p.getThreadFactory());
346        p.shutdown();
349          joinPool(p);
350      }
351  
# Line 371 | Line 373 | public class ScheduledExecutorTest exten
373              assertFalse(p1.isShutdown());
374          }
375          finally {
376 <            p1.shutdown();
376 >            try { p1.shutdown(); } catch(SecurityException ok) { return; }
377          }
378          assertTrue(p1.isShutdown());
379      }
# Line 385 | Line 387 | public class ScheduledExecutorTest exten
387          try {
388              p1.execute(new SmallRunnable());
389          } finally {
390 <            p1.shutdown();
390 >            try { p1.shutdown(); } catch(SecurityException ok) { return; }
391          }
392          try {
393              assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS));
# Line 405 | Line 407 | public class ScheduledExecutorTest exten
407              p1.execute(new SmallRunnable());
408              assertFalse(p1.isTerminating());
409          } finally {
410 <            p1.shutdown();
410 >            try { p1.shutdown(); } catch(SecurityException ok) { return; }
411          }
412          try {
413              assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS));
# Line 430 | Line 432 | public class ScheduledExecutorTest exten
432              BlockingQueue<Runnable> q = p1.getQueue();
433              assertTrue(q.contains(tasks[4]));
434              assertFalse(q.contains(tasks[0]));
433            p1.shutdownNow();
435          } catch(Exception e) {
436              unexpectedException();
437          } finally {
# Line 459 | Line 460 | public class ScheduledExecutorTest exten
460              assertTrue(q.contains((Runnable)tasks[3]));
461              assertTrue(p1.remove((Runnable)tasks[3]));
462              assertFalse(q.contains((Runnable)tasks[3]));
462            p1.shutdownNow();
463          } catch(Exception e) {
464              unexpectedException();
465          } finally {
# Line 492 | Line 492 | public class ScheduledExecutorTest exten
492          ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
493          for(int i = 0; i < 5; i++)
494              p1.schedule(new SmallPossiblyInterruptedRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
495 <        List l = p1.shutdownNow();
495 >        List l;
496 >        try {
497 >            l = p1.shutdownNow();
498 >        } catch (SecurityException ok) {
499 >            return;
500 >        }
501          assertTrue(p1.isShutdown());
502          assertTrue(l.size() > 0 && l.size() <= 5);
503          joinPool(p1);
# Line 511 | Line 516 | public class ScheduledExecutorTest exten
516              ScheduledFuture[] tasks = new ScheduledFuture[5];
517              for(int i = 0; i < 5; i++)
518                  tasks[i] = p1.schedule(new NoOpRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
519 <            p1.shutdown();
519 >            try { p1.shutdown(); } catch(SecurityException ok) { return; }
520              BlockingQueue q = p1.getQueue();
521              for (Iterator it = q.iterator(); it.hasNext();) {
522                  ScheduledFuture t = (ScheduledFuture)it.next();
# Line 542 | Line 547 | public class ScheduledExecutorTest exten
547              ScheduledFuture[] tasks = new ScheduledFuture[5];
548              for(int i = 0; i < 5; i++)
549                  tasks[i] = p1.schedule(new NoOpRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
550 <            p1.shutdown();
550 >            try { p1.shutdown(); } catch(SecurityException ok) { return; }
551              assertTrue(p1.isShutdown());
552              BlockingQueue q = p1.getQueue();
553              assertTrue(q.isEmpty());
# Line 565 | Line 570 | public class ScheduledExecutorTest exten
570              p1.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
571              ScheduledFuture task =
572                  p1.scheduleAtFixedRate(new NoOpRunnable(), 5, 5, TimeUnit.MILLISECONDS);
573 <            p1.shutdown();
573 >            try { p1.shutdown(); } catch(SecurityException ok) { return; }
574              assertTrue(p1.isShutdown());
575              BlockingQueue q = p1.getQueue();
576              assertTrue(q.isEmpty());
# Line 588 | Line 593 | public class ScheduledExecutorTest exten
593              ScheduledFuture task =
594                  p1.scheduleAtFixedRate(new NoOpRunnable(), 1, 1, TimeUnit.MILLISECONDS);
595              assertFalse(task.isCancelled());
596 <            p1.shutdown();
596 >            try { p1.shutdown(); } catch(SecurityException ok) { return; }
597              assertFalse(task.isCancelled());
598              assertFalse(p1.isTerminated());
599              assertTrue(p1.isShutdown());
# Line 602 | Line 607 | public class ScheduledExecutorTest exten
607          catch(Exception ex) {
608              unexpectedException();
609          }
610 <        finally {
611 <            p1.shutdownNow();
610 >        finally {
611 >            joinPool(p1);
612          }
613      }
614  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines