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.16 by jsr166, Mon Nov 2 20:28:31 2009 UTC vs.
Revision 1.17 by jsr166, Mon Nov 16 04:57:09 2009 UTC

# Line 122 | Line 122 | public class AbstractExecutorServiceTest
122              policy.addPermission(new RuntimePermission("getContextClassLoader"));
123              policy.addPermission(new RuntimePermission("setContextClassLoader"));
124              Policy.setPolicy(policy);
125 <        } catch(AccessControlException ok) {
125 >        } catch (AccessControlException ok) {
126              return;
127          }
128          try {
# Line 144 | Line 144 | public class AbstractExecutorServiceTest
144          finally {
145              try {
146                  Policy.setPolicy(savedPolicy);
147 <            } catch(AccessControlException ok) {
147 >            } catch (AccessControlException ok) {
148                  return;
149              }
150          }
# Line 161 | Line 161 | public class AbstractExecutorServiceTest
161              policy.addPermission(new RuntimePermission("getContextClassLoader"));
162              policy.addPermission(new RuntimePermission("setContextClassLoader"));
163              Policy.setPolicy(policy);
164 <        } catch(AccessControlException ok) {
164 >        } catch (AccessControlException ok) {
165              return;
166          }
167  
# Line 197 | Line 197 | public class AbstractExecutorServiceTest
197              policy.addPermission(new RuntimePermission("getContextClassLoader"));
198              policy.addPermission(new RuntimePermission("setContextClassLoader"));
199              Policy.setPolicy(policy);
200 <        } catch(AccessControlException ok) {
200 >        } catch (AccessControlException ok) {
201              return;
202          }
203  
# Line 265 | Line 265 | public class AbstractExecutorServiceTest
265          ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(1));
266          try {
267  
268 <            for(int i = 0; i < 5; ++i){
268 >            for (int i = 0; i < 5; ++i){
269                  p.submit(new MediumRunnable());
270              }
271              shouldThrow();
272 <        } catch(RejectedExecutionException success){}
272 >        } catch (RejectedExecutionException success){}
273          joinPool(p);
274      }
275  
# Line 280 | Line 280 | public class AbstractExecutorServiceTest
280      public void testExecute2() {
281           ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(1));
282          try {
283 <            for(int i = 0; i < 5; ++i) {
283 >            for (int i = 0; i < 5; ++i) {
284                  p.submit(new SmallCallable());
285              }
286              shouldThrow();
287 <        } catch(RejectedExecutionException e){}
287 >        } catch (RejectedExecutionException e){}
288          joinPool(p);
289      }
290  
# Line 303 | Line 303 | public class AbstractExecutorServiceTest
303                                      try {
304                                          Thread.sleep(MEDIUM_DELAY_MS);
305                                          shouldThrow();
306 <                                    } catch(InterruptedException e){
306 >                                    } catch (InterruptedException e){
307                                      }
308                                      return null;
309                                  }
310                              }).get();
311 <                    } catch(InterruptedException success){
312 <                    } catch(Exception e) {
311 >                    } catch (InterruptedException success){
312 >                    } catch (Exception e) {
313                          unexpectedException();
314                      }
315  
# Line 319 | Line 319 | public class AbstractExecutorServiceTest
319              t.start();
320              Thread.sleep(SHORT_DELAY_MS);
321              t.interrupt();
322 <        } catch(Exception e){
322 >        } catch (Exception e){
323              unexpectedException();
324          }
325          joinPool(p);
# Line 337 | Line 337 | public class AbstractExecutorServiceTest
337                      try {
338                          p.submit(new SmallCallable()).get();
339                          shouldThrow();
340 <                    } catch(InterruptedException e){}
341 <                    catch(RejectedExecutionException e2){}
342 <                    catch(ExecutionException e3){}
340 >                    } catch (InterruptedException e){}
341 >                    catch (RejectedExecutionException e2){}
342 >                    catch (ExecutionException e3){}
343                      return Boolean.TRUE;
344                  }
345              };
# Line 350 | Line 350 | public class AbstractExecutorServiceTest
350                  public void run() {
351                      try {
352                          c.call();
353 <                    } catch(Exception e){}
353 >                    } catch (Exception e){}
354                  }
355            });
356          try {
# Line 358 | Line 358 | public class AbstractExecutorServiceTest
358              Thread.sleep(SHORT_DELAY_MS);
359              t.interrupt();
360              t.join();
361 <        } catch(InterruptedException e){
361 >        } catch (InterruptedException e){
362              unexpectedException();
363          }
364  
# Line 380 | Line 380 | public class AbstractExecutorServiceTest
380                      }
381                  };
382  
383 <            for(int i =0; i < 5; i++){
383 >            for (int i =0; i < 5; i++){
384                  p.submit(c).get();
385              }
386  
387              shouldThrow();
388          }
389 <        catch(ExecutionException success){
390 <        } catch(Exception e) {
389 >        catch (ExecutionException success){
390 >        } catch (Exception e) {
391              unexpectedException();
392          }
393          joinPool(p);
# Line 401 | Line 401 | public class AbstractExecutorServiceTest
401          try {
402              e.invokeAny(null);
403          } catch (NullPointerException success) {
404 <        } catch(Exception ex) {
404 >        } catch (Exception ex) {
405              unexpectedException();
406          } finally {
407              joinPool(e);
# Line 416 | Line 416 | public class AbstractExecutorServiceTest
416          try {
417              e.invokeAny(new ArrayList<Callable<String>>());
418          } catch (IllegalArgumentException success) {
419 <        } catch(Exception ex) {
419 >        } catch (Exception ex) {
420              unexpectedException();
421          } finally {
422              joinPool(e);
# Line 434 | Line 434 | public class AbstractExecutorServiceTest
434              l.add(null);
435              e.invokeAny(l);
436          } catch (NullPointerException success) {
437 <        } catch(Exception ex) {
437 >        } catch (Exception ex) {
438              ex.printStackTrace();
439              unexpectedException();
440          } finally {
# Line 451 | Line 451 | public class AbstractExecutorServiceTest
451              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
452              l.add(new NPETask());
453              e.invokeAny(l);
454 <        } catch(ExecutionException success) {
455 <        } catch(Exception ex) {
454 >        } catch (ExecutionException success) {
455 >        } catch (Exception ex) {
456              unexpectedException();
457          } finally {
458              joinPool(e);
# Line 471 | Line 471 | public class AbstractExecutorServiceTest
471              String result = e.invokeAny(l);
472              assertSame(TEST_STRING, result);
473          } catch (ExecutionException success) {
474 <        } catch(Exception ex) {
474 >        } catch (Exception ex) {
475              unexpectedException();
476          } finally {
477              joinPool(e);
# Line 486 | Line 486 | public class AbstractExecutorServiceTest
486          try {
487              e.invokeAll(null);
488          } catch (NullPointerException success) {
489 <        } catch(Exception ex) {
489 >        } catch (Exception ex) {
490              unexpectedException();
491          } finally {
492              joinPool(e);
# Line 501 | Line 501 | public class AbstractExecutorServiceTest
501          try {
502              List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>());
503              assertTrue(r.isEmpty());
504 <        } catch(Exception ex) {
504 >        } catch (Exception ex) {
505              unexpectedException();
506          } finally {
507              joinPool(e);
# Line 519 | Line 519 | public class AbstractExecutorServiceTest
519              l.add(null);
520              e.invokeAll(l);
521          } catch (NullPointerException success) {
522 <        } catch(Exception ex) {
522 >        } catch (Exception ex) {
523              unexpectedException();
524          } finally {
525              joinPool(e);
# Line 538 | Line 538 | public class AbstractExecutorServiceTest
538              assertEquals(1, result.size());
539              for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
540                  it.next().get();
541 <        } catch(ExecutionException success) {
542 <        } catch(Exception ex) {
541 >        } catch (ExecutionException success) {
542 >        } catch (Exception ex) {
543              unexpectedException();
544          } finally {
545              joinPool(e);
# Line 560 | Line 560 | public class AbstractExecutorServiceTest
560              for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
561                  assertSame(TEST_STRING, it.next().get());
562          } catch (ExecutionException success) {
563 <        } catch(Exception ex) {
563 >        } catch (Exception ex) {
564              unexpectedException();
565          } finally {
566              joinPool(e);
# Line 576 | Line 576 | public class AbstractExecutorServiceTest
576          try {
577              e.invokeAny(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
578          } catch (NullPointerException success) {
579 <        } catch(Exception ex) {
579 >        } catch (Exception ex) {
580              unexpectedException();
581          } finally {
582              joinPool(e);
# Line 593 | Line 593 | public class AbstractExecutorServiceTest
593              l.add(new StringTask());
594              e.invokeAny(l, MEDIUM_DELAY_MS, null);
595          } catch (NullPointerException success) {
596 <        } catch(Exception ex) {
596 >        } catch (Exception ex) {
597              unexpectedException();
598          } finally {
599              joinPool(e);
# Line 608 | Line 608 | public class AbstractExecutorServiceTest
608          try {
609              e.invokeAny(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
610          } catch (IllegalArgumentException success) {
611 <        } catch(Exception ex) {
611 >        } catch (Exception ex) {
612              unexpectedException();
613          } finally {
614              joinPool(e);
# Line 626 | Line 626 | public class AbstractExecutorServiceTest
626              l.add(null);
627              e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
628          } catch (NullPointerException success) {
629 <        } catch(Exception ex) {
629 >        } catch (Exception ex) {
630              ex.printStackTrace();
631              unexpectedException();
632          } finally {
# Line 643 | Line 643 | public class AbstractExecutorServiceTest
643              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
644              l.add(new NPETask());
645              e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
646 <        } catch(ExecutionException success) {
647 <        } catch(Exception ex) {
646 >        } catch (ExecutionException success) {
647 >        } catch (Exception ex) {
648              unexpectedException();
649          } finally {
650              joinPool(e);
# Line 663 | Line 663 | public class AbstractExecutorServiceTest
663              String result = e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
664              assertSame(TEST_STRING, result);
665          } catch (ExecutionException success) {
666 <        } catch(Exception ex) {
666 >        } catch (Exception ex) {
667              unexpectedException();
668          } finally {
669              joinPool(e);
# Line 678 | Line 678 | public class AbstractExecutorServiceTest
678          try {
679              e.invokeAll(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
680          } catch (NullPointerException success) {
681 <        } catch(Exception ex) {
681 >        } catch (Exception ex) {
682              unexpectedException();
683          } finally {
684              joinPool(e);
# Line 695 | Line 695 | public class AbstractExecutorServiceTest
695              l.add(new StringTask());
696              e.invokeAll(l, MEDIUM_DELAY_MS, null);
697          } catch (NullPointerException success) {
698 <        } catch(Exception ex) {
698 >        } catch (Exception ex) {
699              unexpectedException();
700          } finally {
701              joinPool(e);
# Line 710 | Line 710 | public class AbstractExecutorServiceTest
710          try {
711              List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
712              assertTrue(r.isEmpty());
713 <        } catch(Exception ex) {
713 >        } catch (Exception ex) {
714              unexpectedException();
715          } finally {
716              joinPool(e);
# Line 728 | Line 728 | public class AbstractExecutorServiceTest
728              l.add(null);
729              e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
730          } catch (NullPointerException success) {
731 <        } catch(Exception ex) {
731 >        } catch (Exception ex) {
732              unexpectedException();
733          } finally {
734              joinPool(e);
# Line 747 | Line 747 | public class AbstractExecutorServiceTest
747              assertEquals(1, result.size());
748              for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
749                  it.next().get();
750 <        } catch(ExecutionException success) {
751 <        } catch(Exception ex) {
750 >        } catch (ExecutionException success) {
751 >        } catch (Exception ex) {
752              unexpectedException();
753          } finally {
754              joinPool(e);
# Line 769 | Line 769 | public class AbstractExecutorServiceTest
769              for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
770                  assertSame(TEST_STRING, it.next().get());
771          } catch (ExecutionException success) {
772 <        } catch(Exception ex) {
772 >        } catch (Exception ex) {
773              unexpectedException();
774          } finally {
775              joinPool(e);
# Line 797 | Line 797 | public class AbstractExecutorServiceTest
797              assertTrue(f2.isDone());
798              assertTrue(f3.isDone());
799              assertTrue(f3.isCancelled());
800 <        } catch(Exception ex) {
800 >        } catch (Exception ex) {
801              unexpectedException();
802          } finally {
803              joinPool(e);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines