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

Comparing jsr166/src/test/tck/SemaphoreTest.java (file contents):
Revision 1.16 by jsr166, Mon Nov 16 04:57:10 2009 UTC vs.
Revision 1.17 by jsr166, Mon Nov 16 05:30:08 2009 UTC

# Line 41 | Line 41 | public class SemaphoreTest extends JSR16
41          public void run() {
42              try {
43                  lock.acquire();
44 <            } catch (InterruptedException success){}
44 >            } catch (InterruptedException success) {}
45          }
46      }
47  
# Line 57 | Line 57 | public class SemaphoreTest extends JSR16
57              try {
58                  lock.acquire();
59                  threadShouldThrow();
60 <            } catch (InterruptedException success){}
60 >            } catch (InterruptedException success) {}
61          }
62      }
63  
# Line 120 | Line 120 | public class SemaphoreTest extends JSR16
120              s.acquire();
121              s.release();
122              assertEquals(1, s.availablePermits());
123 <        } catch ( InterruptedException e){
123 >        } catch ( InterruptedException e) {
124              unexpectedException();
125          }
126      }
# Line 165 | Line 165 | public class SemaphoreTest extends JSR16
165              assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
166              s.release();
167              assertEquals(1, s.availablePermits());
168 <        } catch ( InterruptedException e){
168 >        } catch ( InterruptedException e) {
169              unexpectedException();
170          }
171      }
# Line 182 | Line 182 | public class SemaphoreTest extends JSR16
182                          s.release();
183                          s.release();
184                          s.acquire();
185 <                    } catch (InterruptedException ie){
185 >                    } catch (InterruptedException ie) {
186                          threadUnexpectedException();
187                      }
188                  }
# Line 196 | Line 196 | public class SemaphoreTest extends JSR16
196              s.acquire();
197              s.release();
198              t.join();
199 <        } catch ( InterruptedException e){
199 >        } catch ( InterruptedException e) {
200              unexpectedException();
201          }
202      }
# Line 223 | Line 223 | public class SemaphoreTest extends JSR16
223              s.acquireUninterruptibly();
224              s.release();
225              t.join();
226 <        } catch ( InterruptedException e){
226 >        } catch ( InterruptedException e) {
227              unexpectedException();
228          }
229      }
# Line 242 | Line 242 | public class SemaphoreTest extends JSR16
242                          s.release();
243                          threadAssertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
244  
245 <                    } catch (InterruptedException ie){
245 >                    } catch (InterruptedException ie) {
246                          threadUnexpectedException();
247                      }
248                  }
# Line 255 | Line 255 | public class SemaphoreTest extends JSR16
255              s.release();
256              s.release();
257              t.join();
258 <        } catch ( InterruptedException e){
258 >        } catch ( InterruptedException e) {
259              unexpectedException();
260          }
261      }
# Line 270 | Line 270 | public class SemaphoreTest extends JSR16
270                      try {
271                          s.acquire();
272                          threadShouldThrow();
273 <                    } catch (InterruptedException success){}
273 >                    } catch (InterruptedException success) {}
274                  }
275              });
276          t.start();
# Line 278 | Line 278 | public class SemaphoreTest extends JSR16
278              Thread.sleep(SHORT_DELAY_MS);
279              t.interrupt();
280              t.join();
281 <        } catch (InterruptedException e){
281 >        } catch (InterruptedException e) {
282              unexpectedException();
283          }
284      }
# Line 293 | Line 293 | public class SemaphoreTest extends JSR16
293                      try {
294                          s.tryAcquire(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
295                          threadShouldThrow();
296 <                    } catch (InterruptedException success){
296 >                    } catch (InterruptedException success) {
297                      }
298                  }
299              });
# Line 302 | Line 302 | public class SemaphoreTest extends JSR16
302              Thread.sleep(SHORT_DELAY_MS);
303              t.interrupt();
304              t.join();
305 <        } catch (InterruptedException e){
305 >        } catch (InterruptedException e) {
306              unexpectedException();
307          }
308      }
# Line 331 | Line 331 | public class SemaphoreTest extends JSR16
331              assertFalse(lock.hasQueuedThreads());
332              t1.join();
333              t2.join();
334 <        } catch (Exception e){
334 >        } catch (Exception e) {
335              unexpectedException();
336          }
337      }
# Line 360 | Line 360 | public class SemaphoreTest extends JSR16
360              assertEquals(0, lock.getQueueLength());
361              t1.join();
362              t2.join();
363 <        } catch (Exception e){
363 >        } catch (Exception e) {
364              unexpectedException();
365          }
366      }
# Line 392 | Line 392 | public class SemaphoreTest extends JSR16
392              assertTrue(lock.getQueuedThreads().isEmpty());
393              t1.join();
394              t2.join();
395 <        } catch (Exception e){
395 >        } catch (Exception e) {
396              unexpectedException();
397          }
398      }
# Line 443 | Line 443 | public class SemaphoreTest extends JSR16
443              assertFalse(r.isFair());
444              r.acquire();
445              r.release();
446 <        } catch (Exception e){
446 >        } catch (Exception e) {
447              unexpectedException();
448          }
449      }
# Line 502 | Line 502 | public class SemaphoreTest extends JSR16
502              s.acquire();
503              s.release();
504              assertEquals(1, s.availablePermits());
505 <        } catch ( InterruptedException e){
505 >        } catch (InterruptedException e) {
506              unexpectedException();
507          }
508      }
# Line 524 | Line 524 | public class SemaphoreTest extends JSR16
524              s.release(5);
525              s.acquire(5);
526              assertEquals(1, s.availablePermits());
527 <        } catch ( InterruptedException e){
527 >        } catch ( InterruptedException e) {
528              unexpectedException();
529          }
530      }
# Line 567 | Line 567 | public class SemaphoreTest extends JSR16
567              s.release(5);
568              assertTrue(s.tryAcquire(5, SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
569              assertEquals(1, s.availablePermits());
570 <        } catch ( InterruptedException e){
570 >        } catch ( InterruptedException e) {
571              unexpectedException();
572          }
573      }
# Line 589 | Line 589 | public class SemaphoreTest extends JSR16
589              assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
590              s.release();
591              assertEquals(1, s.availablePermits());
592 <        } catch ( InterruptedException e){
592 >        } catch ( InterruptedException e) {
593              unexpectedException();
594          }
595      }
# Line 606 | Line 606 | public class SemaphoreTest extends JSR16
606                          s.acquire();
607                          s.acquire();
608                          s.acquire();
609 <                    } catch (InterruptedException ie){
609 >                    } catch (InterruptedException ie) {
610                          threadUnexpectedException();
611                      }
612                  }
# Line 622 | Line 622 | public class SemaphoreTest extends JSR16
622              s.release();
623              t.join();
624              assertEquals(2, s.availablePermits());
625 <        } catch ( InterruptedException e){
625 >        } catch ( InterruptedException e) {
626              unexpectedException();
627          }
628      }
# Line 638 | Line 638 | public class SemaphoreTest extends JSR16
638                          s.acquire();
639                          s.release(2);
640                          s.acquire();
641 <                    } catch (InterruptedException ie){
641 >                    } catch (InterruptedException ie) {
642                          threadUnexpectedException();
643                      }
644                  }
# Line 650 | Line 650 | public class SemaphoreTest extends JSR16
650              s.acquire(2);
651              s.release(1);
652              t.join();
653 <        } catch ( InterruptedException e){
653 >        } catch ( InterruptedException e) {
654              unexpectedException();
655          }
656      }
# Line 666 | Line 666 | public class SemaphoreTest extends JSR16
666                          s.acquire(2);
667                          s.acquire(2);
668                          s.release(4);
669 <                    } catch (InterruptedException ie){
669 >                    } catch (InterruptedException ie) {
670                          threadUnexpectedException();
671                      }
672                  }
# Line 679 | Line 679 | public class SemaphoreTest extends JSR16
679              s.acquire(2);
680              s.release(2);
681              t.join();
682 <        } catch ( InterruptedException e){
682 >        } catch ( InterruptedException e) {
683              unexpectedException();
684          }
685      }
# Line 702 | Line 702 | public class SemaphoreTest extends JSR16
702                          threadAssertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
703                          threadAssertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
704  
705 <                    } catch (InterruptedException ie){
705 >                    } catch (InterruptedException ie) {
706                          threadUnexpectedException();
707                      }
708                  }
# Line 715 | Line 715 | public class SemaphoreTest extends JSR16
715              s.release();
716              s.release();
717              t.join();
718 <        } catch ( InterruptedException e){
718 >        } catch ( InterruptedException e) {
719              unexpectedException();
720          }
721      }
# Line 732 | Line 732 | public class SemaphoreTest extends JSR16
732                          s.release(2);
733                          threadAssertTrue(s.tryAcquire(2, SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
734                          s.release(2);
735 <                    } catch (InterruptedException ie){
735 >                    } catch (InterruptedException ie) {
736                          threadUnexpectedException();
737                      }
738                  }
# Line 744 | Line 744 | public class SemaphoreTest extends JSR16
744              assertTrue(s.tryAcquire(2, SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
745              s.release(2);
746              t.join();
747 <        } catch ( InterruptedException e){
747 >        } catch ( InterruptedException e) {
748              unexpectedException();
749          }
750      }
# Line 759 | Line 759 | public class SemaphoreTest extends JSR16
759                      try {
760                          s.acquire();
761                          threadShouldThrow();
762 <                    } catch (InterruptedException success){}
762 >                    } catch (InterruptedException success) {}
763                  }
764              });
765          t.start();
# Line 767 | Line 767 | public class SemaphoreTest extends JSR16
767              Thread.sleep(SHORT_DELAY_MS);
768              t.interrupt();
769              t.join();
770 <        } catch (InterruptedException e){
770 >        } catch (InterruptedException e) {
771              unexpectedException();
772          }
773      }
# Line 782 | Line 782 | public class SemaphoreTest extends JSR16
782                      try {
783                          s.acquire(3);
784                          threadShouldThrow();
785 <                    } catch (InterruptedException success){}
785 >                    } catch (InterruptedException success) {}
786                  }
787              });
788          t.start();
# Line 790 | Line 790 | public class SemaphoreTest extends JSR16
790              Thread.sleep(SHORT_DELAY_MS);
791              t.interrupt();
792              t.join();
793 <        } catch (InterruptedException e){
793 >        } catch (InterruptedException e) {
794              unexpectedException();
795          }
796      }
# Line 805 | Line 805 | public class SemaphoreTest extends JSR16
805                      try {
806                          s.tryAcquire(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
807                          threadShouldThrow();
808 <                    } catch (InterruptedException success){
808 >                    } catch (InterruptedException success) {
809                      }
810                  }
811              });
# Line 814 | Line 814 | public class SemaphoreTest extends JSR16
814              Thread.sleep(SHORT_DELAY_MS);
815              t.interrupt();
816              t.join();
817 <        } catch (InterruptedException e){
817 >        } catch (InterruptedException e) {
818              unexpectedException();
819          }
820      }
# Line 829 | Line 829 | public class SemaphoreTest extends JSR16
829                      try {
830                          s.tryAcquire(4, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
831                          threadShouldThrow();
832 <                    } catch (InterruptedException success){
832 >                    } catch (InterruptedException success) {
833                      }
834                  }
835              });
# Line 838 | Line 838 | public class SemaphoreTest extends JSR16
838              Thread.sleep(SHORT_DELAY_MS);
839              t.interrupt();
840              t.join();
841 <        } catch (InterruptedException e){
841 >        } catch (InterruptedException e) {
842              unexpectedException();
843          }
844      }
# Line 867 | Line 867 | public class SemaphoreTest extends JSR16
867              assertEquals(0, lock.getQueueLength());
868              t1.join();
869              t2.join();
870 <        } catch (Exception e){
870 >        } catch (Exception e) {
871              unexpectedException();
872          }
873      }
# Line 894 | Line 894 | public class SemaphoreTest extends JSR16
894              assertTrue(r.isFair());
895              r.acquire();
896              r.release();
897 <        } catch (Exception e){
897 >        } catch (Exception e) {
898              unexpectedException();
899          }
900      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines